babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. }
  1057. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @returns true if the loader can load the specified file
  1073. */
  1074. canLoad(extension: string): boolean;
  1075. /**
  1076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param createPolynomials will be true if polynomials have been requested
  1080. * @param onLoad defines the callback to trigger once the texture is ready
  1081. * @param onError defines the callback to trigger in case of error
  1082. */
  1083. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1084. /**
  1085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1086. * @param data contains the texture data
  1087. * @param texture defines the BabylonJS internal texture
  1088. * @param callback defines the method to call once ready to upload
  1089. */
  1090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1091. }
  1092. }
  1093. declare module "babylonjs/Engines/IPipelineContext" {
  1094. /**
  1095. * Class used to store and describe the pipeline context associated with an effect
  1096. */
  1097. export interface IPipelineContext {
  1098. /**
  1099. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1100. */
  1101. isAsync: boolean;
  1102. /**
  1103. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1104. */
  1105. isReady: boolean;
  1106. /** @hidden */
  1107. _getVertexShaderCode(): string | null;
  1108. /** @hidden */
  1109. _getFragmentShaderCode(): string | null;
  1110. /** @hidden */
  1111. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1112. }
  1113. }
  1114. declare module "babylonjs/Meshes/dataBuffer" {
  1115. /**
  1116. * Class used to store gfx data (like WebGLBuffer)
  1117. */
  1118. export class DataBuffer {
  1119. /**
  1120. * Gets or sets the number of objects referencing this buffer
  1121. */
  1122. references: number;
  1123. /** Gets or sets the size of the underlying buffer */
  1124. capacity: number;
  1125. /**
  1126. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1127. */
  1128. is32Bits: boolean;
  1129. /**
  1130. * Gets the underlying buffer
  1131. */
  1132. get underlyingResource(): any;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1136. /** @hidden */
  1137. export interface IShaderProcessor {
  1138. attributeProcessor?: (attribute: string) => string;
  1139. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1140. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1141. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1142. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1143. lineProcessor?: (line: string, isFragment: boolean) => string;
  1144. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. }
  1147. }
  1148. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1149. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1150. /** @hidden */
  1151. export interface ProcessingOptions {
  1152. defines: string[];
  1153. indexParameters: any;
  1154. isFragment: boolean;
  1155. shouldUseHighPrecisionShader: boolean;
  1156. supportsUniformBuffers: boolean;
  1157. shadersRepository: string;
  1158. includesShadersStore: {
  1159. [key: string]: string;
  1160. };
  1161. processor?: IShaderProcessor;
  1162. version: string;
  1163. platformName: string;
  1164. lookForClosingBracketForUniformBuffer?: boolean;
  1165. }
  1166. }
  1167. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1168. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1169. /** @hidden */
  1170. export class ShaderCodeNode {
  1171. line: string;
  1172. children: ShaderCodeNode[];
  1173. additionalDefineKey?: string;
  1174. additionalDefineValue?: string;
  1175. isValid(preprocessors: {
  1176. [key: string]: string;
  1177. }): boolean;
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1184. /** @hidden */
  1185. export class ShaderCodeCursor {
  1186. private _lines;
  1187. lineIndex: number;
  1188. get currentLine(): string;
  1189. get canRead(): boolean;
  1190. set lines(value: string[]);
  1191. }
  1192. }
  1193. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1194. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1195. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1196. /** @hidden */
  1197. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1198. process(preprocessors: {
  1199. [key: string]: string;
  1200. }, options: ProcessingOptions): string;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1204. /** @hidden */
  1205. export class ShaderDefineExpression {
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. private static _OperatorPriority;
  1210. private static _Stack;
  1211. static postfixToInfix(postfix: string[]): string;
  1212. static infixToPostfix(infix: string): string[];
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. 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>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. 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;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. 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;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. import { WebRequest } from "babylonjs/Misc/webRequest";
  1474. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1476. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1477. /** @hidden */
  1478. export class ShaderProcessor {
  1479. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1480. private static _ProcessPrecision;
  1481. private static _ExtractOperation;
  1482. private static _BuildSubExpression;
  1483. private static _BuildExpression;
  1484. private static _MoveCursorWithinIf;
  1485. private static _MoveCursor;
  1486. private static _EvaluatePreProcessors;
  1487. private static _PreparePreProcessors;
  1488. private static _ProcessShaderConversion;
  1489. private static _ProcessIncludes;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. * @hidden
  1500. */
  1501. 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;
  1502. }
  1503. }
  1504. declare module "babylonjs/Maths/math.like" {
  1505. import { float, int, DeepImmutable } from "babylonjs/types";
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IColor4Like {
  1510. r: float;
  1511. g: float;
  1512. b: float;
  1513. a: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IColor3Like {
  1519. r: float;
  1520. g: float;
  1521. b: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector4Like {
  1527. x: float;
  1528. y: float;
  1529. z: float;
  1530. w: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector3Like {
  1536. x: float;
  1537. y: float;
  1538. z: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector2Like {
  1544. x: float;
  1545. y: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IMatrixLike {
  1551. toArray(): DeepImmutable<Float32Array>;
  1552. updateFlag: int;
  1553. }
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IViewportLike {
  1558. x: float;
  1559. y: float;
  1560. width: float;
  1561. height: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IPlaneLike {
  1567. normal: IVector3Like;
  1568. d: float;
  1569. normalize(): void;
  1570. }
  1571. }
  1572. declare module "babylonjs/Materials/iEffectFallbacks" {
  1573. import { Effect } from "babylonjs/Materials/effect";
  1574. /**
  1575. * Interface used to define common properties for effect fallbacks
  1576. */
  1577. export interface IEffectFallbacks {
  1578. /**
  1579. * Removes the defines that should be removed when falling back.
  1580. * @param currentDefines defines the current define statements for the shader.
  1581. * @param effect defines the current effect we try to compile
  1582. * @returns The resulting defines with defines of the current rank removed.
  1583. */
  1584. reduce(currentDefines: string, effect: Effect): string;
  1585. /**
  1586. * Removes the fallback from the bound mesh.
  1587. */
  1588. unBindMesh(): void;
  1589. /**
  1590. * Checks to see if more fallbacks are still availible.
  1591. */
  1592. hasMoreFallbacks: boolean;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1596. /**
  1597. * Class used to evalaute queries containing `and` and `or` operators
  1598. */
  1599. export class AndOrNotEvaluator {
  1600. /**
  1601. * Evaluate a query
  1602. * @param query defines the query to evaluate
  1603. * @param evaluateCallback defines the callback used to filter result
  1604. * @returns true if the query matches
  1605. */
  1606. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1607. private static _HandleParenthesisContent;
  1608. private static _SimplifyNegation;
  1609. }
  1610. }
  1611. declare module "babylonjs/Misc/tags" {
  1612. /**
  1613. * Class used to store custom tags
  1614. */
  1615. export class Tags {
  1616. /**
  1617. * Adds support for tags on the given object
  1618. * @param obj defines the object to use
  1619. */
  1620. static EnableFor(obj: any): void;
  1621. /**
  1622. * Removes tags support
  1623. * @param obj defines the object to use
  1624. */
  1625. static DisableFor(obj: any): void;
  1626. /**
  1627. * Gets a boolean indicating if the given object has tags
  1628. * @param obj defines the object to use
  1629. * @returns a boolean
  1630. */
  1631. static HasTags(obj: any): boolean;
  1632. /**
  1633. * Gets the tags available on a given object
  1634. * @param obj defines the object to use
  1635. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1636. * @returns the tags
  1637. */
  1638. static GetTags(obj: any, asString?: boolean): any;
  1639. /**
  1640. * Adds tags to an object
  1641. * @param obj defines the object to use
  1642. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1643. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1644. */
  1645. static AddTagsTo(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _AddTagTo(obj: any, tag: string): void;
  1650. /**
  1651. * Removes specific tags from a specific object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tags to remove
  1654. */
  1655. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1656. /**
  1657. * @hidden
  1658. */
  1659. static _RemoveTagFrom(obj: any, tag: string): void;
  1660. /**
  1661. * Defines if tags hosted on an object match a given query
  1662. * @param obj defines the object to use
  1663. * @param tagsQuery defines the tag query
  1664. * @returns a boolean
  1665. */
  1666. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1667. }
  1668. }
  1669. declare module "babylonjs/Maths/math.scalar" {
  1670. /**
  1671. * Scalar computation library
  1672. */
  1673. export class Scalar {
  1674. /**
  1675. * Two pi constants convenient for computation.
  1676. */
  1677. static TwoPi: number;
  1678. /**
  1679. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1680. * @param a number
  1681. * @param b number
  1682. * @param epsilon (default = 1.401298E-45)
  1683. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1684. */
  1685. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1686. /**
  1687. * Returns a string : the upper case translation of the number i to hexadecimal.
  1688. * @param i number
  1689. * @returns the upper case translation of the number i to hexadecimal.
  1690. */
  1691. static ToHex(i: number): string;
  1692. /**
  1693. * Returns -1 if value is negative and +1 is value is positive.
  1694. * @param value the value
  1695. * @returns the value itself if it's equal to zero.
  1696. */
  1697. static Sign(value: number): number;
  1698. /**
  1699. * Returns the value itself if it's between min and max.
  1700. * Returns min if the value is lower than min.
  1701. * Returns max if the value is greater than max.
  1702. * @param value the value to clmap
  1703. * @param min the min value to clamp to (default: 0)
  1704. * @param max the max value to clamp to (default: 1)
  1705. * @returns the clamped value
  1706. */
  1707. static Clamp(value: number, min?: number, max?: number): number;
  1708. /**
  1709. * the log2 of value.
  1710. * @param value the value to compute log2 of
  1711. * @returns the log2 of value.
  1712. */
  1713. static Log2(value: number): number;
  1714. /**
  1715. * Loops the value, so that it is never larger than length and never smaller than 0.
  1716. *
  1717. * This is similar to the modulo operator but it works with floating point numbers.
  1718. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1719. * With t = 5 and length = 2.5, the result would be 0.0.
  1720. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1721. * @param value the value
  1722. * @param length the length
  1723. * @returns the looped value
  1724. */
  1725. static Repeat(value: number, length: number): number;
  1726. /**
  1727. * Normalize the value between 0.0 and 1.0 using min and max values
  1728. * @param value value to normalize
  1729. * @param min max to normalize between
  1730. * @param max min to normalize between
  1731. * @returns the normalized value
  1732. */
  1733. static Normalize(value: number, min: number, max: number): number;
  1734. /**
  1735. * Denormalize the value from 0.0 and 1.0 using min and max values
  1736. * @param normalized value to denormalize
  1737. * @param min max to denormalize between
  1738. * @param max min to denormalize between
  1739. * @returns the denormalized value
  1740. */
  1741. static Denormalize(normalized: number, min: number, max: number): number;
  1742. /**
  1743. * Calculates the shortest difference between two given angles given in degrees.
  1744. * @param current current angle in degrees
  1745. * @param target target angle in degrees
  1746. * @returns the delta
  1747. */
  1748. static DeltaAngle(current: number, target: number): number;
  1749. /**
  1750. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1751. * @param tx value
  1752. * @param length length
  1753. * @returns The returned value will move back and forth between 0 and length
  1754. */
  1755. static PingPong(tx: number, length: number): number;
  1756. /**
  1757. * Interpolates between min and max with smoothing at the limits.
  1758. *
  1759. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1760. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1761. * @param from from
  1762. * @param to to
  1763. * @param tx value
  1764. * @returns the smooth stepped value
  1765. */
  1766. static SmoothStep(from: number, to: number, tx: number): number;
  1767. /**
  1768. * Moves a value current towards target.
  1769. *
  1770. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1771. * Negative values of maxDelta pushes the value away from target.
  1772. * @param current current value
  1773. * @param target target value
  1774. * @param maxDelta max distance to move
  1775. * @returns resulting value
  1776. */
  1777. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1778. /**
  1779. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1780. *
  1781. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1782. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting angle
  1787. */
  1788. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1791. * @param start start value
  1792. * @param end target value
  1793. * @param amount amount to lerp between
  1794. * @returns the lerped value
  1795. */
  1796. static Lerp(start: number, end: number, amount: number): number;
  1797. /**
  1798. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1800. * @param start start value
  1801. * @param end target value
  1802. * @param amount amount to lerp between
  1803. * @returns the lerped value
  1804. */
  1805. static LerpAngle(start: number, end: number, amount: number): number;
  1806. /**
  1807. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1808. * @param a start value
  1809. * @param b target value
  1810. * @param value value between a and b
  1811. * @returns the inverseLerp value
  1812. */
  1813. static InverseLerp(a: number, b: number, value: number): number;
  1814. /**
  1815. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1816. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1817. * @param value1 spline value
  1818. * @param tangent1 spline value
  1819. * @param value2 spline value
  1820. * @param tangent2 spline value
  1821. * @param amount input value
  1822. * @returns hermite result
  1823. */
  1824. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1825. /**
  1826. * Returns a random float number between and min and max values
  1827. * @param min min value of random
  1828. * @param max max value of random
  1829. * @returns random value
  1830. */
  1831. static RandomRange(min: number, max: number): number;
  1832. /**
  1833. * This function returns percentage of a number in a given range.
  1834. *
  1835. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1836. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1837. * @param number to convert to percentage
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the percentage
  1841. */
  1842. static RangeToPercent(number: number, min: number, max: number): number;
  1843. /**
  1844. * This function returns number that corresponds to the percentage in a given range.
  1845. *
  1846. * PercentToRange(0.34,0,100) will return 34.
  1847. * @param percent to convert to number
  1848. * @param min min range
  1849. * @param max max range
  1850. * @returns the number
  1851. */
  1852. static PercentToRange(percent: number, min: number, max: number): number;
  1853. /**
  1854. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1855. * @param angle The angle to normalize in radian.
  1856. * @return The converted angle.
  1857. */
  1858. static NormalizeRadians(angle: number): number;
  1859. }
  1860. }
  1861. declare module "babylonjs/Maths/math.constants" {
  1862. /**
  1863. * Constant used to convert a value to gamma space
  1864. * @ignorenaming
  1865. */
  1866. export const ToGammaSpace: number;
  1867. /**
  1868. * Constant used to convert a value to linear space
  1869. * @ignorenaming
  1870. */
  1871. export const ToLinearSpace = 2.2;
  1872. /**
  1873. * Constant used to define the minimal number value in Babylon.js
  1874. * @ignorenaming
  1875. */
  1876. let Epsilon: number;
  1877. export { Epsilon };
  1878. }
  1879. declare module "babylonjs/Maths/math.viewport" {
  1880. /**
  1881. * Class used to represent a viewport on screen
  1882. */
  1883. export class Viewport {
  1884. /** viewport left coordinate */
  1885. x: number;
  1886. /** viewport top coordinate */
  1887. y: number;
  1888. /**viewport width */
  1889. width: number;
  1890. /** viewport height */
  1891. height: number;
  1892. /**
  1893. * Creates a Viewport object located at (x, y) and sized (width, height)
  1894. * @param x defines viewport left coordinate
  1895. * @param y defines viewport top coordinate
  1896. * @param width defines the viewport width
  1897. * @param height defines the viewport height
  1898. */
  1899. constructor(
  1900. /** viewport left coordinate */
  1901. x: number,
  1902. /** viewport top coordinate */
  1903. y: number,
  1904. /**viewport width */
  1905. width: number,
  1906. /** viewport height */
  1907. height: number);
  1908. /**
  1909. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1910. * @param renderWidth defines the rendering width
  1911. * @param renderHeight defines the rendering height
  1912. * @returns a new Viewport
  1913. */
  1914. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1915. /**
  1916. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1917. * @param renderWidth defines the rendering width
  1918. * @param renderHeight defines the rendering height
  1919. * @param ref defines the target viewport
  1920. * @returns the current viewport
  1921. */
  1922. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1923. /**
  1924. * Returns a new Viewport copied from the current one
  1925. * @returns a new Viewport
  1926. */
  1927. clone(): Viewport;
  1928. }
  1929. }
  1930. declare module "babylonjs/Misc/arrayTools" {
  1931. /**
  1932. * Class containing a set of static utilities functions for arrays.
  1933. */
  1934. export class ArrayTools {
  1935. /**
  1936. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1937. * @param size the number of element to construct and put in the array
  1938. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1939. * @returns a new array filled with new objects
  1940. */
  1941. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1942. }
  1943. }
  1944. declare module "babylonjs/Maths/math.plane" {
  1945. import { DeepImmutable } from "babylonjs/types";
  1946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1947. /**
  1948. * Represens a plane by the equation ax + by + cz + d = 0
  1949. */
  1950. export class Plane {
  1951. private static _TmpMatrix;
  1952. /**
  1953. * Normal of the plane (a,b,c)
  1954. */
  1955. normal: Vector3;
  1956. /**
  1957. * d component of the plane
  1958. */
  1959. d: number;
  1960. /**
  1961. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1962. * @param a a component of the plane
  1963. * @param b b component of the plane
  1964. * @param c c component of the plane
  1965. * @param d d component of the plane
  1966. */
  1967. constructor(a: number, b: number, c: number, d: number);
  1968. /**
  1969. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * @returns a new plane copied from the current Plane.
  1974. */
  1975. clone(): Plane;
  1976. /**
  1977. * @returns the string "Plane".
  1978. */
  1979. getClassName(): string;
  1980. /**
  1981. * @returns the Plane hash code.
  1982. */
  1983. getHashCode(): number;
  1984. /**
  1985. * Normalize the current Plane in place.
  1986. * @returns the updated Plane.
  1987. */
  1988. normalize(): Plane;
  1989. /**
  1990. * Applies a transformation the plane and returns the result
  1991. * @param transformation the transformation matrix to be applied to the plane
  1992. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1993. */
  1994. transform(transformation: DeepImmutable<Matrix>): Plane;
  1995. /**
  1996. * Compute the dot product between the point and the plane normal
  1997. * @param point point to calculate the dot product with
  1998. * @returns the dot product (float) of the point coordinates and the plane normal.
  1999. */
  2000. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2001. /**
  2002. * Updates the current Plane from the plane defined by the three given points.
  2003. * @param point1 one of the points used to contruct the plane
  2004. * @param point2 one of the points used to contruct the plane
  2005. * @param point3 one of the points used to contruct the plane
  2006. * @returns the updated Plane.
  2007. */
  2008. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2009. /**
  2010. * Checks if the plane is facing a given direction
  2011. * @param direction the direction to check if the plane is facing
  2012. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2013. * @returns True is the vector "direction" is the same side than the plane normal.
  2014. */
  2015. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2016. /**
  2017. * Calculates the distance to a point
  2018. * @param point point to calculate distance to
  2019. * @returns the signed distance (float) from the given point to the Plane.
  2020. */
  2021. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2022. /**
  2023. * Creates a plane from an array
  2024. * @param array the array to create a plane from
  2025. * @returns a new Plane from the given array.
  2026. */
  2027. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2028. /**
  2029. * Creates a plane from three points
  2030. * @param point1 point used to create the plane
  2031. * @param point2 point used to create the plane
  2032. * @param point3 point used to create the plane
  2033. * @returns a new Plane defined by the three given points.
  2034. */
  2035. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Creates a plane from an origin point and a normal
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @returns a new Plane the normal vector to this plane at the given origin point.
  2041. * Note : the vector "normal" is updated because normalized.
  2042. */
  2043. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2044. /**
  2045. * Calculates the distance from a plane and a point
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @param point point to calculate distance to
  2049. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2050. */
  2051. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2052. }
  2053. }
  2054. declare module "babylonjs/Maths/math.vector" {
  2055. import { Viewport } from "babylonjs/Maths/math.viewport";
  2056. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2057. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2058. import { Plane } from "babylonjs/Maths/math.plane";
  2059. /**
  2060. * Class representing a vector containing 2 coordinates
  2061. */
  2062. export class Vector2 {
  2063. /** defines the first coordinate */
  2064. x: number;
  2065. /** defines the second coordinate */
  2066. y: number;
  2067. /**
  2068. * Creates a new Vector2 from the given x and y coordinates
  2069. * @param x defines the first coordinate
  2070. * @param y defines the second coordinate
  2071. */
  2072. constructor(
  2073. /** defines the first coordinate */
  2074. x?: number,
  2075. /** defines the second coordinate */
  2076. y?: number);
  2077. /**
  2078. * Gets a string with the Vector2 coordinates
  2079. * @returns a string with the Vector2 coordinates
  2080. */
  2081. toString(): string;
  2082. /**
  2083. * Gets class name
  2084. * @returns the string "Vector2"
  2085. */
  2086. getClassName(): string;
  2087. /**
  2088. * Gets current vector hash code
  2089. * @returns the Vector2 hash code as a number
  2090. */
  2091. getHashCode(): number;
  2092. /**
  2093. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2094. * @param array defines the source array
  2095. * @param index defines the offset in source array
  2096. * @returns the current Vector2
  2097. */
  2098. toArray(array: FloatArray, index?: number): Vector2;
  2099. /**
  2100. * Copy the current vector to an array
  2101. * @returns a new array with 2 elements: the Vector2 coordinates.
  2102. */
  2103. asArray(): number[];
  2104. /**
  2105. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2106. * @param source defines the source Vector2
  2107. * @returns the current updated Vector2
  2108. */
  2109. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2110. /**
  2111. * Sets the Vector2 coordinates with the given floats
  2112. * @param x defines the first coordinate
  2113. * @param y defines the second coordinate
  2114. * @returns the current updated Vector2
  2115. */
  2116. copyFromFloats(x: number, y: number): Vector2;
  2117. /**
  2118. * Sets the Vector2 coordinates with the given floats
  2119. * @param x defines the first coordinate
  2120. * @param y defines the second coordinate
  2121. * @returns the current updated Vector2
  2122. */
  2123. set(x: number, y: number): Vector2;
  2124. /**
  2125. * Add another vector with the current one
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2128. */
  2129. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @param result defines the target vector
  2134. * @returns the unmodified current Vector2
  2135. */
  2136. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2137. /**
  2138. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2139. * @param otherVector defines the other vector
  2140. * @returns the current updated Vector2
  2141. */
  2142. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns a new Vector2
  2147. */
  2148. addVector3(otherVector: Vector3): Vector2;
  2149. /**
  2150. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2151. * @param otherVector defines the other vector
  2152. * @returns a new Vector2
  2153. */
  2154. subtract(otherVector: Vector2): Vector2;
  2155. /**
  2156. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2157. * @param otherVector defines the other vector
  2158. * @param result defines the target vector
  2159. * @returns the unmodified current Vector2
  2160. */
  2161. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2162. /**
  2163. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @returns the current updated Vector2
  2166. */
  2167. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Multiplies in place the current Vector2 coordinates by the given ones
  2170. * @param otherVector defines the other vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2176. * @param otherVector defines the other vector
  2177. * @returns a new Vector2
  2178. */
  2179. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2182. * @param otherVector defines the other vector
  2183. * @param result defines the target vector
  2184. * @returns the unmodified current Vector2
  2185. */
  2186. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns a new Vector2
  2192. */
  2193. multiplyByFloats(x: number, y: number): Vector2;
  2194. /**
  2195. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2
  2198. */
  2199. divide(otherVector: Vector2): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Divides the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 with current Vector2 negated coordinates
  2215. * @returns a new Vector2
  2216. */
  2217. negate(): Vector2;
  2218. /**
  2219. * Negate this vector in place
  2220. * @returns this
  2221. */
  2222. negateInPlace(): Vector2;
  2223. /**
  2224. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2225. * @param result defines the Vector3 object where to store the result
  2226. * @returns the current Vector2
  2227. */
  2228. negateToRef(result: Vector2): Vector2;
  2229. /**
  2230. * Multiply the Vector2 coordinates by scale
  2231. * @param scale defines the scaling factor
  2232. * @returns the current updated Vector2
  2233. */
  2234. scaleInPlace(scale: number): Vector2;
  2235. /**
  2236. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2237. * @param scale defines the scaling factor
  2238. * @returns a new Vector2
  2239. */
  2240. scale(scale: number): Vector2;
  2241. /**
  2242. * Scale the current Vector2 values by a factor to a given Vector2
  2243. * @param scale defines the scale factor
  2244. * @param result defines the Vector2 object where to store the result
  2245. * @returns the unmodified current Vector2
  2246. */
  2247. scaleToRef(scale: number, result: Vector2): Vector2;
  2248. /**
  2249. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2250. * @param scale defines the scale factor
  2251. * @param result defines the Vector2 object where to store the result
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a boolean if two vectors are equals
  2257. * @param otherVector defines the other vector
  2258. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2259. */
  2260. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2261. /**
  2262. * Gets a boolean if two vectors are equals (using an epsilon value)
  2263. * @param otherVector defines the other vector
  2264. * @param epsilon defines the minimal distance to consider equality
  2265. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2266. */
  2267. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2268. /**
  2269. * Gets a new Vector2 from current Vector2 floored values
  2270. * @returns a new Vector2
  2271. */
  2272. floor(): Vector2;
  2273. /**
  2274. * Gets a new Vector2 from current Vector2 floored values
  2275. * @returns a new Vector2
  2276. */
  2277. fract(): Vector2;
  2278. /**
  2279. * Gets the length of the vector
  2280. * @returns the vector length (float)
  2281. */
  2282. length(): number;
  2283. /**
  2284. * Gets the vector squared length
  2285. * @returns the vector squared length (float)
  2286. */
  2287. lengthSquared(): number;
  2288. /**
  2289. * Normalize the vector
  2290. * @returns the current updated Vector2
  2291. */
  2292. normalize(): Vector2;
  2293. /**
  2294. * Gets a new Vector2 copied from the Vector2
  2295. * @returns a new Vector2
  2296. */
  2297. clone(): Vector2;
  2298. /**
  2299. * Gets a new Vector2(0, 0)
  2300. * @returns a new Vector2
  2301. */
  2302. static Zero(): Vector2;
  2303. /**
  2304. * Gets a new Vector2(1, 1)
  2305. * @returns a new Vector2
  2306. */
  2307. static One(): Vector2;
  2308. /**
  2309. * Gets a new Vector2 set from the given index element of the given array
  2310. * @param array defines the data source
  2311. * @param offset defines the offset in the data source
  2312. * @returns a new Vector2
  2313. */
  2314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2315. /**
  2316. * Sets "result" from the given index element of the given array
  2317. * @param array defines the data source
  2318. * @param offset defines the offset in the data source
  2319. * @param result defines the target vector
  2320. */
  2321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2322. /**
  2323. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2324. * @param value1 defines 1st point of control
  2325. * @param value2 defines 2nd point of control
  2326. * @param value3 defines 3rd point of control
  2327. * @param value4 defines 4th point of control
  2328. * @param amount defines the interpolation factor
  2329. * @returns a new Vector2
  2330. */
  2331. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2332. /**
  2333. * 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".
  2334. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2335. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2336. * @param value defines the value to clamp
  2337. * @param min defines the lower limit
  2338. * @param max defines the upper limit
  2339. * @returns a new Vector2
  2340. */
  2341. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2342. /**
  2343. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2344. * @param value1 defines the 1st control point
  2345. * @param tangent1 defines the outgoing tangent
  2346. * @param value2 defines the 2nd control point
  2347. * @param tangent2 defines the incoming tangent
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2354. * @param start defines the start vector
  2355. * @param end defines the end vector
  2356. * @param amount defines the interpolation factor
  2357. * @returns a new Vector2
  2358. */
  2359. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2360. /**
  2361. * Gets the dot product of the vector "left" and the vector "right"
  2362. * @param left defines first vector
  2363. * @param right defines second vector
  2364. * @returns the dot product (float)
  2365. */
  2366. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2367. /**
  2368. * Returns a new Vector2 equal to the normalized given vector
  2369. * @param vector defines the vector to normalize
  2370. * @returns a new Vector2
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2373. /**
  2374. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2375. * @param left defines 1st vector
  2376. * @param right defines 2nd vector
  2377. * @returns a new Vector2
  2378. */
  2379. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2380. /**
  2381. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2382. * @param left defines 1st vector
  2383. * @param right defines 2nd vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2389. * @param vector defines the vector to transform
  2390. * @param transformation defines the matrix to apply
  2391. * @returns a new Vector2
  2392. */
  2393. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2394. /**
  2395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2396. * @param vector defines the vector to transform
  2397. * @param transformation defines the matrix to apply
  2398. * @param result defines the target vector
  2399. */
  2400. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2401. /**
  2402. * Determines if a given vector is included in a triangle
  2403. * @param p defines the vector to test
  2404. * @param p0 defines 1st triangle point
  2405. * @param p1 defines 2nd triangle point
  2406. * @param p2 defines 3rd triangle point
  2407. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2408. */
  2409. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2410. /**
  2411. * Gets the distance between the vectors "value1" and "value2"
  2412. * @param value1 defines first vector
  2413. * @param value2 defines second vector
  2414. * @returns the distance between vectors
  2415. */
  2416. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2417. /**
  2418. * Returns the squared distance between the vectors "value1" and "value2"
  2419. * @param value1 defines first vector
  2420. * @param value2 defines second vector
  2421. * @returns the squared distance between vectors
  2422. */
  2423. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2424. /**
  2425. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2426. * @param value1 defines first vector
  2427. * @param value2 defines second vector
  2428. * @returns a new Vector2
  2429. */
  2430. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2433. * @param p defines the middle point
  2434. * @param segA defines one point of the segment
  2435. * @param segB defines the other point of the segment
  2436. * @returns the shortest distance
  2437. */
  2438. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2439. }
  2440. /**
  2441. * Class used to store (x,y,z) vector representation
  2442. * A Vector3 is the main object used in 3D geometry
  2443. * It can represent etiher the coordinates of a point the space, either a direction
  2444. * Reminder: js uses a left handed forward facing system
  2445. */
  2446. export class Vector3 {
  2447. /**
  2448. * Defines the first coordinates (on X axis)
  2449. */
  2450. x: number;
  2451. /**
  2452. * Defines the second coordinates (on Y axis)
  2453. */
  2454. y: number;
  2455. /**
  2456. * Defines the third coordinates (on Z axis)
  2457. */
  2458. z: number;
  2459. private static _UpReadOnly;
  2460. private static _ZeroReadOnly;
  2461. /**
  2462. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2463. * @param x defines the first coordinates (on X axis)
  2464. * @param y defines the second coordinates (on Y axis)
  2465. * @param z defines the third coordinates (on Z axis)
  2466. */
  2467. constructor(
  2468. /**
  2469. * Defines the first coordinates (on X axis)
  2470. */
  2471. x?: number,
  2472. /**
  2473. * Defines the second coordinates (on Y axis)
  2474. */
  2475. y?: number,
  2476. /**
  2477. * Defines the third coordinates (on Z axis)
  2478. */
  2479. z?: number);
  2480. /**
  2481. * Creates a string representation of the Vector3
  2482. * @returns a string with the Vector3 coordinates.
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name
  2487. * @returns the string "Vector3"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Creates the Vector3 hash code
  2492. * @returns a number which tends to be unique between Vector3 instances
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Creates an array containing three elements : the coordinates of the Vector3
  2497. * @returns a new array of numbers
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2502. * @param array defines the destination array
  2503. * @param index defines the offset in the destination array
  2504. * @returns the current Vector3
  2505. */
  2506. toArray(array: FloatArray, index?: number): Vector3;
  2507. /**
  2508. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2509. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2510. */
  2511. toQuaternion(): Quaternion;
  2512. /**
  2513. * Adds the given vector to the current Vector3
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Adds the given coordinates to the current Vector3
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the current updated Vector3
  2524. */
  2525. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2528. * @param otherVector defines the second operand
  2529. * @returns the resulting Vector3
  2530. */
  2531. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Subtract the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2547. * @param otherVector defines the second operand
  2548. * @returns the resulting Vector3
  2549. */
  2550. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2553. * @param otherVector defines the second operand
  2554. * @param result defines the Vector3 object where to store the result
  2555. * @returns the current Vector3
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2558. /**
  2559. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2566. /**
  2567. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2568. * @param x defines the x coordinate of the operand
  2569. * @param y defines the y coordinate of the operand
  2570. * @param z defines the z coordinate of the operand
  2571. * @param result defines the Vector3 object where to store the result
  2572. * @returns the current Vector3
  2573. */
  2574. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2575. /**
  2576. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2577. * @returns a new Vector3
  2578. */
  2579. negate(): Vector3;
  2580. /**
  2581. * Negate this vector in place
  2582. * @returns this
  2583. */
  2584. negateInPlace(): Vector3;
  2585. /**
  2586. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the current Vector3
  2589. */
  2590. negateToRef(result: Vector3): Vector3;
  2591. /**
  2592. * Multiplies the Vector3 coordinates by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns the current updated Vector3
  2595. */
  2596. scaleInPlace(scale: number): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2599. * @param scale defines the multiplier factor
  2600. * @returns a new Vector3
  2601. */
  2602. scale(scale: number): Vector3;
  2603. /**
  2604. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2605. * @param scale defines the multiplier factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the current Vector3
  2608. */
  2609. scaleToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2612. * @param scale defines the scale factor
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the unmodified current Vector3
  2615. */
  2616. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2617. /**
  2618. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2619. * @param origin defines the origin of the projection ray
  2620. * @param plane defines the plane to project to
  2621. * @returns the projected vector3
  2622. */
  2623. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2624. /**
  2625. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2626. * @param origin defines the origin of the projection ray
  2627. * @param plane defines the plane to project to
  2628. * @param result defines the Vector3 where to store the result
  2629. */
  2630. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2633. * @param otherVector defines the second operand
  2634. * @returns true if both vectors are equals
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2639. * @param otherVector defines the second operand
  2640. * @param epsilon defines the minimal distance to define values as equals
  2641. * @returns true if both vectors are distant less than epsilon
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2644. /**
  2645. * Returns true if the current Vector3 coordinates equals the given floats
  2646. * @param x defines the x coordinate of the operand
  2647. * @param y defines the y coordinate of the operand
  2648. * @param z defines the z coordinate of the operand
  2649. * @returns true if both vectors are equals
  2650. */
  2651. equalsToFloats(x: number, y: number, z: number): boolean;
  2652. /**
  2653. * Multiplies the current Vector3 coordinates by the given ones
  2654. * @param otherVector defines the second operand
  2655. * @returns the current updated Vector3
  2656. */
  2657. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2660. * @param otherVector defines the second operand
  2661. * @returns the new Vector3
  2662. */
  2663. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2664. /**
  2665. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2666. * @param otherVector defines the second operand
  2667. * @param result defines the Vector3 object where to store the result
  2668. * @returns the current Vector3
  2669. */
  2670. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the new Vector3
  2677. */
  2678. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2681. * @param otherVector defines the second operand
  2682. * @returns the new Vector3
  2683. */
  2684. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2687. * @param otherVector defines the second operand
  2688. * @param result defines the Vector3 object where to store the result
  2689. * @returns the current Vector3
  2690. */
  2691. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2692. /**
  2693. * Divides the current Vector3 coordinates by the given ones.
  2694. * @param otherVector defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. divideInPlace(otherVector: Vector3): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2706. * @param other defines the second operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2720. * @param x defines the x coordinate of the operand
  2721. * @param y defines the y coordinate of the operand
  2722. * @param z defines the z coordinate of the operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2726. /**
  2727. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2728. * Check if is non uniform within a certain amount of decimal places to account for this
  2729. * @param epsilon the amount the values can differ
  2730. * @returns if the the vector is non uniform to a certain number of decimal places
  2731. */
  2732. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2733. /**
  2734. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2735. */
  2736. get isNonUniform(): boolean;
  2737. /**
  2738. * Gets a new Vector3 from current Vector3 floored values
  2739. * @returns a new Vector3
  2740. */
  2741. floor(): Vector3;
  2742. /**
  2743. * Gets a new Vector3 from current Vector3 floored values
  2744. * @returns a new Vector3
  2745. */
  2746. fract(): Vector3;
  2747. /**
  2748. * Gets the length of the Vector3
  2749. * @returns the length of the Vector3
  2750. */
  2751. length(): number;
  2752. /**
  2753. * Gets the squared length of the Vector3
  2754. * @returns squared length of the Vector3
  2755. */
  2756. lengthSquared(): number;
  2757. /**
  2758. * Normalize the current Vector3.
  2759. * Please note that this is an in place operation.
  2760. * @returns the current updated Vector3
  2761. */
  2762. normalize(): Vector3;
  2763. /**
  2764. * Reorders the x y z properties of the vector in place
  2765. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2766. * @returns the current updated vector
  2767. */
  2768. reorderInPlace(order: string): this;
  2769. /**
  2770. * Rotates the vector around 0,0,0 by a quaternion
  2771. * @param quaternion the rotation quaternion
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2776. /**
  2777. * Rotates a vector around a given point
  2778. * @param quaternion the rotation quaternion
  2779. * @param point the point to rotate around
  2780. * @param result vector to store the result
  2781. * @returns the resulting vector
  2782. */
  2783. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2784. /**
  2785. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2786. * The cross product is then orthogonal to both current and "other"
  2787. * @param other defines the right operand
  2788. * @returns the cross product
  2789. */
  2790. cross(other: Vector3): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 with the given input length.
  2793. * Please note that this is an in place operation.
  2794. * @param len the length of the vector
  2795. * @returns the current updated Vector3
  2796. */
  2797. normalizeFromLength(len: number): Vector3;
  2798. /**
  2799. * Normalize the current Vector3 to a new vector
  2800. * @returns the new Vector3
  2801. */
  2802. normalizeToNew(): Vector3;
  2803. /**
  2804. * Normalize the current Vector3 to the reference
  2805. * @param reference define the Vector3 to update
  2806. * @returns the updated Vector3
  2807. */
  2808. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Creates a new Vector3 copied from the current Vector3
  2811. * @returns the new Vector3
  2812. */
  2813. clone(): Vector3;
  2814. /**
  2815. * Copies the given vector coordinates to the current Vector3 ones
  2816. * @param source defines the source Vector3
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. copyFromFloats(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given floats to the current Vector3 coordinates
  2830. * @param x defines the x coordinate of the operand
  2831. * @param y defines the y coordinate of the operand
  2832. * @param z defines the z coordinate of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. set(x: number, y: number, z: number): Vector3;
  2836. /**
  2837. * Copies the given float to the current Vector3 coordinates
  2838. * @param v defines the x, y and z coordinates of the operand
  2839. * @returns the current updated Vector3
  2840. */
  2841. setAll(v: number): Vector3;
  2842. /**
  2843. * Get the clip factor between two vectors
  2844. * @param vector0 defines the first operand
  2845. * @param vector1 defines the second operand
  2846. * @param axis defines the axis to use
  2847. * @param size defines the size along the axis
  2848. * @returns the clip factor
  2849. */
  2850. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2851. /**
  2852. * Get angle between two vectors
  2853. * @param vector0 angle between vector0 and vector1
  2854. * @param vector1 angle between vector0 and vector1
  2855. * @param normal direction of the normal
  2856. * @return the angle between vector0 and vector1
  2857. */
  2858. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. */
  2865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @returns the new Vector3
  2871. * @deprecated Please use FromArray instead.
  2872. */
  2873. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2876. * @param array defines the source array
  2877. * @param offset defines the offset in the source array
  2878. * @param result defines the Vector3 where to store the result
  2879. */
  2880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @param result defines the Vector3 where to store the result
  2886. * @deprecated Please use FromArrayToRef instead.
  2887. */
  2888. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2889. /**
  2890. * Sets the given vector "result" with the given floats.
  2891. * @param x defines the x coordinate of the source
  2892. * @param y defines the y coordinate of the source
  2893. * @param z defines the z coordinate of the source
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2899. * @returns a new empty Vector3
  2900. */
  2901. static Zero(): Vector3;
  2902. /**
  2903. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2904. * @returns a new unit Vector3
  2905. */
  2906. static One(): Vector3;
  2907. /**
  2908. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2909. * @returns a new up Vector3
  2910. */
  2911. static Up(): Vector3;
  2912. /**
  2913. * Gets a up Vector3 that must not be updated
  2914. */
  2915. static get UpReadOnly(): DeepImmutable<Vector3>;
  2916. /**
  2917. * Gets a zero Vector3 that must not be updated
  2918. */
  2919. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2922. * @returns a new down Vector3
  2923. */
  2924. static Down(): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Forward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2933. * @param rightHandedSystem is the scene right-handed (negative-z)
  2934. * @returns a new forward Vector3
  2935. */
  2936. static Backward(rightHandedSystem?: boolean): Vector3;
  2937. /**
  2938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2939. * @returns a new right Vector3
  2940. */
  2941. static Right(): Vector3;
  2942. /**
  2943. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2944. * @returns a new left Vector3
  2945. */
  2946. static Left(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the transformed Vector3
  2953. */
  2954. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2965. * This method computes tranformed coordinates only, not transformed direction vectors
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the new Vector3
  2979. */
  2980. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2991. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3001. * @param value1 defines the first control point
  3002. * @param value2 defines the second control point
  3003. * @param value3 defines the third control point
  3004. * @param value4 defines the fourth control point
  3005. * @param amount defines the amount on the spline to use
  3006. * @returns the new Vector3
  3007. */
  3008. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3009. /**
  3010. * 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"
  3011. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3012. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3013. * @param value defines the current value
  3014. * @param min defines the lower range value
  3015. * @param max defines the upper range value
  3016. * @returns the new Vector3
  3017. */
  3018. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3019. /**
  3020. * 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"
  3021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3023. * @param value defines the current value
  3024. * @param min defines the lower range value
  3025. * @param max defines the upper range value
  3026. * @param result defines the Vector3 where to store the result
  3027. */
  3028. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3029. /**
  3030. * Checks if a given vector is inside a specific range
  3031. * @param v defines the vector to test
  3032. * @param min defines the minimum range
  3033. * @param max defines the maximum range
  3034. */
  3035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3036. /**
  3037. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3038. * @param value1 defines the first control point
  3039. * @param tangent1 defines the first tangent vector
  3040. * @param value2 defines the second control point
  3041. * @param tangent2 defines the second tangent vector
  3042. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @returns the new Vector3
  3052. */
  3053. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3054. /**
  3055. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3056. * @param start defines the start value
  3057. * @param end defines the end value
  3058. * @param amount max defines amount between both (between 0 and 1)
  3059. * @param result defines the Vector3 where to store the result
  3060. */
  3061. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3062. /**
  3063. * Returns the dot product (float) between the vectors "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the dot product
  3067. */
  3068. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3069. /**
  3070. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @returns the cross product
  3075. */
  3076. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the cross product of "left" and "right"
  3079. * The cross product is then orthogonal to both "left" and "right"
  3080. * @param left defines the left operand
  3081. * @param right defines the right operand
  3082. * @param result defines the Vector3 where to store the result
  3083. */
  3084. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3085. /**
  3086. * Returns a new Vector3 as the normalization of the given vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @returns the new Vector3
  3089. */
  3090. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * Sets the given vector "result" with the normalization of the given first vector
  3093. * @param vector defines the Vector3 to normalize
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Project a Vector3 onto screen space
  3099. * @param vector defines the Vector3 to project
  3100. * @param world defines the world matrix to use
  3101. * @param transform defines the transform (view x projection) matrix to use
  3102. * @param viewport defines the screen viewport to use
  3103. * @returns the new Vector3
  3104. */
  3105. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3106. /** @hidden */
  3107. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3108. /**
  3109. * Unproject from screen space to object space
  3110. * @param source defines the screen space Vector3 to use
  3111. * @param viewportWidth defines the current width of the viewport
  3112. * @param viewportHeight defines the current height of the viewport
  3113. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3114. * @param transform defines the transform (view x projection) matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @returns the new Vector3
  3127. */
  3128. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param source defines the screen space Vector3 to use
  3132. * @param viewportWidth defines the current width of the viewport
  3133. * @param viewportHeight defines the current height of the viewport
  3134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3135. * @param view defines the view matrix to use
  3136. * @param projection defines the projection matrix to use
  3137. * @param result defines the Vector3 where to store the result
  3138. */
  3139. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param sourceX defines the screen space x coordinate to use
  3143. * @param sourceY defines the screen space y coordinate to use
  3144. * @param sourceZ defines the screen space z coordinate to use
  3145. * @param viewportWidth defines the current width of the viewport
  3146. * @param viewportHeight defines the current height of the viewport
  3147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3148. * @param view defines the view matrix to use
  3149. * @param projection defines the projection matrix to use
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3153. /**
  3154. * Gets the minimal coordinate values between two Vector3
  3155. * @param left defines the first operand
  3156. * @param right defines the second operand
  3157. * @returns the new Vector3
  3158. */
  3159. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Gets the maximal coordinate values between two Vector3
  3162. * @param left defines the first operand
  3163. * @param right defines the second operand
  3164. * @returns the new Vector3
  3165. */
  3166. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3167. /**
  3168. * Returns the distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the distance
  3172. */
  3173. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns the squared distance between the vectors "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the squared distance
  3179. */
  3180. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3181. /**
  3182. * Returns a new Vector3 located at the center between "value1" and "value2"
  3183. * @param value1 defines the first operand
  3184. * @param value2 defines the second operand
  3185. * @returns the new Vector3
  3186. */
  3187. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3190. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3191. * to something in order to rotate it from its local system to the given target system
  3192. * Note: axis1, axis2 and axis3 are normalized during this operation
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @returns a new Vector3
  3197. */
  3198. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3201. * @param axis1 defines the first axis
  3202. * @param axis2 defines the second axis
  3203. * @param axis3 defines the third axis
  3204. * @param ref defines the Vector3 where to store the result
  3205. */
  3206. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3207. }
  3208. /**
  3209. * Vector4 class created for EulerAngle class conversion to Quaternion
  3210. */
  3211. export class Vector4 {
  3212. /** x value of the vector */
  3213. x: number;
  3214. /** y value of the vector */
  3215. y: number;
  3216. /** z value of the vector */
  3217. z: number;
  3218. /** w value of the vector */
  3219. w: number;
  3220. /**
  3221. * Creates a Vector4 object from the given floats.
  3222. * @param x x value of the vector
  3223. * @param y y value of the vector
  3224. * @param z z value of the vector
  3225. * @param w w value of the vector
  3226. */
  3227. constructor(
  3228. /** x value of the vector */
  3229. x: number,
  3230. /** y value of the vector */
  3231. y: number,
  3232. /** z value of the vector */
  3233. z: number,
  3234. /** w value of the vector */
  3235. w: number);
  3236. /**
  3237. * Returns the string with the Vector4 coordinates.
  3238. * @returns a string containing all the vector values
  3239. */
  3240. toString(): string;
  3241. /**
  3242. * Returns the string "Vector4".
  3243. * @returns "Vector4"
  3244. */
  3245. getClassName(): string;
  3246. /**
  3247. * Returns the Vector4 hash code.
  3248. * @returns a unique hash code
  3249. */
  3250. getHashCode(): number;
  3251. /**
  3252. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3253. * @returns the resulting array
  3254. */
  3255. asArray(): number[];
  3256. /**
  3257. * Populates the given array from the given index with the Vector4 coordinates.
  3258. * @param array array to populate
  3259. * @param index index of the array to start at (default: 0)
  3260. * @returns the Vector4.
  3261. */
  3262. toArray(array: FloatArray, index?: number): Vector4;
  3263. /**
  3264. * Adds the given vector to the current Vector4.
  3265. * @param otherVector the vector to add
  3266. * @returns the updated Vector4.
  3267. */
  3268. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @returns the resulting vector
  3273. */
  3274. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3277. * @param otherVector the vector to add
  3278. * @param result the vector to store the result
  3279. * @returns the current Vector4.
  3280. */
  3281. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3282. /**
  3283. * Subtract in place the given vector from the current Vector4.
  3284. * @param otherVector the vector to subtract
  3285. * @returns the updated Vector4.
  3286. */
  3287. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the new vector with the result
  3292. */
  3293. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3296. * @param otherVector the vector to subtract
  3297. * @param result the vector to store the result
  3298. * @returns the current Vector4.
  3299. */
  3300. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3303. */
  3304. /**
  3305. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3306. * @param x value to subtract
  3307. * @param y value to subtract
  3308. * @param z value to subtract
  3309. * @param w value to subtract
  3310. * @returns new vector containing the result
  3311. */
  3312. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3313. /**
  3314. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3315. * @param x value to subtract
  3316. * @param y value to subtract
  3317. * @param z value to subtract
  3318. * @param w value to subtract
  3319. * @param result the vector to store the result in
  3320. * @returns the current Vector4.
  3321. */
  3322. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3325. * @returns a new vector with the negated values
  3326. */
  3327. negate(): Vector4;
  3328. /**
  3329. * Negate this vector in place
  3330. * @returns this
  3331. */
  3332. negateInPlace(): Vector4;
  3333. /**
  3334. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3335. * @param result defines the Vector3 object where to store the result
  3336. * @returns the current Vector4
  3337. */
  3338. negateToRef(result: Vector4): Vector4;
  3339. /**
  3340. * Multiplies the current Vector4 coordinates by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns the updated Vector4.
  3343. */
  3344. scaleInPlace(scale: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @returns a new vector with the result
  3349. */
  3350. scale(scale: number): Vector4;
  3351. /**
  3352. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3353. * @param scale the number to scale with
  3354. * @param result a vector to store the result in
  3355. * @returns the current Vector4.
  3356. */
  3357. scaleToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3360. * @param scale defines the scale factor
  3361. * @param result defines the Vector4 object where to store the result
  3362. * @returns the unmodified current Vector4
  3363. */
  3364. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3367. * @param otherVector the vector to compare against
  3368. * @returns true if they are equal
  3369. */
  3370. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3371. /**
  3372. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3373. * @param otherVector vector to compare against
  3374. * @param epsilon (Default: very small number)
  3375. * @returns true if they are equal
  3376. */
  3377. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3378. /**
  3379. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3380. * @param x x value to compare against
  3381. * @param y y value to compare against
  3382. * @param z z value to compare against
  3383. * @param w w value to compare against
  3384. * @returns true if equal
  3385. */
  3386. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3387. /**
  3388. * Multiplies in place the current Vector4 by the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns the updated Vector4.
  3391. */
  3392. multiplyInPlace(otherVector: Vector4): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @returns resulting new vector
  3397. */
  3398. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3399. /**
  3400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3401. * @param otherVector vector to multiple with
  3402. * @param result vector to store the result
  3403. * @returns the current Vector4.
  3404. */
  3405. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3408. * @param x x value multiply with
  3409. * @param y y value multiply with
  3410. * @param z z value multiply with
  3411. * @param w w value multiply with
  3412. * @returns resulting new vector
  3413. */
  3414. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3415. /**
  3416. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @returns resulting new vector
  3419. */
  3420. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3423. * @param otherVector vector to devide with
  3424. * @param result vector to store the result
  3425. * @returns the current Vector4.
  3426. */
  3427. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3428. /**
  3429. * Divides the current Vector3 coordinates by the given ones.
  3430. * @param otherVector vector to devide with
  3431. * @returns the updated Vector3.
  3432. */
  3433. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3442. * @param other defines the second operand
  3443. * @returns the current updated Vector4
  3444. */
  3445. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Gets a new Vector4 from current Vector4 floored values
  3448. * @returns a new Vector4
  3449. */
  3450. floor(): Vector4;
  3451. /**
  3452. * Gets a new Vector4 from current Vector3 floored values
  3453. * @returns a new Vector4
  3454. */
  3455. fract(): Vector4;
  3456. /**
  3457. * Returns the Vector4 length (float).
  3458. * @returns the length
  3459. */
  3460. length(): number;
  3461. /**
  3462. * Returns the Vector4 squared length (float).
  3463. * @returns the length squared
  3464. */
  3465. lengthSquared(): number;
  3466. /**
  3467. * Normalizes in place the Vector4.
  3468. * @returns the updated Vector4.
  3469. */
  3470. normalize(): Vector4;
  3471. /**
  3472. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3473. * @returns this converted to a new vector3
  3474. */
  3475. toVector3(): Vector3;
  3476. /**
  3477. * Returns a new Vector4 copied from the current one.
  3478. * @returns the new cloned vector
  3479. */
  3480. clone(): Vector4;
  3481. /**
  3482. * Updates the current Vector4 with the given one coordinates.
  3483. * @param source the source vector to copy from
  3484. * @returns the updated Vector4.
  3485. */
  3486. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3487. /**
  3488. * Updates the current Vector4 coordinates with the given floats.
  3489. * @param x float to copy from
  3490. * @param y float to copy from
  3491. * @param z float to copy from
  3492. * @param w float to copy from
  3493. * @returns the updated Vector4.
  3494. */
  3495. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3496. /**
  3497. * Updates the current Vector4 coordinates with the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @returns the updated Vector4.
  3503. */
  3504. set(x: number, y: number, z: number, w: number): Vector4;
  3505. /**
  3506. * Copies the given float to the current Vector3 coordinates
  3507. * @param v defines the x, y, z and w coordinates of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. setAll(v: number): Vector4;
  3511. /**
  3512. * Returns a new Vector4 set from the starting index of the given array.
  3513. * @param array the array to pull values from
  3514. * @param offset the offset into the array to start at
  3515. * @returns the new vector
  3516. */
  3517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given array.
  3520. * @param array the array to pull values from
  3521. * @param offset the offset into the array to start at
  3522. * @param result the vector to store the result in
  3523. */
  3524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" from the starting index of the given Float32Array.
  3527. * @param array the array to pull values from
  3528. * @param offset the offset into the array to start at
  3529. * @param result the vector to store the result in
  3530. */
  3531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3532. /**
  3533. * Updates the given vector "result" coordinates from the given floats.
  3534. * @param x float to set from
  3535. * @param y float to set from
  3536. * @param z float to set from
  3537. * @param w float to set from
  3538. * @param result the vector to the floats in
  3539. */
  3540. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3541. /**
  3542. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3543. * @returns the new vector
  3544. */
  3545. static Zero(): Vector4;
  3546. /**
  3547. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3548. * @returns the new vector
  3549. */
  3550. static One(): Vector4;
  3551. /**
  3552. * Returns a new normalized Vector4 from the given one.
  3553. * @param vector the vector to normalize
  3554. * @returns the vector
  3555. */
  3556. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the normalization of the given one.
  3559. * @param vector the vector to normalize
  3560. * @param result the vector to store the result in
  3561. */
  3562. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3563. /**
  3564. * Returns a vector with the minimum values from the left and right vectors
  3565. * @param left left vector to minimize
  3566. * @param right right vector to minimize
  3567. * @returns a new vector with the minimum of the left and right vector values
  3568. */
  3569. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns a vector with the maximum values from the left and right vectors
  3572. * @param left left vector to maximize
  3573. * @param right right vector to maximize
  3574. * @returns a new vector with the maximum of the left and right vector values
  3575. */
  3576. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3577. /**
  3578. * Returns the distance (float) between the vectors "value1" and "value2".
  3579. * @param value1 value to calulate the distance between
  3580. * @param value2 value to calulate the distance between
  3581. * @return the distance between the two vectors
  3582. */
  3583. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the distance between
  3587. * @param value2 value to calulate the distance between
  3588. * @return the distance between the two vectors squared
  3589. */
  3590. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3591. /**
  3592. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3593. * @param value1 value to calulate the center between
  3594. * @param value2 value to calulate the center between
  3595. * @return the center between the two vectors
  3596. */
  3597. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @returns the new vector
  3604. */
  3605. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param vector the vector to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the result in
  3612. */
  3613. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3616. * This methods computes transformed normalized direction vectors only.
  3617. * @param x value to transform
  3618. * @param y value to transform
  3619. * @param z value to transform
  3620. * @param w value to transform
  3621. * @param transformation the transformation matrix to apply
  3622. * @param result the vector to store the results in
  3623. */
  3624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3625. /**
  3626. * Creates a new Vector4 from a Vector3
  3627. * @param source defines the source data
  3628. * @param w defines the 4th component (default is 0)
  3629. * @returns a new Vector4
  3630. */
  3631. static FromVector3(source: Vector3, w?: number): Vector4;
  3632. }
  3633. /**
  3634. * Class used to store quaternion data
  3635. * @see https://en.wikipedia.org/wiki/Quaternion
  3636. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3637. */
  3638. export class Quaternion {
  3639. /** defines the first component (0 by default) */
  3640. x: number;
  3641. /** defines the second component (0 by default) */
  3642. y: number;
  3643. /** defines the third component (0 by default) */
  3644. z: number;
  3645. /** defines the fourth component (1.0 by default) */
  3646. w: number;
  3647. /**
  3648. * Creates a new Quaternion from the given floats
  3649. * @param x defines the first component (0 by default)
  3650. * @param y defines the second component (0 by default)
  3651. * @param z defines the third component (0 by default)
  3652. * @param w defines the fourth component (1.0 by default)
  3653. */
  3654. constructor(
  3655. /** defines the first component (0 by default) */
  3656. x?: number,
  3657. /** defines the second component (0 by default) */
  3658. y?: number,
  3659. /** defines the third component (0 by default) */
  3660. z?: number,
  3661. /** defines the fourth component (1.0 by default) */
  3662. w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * 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)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * 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
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. 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;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. 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;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * 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"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * 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".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * 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"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * 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".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * 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.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * 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)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @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
  5102. * @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
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. 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);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): 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. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. 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;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. 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;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. 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;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /** @hidden */
  7852. _prefiltered: boolean;
  7853. /**
  7854. * Creates a cube texture from an array of image urls
  7855. * @param files defines an array of image urls
  7856. * @param scene defines the hosting scene
  7857. * @param noMipmap specifies if mip maps are not used
  7858. * @returns a cube texture
  7859. */
  7860. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7861. /**
  7862. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7863. * @param url defines the url of the prefiltered texture
  7864. * @param scene defines the scene the texture is attached to
  7865. * @param forcedExtension defines the extension of the file if different from the url
  7866. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7867. * @return the prefiltered texture
  7868. */
  7869. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7870. /**
  7871. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7872. * as prefiltered data.
  7873. * @param rootUrl defines the url of the texture or the root name of the six images
  7874. * @param null defines the scene or engine the texture is attached to
  7875. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7876. * @param noMipmap defines if mipmaps should be created or not
  7877. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7878. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7879. * @param onError defines a callback triggered in case of error during load
  7880. * @param format defines the internal format to use for the texture once loaded
  7881. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7882. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7883. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7884. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7885. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7886. * @return the cube texture
  7887. */
  7888. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7889. /**
  7890. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7891. */
  7892. get isPrefiltered(): boolean;
  7893. /**
  7894. * Get the current class name of the texture useful for serialization or dynamic coding.
  7895. * @returns "CubeTexture"
  7896. */
  7897. getClassName(): string;
  7898. /**
  7899. * Update the url (and optional buffer) of this texture if url was null during construction.
  7900. * @param url the url of the texture
  7901. * @param forcedExtension defines the extension to use
  7902. * @param onLoad callback called when the texture is loaded (defaults to null)
  7903. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7904. */
  7905. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7906. /**
  7907. * Delays loading of the cube texture
  7908. * @param forcedExtension defines the extension to use
  7909. */
  7910. delayLoad(forcedExtension?: string): void;
  7911. /**
  7912. * Returns the reflection texture matrix
  7913. * @returns the reflection texture matrix
  7914. */
  7915. getReflectionTextureMatrix(): Matrix;
  7916. /**
  7917. * Sets the reflection texture matrix
  7918. * @param value Reflection texture matrix
  7919. */
  7920. setReflectionTextureMatrix(value: Matrix): void;
  7921. /**
  7922. * Parses text to create a cube texture
  7923. * @param parsedTexture define the serialized text to read from
  7924. * @param scene defines the hosting scene
  7925. * @param rootUrl defines the root url of the cube texture
  7926. * @returns a cube texture
  7927. */
  7928. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7929. /**
  7930. * Makes a clone, or deep copy, of the cube texture
  7931. * @returns a new cube texture
  7932. */
  7933. clone(): CubeTexture;
  7934. }
  7935. }
  7936. declare module "babylonjs/Materials/materialDefines" {
  7937. /**
  7938. * Manages the defines for the Material
  7939. */
  7940. export class MaterialDefines {
  7941. /** @hidden */
  7942. protected _keys: string[];
  7943. private _isDirty;
  7944. /** @hidden */
  7945. _renderId: number;
  7946. /** @hidden */
  7947. _areLightsDirty: boolean;
  7948. /** @hidden */
  7949. _areLightsDisposed: boolean;
  7950. /** @hidden */
  7951. _areAttributesDirty: boolean;
  7952. /** @hidden */
  7953. _areTexturesDirty: boolean;
  7954. /** @hidden */
  7955. _areFresnelDirty: boolean;
  7956. /** @hidden */
  7957. _areMiscDirty: boolean;
  7958. /** @hidden */
  7959. _areImageProcessingDirty: boolean;
  7960. /** @hidden */
  7961. _normals: boolean;
  7962. /** @hidden */
  7963. _uvs: boolean;
  7964. /** @hidden */
  7965. _needNormals: boolean;
  7966. /** @hidden */
  7967. _needUVs: boolean;
  7968. [id: string]: any;
  7969. /**
  7970. * Specifies if the material needs to be re-calculated
  7971. */
  7972. get isDirty(): boolean;
  7973. /**
  7974. * Marks the material to indicate that it has been re-calculated
  7975. */
  7976. markAsProcessed(): void;
  7977. /**
  7978. * Marks the material to indicate that it needs to be re-calculated
  7979. */
  7980. markAsUnprocessed(): void;
  7981. /**
  7982. * Marks the material to indicate all of its defines need to be re-calculated
  7983. */
  7984. markAllAsDirty(): void;
  7985. /**
  7986. * Marks the material to indicate that image processing needs to be re-calculated
  7987. */
  7988. markAsImageProcessingDirty(): void;
  7989. /**
  7990. * Marks the material to indicate the lights need to be re-calculated
  7991. * @param disposed Defines whether the light is dirty due to dispose or not
  7992. */
  7993. markAsLightDirty(disposed?: boolean): void;
  7994. /**
  7995. * Marks the attribute state as changed
  7996. */
  7997. markAsAttributesDirty(): void;
  7998. /**
  7999. * Marks the texture state as changed
  8000. */
  8001. markAsTexturesDirty(): void;
  8002. /**
  8003. * Marks the fresnel state as changed
  8004. */
  8005. markAsFresnelDirty(): void;
  8006. /**
  8007. * Marks the misc state as changed
  8008. */
  8009. markAsMiscDirty(): void;
  8010. /**
  8011. * Rebuilds the material defines
  8012. */
  8013. rebuild(): void;
  8014. /**
  8015. * Specifies if two material defines are equal
  8016. * @param other - A material define instance to compare to
  8017. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8018. */
  8019. isEqual(other: MaterialDefines): boolean;
  8020. /**
  8021. * Clones this instance's defines to another instance
  8022. * @param other - material defines to clone values to
  8023. */
  8024. cloneTo(other: MaterialDefines): void;
  8025. /**
  8026. * Resets the material define values
  8027. */
  8028. reset(): void;
  8029. /**
  8030. * Converts the material define values to a string
  8031. * @returns - String of material define information
  8032. */
  8033. toString(): string;
  8034. }
  8035. }
  8036. declare module "babylonjs/Materials/colorCurves" {
  8037. import { Effect } from "babylonjs/Materials/effect";
  8038. /**
  8039. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8040. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8041. * 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;
  8042. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8043. */
  8044. export class ColorCurves {
  8045. private _dirty;
  8046. private _tempColor;
  8047. private _globalCurve;
  8048. private _highlightsCurve;
  8049. private _midtonesCurve;
  8050. private _shadowsCurve;
  8051. private _positiveCurve;
  8052. private _negativeCurve;
  8053. private _globalHue;
  8054. private _globalDensity;
  8055. private _globalSaturation;
  8056. private _globalExposure;
  8057. /**
  8058. * Gets the global Hue value.
  8059. * 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).
  8060. */
  8061. get globalHue(): number;
  8062. /**
  8063. * Sets the global Hue value.
  8064. * 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).
  8065. */
  8066. set globalHue(value: number);
  8067. /**
  8068. * Gets the global Density value.
  8069. * 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.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. get globalDensity(): number;
  8073. /**
  8074. * Sets the global Density value.
  8075. * 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.
  8076. * Values less than zero provide a filter of opposite hue.
  8077. */
  8078. set globalDensity(value: number);
  8079. /**
  8080. * Gets the global Saturation value.
  8081. * 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.
  8082. */
  8083. get globalSaturation(): number;
  8084. /**
  8085. * Sets the global Saturation value.
  8086. * 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.
  8087. */
  8088. set globalSaturation(value: number);
  8089. /**
  8090. * Gets the global Exposure value.
  8091. * 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.
  8092. */
  8093. get globalExposure(): number;
  8094. /**
  8095. * Sets the global Exposure 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 exposure and negative values decrease exposure.
  8097. */
  8098. set globalExposure(value: number);
  8099. private _highlightsHue;
  8100. private _highlightsDensity;
  8101. private _highlightsSaturation;
  8102. private _highlightsExposure;
  8103. /**
  8104. * Gets the highlights Hue value.
  8105. * 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).
  8106. */
  8107. get highlightsHue(): number;
  8108. /**
  8109. * Sets the highlights Hue value.
  8110. * 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).
  8111. */
  8112. set highlightsHue(value: number);
  8113. /**
  8114. * Gets the highlights Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. get highlightsDensity(): number;
  8119. /**
  8120. * Sets the highlights Density value.
  8121. * 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.
  8122. * Values less than zero provide a filter of opposite hue.
  8123. */
  8124. set highlightsDensity(value: number);
  8125. /**
  8126. * Gets the highlights Saturation value.
  8127. * 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.
  8128. */
  8129. get highlightsSaturation(): number;
  8130. /**
  8131. * Sets the highlights Saturation value.
  8132. * 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.
  8133. */
  8134. set highlightsSaturation(value: number);
  8135. /**
  8136. * Gets the highlights Exposure value.
  8137. * 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.
  8138. */
  8139. get highlightsExposure(): number;
  8140. /**
  8141. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  8143. */
  8144. set highlightsExposure(value: number);
  8145. private _midtonesHue;
  8146. private _midtonesDensity;
  8147. private _midtonesSaturation;
  8148. private _midtonesExposure;
  8149. /**
  8150. * Gets the midtones Hue value.
  8151. * 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).
  8152. */
  8153. get midtonesHue(): number;
  8154. /**
  8155. * Sets the midtones Hue value.
  8156. * 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).
  8157. */
  8158. set midtonesHue(value: number);
  8159. /**
  8160. * Gets the midtones Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. get midtonesDensity(): number;
  8165. /**
  8166. * Sets the midtones Density value.
  8167. * 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.
  8168. * Values less than zero provide a filter of opposite hue.
  8169. */
  8170. set midtonesDensity(value: number);
  8171. /**
  8172. * Gets the midtones Saturation value.
  8173. * 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.
  8174. */
  8175. get midtonesSaturation(): number;
  8176. /**
  8177. * Sets the midtones Saturation value.
  8178. * 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.
  8179. */
  8180. set midtonesSaturation(value: number);
  8181. /**
  8182. * Gets the midtones Exposure value.
  8183. * 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.
  8184. */
  8185. get midtonesExposure(): number;
  8186. /**
  8187. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  8189. */
  8190. set midtonesExposure(value: number);
  8191. private _shadowsHue;
  8192. private _shadowsDensity;
  8193. private _shadowsSaturation;
  8194. private _shadowsExposure;
  8195. /**
  8196. * Gets the shadows Hue value.
  8197. * 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).
  8198. */
  8199. get shadowsHue(): number;
  8200. /**
  8201. * Sets the shadows Hue value.
  8202. * 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).
  8203. */
  8204. set shadowsHue(value: number);
  8205. /**
  8206. * Gets the shadows Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. get shadowsDensity(): number;
  8211. /**
  8212. * Sets the shadows Density value.
  8213. * 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.
  8214. * Values less than zero provide a filter of opposite hue.
  8215. */
  8216. set shadowsDensity(value: number);
  8217. /**
  8218. * Gets the shadows Saturation value.
  8219. * 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.
  8220. */
  8221. get shadowsSaturation(): number;
  8222. /**
  8223. * Sets the shadows Saturation value.
  8224. * 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.
  8225. */
  8226. set shadowsSaturation(value: number);
  8227. /**
  8228. * Gets the shadows Exposure value.
  8229. * 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.
  8230. */
  8231. get shadowsExposure(): number;
  8232. /**
  8233. * Sets the shadows Exposure value.
  8234. * 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.
  8235. */
  8236. set shadowsExposure(value: number);
  8237. /**
  8238. * Returns the class name
  8239. * @returns The class name
  8240. */
  8241. getClassName(): string;
  8242. /**
  8243. * Binds the color curves to the shader.
  8244. * @param colorCurves The color curve to bind
  8245. * @param effect The effect to bind to
  8246. * @param positiveUniform The positive uniform shader parameter
  8247. * @param neutralUniform The neutral uniform shader parameter
  8248. * @param negativeUniform The negative uniform shader parameter
  8249. */
  8250. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8251. /**
  8252. * Prepare the list of uniforms associated with the ColorCurves effects.
  8253. * @param uniformsList The list of uniforms used in the effect
  8254. */
  8255. static PrepareUniforms(uniformsList: string[]): void;
  8256. /**
  8257. * Returns color grading data based on a hue, density, saturation and exposure value.
  8258. * @param filterHue The hue of the color filter.
  8259. * @param filterDensity The density of the color filter.
  8260. * @param saturation The saturation.
  8261. * @param exposure The exposure.
  8262. * @param result The result data container.
  8263. */
  8264. private getColorGradingDataToRef;
  8265. /**
  8266. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8267. * @param value The input slider value in range [-100,100].
  8268. * @returns Adjusted value.
  8269. */
  8270. private static applyColorGradingSliderNonlinear;
  8271. /**
  8272. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8273. * @param hue The hue (H) input.
  8274. * @param saturation The saturation (S) input.
  8275. * @param brightness The brightness (B) input.
  8276. * @result An RGBA color represented as Vector4.
  8277. */
  8278. private static fromHSBToRef;
  8279. /**
  8280. * Returns a value clamped between min and max
  8281. * @param value The value to clamp
  8282. * @param min The minimum of value
  8283. * @param max The maximum of value
  8284. * @returns The clamped value.
  8285. */
  8286. private static clamp;
  8287. /**
  8288. * Clones the current color curve instance.
  8289. * @return The cloned curves
  8290. */
  8291. clone(): ColorCurves;
  8292. /**
  8293. * Serializes the current color curve instance to a json representation.
  8294. * @return a JSON representation
  8295. */
  8296. serialize(): any;
  8297. /**
  8298. * Parses the color curve from a json representation.
  8299. * @param source the JSON source to parse
  8300. * @return The parsed curves
  8301. */
  8302. static Parse(source: any): ColorCurves;
  8303. }
  8304. }
  8305. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8306. import { Observable } from "babylonjs/Misc/observable";
  8307. import { Nullable } from "babylonjs/types";
  8308. import { Color4 } from "babylonjs/Maths/math.color";
  8309. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8310. import { Effect } from "babylonjs/Materials/effect";
  8311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8312. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8313. /**
  8314. * Interface to follow in your material defines to integrate easily the
  8315. * Image proccessing functions.
  8316. * @hidden
  8317. */
  8318. export interface IImageProcessingConfigurationDefines {
  8319. IMAGEPROCESSING: boolean;
  8320. VIGNETTE: boolean;
  8321. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8322. VIGNETTEBLENDMODEOPAQUE: boolean;
  8323. TONEMAPPING: boolean;
  8324. TONEMAPPING_ACES: boolean;
  8325. CONTRAST: boolean;
  8326. EXPOSURE: boolean;
  8327. COLORCURVES: boolean;
  8328. COLORGRADING: boolean;
  8329. COLORGRADING3D: boolean;
  8330. SAMPLER3DGREENDEPTH: boolean;
  8331. SAMPLER3DBGRMAP: boolean;
  8332. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8333. }
  8334. /**
  8335. * @hidden
  8336. */
  8337. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8338. IMAGEPROCESSING: boolean;
  8339. VIGNETTE: boolean;
  8340. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8341. VIGNETTEBLENDMODEOPAQUE: boolean;
  8342. TONEMAPPING: boolean;
  8343. TONEMAPPING_ACES: boolean;
  8344. CONTRAST: boolean;
  8345. COLORCURVES: boolean;
  8346. COLORGRADING: boolean;
  8347. COLORGRADING3D: boolean;
  8348. SAMPLER3DGREENDEPTH: boolean;
  8349. SAMPLER3DBGRMAP: boolean;
  8350. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8351. EXPOSURE: boolean;
  8352. constructor();
  8353. }
  8354. /**
  8355. * This groups together the common properties used for image processing either in direct forward pass
  8356. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8357. * or not.
  8358. */
  8359. export class ImageProcessingConfiguration {
  8360. /**
  8361. * Default tone mapping applied in BabylonJS.
  8362. */
  8363. static readonly TONEMAPPING_STANDARD: number;
  8364. /**
  8365. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8366. * to other engines rendering to increase portability.
  8367. */
  8368. static readonly TONEMAPPING_ACES: number;
  8369. /**
  8370. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8371. */
  8372. colorCurves: Nullable<ColorCurves>;
  8373. private _colorCurvesEnabled;
  8374. /**
  8375. * Gets wether the color curves effect is enabled.
  8376. */
  8377. get colorCurvesEnabled(): boolean;
  8378. /**
  8379. * Sets wether the color curves effect is enabled.
  8380. */
  8381. set colorCurvesEnabled(value: boolean);
  8382. private _colorGradingTexture;
  8383. /**
  8384. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8385. */
  8386. get colorGradingTexture(): Nullable<BaseTexture>;
  8387. /**
  8388. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8389. */
  8390. set colorGradingTexture(value: Nullable<BaseTexture>);
  8391. private _colorGradingEnabled;
  8392. /**
  8393. * Gets wether the color grading effect is enabled.
  8394. */
  8395. get colorGradingEnabled(): boolean;
  8396. /**
  8397. * Sets wether the color grading effect is enabled.
  8398. */
  8399. set colorGradingEnabled(value: boolean);
  8400. private _colorGradingWithGreenDepth;
  8401. /**
  8402. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8403. */
  8404. get colorGradingWithGreenDepth(): boolean;
  8405. /**
  8406. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8407. */
  8408. set colorGradingWithGreenDepth(value: boolean);
  8409. private _colorGradingBGR;
  8410. /**
  8411. * Gets wether the color grading texture contains BGR values.
  8412. */
  8413. get colorGradingBGR(): boolean;
  8414. /**
  8415. * Sets wether the color grading texture contains BGR values.
  8416. */
  8417. set colorGradingBGR(value: boolean);
  8418. /** @hidden */
  8419. _exposure: number;
  8420. /**
  8421. * Gets the Exposure used in the effect.
  8422. */
  8423. get exposure(): number;
  8424. /**
  8425. * Sets the Exposure used in the effect.
  8426. */
  8427. set exposure(value: number);
  8428. private _toneMappingEnabled;
  8429. /**
  8430. * Gets wether the tone mapping effect is enabled.
  8431. */
  8432. get toneMappingEnabled(): boolean;
  8433. /**
  8434. * Sets wether the tone mapping effect is enabled.
  8435. */
  8436. set toneMappingEnabled(value: boolean);
  8437. private _toneMappingType;
  8438. /**
  8439. * Gets the type of tone mapping effect.
  8440. */
  8441. get toneMappingType(): number;
  8442. /**
  8443. * Sets the type of tone mapping effect used in BabylonJS.
  8444. */
  8445. set toneMappingType(value: number);
  8446. protected _contrast: number;
  8447. /**
  8448. * Gets the contrast used in the effect.
  8449. */
  8450. get contrast(): number;
  8451. /**
  8452. * Sets the contrast used in the effect.
  8453. */
  8454. set contrast(value: number);
  8455. /**
  8456. * Vignette stretch size.
  8457. */
  8458. vignetteStretch: number;
  8459. /**
  8460. * Vignette centre X Offset.
  8461. */
  8462. vignetteCentreX: number;
  8463. /**
  8464. * Vignette centre Y Offset.
  8465. */
  8466. vignetteCentreY: number;
  8467. /**
  8468. * Vignette weight or intensity of the vignette effect.
  8469. */
  8470. vignetteWeight: number;
  8471. /**
  8472. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8473. * if vignetteEnabled is set to true.
  8474. */
  8475. vignetteColor: Color4;
  8476. /**
  8477. * Camera field of view used by the Vignette effect.
  8478. */
  8479. vignetteCameraFov: number;
  8480. private _vignetteBlendMode;
  8481. /**
  8482. * Gets the vignette blend mode allowing different kind of effect.
  8483. */
  8484. get vignetteBlendMode(): number;
  8485. /**
  8486. * Sets the vignette blend mode allowing different kind of effect.
  8487. */
  8488. set vignetteBlendMode(value: number);
  8489. private _vignetteEnabled;
  8490. /**
  8491. * Gets wether the vignette effect is enabled.
  8492. */
  8493. get vignetteEnabled(): boolean;
  8494. /**
  8495. * Sets wether the vignette effect is enabled.
  8496. */
  8497. set vignetteEnabled(value: boolean);
  8498. private _applyByPostProcess;
  8499. /**
  8500. * Gets wether the image processing is applied through a post process or not.
  8501. */
  8502. get applyByPostProcess(): boolean;
  8503. /**
  8504. * Sets wether the image processing is applied through a post process or not.
  8505. */
  8506. set applyByPostProcess(value: boolean);
  8507. private _isEnabled;
  8508. /**
  8509. * Gets wether the image processing is enabled or not.
  8510. */
  8511. get isEnabled(): boolean;
  8512. /**
  8513. * Sets wether the image processing is enabled or not.
  8514. */
  8515. set isEnabled(value: boolean);
  8516. /**
  8517. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8518. */
  8519. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8520. /**
  8521. * Method called each time the image processing information changes requires to recompile the effect.
  8522. */
  8523. protected _updateParameters(): void;
  8524. /**
  8525. * Gets the current class name.
  8526. * @return "ImageProcessingConfiguration"
  8527. */
  8528. getClassName(): string;
  8529. /**
  8530. * Prepare the list of uniforms associated with the Image Processing effects.
  8531. * @param uniforms The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of samplers associated with the Image Processing effects.
  8537. * @param samplersList The list of uniforms used in the effect
  8538. * @param defines the list of defines currently in use
  8539. */
  8540. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8541. /**
  8542. * Prepare the list of defines associated to the shader.
  8543. * @param defines the list of defines to complete
  8544. * @param forPostProcess Define if we are currently in post process mode or not
  8545. */
  8546. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8547. /**
  8548. * Returns true if all the image processing information are ready.
  8549. * @returns True if ready, otherwise, false
  8550. */
  8551. isReady(): boolean;
  8552. /**
  8553. * Binds the image processing to the shader.
  8554. * @param effect The effect to bind to
  8555. * @param overrideAspectRatio Override the aspect ratio of the effect
  8556. */
  8557. bind(effect: Effect, overrideAspectRatio?: number): void;
  8558. /**
  8559. * Clones the current image processing instance.
  8560. * @return The cloned image processing
  8561. */
  8562. clone(): ImageProcessingConfiguration;
  8563. /**
  8564. * Serializes the current image processing instance to a json representation.
  8565. * @return a JSON representation
  8566. */
  8567. serialize(): any;
  8568. /**
  8569. * Parses the image processing from a json representation.
  8570. * @param source the JSON source to parse
  8571. * @return The parsed image processing
  8572. */
  8573. static Parse(source: any): ImageProcessingConfiguration;
  8574. private static _VIGNETTEMODE_MULTIPLY;
  8575. private static _VIGNETTEMODE_OPAQUE;
  8576. /**
  8577. * Used to apply the vignette as a mix with the pixel color.
  8578. */
  8579. static get VIGNETTEMODE_MULTIPLY(): number;
  8580. /**
  8581. * Used to apply the vignette as a replacement of the pixel color.
  8582. */
  8583. static get VIGNETTEMODE_OPAQUE(): number;
  8584. }
  8585. }
  8586. declare module "babylonjs/Shaders/postprocess.vertex" {
  8587. /** @hidden */
  8588. export var postprocessVertexShader: {
  8589. name: string;
  8590. shader: string;
  8591. };
  8592. }
  8593. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8595. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8596. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8597. module "babylonjs/Engines/thinEngine" {
  8598. interface ThinEngine {
  8599. /**
  8600. * Creates a new render target texture
  8601. * @param size defines the size of the texture
  8602. * @param options defines the options used to create the texture
  8603. * @returns a new render target texture stored in an InternalTexture
  8604. */
  8605. createRenderTargetTexture(size: number | {
  8606. width: number;
  8607. height: number;
  8608. layers?: number;
  8609. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8610. /**
  8611. * Creates a depth stencil texture.
  8612. * This is only available in WebGL 2 or with the depth texture extension available.
  8613. * @param size The size of face edge in the texture.
  8614. * @param options The options defining the texture.
  8615. * @returns The texture
  8616. */
  8617. createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. /** @hidden */
  8623. _createDepthStencilTexture(size: number | {
  8624. width: number;
  8625. height: number;
  8626. layers?: number;
  8627. }, options: DepthTextureCreationOptions): InternalTexture;
  8628. }
  8629. }
  8630. }
  8631. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8632. /**
  8633. * Defines the kind of connection point for node based material
  8634. */
  8635. export enum NodeMaterialBlockConnectionPointTypes {
  8636. /** Float */
  8637. Float = 1,
  8638. /** Int */
  8639. Int = 2,
  8640. /** Vector2 */
  8641. Vector2 = 4,
  8642. /** Vector3 */
  8643. Vector3 = 8,
  8644. /** Vector4 */
  8645. Vector4 = 16,
  8646. /** Color3 */
  8647. Color3 = 32,
  8648. /** Color4 */
  8649. Color4 = 64,
  8650. /** Matrix */
  8651. Matrix = 128,
  8652. /** Custom object */
  8653. Object = 256,
  8654. /** Detect type based on connection */
  8655. AutoDetect = 1024,
  8656. /** Output type that will be defined by input type */
  8657. BasedOnInput = 2048
  8658. }
  8659. }
  8660. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8661. /**
  8662. * Enum used to define the target of a block
  8663. */
  8664. export enum NodeMaterialBlockTargets {
  8665. /** Vertex shader */
  8666. Vertex = 1,
  8667. /** Fragment shader */
  8668. Fragment = 2,
  8669. /** Neutral */
  8670. Neutral = 4,
  8671. /** Vertex and Fragment */
  8672. VertexAndFragment = 3
  8673. }
  8674. }
  8675. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8676. /**
  8677. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8678. */
  8679. export enum NodeMaterialBlockConnectionPointMode {
  8680. /** Value is an uniform */
  8681. Uniform = 0,
  8682. /** Value is a mesh attribute */
  8683. Attribute = 1,
  8684. /** Value is a varying between vertex and fragment shaders */
  8685. Varying = 2,
  8686. /** Mode is undefined */
  8687. Undefined = 3
  8688. }
  8689. }
  8690. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8691. /**
  8692. * Enum used to define system values e.g. values automatically provided by the system
  8693. */
  8694. export enum NodeMaterialSystemValues {
  8695. /** World */
  8696. World = 1,
  8697. /** View */
  8698. View = 2,
  8699. /** Projection */
  8700. Projection = 3,
  8701. /** ViewProjection */
  8702. ViewProjection = 4,
  8703. /** WorldView */
  8704. WorldView = 5,
  8705. /** WorldViewProjection */
  8706. WorldViewProjection = 6,
  8707. /** CameraPosition */
  8708. CameraPosition = 7,
  8709. /** Fog Color */
  8710. FogColor = 8,
  8711. /** Delta time */
  8712. DeltaTime = 9
  8713. }
  8714. }
  8715. declare module "babylonjs/Maths/math.axis" {
  8716. import { Vector3 } from "babylonjs/Maths/math.vector";
  8717. /** Defines supported spaces */
  8718. export enum Space {
  8719. /** Local (object) space */
  8720. LOCAL = 0,
  8721. /** World space */
  8722. WORLD = 1,
  8723. /** Bone space */
  8724. BONE = 2
  8725. }
  8726. /** Defines the 3 main axes */
  8727. export class Axis {
  8728. /** X axis */
  8729. static X: Vector3;
  8730. /** Y axis */
  8731. static Y: Vector3;
  8732. /** Z axis */
  8733. static Z: Vector3;
  8734. }
  8735. }
  8736. declare module "babylonjs/Maths/math.frustum" {
  8737. import { Matrix } from "babylonjs/Maths/math.vector";
  8738. import { DeepImmutable } from "babylonjs/types";
  8739. import { Plane } from "babylonjs/Maths/math.plane";
  8740. /**
  8741. * Represents a camera frustum
  8742. */
  8743. export class Frustum {
  8744. /**
  8745. * Gets the planes representing the frustum
  8746. * @param transform matrix to be applied to the returned planes
  8747. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8748. */
  8749. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8750. /**
  8751. * Gets the near frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the far frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the left frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the right frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the top frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Gets the bottom frustum plane transformed by the transform matrix
  8782. * @param transform transformation matrix to be applied to the resulting frustum plane
  8783. * @param frustumPlane the resuling frustum plane
  8784. */
  8785. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8786. /**
  8787. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8788. * @param transform transformation matrix to be applied to the resulting frustum planes
  8789. * @param frustumPlanes the resuling frustum planes
  8790. */
  8791. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8792. }
  8793. }
  8794. declare module "babylonjs/Maths/math.size" {
  8795. /**
  8796. * Interface for the size containing width and height
  8797. */
  8798. export interface ISize {
  8799. /**
  8800. * Width
  8801. */
  8802. width: number;
  8803. /**
  8804. * Heighht
  8805. */
  8806. height: number;
  8807. }
  8808. /**
  8809. * Size containing widht and height
  8810. */
  8811. export class Size implements ISize {
  8812. /**
  8813. * Width
  8814. */
  8815. width: number;
  8816. /**
  8817. * Height
  8818. */
  8819. height: number;
  8820. /**
  8821. * Creates a Size object from the given width and height (floats).
  8822. * @param width width of the new size
  8823. * @param height height of the new size
  8824. */
  8825. constructor(width: number, height: number);
  8826. /**
  8827. * Returns a string with the Size width and height
  8828. * @returns a string with the Size width and height
  8829. */
  8830. toString(): string;
  8831. /**
  8832. * "Size"
  8833. * @returns the string "Size"
  8834. */
  8835. getClassName(): string;
  8836. /**
  8837. * Returns the Size hash code.
  8838. * @returns a hash code for a unique width and height
  8839. */
  8840. getHashCode(): number;
  8841. /**
  8842. * Updates the current size from the given one.
  8843. * @param src the given size
  8844. */
  8845. copyFrom(src: Size): void;
  8846. /**
  8847. * Updates in place the current Size from the given floats.
  8848. * @param width width of the new size
  8849. * @param height height of the new size
  8850. * @returns the updated Size.
  8851. */
  8852. copyFromFloats(width: number, height: number): Size;
  8853. /**
  8854. * Updates in place the current Size from the given floats.
  8855. * @param width width to set
  8856. * @param height height to set
  8857. * @returns the updated Size.
  8858. */
  8859. set(width: number, height: number): Size;
  8860. /**
  8861. * Multiplies the width and height by numbers
  8862. * @param w factor to multiple the width by
  8863. * @param h factor to multiple the height by
  8864. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8865. */
  8866. multiplyByFloats(w: number, h: number): Size;
  8867. /**
  8868. * Clones the size
  8869. * @returns a new Size copied from the given one.
  8870. */
  8871. clone(): Size;
  8872. /**
  8873. * True if the current Size and the given one width and height are strictly equal.
  8874. * @param other the other size to compare against
  8875. * @returns True if the current Size and the given one width and height are strictly equal.
  8876. */
  8877. equals(other: Size): boolean;
  8878. /**
  8879. * The surface of the Size : width * height (float).
  8880. */
  8881. get surface(): number;
  8882. /**
  8883. * Create a new size of zero
  8884. * @returns a new Size set to (0.0, 0.0)
  8885. */
  8886. static Zero(): Size;
  8887. /**
  8888. * Sums the width and height of two sizes
  8889. * @param otherSize size to add to this size
  8890. * @returns a new Size set as the addition result of the current Size and the given one.
  8891. */
  8892. add(otherSize: Size): Size;
  8893. /**
  8894. * Subtracts the width and height of two
  8895. * @param otherSize size to subtract to this size
  8896. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8897. */
  8898. subtract(otherSize: Size): Size;
  8899. /**
  8900. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8901. * @param start starting size to lerp between
  8902. * @param end end size to lerp between
  8903. * @param amount amount to lerp between the start and end values
  8904. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8905. */
  8906. static Lerp(start: Size, end: Size, amount: number): Size;
  8907. }
  8908. }
  8909. declare module "babylonjs/Maths/math.vertexFormat" {
  8910. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8911. /**
  8912. * Contains position and normal vectors for a vertex
  8913. */
  8914. export class PositionNormalVertex {
  8915. /** the position of the vertex (defaut: 0,0,0) */
  8916. position: Vector3;
  8917. /** the normal of the vertex (defaut: 0,1,0) */
  8918. normal: Vector3;
  8919. /**
  8920. * Creates a PositionNormalVertex
  8921. * @param position the position of the vertex (defaut: 0,0,0)
  8922. * @param normal the normal of the vertex (defaut: 0,1,0)
  8923. */
  8924. constructor(
  8925. /** the position of the vertex (defaut: 0,0,0) */
  8926. position?: Vector3,
  8927. /** the normal of the vertex (defaut: 0,1,0) */
  8928. normal?: Vector3);
  8929. /**
  8930. * Clones the PositionNormalVertex
  8931. * @returns the cloned PositionNormalVertex
  8932. */
  8933. clone(): PositionNormalVertex;
  8934. }
  8935. /**
  8936. * Contains position, normal and uv vectors for a vertex
  8937. */
  8938. export class PositionNormalTextureVertex {
  8939. /** the position of the vertex (defaut: 0,0,0) */
  8940. position: Vector3;
  8941. /** the normal of the vertex (defaut: 0,1,0) */
  8942. normal: Vector3;
  8943. /** the uv of the vertex (default: 0,0) */
  8944. uv: Vector2;
  8945. /**
  8946. * Creates a PositionNormalTextureVertex
  8947. * @param position the position of the vertex (defaut: 0,0,0)
  8948. * @param normal the normal of the vertex (defaut: 0,1,0)
  8949. * @param uv the uv of the vertex (default: 0,0)
  8950. */
  8951. constructor(
  8952. /** the position of the vertex (defaut: 0,0,0) */
  8953. position?: Vector3,
  8954. /** the normal of the vertex (defaut: 0,1,0) */
  8955. normal?: Vector3,
  8956. /** the uv of the vertex (default: 0,0) */
  8957. uv?: Vector2);
  8958. /**
  8959. * Clones the PositionNormalTextureVertex
  8960. * @returns the cloned PositionNormalTextureVertex
  8961. */
  8962. clone(): PositionNormalTextureVertex;
  8963. }
  8964. }
  8965. declare module "babylonjs/Maths/math" {
  8966. export * from "babylonjs/Maths/math.axis";
  8967. export * from "babylonjs/Maths/math.color";
  8968. export * from "babylonjs/Maths/math.constants";
  8969. export * from "babylonjs/Maths/math.frustum";
  8970. export * from "babylonjs/Maths/math.path";
  8971. export * from "babylonjs/Maths/math.plane";
  8972. export * from "babylonjs/Maths/math.size";
  8973. export * from "babylonjs/Maths/math.vector";
  8974. export * from "babylonjs/Maths/math.vertexFormat";
  8975. export * from "babylonjs/Maths/math.viewport";
  8976. }
  8977. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8978. /**
  8979. * Enum defining the type of animations supported by InputBlock
  8980. */
  8981. export enum AnimatedInputBlockTypes {
  8982. /** No animation */
  8983. None = 0,
  8984. /** Time based animation. Will only work for floats */
  8985. Time = 1
  8986. }
  8987. }
  8988. declare module "babylonjs/Lights/shadowLight" {
  8989. import { Camera } from "babylonjs/Cameras/camera";
  8990. import { Scene } from "babylonjs/scene";
  8991. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8993. import { Light } from "babylonjs/Lights/light";
  8994. /**
  8995. * Interface describing all the common properties and methods a shadow light needs to implement.
  8996. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8997. * as well as binding the different shadow properties to the effects.
  8998. */
  8999. export interface IShadowLight extends Light {
  9000. /**
  9001. * The light id in the scene (used in scene.findLighById for instance)
  9002. */
  9003. id: string;
  9004. /**
  9005. * The position the shdow will be casted from.
  9006. */
  9007. position: Vector3;
  9008. /**
  9009. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9010. */
  9011. direction: Vector3;
  9012. /**
  9013. * The transformed position. Position of the light in world space taking parenting in account.
  9014. */
  9015. transformedPosition: Vector3;
  9016. /**
  9017. * The transformed direction. Direction of the light in world space taking parenting in account.
  9018. */
  9019. transformedDirection: Vector3;
  9020. /**
  9021. * The friendly name of the light in the scene.
  9022. */
  9023. name: string;
  9024. /**
  9025. * Defines the shadow projection clipping minimum z value.
  9026. */
  9027. shadowMinZ: number;
  9028. /**
  9029. * Defines the shadow projection clipping maximum z value.
  9030. */
  9031. shadowMaxZ: number;
  9032. /**
  9033. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9034. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9035. */
  9036. computeTransformedInformation(): boolean;
  9037. /**
  9038. * Gets the scene the light belongs to.
  9039. * @returns The scene
  9040. */
  9041. getScene(): Scene;
  9042. /**
  9043. * Callback defining a custom Projection Matrix Builder.
  9044. * This can be used to override the default projection matrix computation.
  9045. */
  9046. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9047. /**
  9048. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9049. * @param matrix The materix to updated with the projection information
  9050. * @param viewMatrix The transform matrix of the light
  9051. * @param renderList The list of mesh to render in the map
  9052. * @returns The current light
  9053. */
  9054. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9055. /**
  9056. * Gets the current depth scale used in ESM.
  9057. * @returns The scale
  9058. */
  9059. getDepthScale(): number;
  9060. /**
  9061. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9062. * @returns true if a cube texture needs to be use
  9063. */
  9064. needCube(): boolean;
  9065. /**
  9066. * Detects if the projection matrix requires to be recomputed this frame.
  9067. * @returns true if it requires to be recomputed otherwise, false.
  9068. */
  9069. needProjectionMatrixCompute(): boolean;
  9070. /**
  9071. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9072. */
  9073. forceProjectionMatrixCompute(): void;
  9074. /**
  9075. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9076. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9077. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9078. */
  9079. getShadowDirection(faceIndex?: number): Vector3;
  9080. /**
  9081. * Gets the minZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the min for
  9083. * @returns the depth min z
  9084. */
  9085. getDepthMinZ(activeCamera: Camera): number;
  9086. /**
  9087. * Gets the maxZ used for shadow according to both the scene and the light.
  9088. * @param activeCamera The camera we are returning the max for
  9089. * @returns the depth max z
  9090. */
  9091. getDepthMaxZ(activeCamera: Camera): number;
  9092. }
  9093. /**
  9094. * Base implementation IShadowLight
  9095. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9096. */
  9097. export abstract class ShadowLight extends Light implements IShadowLight {
  9098. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9099. protected _position: Vector3;
  9100. protected _setPosition(value: Vector3): void;
  9101. /**
  9102. * Sets the position the shadow will be casted from. Also use as the light position for both
  9103. * point and spot lights.
  9104. */
  9105. get position(): Vector3;
  9106. /**
  9107. * Sets the position the shadow will be casted from. Also use as the light position for both
  9108. * point and spot lights.
  9109. */
  9110. set position(value: Vector3);
  9111. protected _direction: Vector3;
  9112. protected _setDirection(value: Vector3): void;
  9113. /**
  9114. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9115. * Also use as the light direction on spot and directional lights.
  9116. */
  9117. get direction(): Vector3;
  9118. /**
  9119. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9120. * Also use as the light direction on spot and directional lights.
  9121. */
  9122. set direction(value: Vector3);
  9123. protected _shadowMinZ: number;
  9124. /**
  9125. * Gets the shadow projection clipping minimum z value.
  9126. */
  9127. get shadowMinZ(): number;
  9128. /**
  9129. * Sets the shadow projection clipping minimum z value.
  9130. */
  9131. set shadowMinZ(value: number);
  9132. protected _shadowMaxZ: number;
  9133. /**
  9134. * Sets the shadow projection clipping maximum z value.
  9135. */
  9136. get shadowMaxZ(): number;
  9137. /**
  9138. * Gets the shadow projection clipping maximum z value.
  9139. */
  9140. set shadowMaxZ(value: number);
  9141. /**
  9142. * Callback defining a custom Projection Matrix Builder.
  9143. * This can be used to override the default projection matrix computation.
  9144. */
  9145. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9146. /**
  9147. * The transformed position. Position of the light in world space taking parenting in account.
  9148. */
  9149. transformedPosition: Vector3;
  9150. /**
  9151. * The transformed direction. Direction of the light in world space taking parenting in account.
  9152. */
  9153. transformedDirection: Vector3;
  9154. private _needProjectionMatrixCompute;
  9155. /**
  9156. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9157. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9158. */
  9159. computeTransformedInformation(): boolean;
  9160. /**
  9161. * Return the depth scale used for the shadow map.
  9162. * @returns the depth scale.
  9163. */
  9164. getDepthScale(): number;
  9165. /**
  9166. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9167. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9168. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9169. */
  9170. getShadowDirection(faceIndex?: number): Vector3;
  9171. /**
  9172. * Returns the ShadowLight absolute position in the World.
  9173. * @returns the position vector in world space
  9174. */
  9175. getAbsolutePosition(): Vector3;
  9176. /**
  9177. * Sets the ShadowLight direction toward the passed target.
  9178. * @param target The point to target in local space
  9179. * @returns the updated ShadowLight direction
  9180. */
  9181. setDirectionToTarget(target: Vector3): Vector3;
  9182. /**
  9183. * Returns the light rotation in euler definition.
  9184. * @returns the x y z rotation in local space.
  9185. */
  9186. getRotation(): Vector3;
  9187. /**
  9188. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9189. * @returns true if a cube texture needs to be use
  9190. */
  9191. needCube(): boolean;
  9192. /**
  9193. * Detects if the projection matrix requires to be recomputed this frame.
  9194. * @returns true if it requires to be recomputed otherwise, false.
  9195. */
  9196. needProjectionMatrixCompute(): boolean;
  9197. /**
  9198. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9199. */
  9200. forceProjectionMatrixCompute(): void;
  9201. /** @hidden */
  9202. _initCache(): void;
  9203. /** @hidden */
  9204. _isSynchronized(): boolean;
  9205. /**
  9206. * Computes the world matrix of the node
  9207. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9208. * @returns the world matrix
  9209. */
  9210. computeWorldMatrix(force?: boolean): Matrix;
  9211. /**
  9212. * Gets the minZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the min for
  9214. * @returns the depth min z
  9215. */
  9216. getDepthMinZ(activeCamera: Camera): number;
  9217. /**
  9218. * Gets the maxZ used for shadow according to both the scene and the light.
  9219. * @param activeCamera The camera we are returning the max for
  9220. * @returns the depth max z
  9221. */
  9222. getDepthMaxZ(activeCamera: Camera): number;
  9223. /**
  9224. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9225. * @param matrix The materix to updated with the projection information
  9226. * @param viewMatrix The transform matrix of the light
  9227. * @param renderList The list of mesh to render in the map
  9228. * @returns The current light
  9229. */
  9230. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9231. }
  9232. }
  9233. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9234. /** @hidden */
  9235. export var packingFunctions: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9241. /** @hidden */
  9242. export var bayerDitherFunctions: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9248. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9249. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9250. /** @hidden */
  9251. export var shadowMapFragmentDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9257. /** @hidden */
  9258. export var clipPlaneFragmentDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9264. /** @hidden */
  9265. export var clipPlaneFragment: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9271. /** @hidden */
  9272. export var shadowMapFragment: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9278. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9279. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9280. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9281. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9282. /** @hidden */
  9283. export var shadowMapPixelShader: {
  9284. name: string;
  9285. shader: string;
  9286. };
  9287. }
  9288. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9289. /** @hidden */
  9290. export var bonesDeclaration: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9296. /** @hidden */
  9297. export var morphTargetsVertexGlobalDeclaration: {
  9298. name: string;
  9299. shader: string;
  9300. };
  9301. }
  9302. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9303. /** @hidden */
  9304. export var morphTargetsVertexDeclaration: {
  9305. name: string;
  9306. shader: string;
  9307. };
  9308. }
  9309. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9310. /** @hidden */
  9311. export var instancesDeclaration: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9317. /** @hidden */
  9318. export var helperFunctions: {
  9319. name: string;
  9320. shader: string;
  9321. };
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9324. /** @hidden */
  9325. export var shadowMapVertexDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9331. /** @hidden */
  9332. export var clipPlaneVertexDeclaration: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9338. /** @hidden */
  9339. export var morphTargetsVertex: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9345. /** @hidden */
  9346. export var instancesVertex: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9352. /** @hidden */
  9353. export var bonesVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9359. /** @hidden */
  9360. export var shadowMapVertexNormalBias: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9366. /** @hidden */
  9367. export var shadowMapVertexMetric: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9373. /** @hidden */
  9374. export var clipPlaneVertex: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9380. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9383. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9384. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9390. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9391. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9392. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9393. /** @hidden */
  9394. export var shadowMapVertexShader: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9400. /** @hidden */
  9401. export var depthBoxBlurPixelShader: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9407. /** @hidden */
  9408. export var shadowMapFragmentSoftTransparentShadow: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module "babylonjs/Materials/effectFallbacks" {
  9414. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9415. import { Effect } from "babylonjs/Materials/effect";
  9416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9417. /**
  9418. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9419. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9420. */
  9421. export class EffectFallbacks implements IEffectFallbacks {
  9422. private _defines;
  9423. private _currentRank;
  9424. private _maxRank;
  9425. private _mesh;
  9426. /**
  9427. * Removes the fallback from the bound mesh.
  9428. */
  9429. unBindMesh(): void;
  9430. /**
  9431. * Adds a fallback on the specified property.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param define The name of the define in the shader
  9434. */
  9435. addFallback(rank: number, define: string): void;
  9436. /**
  9437. * Sets the mesh to use CPU skinning when needing to fallback.
  9438. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9439. * @param mesh The mesh to use the fallbacks.
  9440. */
  9441. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9442. /**
  9443. * Checks to see if more fallbacks are still availible.
  9444. */
  9445. get hasMoreFallbacks(): boolean;
  9446. /**
  9447. * Removes the defines that should be removed when falling back.
  9448. * @param currentDefines defines the current define statements for the shader.
  9449. * @param effect defines the current effect we try to compile
  9450. * @returns The resulting defines with defines of the current rank removed.
  9451. */
  9452. reduce(currentDefines: string, effect: Effect): string;
  9453. }
  9454. }
  9455. declare module "babylonjs/Actions/action" {
  9456. import { Observable } from "babylonjs/Misc/observable";
  9457. import { Condition } from "babylonjs/Actions/condition";
  9458. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9459. import { ActionManager } from "babylonjs/Actions/actionManager";
  9460. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9461. /**
  9462. * Interface used to define Action
  9463. */
  9464. export interface IAction {
  9465. /**
  9466. * Trigger for the action
  9467. */
  9468. trigger: number;
  9469. /** Options of the trigger */
  9470. triggerOptions: any;
  9471. /**
  9472. * Gets the trigger parameters
  9473. * @returns the trigger parameters
  9474. */
  9475. getTriggerParameter(): any;
  9476. /**
  9477. * Internal only - executes current action event
  9478. * @hidden
  9479. */
  9480. _executeCurrent(evt?: ActionEvent): void;
  9481. /**
  9482. * Serialize placeholder for child classes
  9483. * @param parent of child
  9484. * @returns the serialized object
  9485. */
  9486. serialize(parent: any): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. _prepare(): void;
  9492. /**
  9493. * Internal only - manager for action
  9494. * @hidden
  9495. */
  9496. _actionManager: AbstractActionManager;
  9497. /**
  9498. * Adds action to chain of actions, may be a DoNothingAction
  9499. * @param action defines the next action to execute
  9500. * @returns The action passed in
  9501. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9502. */
  9503. then(action: IAction): IAction;
  9504. }
  9505. /**
  9506. * The action to be carried out following a trigger
  9507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9508. */
  9509. export class Action implements IAction {
  9510. /** the trigger, with or without parameters, for the action */
  9511. triggerOptions: any;
  9512. /**
  9513. * Trigger for the action
  9514. */
  9515. trigger: number;
  9516. /**
  9517. * Internal only - manager for action
  9518. * @hidden
  9519. */
  9520. _actionManager: ActionManager;
  9521. private _nextActiveAction;
  9522. private _child;
  9523. private _condition?;
  9524. private _triggerParameter;
  9525. /**
  9526. * An event triggered prior to action being executed.
  9527. */
  9528. onBeforeExecuteObservable: Observable<Action>;
  9529. /**
  9530. * Creates a new Action
  9531. * @param triggerOptions the trigger, with or without parameters, for the action
  9532. * @param condition an optional determinant of action
  9533. */
  9534. constructor(
  9535. /** the trigger, with or without parameters, for the action */
  9536. triggerOptions: any, condition?: Condition);
  9537. /**
  9538. * Internal only
  9539. * @hidden
  9540. */
  9541. _prepare(): void;
  9542. /**
  9543. * Gets the trigger parameters
  9544. * @returns the trigger parameters
  9545. */
  9546. getTriggerParameter(): any;
  9547. /**
  9548. * Internal only - executes current action event
  9549. * @hidden
  9550. */
  9551. _executeCurrent(evt?: ActionEvent): void;
  9552. /**
  9553. * Execute placeholder for child classes
  9554. * @param evt optional action event
  9555. */
  9556. execute(evt?: ActionEvent): void;
  9557. /**
  9558. * Skips to next active action
  9559. */
  9560. skipToNextActiveAction(): void;
  9561. /**
  9562. * Adds action to chain of actions, may be a DoNothingAction
  9563. * @param action defines the next action to execute
  9564. * @returns The action passed in
  9565. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9566. */
  9567. then(action: Action): Action;
  9568. /**
  9569. * Internal only
  9570. * @hidden
  9571. */
  9572. _getProperty(propertyPath: string): string;
  9573. /**
  9574. * Internal only
  9575. * @hidden
  9576. */
  9577. _getEffectiveTarget(target: any, propertyPath: string): any;
  9578. /**
  9579. * Serialize placeholder for child classes
  9580. * @param parent of child
  9581. * @returns the serialized object
  9582. */
  9583. serialize(parent: any): any;
  9584. /**
  9585. * Internal only called by serialize
  9586. * @hidden
  9587. */
  9588. protected _serialize(serializedAction: any, parent?: any): any;
  9589. /**
  9590. * Internal only
  9591. * @hidden
  9592. */
  9593. static _SerializeValueAsString: (value: any) => string;
  9594. /**
  9595. * Internal only
  9596. * @hidden
  9597. */
  9598. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9599. name: string;
  9600. targetType: string;
  9601. value: string;
  9602. };
  9603. }
  9604. }
  9605. declare module "babylonjs/Actions/condition" {
  9606. import { ActionManager } from "babylonjs/Actions/actionManager";
  9607. /**
  9608. * A Condition applied to an Action
  9609. */
  9610. export class Condition {
  9611. /**
  9612. * Internal only - manager for action
  9613. * @hidden
  9614. */
  9615. _actionManager: ActionManager;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. _evaluationId: number;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. _currentResult: boolean;
  9626. /**
  9627. * Creates a new Condition
  9628. * @param actionManager the manager of the action the condition is applied to
  9629. */
  9630. constructor(actionManager: ActionManager);
  9631. /**
  9632. * Check if the current condition is valid
  9633. * @returns a boolean
  9634. */
  9635. isValid(): boolean;
  9636. /**
  9637. * Internal only
  9638. * @hidden
  9639. */
  9640. _getProperty(propertyPath: string): string;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. _getEffectiveTarget(target: any, propertyPath: string): any;
  9646. /**
  9647. * Serialize placeholder for child classes
  9648. * @returns the serialized object
  9649. */
  9650. serialize(): any;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. protected _serialize(serializedCondition: any): any;
  9656. }
  9657. /**
  9658. * Defines specific conditional operators as extensions of Condition
  9659. */
  9660. export class ValueCondition extends Condition {
  9661. /** path to specify the property of the target the conditional operator uses */
  9662. propertyPath: string;
  9663. /** the value compared by the conditional operator against the current value of the property */
  9664. value: any;
  9665. /** the conditional operator, default ValueCondition.IsEqual */
  9666. operator: number;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. private static _IsEqual;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsDifferent;
  9677. /**
  9678. * Internal only
  9679. * @hidden
  9680. */
  9681. private static _IsGreater;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private static _IsLesser;
  9687. /**
  9688. * returns the number for IsEqual
  9689. */
  9690. static get IsEqual(): number;
  9691. /**
  9692. * Returns the number for IsDifferent
  9693. */
  9694. static get IsDifferent(): number;
  9695. /**
  9696. * Returns the number for IsGreater
  9697. */
  9698. static get IsGreater(): number;
  9699. /**
  9700. * Returns the number for IsLesser
  9701. */
  9702. static get IsLesser(): number;
  9703. /**
  9704. * Internal only The action manager for the condition
  9705. * @hidden
  9706. */
  9707. _actionManager: ActionManager;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private _target;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private _effectiveTarget;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. private _property;
  9723. /**
  9724. * Creates a new ValueCondition
  9725. * @param actionManager manager for the action the condition applies to
  9726. * @param target for the action
  9727. * @param propertyPath path to specify the property of the target the conditional operator uses
  9728. * @param value the value compared by the conditional operator against the current value of the property
  9729. * @param operator the conditional operator, default ValueCondition.IsEqual
  9730. */
  9731. constructor(actionManager: ActionManager, target: any,
  9732. /** path to specify the property of the target the conditional operator uses */
  9733. propertyPath: string,
  9734. /** the value compared by the conditional operator against the current value of the property */
  9735. value: any,
  9736. /** the conditional operator, default ValueCondition.IsEqual */
  9737. operator?: number);
  9738. /**
  9739. * Compares the given value with the property value for the specified conditional operator
  9740. * @returns the result of the comparison
  9741. */
  9742. isValid(): boolean;
  9743. /**
  9744. * Serialize the ValueCondition into a JSON compatible object
  9745. * @returns serialization object
  9746. */
  9747. serialize(): any;
  9748. /**
  9749. * Gets the name of the conditional operator for the ValueCondition
  9750. * @param operator the conditional operator
  9751. * @returns the name
  9752. */
  9753. static GetOperatorName(operator: number): string;
  9754. }
  9755. /**
  9756. * Defines a predicate condition as an extension of Condition
  9757. */
  9758. export class PredicateCondition extends Condition {
  9759. /** defines the predicate function used to validate the condition */
  9760. predicate: () => boolean;
  9761. /**
  9762. * Internal only - manager for action
  9763. * @hidden
  9764. */
  9765. _actionManager: ActionManager;
  9766. /**
  9767. * Creates a new PredicateCondition
  9768. * @param actionManager manager for the action the condition applies to
  9769. * @param predicate defines the predicate function used to validate the condition
  9770. */
  9771. constructor(actionManager: ActionManager,
  9772. /** defines the predicate function used to validate the condition */
  9773. predicate: () => boolean);
  9774. /**
  9775. * @returns the validity of the predicate condition
  9776. */
  9777. isValid(): boolean;
  9778. }
  9779. /**
  9780. * Defines a state condition as an extension of Condition
  9781. */
  9782. export class StateCondition extends Condition {
  9783. /** Value to compare with target state */
  9784. value: string;
  9785. /**
  9786. * Internal only - manager for action
  9787. * @hidden
  9788. */
  9789. _actionManager: ActionManager;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private _target;
  9795. /**
  9796. * Creates a new StateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param target of the condition
  9799. * @param value to compare with target state
  9800. */
  9801. constructor(actionManager: ActionManager, target: any,
  9802. /** Value to compare with target state */
  9803. value: string);
  9804. /**
  9805. * Gets a boolean indicating if the current condition is met
  9806. * @returns the validity of the state
  9807. */
  9808. isValid(): boolean;
  9809. /**
  9810. * Serialize the StateCondition into a JSON compatible object
  9811. * @returns serialization object
  9812. */
  9813. serialize(): any;
  9814. }
  9815. }
  9816. declare module "babylonjs/Actions/directActions" {
  9817. import { Action } from "babylonjs/Actions/action";
  9818. import { Condition } from "babylonjs/Actions/condition";
  9819. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9820. /**
  9821. * This defines an action responsible to toggle a boolean once triggered.
  9822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9823. */
  9824. export class SwitchBooleanAction extends Action {
  9825. /**
  9826. * The path to the boolean property in the target object
  9827. */
  9828. propertyPath: string;
  9829. private _target;
  9830. private _effectiveTarget;
  9831. private _property;
  9832. /**
  9833. * Instantiate the action
  9834. * @param triggerOptions defines the trigger options
  9835. * @param target defines the object containing the boolean
  9836. * @param propertyPath defines the path to the boolean property in the target object
  9837. * @param condition defines the trigger related conditions
  9838. */
  9839. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9840. /** @hidden */
  9841. _prepare(): void;
  9842. /**
  9843. * Execute the action toggle the boolean value.
  9844. */
  9845. execute(): void;
  9846. /**
  9847. * Serializes the actions and its related information.
  9848. * @param parent defines the object to serialize in
  9849. * @returns the serialized object
  9850. */
  9851. serialize(parent: any): any;
  9852. }
  9853. /**
  9854. * This defines an action responsible to set a the state field of the target
  9855. * to a desired value once triggered.
  9856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9857. */
  9858. export class SetStateAction extends Action {
  9859. /**
  9860. * The value to store in the state field.
  9861. */
  9862. value: string;
  9863. private _target;
  9864. /**
  9865. * Instantiate the action
  9866. * @param triggerOptions defines the trigger options
  9867. * @param target defines the object containing the state property
  9868. * @param value defines the value to store in the state field
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9872. /**
  9873. * Execute the action and store the value on the target state property.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to set a property of the target
  9885. * to a desired value once triggered.
  9886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9887. */
  9888. export class SetValueAction extends Action {
  9889. /**
  9890. * The path of the property to set in the target.
  9891. */
  9892. propertyPath: string;
  9893. /**
  9894. * The value to set in the property
  9895. */
  9896. value: any;
  9897. private _target;
  9898. private _effectiveTarget;
  9899. private _property;
  9900. /**
  9901. * Instantiate the action
  9902. * @param triggerOptions defines the trigger options
  9903. * @param target defines the object containing the property
  9904. * @param propertyPath defines the path of the property to set in the target
  9905. * @param value defines the value to set in the property
  9906. * @param condition defines the trigger related conditions
  9907. */
  9908. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9909. /** @hidden */
  9910. _prepare(): void;
  9911. /**
  9912. * Execute the action and set the targetted property to the desired value.
  9913. */
  9914. execute(): void;
  9915. /**
  9916. * Serializes the actions and its related information.
  9917. * @param parent defines the object to serialize in
  9918. * @returns the serialized object
  9919. */
  9920. serialize(parent: any): any;
  9921. }
  9922. /**
  9923. * This defines an action responsible to increment the target value
  9924. * to a desired value once triggered.
  9925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9926. */
  9927. export class IncrementValueAction extends Action {
  9928. /**
  9929. * The path of the property to increment in the target.
  9930. */
  9931. propertyPath: string;
  9932. /**
  9933. * The value we should increment the property by.
  9934. */
  9935. value: any;
  9936. private _target;
  9937. private _effectiveTarget;
  9938. private _property;
  9939. /**
  9940. * Instantiate the action
  9941. * @param triggerOptions defines the trigger options
  9942. * @param target defines the object containing the property
  9943. * @param propertyPath defines the path of the property to increment in the target
  9944. * @param value defines the value value we should increment the property by
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and increment the target of the value amount.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. /**
  9962. * This defines an action responsible to start an animation once triggered.
  9963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9964. */
  9965. export class PlayAnimationAction extends Action {
  9966. /**
  9967. * Where the animation should start (animation frame)
  9968. */
  9969. from: number;
  9970. /**
  9971. * Where the animation should stop (animation frame)
  9972. */
  9973. to: number;
  9974. /**
  9975. * Define if the animation should loop or stop after the first play.
  9976. */
  9977. loop?: boolean;
  9978. private _target;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the target animation or animation name
  9983. * @param from defines from where the animation should start (animation frame)
  9984. * @param end defines where the animation should stop (animation frame)
  9985. * @param loop defines if the animation should loop or stop after the first play
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and play the animation.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to stop an animation once triggered.
  10004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10005. */
  10006. export class StopAnimationAction extends Action {
  10007. private _target;
  10008. /**
  10009. * Instantiate the action
  10010. * @param triggerOptions defines the trigger options
  10011. * @param target defines the target animation or animation name
  10012. * @param condition defines the trigger related conditions
  10013. */
  10014. constructor(triggerOptions: any, target: any, condition?: Condition);
  10015. /** @hidden */
  10016. _prepare(): void;
  10017. /**
  10018. * Execute the action and stop the animation.
  10019. */
  10020. execute(): void;
  10021. /**
  10022. * Serializes the actions and its related information.
  10023. * @param parent defines the object to serialize in
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. }
  10028. /**
  10029. * This defines an action responsible that does nothing once triggered.
  10030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10031. */
  10032. export class DoNothingAction extends Action {
  10033. /**
  10034. * Instantiate the action
  10035. * @param triggerOptions defines the trigger options
  10036. * @param condition defines the trigger related conditions
  10037. */
  10038. constructor(triggerOptions?: any, condition?: Condition);
  10039. /**
  10040. * Execute the action and do nothing.
  10041. */
  10042. execute(): void;
  10043. /**
  10044. * Serializes the actions and its related information.
  10045. * @param parent defines the object to serialize in
  10046. * @returns the serialized object
  10047. */
  10048. serialize(parent: any): any;
  10049. }
  10050. /**
  10051. * This defines an action responsible to trigger several actions once triggered.
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10053. */
  10054. export class CombineAction extends Action {
  10055. /**
  10056. * The list of aggregated animations to run.
  10057. */
  10058. children: Action[];
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param children defines the list of aggregated animations to run
  10063. * @param condition defines the trigger related conditions
  10064. */
  10065. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10066. /** @hidden */
  10067. _prepare(): void;
  10068. /**
  10069. * Execute the action and executes all the aggregated actions.
  10070. */
  10071. execute(evt: ActionEvent): void;
  10072. /**
  10073. * Serializes the actions and its related information.
  10074. * @param parent defines the object to serialize in
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. }
  10079. /**
  10080. * This defines an action responsible to run code (external event) once triggered.
  10081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10082. */
  10083. export class ExecuteCodeAction extends Action {
  10084. /**
  10085. * The callback function to run.
  10086. */
  10087. func: (evt: ActionEvent) => void;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param func defines the callback function to run
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10095. /**
  10096. * Execute the action and run the attached code.
  10097. */
  10098. execute(evt: ActionEvent): void;
  10099. }
  10100. /**
  10101. * This defines an action responsible to set the parent property of the target once triggered.
  10102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10103. */
  10104. export class SetParentAction extends Action {
  10105. private _parent;
  10106. private _target;
  10107. /**
  10108. * Instantiate the action
  10109. * @param triggerOptions defines the trigger options
  10110. * @param target defines the target containing the parent property
  10111. * @param parent defines from where the animation should start (animation frame)
  10112. * @param condition defines the trigger related conditions
  10113. */
  10114. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10115. /** @hidden */
  10116. _prepare(): void;
  10117. /**
  10118. * Execute the action and set the parent property.
  10119. */
  10120. execute(): void;
  10121. /**
  10122. * Serializes the actions and its related information.
  10123. * @param parent defines the object to serialize in
  10124. * @returns the serialized object
  10125. */
  10126. serialize(parent: any): any;
  10127. }
  10128. }
  10129. declare module "babylonjs/Actions/actionManager" {
  10130. import { Nullable } from "babylonjs/types";
  10131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10132. import { Scene } from "babylonjs/scene";
  10133. import { IAction } from "babylonjs/Actions/action";
  10134. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10136. /**
  10137. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10138. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10140. */
  10141. export class ActionManager extends AbstractActionManager {
  10142. /**
  10143. * Nothing
  10144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10145. */
  10146. static readonly NothingTrigger: number;
  10147. /**
  10148. * On pick
  10149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10150. */
  10151. static readonly OnPickTrigger: number;
  10152. /**
  10153. * On left pick
  10154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10155. */
  10156. static readonly OnLeftPickTrigger: number;
  10157. /**
  10158. * On right pick
  10159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10160. */
  10161. static readonly OnRightPickTrigger: number;
  10162. /**
  10163. * On center pick
  10164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly OnCenterPickTrigger: number;
  10167. /**
  10168. * On pick down
  10169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnPickDownTrigger: number;
  10172. /**
  10173. * On double pick
  10174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnDoublePickTrigger: number;
  10177. /**
  10178. * On pick up
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickUpTrigger: number;
  10182. /**
  10183. * On pick out.
  10184. * This trigger will only be raised if you also declared a OnPickDown
  10185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnPickOutTrigger: number;
  10188. /**
  10189. * On long press
  10190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnLongPressTrigger: number;
  10193. /**
  10194. * On pointer over
  10195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnPointerOverTrigger: number;
  10198. /**
  10199. * On pointer out
  10200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnPointerOutTrigger: number;
  10203. /**
  10204. * On every frame
  10205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnEveryFrameTrigger: number;
  10208. /**
  10209. * On intersection enter
  10210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnIntersectionEnterTrigger: number;
  10213. /**
  10214. * On intersection exit
  10215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnIntersectionExitTrigger: number;
  10218. /**
  10219. * On key down
  10220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnKeyDownTrigger: number;
  10223. /**
  10224. * On key up
  10225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnKeyUpTrigger: number;
  10228. private _scene;
  10229. /**
  10230. * Creates a new action manager
  10231. * @param scene defines the hosting scene
  10232. */
  10233. constructor(scene: Scene);
  10234. /**
  10235. * Releases all associated resources
  10236. */
  10237. dispose(): void;
  10238. /**
  10239. * Gets hosting scene
  10240. * @returns the hosting scene
  10241. */
  10242. getScene(): Scene;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers
  10245. * @param triggers defines the triggers to be tested
  10246. * @return a boolean indicating whether one (or more) of the triggers is handled
  10247. */
  10248. hasSpecificTriggers(triggers: number[]): boolean;
  10249. /**
  10250. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10251. * speed.
  10252. * @param triggerA defines the trigger to be tested
  10253. * @param triggerB defines the trigger to be tested
  10254. * @return a boolean indicating whether one (or more) of the triggers is handled
  10255. */
  10256. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10257. /**
  10258. * Does this action manager handles actions of a given trigger
  10259. * @param trigger defines the trigger to be tested
  10260. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10261. * @return whether the trigger is handled
  10262. */
  10263. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10264. /**
  10265. * Does this action manager has pointer triggers
  10266. */
  10267. get hasPointerTriggers(): boolean;
  10268. /**
  10269. * Does this action manager has pick triggers
  10270. */
  10271. get hasPickTriggers(): boolean;
  10272. /**
  10273. * Registers an action to this action manager
  10274. * @param action defines the action to be registered
  10275. * @return the action amended (prepared) after registration
  10276. */
  10277. registerAction(action: IAction): Nullable<IAction>;
  10278. /**
  10279. * Unregisters an action to this action manager
  10280. * @param action defines the action to be unregistered
  10281. * @return a boolean indicating whether the action has been unregistered
  10282. */
  10283. unregisterAction(action: IAction): Boolean;
  10284. /**
  10285. * Process a specific trigger
  10286. * @param trigger defines the trigger to process
  10287. * @param evt defines the event details to be processed
  10288. */
  10289. processTrigger(trigger: number, evt?: IActionEvent): void;
  10290. /** @hidden */
  10291. _getEffectiveTarget(target: any, propertyPath: string): any;
  10292. /** @hidden */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Serialize this manager to a JSON object
  10296. * @param name defines the property name to store this manager
  10297. * @returns a JSON representation of this manager
  10298. */
  10299. serialize(name: string): any;
  10300. /**
  10301. * Creates a new ActionManager from a JSON data
  10302. * @param parsedActions defines the JSON data to read from
  10303. * @param object defines the hosting mesh
  10304. * @param scene defines the hosting scene
  10305. */
  10306. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10307. /**
  10308. * Get a trigger name by index
  10309. * @param trigger defines the trigger index
  10310. * @returns a trigger name
  10311. */
  10312. static GetTriggerName(trigger: number): string;
  10313. }
  10314. }
  10315. declare module "babylonjs/Sprites/sprite" {
  10316. import { Vector3 } from "babylonjs/Maths/math.vector";
  10317. import { Nullable } from "babylonjs/types";
  10318. import { ActionManager } from "babylonjs/Actions/actionManager";
  10319. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10320. import { Color4 } from "babylonjs/Maths/math.color";
  10321. import { Observable } from "babylonjs/Misc/observable";
  10322. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10323. import { Animation } from "babylonjs/Animations/animation";
  10324. /**
  10325. * Class used to represent a sprite
  10326. * @see http://doc.babylonjs.com/babylon101/sprites
  10327. */
  10328. export class Sprite implements IAnimatable {
  10329. /** defines the name */
  10330. name: string;
  10331. /** Gets or sets the current world position */
  10332. position: Vector3;
  10333. /** Gets or sets the main color */
  10334. color: Color4;
  10335. /** Gets or sets the width */
  10336. width: number;
  10337. /** Gets or sets the height */
  10338. height: number;
  10339. /** Gets or sets rotation angle */
  10340. angle: number;
  10341. /** Gets or sets the cell index in the sprite sheet */
  10342. cellIndex: number;
  10343. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10344. cellRef: string;
  10345. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10346. invertU: boolean;
  10347. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10348. invertV: boolean;
  10349. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10350. disposeWhenFinishedAnimating: boolean;
  10351. /** Gets the list of attached animations */
  10352. animations: Nullable<Array<Animation>>;
  10353. /** Gets or sets a boolean indicating if the sprite can be picked */
  10354. isPickable: boolean;
  10355. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10356. useAlphaForPicking: boolean;
  10357. /** @hidden */
  10358. _xOffset: number;
  10359. /** @hidden */
  10360. _yOffset: number;
  10361. /** @hidden */
  10362. _xSize: number;
  10363. /** @hidden */
  10364. _ySize: number;
  10365. /**
  10366. * Gets or sets the associated action manager
  10367. */
  10368. actionManager: Nullable<ActionManager>;
  10369. /**
  10370. * An event triggered when the control has been disposed
  10371. */
  10372. onDisposeObservable: Observable<Sprite>;
  10373. private _animationStarted;
  10374. private _loopAnimation;
  10375. private _fromIndex;
  10376. private _toIndex;
  10377. private _delay;
  10378. private _direction;
  10379. private _manager;
  10380. private _time;
  10381. private _onAnimationEnd;
  10382. /**
  10383. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10384. */
  10385. isVisible: boolean;
  10386. /**
  10387. * Gets or sets the sprite size
  10388. */
  10389. get size(): number;
  10390. set size(value: number);
  10391. /**
  10392. * Returns a boolean indicating if the animation is started
  10393. */
  10394. get animationStarted(): boolean;
  10395. /**
  10396. * Gets or sets the unique id of the sprite
  10397. */
  10398. uniqueId: number;
  10399. /**
  10400. * Gets the manager of this sprite
  10401. */
  10402. get manager(): ISpriteManager;
  10403. /**
  10404. * Creates a new Sprite
  10405. * @param name defines the name
  10406. * @param manager defines the manager
  10407. */
  10408. constructor(
  10409. /** defines the name */
  10410. name: string, manager: ISpriteManager);
  10411. /**
  10412. * Returns the string "Sprite"
  10413. * @returns "Sprite"
  10414. */
  10415. getClassName(): string;
  10416. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10417. get fromIndex(): number;
  10418. set fromIndex(value: number);
  10419. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10420. get toIndex(): number;
  10421. set toIndex(value: number);
  10422. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10423. get loopAnimation(): boolean;
  10424. set loopAnimation(value: boolean);
  10425. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10426. get delay(): number;
  10427. set delay(value: number);
  10428. /**
  10429. * Starts an animation
  10430. * @param from defines the initial key
  10431. * @param to defines the end key
  10432. * @param loop defines if the animation must loop
  10433. * @param delay defines the start delay (in ms)
  10434. * @param onAnimationEnd defines a callback to call when animation ends
  10435. */
  10436. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  10437. /** Stops current animation (if any) */
  10438. stopAnimation(): void;
  10439. /** @hidden */
  10440. _animate(deltaTime: number): void;
  10441. /** Release associated resources */
  10442. dispose(): void;
  10443. }
  10444. }
  10445. declare module "babylonjs/Collisions/pickingInfo" {
  10446. import { Nullable } from "babylonjs/types";
  10447. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10449. import { Sprite } from "babylonjs/Sprites/sprite";
  10450. import { Ray } from "babylonjs/Culling/ray";
  10451. /**
  10452. * Information about the result of picking within a scene
  10453. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10454. */
  10455. export class PickingInfo {
  10456. /** @hidden */
  10457. _pickingUnavailable: boolean;
  10458. /**
  10459. * If the pick collided with an object
  10460. */
  10461. hit: boolean;
  10462. /**
  10463. * Distance away where the pick collided
  10464. */
  10465. distance: number;
  10466. /**
  10467. * The location of pick collision
  10468. */
  10469. pickedPoint: Nullable<Vector3>;
  10470. /**
  10471. * The mesh corresponding the the pick collision
  10472. */
  10473. pickedMesh: Nullable<AbstractMesh>;
  10474. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10475. bu: number;
  10476. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10477. bv: number;
  10478. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10479. faceId: number;
  10480. /** Id of the the submesh that was picked */
  10481. subMeshId: number;
  10482. /** If a sprite was picked, this will be the sprite the pick collided with */
  10483. pickedSprite: Nullable<Sprite>;
  10484. /**
  10485. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10486. */
  10487. originMesh: Nullable<AbstractMesh>;
  10488. /**
  10489. * The ray that was used to perform the picking.
  10490. */
  10491. ray: Nullable<Ray>;
  10492. /**
  10493. * Gets the normal correspodning to the face the pick collided with
  10494. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10495. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10496. * @returns The normal correspodning to the face the pick collided with
  10497. */
  10498. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10499. /**
  10500. * Gets the texture coordinates of where the pick occured
  10501. * @returns the vector containing the coordnates of the texture
  10502. */
  10503. getTextureCoordinates(): Nullable<Vector2>;
  10504. }
  10505. }
  10506. declare module "babylonjs/Culling/ray" {
  10507. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10508. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10510. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10511. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10512. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10513. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10514. import { Plane } from "babylonjs/Maths/math.plane";
  10515. /**
  10516. * Class representing a ray with position and direction
  10517. */
  10518. export class Ray {
  10519. /** origin point */
  10520. origin: Vector3;
  10521. /** direction */
  10522. direction: Vector3;
  10523. /** length of the ray */
  10524. length: number;
  10525. private static readonly TmpVector3;
  10526. private _tmpRay;
  10527. /**
  10528. * Creates a new ray
  10529. * @param origin origin point
  10530. * @param direction direction
  10531. * @param length length of the ray
  10532. */
  10533. constructor(
  10534. /** origin point */
  10535. origin: Vector3,
  10536. /** direction */
  10537. direction: Vector3,
  10538. /** length of the ray */
  10539. length?: number);
  10540. /**
  10541. * Checks if the ray intersects a box
  10542. * This does not account for the ray lenght by design to improve perfs.
  10543. * @param minimum bound of the box
  10544. * @param maximum bound of the box
  10545. * @param intersectionTreshold extra extend to be added to the box in all direction
  10546. * @returns if the box was hit
  10547. */
  10548. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10549. /**
  10550. * Checks if the ray intersects a box
  10551. * This does not account for the ray lenght by design to improve perfs.
  10552. * @param box the bounding box to check
  10553. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10554. * @returns if the box was hit
  10555. */
  10556. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10557. /**
  10558. * If the ray hits a sphere
  10559. * @param sphere the bounding sphere to check
  10560. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10561. * @returns true if it hits the sphere
  10562. */
  10563. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * If the ray hits a triange
  10566. * @param vertex0 triangle vertex
  10567. * @param vertex1 triangle vertex
  10568. * @param vertex2 triangle vertex
  10569. * @returns intersection information if hit
  10570. */
  10571. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10572. /**
  10573. * Checks if ray intersects a plane
  10574. * @param plane the plane to check
  10575. * @returns the distance away it was hit
  10576. */
  10577. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10578. /**
  10579. * Calculate the intercept of a ray on a given axis
  10580. * @param axis to check 'x' | 'y' | 'z'
  10581. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10582. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10583. */
  10584. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10585. /**
  10586. * Checks if ray intersects a mesh
  10587. * @param mesh the mesh to check
  10588. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10589. * @returns picking info of the intersecton
  10590. */
  10591. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10592. /**
  10593. * Checks if ray intersects a mesh
  10594. * @param meshes the meshes to check
  10595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10596. * @param results array to store result in
  10597. * @returns Array of picking infos
  10598. */
  10599. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10600. private _comparePickingInfo;
  10601. private static smallnum;
  10602. private static rayl;
  10603. /**
  10604. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10605. * @param sega the first point of the segment to test the intersection against
  10606. * @param segb the second point of the segment to test the intersection against
  10607. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10608. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10609. */
  10610. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10611. /**
  10612. * Update the ray from viewport position
  10613. * @param x position
  10614. * @param y y position
  10615. * @param viewportWidth viewport width
  10616. * @param viewportHeight viewport height
  10617. * @param world world matrix
  10618. * @param view view matrix
  10619. * @param projection projection matrix
  10620. * @returns this ray updated
  10621. */
  10622. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10623. /**
  10624. * Creates a ray with origin and direction of 0,0,0
  10625. * @returns the new ray
  10626. */
  10627. static Zero(): Ray;
  10628. /**
  10629. * Creates a new ray from screen space and viewport
  10630. * @param x position
  10631. * @param y y position
  10632. * @param viewportWidth viewport width
  10633. * @param viewportHeight viewport height
  10634. * @param world world matrix
  10635. * @param view view matrix
  10636. * @param projection projection matrix
  10637. * @returns new ray
  10638. */
  10639. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10640. /**
  10641. * 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
  10642. * transformed to the given world matrix.
  10643. * @param origin The origin point
  10644. * @param end The end point
  10645. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10646. * @returns the new ray
  10647. */
  10648. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10649. /**
  10650. * Transforms a ray by a matrix
  10651. * @param ray ray to transform
  10652. * @param matrix matrix to apply
  10653. * @returns the resulting new ray
  10654. */
  10655. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10656. /**
  10657. * Transforms a ray by a matrix
  10658. * @param ray ray to transform
  10659. * @param matrix matrix to apply
  10660. * @param result ray to store result in
  10661. */
  10662. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10663. /**
  10664. * Unproject a ray from screen space to object space
  10665. * @param sourceX defines the screen space x coordinate to use
  10666. * @param sourceY defines the screen space y coordinate to use
  10667. * @param viewportWidth defines the current width of the viewport
  10668. * @param viewportHeight defines the current height of the viewport
  10669. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10670. * @param view defines the view matrix to use
  10671. * @param projection defines the projection matrix to use
  10672. */
  10673. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10674. }
  10675. /**
  10676. * Type used to define predicate used to select faces when a mesh intersection is detected
  10677. */
  10678. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10679. module "babylonjs/scene" {
  10680. interface Scene {
  10681. /** @hidden */
  10682. _tempPickingRay: Nullable<Ray>;
  10683. /** @hidden */
  10684. _cachedRayForTransform: Ray;
  10685. /** @hidden */
  10686. _pickWithRayInverseMatrix: Matrix;
  10687. /** @hidden */
  10688. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10689. /** @hidden */
  10690. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10691. }
  10692. }
  10693. }
  10694. declare module "babylonjs/sceneComponent" {
  10695. import { Scene } from "babylonjs/scene";
  10696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10697. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10698. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10699. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10700. import { Nullable } from "babylonjs/types";
  10701. import { Camera } from "babylonjs/Cameras/camera";
  10702. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10703. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10704. import { AbstractScene } from "babylonjs/abstractScene";
  10705. import { Mesh } from "babylonjs/Meshes/mesh";
  10706. /**
  10707. * Groups all the scene component constants in one place to ease maintenance.
  10708. * @hidden
  10709. */
  10710. export class SceneComponentConstants {
  10711. static readonly NAME_EFFECTLAYER: string;
  10712. static readonly NAME_LAYER: string;
  10713. static readonly NAME_LENSFLARESYSTEM: string;
  10714. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10715. static readonly NAME_PARTICLESYSTEM: string;
  10716. static readonly NAME_GAMEPAD: string;
  10717. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10718. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10719. static readonly NAME_DEPTHRENDERER: string;
  10720. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10721. static readonly NAME_SPRITE: string;
  10722. static readonly NAME_OUTLINERENDERER: string;
  10723. static readonly NAME_PROCEDURALTEXTURE: string;
  10724. static readonly NAME_SHADOWGENERATOR: string;
  10725. static readonly NAME_OCTREE: string;
  10726. static readonly NAME_PHYSICSENGINE: string;
  10727. static readonly NAME_AUDIO: string;
  10728. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10729. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10730. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10731. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10732. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10733. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10734. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10735. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10736. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10737. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10738. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10739. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10740. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10741. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10742. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10743. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10744. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10745. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10746. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10747. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10748. static readonly STEP_AFTERRENDER_AUDIO: number;
  10749. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10750. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10751. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10752. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10753. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10754. static readonly STEP_POINTERMOVE_SPRITE: number;
  10755. static readonly STEP_POINTERDOWN_SPRITE: number;
  10756. static readonly STEP_POINTERUP_SPRITE: number;
  10757. }
  10758. /**
  10759. * This represents a scene component.
  10760. *
  10761. * This is used to decouple the dependency the scene is having on the different workloads like
  10762. * layers, post processes...
  10763. */
  10764. export interface ISceneComponent {
  10765. /**
  10766. * The name of the component. Each component must have a unique name.
  10767. */
  10768. name: string;
  10769. /**
  10770. * The scene the component belongs to.
  10771. */
  10772. scene: Scene;
  10773. /**
  10774. * Register the component to one instance of a scene.
  10775. */
  10776. register(): void;
  10777. /**
  10778. * Rebuilds the elements related to this component in case of
  10779. * context lost for instance.
  10780. */
  10781. rebuild(): void;
  10782. /**
  10783. * Disposes the component and the associated ressources.
  10784. */
  10785. dispose(): void;
  10786. }
  10787. /**
  10788. * This represents a SERIALIZABLE scene component.
  10789. *
  10790. * This extends Scene Component to add Serialization methods on top.
  10791. */
  10792. export interface ISceneSerializableComponent extends ISceneComponent {
  10793. /**
  10794. * Adds all the elements from the container to the scene
  10795. * @param container the container holding the elements
  10796. */
  10797. addFromContainer(container: AbstractScene): void;
  10798. /**
  10799. * Removes all the elements in the container from the scene
  10800. * @param container contains the elements to remove
  10801. * @param dispose if the removed element should be disposed (default: false)
  10802. */
  10803. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10804. /**
  10805. * Serializes the component data to the specified json object
  10806. * @param serializationObject The object to serialize to
  10807. */
  10808. serialize(serializationObject: any): void;
  10809. }
  10810. /**
  10811. * Strong typing of a Mesh related stage step action
  10812. */
  10813. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10814. /**
  10815. * Strong typing of a Evaluate Sub Mesh related stage step action
  10816. */
  10817. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10818. /**
  10819. * Strong typing of a Active Mesh related stage step action
  10820. */
  10821. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10822. /**
  10823. * Strong typing of a Camera related stage step action
  10824. */
  10825. export type CameraStageAction = (camera: Camera) => void;
  10826. /**
  10827. * Strong typing of a Camera Frame buffer related stage step action
  10828. */
  10829. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10830. /**
  10831. * Strong typing of a Render Target related stage step action
  10832. */
  10833. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10834. /**
  10835. * Strong typing of a RenderingGroup related stage step action
  10836. */
  10837. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10838. /**
  10839. * Strong typing of a Mesh Render related stage step action
  10840. */
  10841. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10842. /**
  10843. * Strong typing of a simple stage step action
  10844. */
  10845. export type SimpleStageAction = () => void;
  10846. /**
  10847. * Strong typing of a render target action.
  10848. */
  10849. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10850. /**
  10851. * Strong typing of a pointer move action.
  10852. */
  10853. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10854. /**
  10855. * Strong typing of a pointer up/down action.
  10856. */
  10857. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10858. /**
  10859. * Representation of a stage in the scene (Basically a list of ordered steps)
  10860. * @hidden
  10861. */
  10862. export class Stage<T extends Function> extends Array<{
  10863. index: number;
  10864. component: ISceneComponent;
  10865. action: T;
  10866. }> {
  10867. /**
  10868. * Hide ctor from the rest of the world.
  10869. * @param items The items to add.
  10870. */
  10871. private constructor();
  10872. /**
  10873. * Creates a new Stage.
  10874. * @returns A new instance of a Stage
  10875. */
  10876. static Create<T extends Function>(): Stage<T>;
  10877. /**
  10878. * Registers a step in an ordered way in the targeted stage.
  10879. * @param index Defines the position to register the step in
  10880. * @param component Defines the component attached to the step
  10881. * @param action Defines the action to launch during the step
  10882. */
  10883. registerStep(index: number, component: ISceneComponent, action: T): void;
  10884. /**
  10885. * Clears all the steps from the stage.
  10886. */
  10887. clear(): void;
  10888. }
  10889. }
  10890. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10891. import { Nullable } from "babylonjs/types";
  10892. import { Observable } from "babylonjs/Misc/observable";
  10893. import { Scene } from "babylonjs/scene";
  10894. import { Sprite } from "babylonjs/Sprites/sprite";
  10895. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10896. import { Ray } from "babylonjs/Culling/ray";
  10897. import { Camera } from "babylonjs/Cameras/camera";
  10898. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10899. import { ISceneComponent } from "babylonjs/sceneComponent";
  10900. module "babylonjs/scene" {
  10901. interface Scene {
  10902. /** @hidden */
  10903. _pointerOverSprite: Nullable<Sprite>;
  10904. /** @hidden */
  10905. _pickedDownSprite: Nullable<Sprite>;
  10906. /** @hidden */
  10907. _tempSpritePickingRay: Nullable<Ray>;
  10908. /**
  10909. * All of the sprite managers added to this scene
  10910. * @see http://doc.babylonjs.com/babylon101/sprites
  10911. */
  10912. spriteManagers: Array<ISpriteManager>;
  10913. /**
  10914. * An event triggered when sprites rendering is about to start
  10915. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10916. */
  10917. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10918. /**
  10919. * An event triggered when sprites rendering is done
  10920. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10921. */
  10922. onAfterSpritesRenderingObservable: Observable<Scene>;
  10923. /** @hidden */
  10924. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10925. /** Launch a ray to try to pick a sprite in the scene
  10926. * @param x position on screen
  10927. * @param y position on screen
  10928. * @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
  10929. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10930. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10931. * @returns a PickingInfo
  10932. */
  10933. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10934. /** Use the given ray to pick a sprite in the scene
  10935. * @param ray The ray (in world space) to use to pick meshes
  10936. * @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
  10937. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10938. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10939. * @returns a PickingInfo
  10940. */
  10941. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10942. /** @hidden */
  10943. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10944. /** Launch a ray to try to pick sprites in the scene
  10945. * @param x position on screen
  10946. * @param y position on screen
  10947. * @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
  10948. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10949. * @returns a PickingInfo array
  10950. */
  10951. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10952. /** Use the given ray to pick sprites in the scene
  10953. * @param ray The ray (in world space) to use to pick meshes
  10954. * @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
  10955. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10956. * @returns a PickingInfo array
  10957. */
  10958. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10959. /**
  10960. * Force the sprite under the pointer
  10961. * @param sprite defines the sprite to use
  10962. */
  10963. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10964. /**
  10965. * Gets the sprite under the pointer
  10966. * @returns a Sprite or null if no sprite is under the pointer
  10967. */
  10968. getPointerOverSprite(): Nullable<Sprite>;
  10969. }
  10970. }
  10971. /**
  10972. * Defines the sprite scene component responsible to manage sprites
  10973. * in a given scene.
  10974. */
  10975. export class SpriteSceneComponent implements ISceneComponent {
  10976. /**
  10977. * The component name helpfull to identify the component in the list of scene components.
  10978. */
  10979. readonly name: string;
  10980. /**
  10981. * The scene the component belongs to.
  10982. */
  10983. scene: Scene;
  10984. /** @hidden */
  10985. private _spritePredicate;
  10986. /**
  10987. * Creates a new instance of the component for the given scene
  10988. * @param scene Defines the scene to register the component in
  10989. */
  10990. constructor(scene: Scene);
  10991. /**
  10992. * Registers the component in a given scene
  10993. */
  10994. register(): void;
  10995. /**
  10996. * Rebuilds the elements related to this component in case of
  10997. * context lost for instance.
  10998. */
  10999. rebuild(): void;
  11000. /**
  11001. * Disposes the component and the associated ressources.
  11002. */
  11003. dispose(): void;
  11004. private _pickSpriteButKeepRay;
  11005. private _pointerMove;
  11006. private _pointerDown;
  11007. private _pointerUp;
  11008. }
  11009. }
  11010. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11011. /** @hidden */
  11012. export var fogFragmentDeclaration: {
  11013. name: string;
  11014. shader: string;
  11015. };
  11016. }
  11017. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11018. /** @hidden */
  11019. export var fogFragment: {
  11020. name: string;
  11021. shader: string;
  11022. };
  11023. }
  11024. declare module "babylonjs/Shaders/sprites.fragment" {
  11025. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11026. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11027. /** @hidden */
  11028. export var spritesPixelShader: {
  11029. name: string;
  11030. shader: string;
  11031. };
  11032. }
  11033. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11034. /** @hidden */
  11035. export var fogVertexDeclaration: {
  11036. name: string;
  11037. shader: string;
  11038. };
  11039. }
  11040. declare module "babylonjs/Shaders/sprites.vertex" {
  11041. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11042. /** @hidden */
  11043. export var spritesVertexShader: {
  11044. name: string;
  11045. shader: string;
  11046. };
  11047. }
  11048. declare module "babylonjs/Sprites/spriteManager" {
  11049. import { IDisposable, Scene } from "babylonjs/scene";
  11050. import { Nullable } from "babylonjs/types";
  11051. import { Observable } from "babylonjs/Misc/observable";
  11052. import { Sprite } from "babylonjs/Sprites/sprite";
  11053. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11054. import { Camera } from "babylonjs/Cameras/camera";
  11055. import { Texture } from "babylonjs/Materials/Textures/texture";
  11056. import "babylonjs/Shaders/sprites.fragment";
  11057. import "babylonjs/Shaders/sprites.vertex";
  11058. import { Ray } from "babylonjs/Culling/ray";
  11059. /**
  11060. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11061. */
  11062. export interface ISpriteManager extends IDisposable {
  11063. /**
  11064. * Gets manager's name
  11065. */
  11066. name: string;
  11067. /**
  11068. * Restricts the camera to viewing objects with the same layerMask.
  11069. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11070. */
  11071. layerMask: number;
  11072. /**
  11073. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11074. */
  11075. isPickable: boolean;
  11076. /**
  11077. * Gets the hosting scene
  11078. */
  11079. scene: Scene;
  11080. /**
  11081. * Specifies the rendering group id for this mesh (0 by default)
  11082. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11083. */
  11084. renderingGroupId: number;
  11085. /**
  11086. * Defines the list of sprites managed by the manager.
  11087. */
  11088. sprites: Array<Sprite>;
  11089. /**
  11090. * Gets or sets the spritesheet texture
  11091. */
  11092. texture: Texture;
  11093. /** Defines the default width of a cell in the spritesheet */
  11094. cellWidth: number;
  11095. /** Defines the default height of a cell in the spritesheet */
  11096. cellHeight: number;
  11097. /**
  11098. * Tests the intersection of a sprite with a specific ray.
  11099. * @param ray The ray we are sending to test the collision
  11100. * @param camera The camera space we are sending rays in
  11101. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11102. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11103. * @returns picking info or null.
  11104. */
  11105. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @returns null if no hit or a PickingInfo array
  11112. */
  11113. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11114. /**
  11115. * Renders the list of sprites on screen.
  11116. */
  11117. render(): void;
  11118. }
  11119. /**
  11120. * Class used to manage multiple sprites on the same spritesheet
  11121. * @see http://doc.babylonjs.com/babylon101/sprites
  11122. */
  11123. export class SpriteManager implements ISpriteManager {
  11124. /** defines the manager's name */
  11125. name: string;
  11126. /** Gets the list of sprites */
  11127. sprites: Sprite[];
  11128. /** Gets or sets the rendering group id (0 by default) */
  11129. renderingGroupId: number;
  11130. /** Gets or sets camera layer mask */
  11131. layerMask: number;
  11132. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11133. fogEnabled: boolean;
  11134. /** Gets or sets a boolean indicating if the sprites are pickable */
  11135. isPickable: boolean;
  11136. /** Defines the default width of a cell in the spritesheet */
  11137. cellWidth: number;
  11138. /** Defines the default height of a cell in the spritesheet */
  11139. cellHeight: number;
  11140. /** Associative array from JSON sprite data file */
  11141. private _cellData;
  11142. /** Array of sprite names from JSON sprite data file */
  11143. private _spriteMap;
  11144. /** True when packed cell data from JSON file is ready*/
  11145. private _packedAndReady;
  11146. private _textureContent;
  11147. /**
  11148. * An event triggered when the manager is disposed.
  11149. */
  11150. onDisposeObservable: Observable<SpriteManager>;
  11151. private _onDisposeObserver;
  11152. /**
  11153. * Callback called when the manager is disposed
  11154. */
  11155. set onDispose(callback: () => void);
  11156. private _capacity;
  11157. private _fromPacked;
  11158. private _spriteTexture;
  11159. private _epsilon;
  11160. private _scene;
  11161. private _vertexData;
  11162. private _buffer;
  11163. private _vertexBuffers;
  11164. private _indexBuffer;
  11165. private _effectBase;
  11166. private _effectFog;
  11167. /**
  11168. * Gets or sets the unique id of the sprite
  11169. */
  11170. uniqueId: number;
  11171. /**
  11172. * Gets the array of sprites
  11173. */
  11174. get children(): Sprite[];
  11175. /**
  11176. * Gets the hosting scene
  11177. */
  11178. get scene(): Scene;
  11179. /**
  11180. * Gets the capacity of the manager
  11181. */
  11182. get capacity(): number;
  11183. /**
  11184. * Gets or sets the spritesheet texture
  11185. */
  11186. get texture(): Texture;
  11187. set texture(value: Texture);
  11188. private _blendMode;
  11189. /**
  11190. * Blend mode use to render the particle, it can be any of
  11191. * the static Constants.ALPHA_x properties provided in this class.
  11192. * Default value is Constants.ALPHA_COMBINE
  11193. */
  11194. get blendMode(): number;
  11195. set blendMode(blendMode: number);
  11196. /** Disables writing to the depth buffer when rendering the sprites.
  11197. * It can be handy to disable depth writing when using textures without alpha channel
  11198. * and setting some specific blend modes.
  11199. */
  11200. disableDepthWrite: boolean;
  11201. /**
  11202. * Creates a new sprite manager
  11203. * @param name defines the manager's name
  11204. * @param imgUrl defines the sprite sheet url
  11205. * @param capacity defines the maximum allowed number of sprites
  11206. * @param cellSize defines the size of a sprite cell
  11207. * @param scene defines the hosting scene
  11208. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11209. * @param samplingMode defines the smapling mode to use with spritesheet
  11210. * @param fromPacked set to false; do not alter
  11211. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11212. */
  11213. constructor(
  11214. /** defines the manager's name */
  11215. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11216. /**
  11217. * Returns the string "SpriteManager"
  11218. * @returns "SpriteManager"
  11219. */
  11220. getClassName(): string;
  11221. private _makePacked;
  11222. private _appendSpriteVertex;
  11223. private _checkTextureAlpha;
  11224. /**
  11225. * Intersects the sprites with a ray
  11226. * @param ray defines the ray to intersect with
  11227. * @param camera defines the current active camera
  11228. * @param predicate defines a predicate used to select candidate sprites
  11229. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11230. * @returns null if no hit or a PickingInfo
  11231. */
  11232. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11233. /**
  11234. * Intersects the sprites with a ray
  11235. * @param ray defines the ray to intersect with
  11236. * @param camera defines the current active camera
  11237. * @param predicate defines a predicate used to select candidate sprites
  11238. * @returns null if no hit or a PickingInfo array
  11239. */
  11240. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11241. /**
  11242. * Render all child sprites
  11243. */
  11244. render(): void;
  11245. /**
  11246. * Release associated resources
  11247. */
  11248. dispose(): void;
  11249. }
  11250. }
  11251. declare module "babylonjs/Misc/gradients" {
  11252. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11253. /** Interface used by value gradients (color, factor, ...) */
  11254. export interface IValueGradient {
  11255. /**
  11256. * Gets or sets the gradient value (between 0 and 1)
  11257. */
  11258. gradient: number;
  11259. }
  11260. /** Class used to store color4 gradient */
  11261. export class ColorGradient implements IValueGradient {
  11262. /**
  11263. * Gets or sets the gradient value (between 0 and 1)
  11264. */
  11265. gradient: number;
  11266. /**
  11267. * Gets or sets first associated color
  11268. */
  11269. color1: Color4;
  11270. /**
  11271. * Gets or sets second associated color
  11272. */
  11273. color2?: Color4 | undefined;
  11274. /**
  11275. * Creates a new color4 gradient
  11276. * @param gradient gets or sets the gradient value (between 0 and 1)
  11277. * @param color1 gets or sets first associated color
  11278. * @param color2 gets or sets first second color
  11279. */
  11280. constructor(
  11281. /**
  11282. * Gets or sets the gradient value (between 0 and 1)
  11283. */
  11284. gradient: number,
  11285. /**
  11286. * Gets or sets first associated color
  11287. */
  11288. color1: Color4,
  11289. /**
  11290. * Gets or sets second associated color
  11291. */
  11292. color2?: Color4 | undefined);
  11293. /**
  11294. * Will get a color picked randomly between color1 and color2.
  11295. * If color2 is undefined then color1 will be used
  11296. * @param result defines the target Color4 to store the result in
  11297. */
  11298. getColorToRef(result: Color4): void;
  11299. }
  11300. /** Class used to store color 3 gradient */
  11301. export class Color3Gradient implements IValueGradient {
  11302. /**
  11303. * Gets or sets the gradient value (between 0 and 1)
  11304. */
  11305. gradient: number;
  11306. /**
  11307. * Gets or sets the associated color
  11308. */
  11309. color: Color3;
  11310. /**
  11311. * Creates a new color3 gradient
  11312. * @param gradient gets or sets the gradient value (between 0 and 1)
  11313. * @param color gets or sets associated color
  11314. */
  11315. constructor(
  11316. /**
  11317. * Gets or sets the gradient value (between 0 and 1)
  11318. */
  11319. gradient: number,
  11320. /**
  11321. * Gets or sets the associated color
  11322. */
  11323. color: Color3);
  11324. }
  11325. /** Class used to store factor gradient */
  11326. export class FactorGradient implements IValueGradient {
  11327. /**
  11328. * Gets or sets the gradient value (between 0 and 1)
  11329. */
  11330. gradient: number;
  11331. /**
  11332. * Gets or sets first associated factor
  11333. */
  11334. factor1: number;
  11335. /**
  11336. * Gets or sets second associated factor
  11337. */
  11338. factor2?: number | undefined;
  11339. /**
  11340. * Creates a new factor gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param factor1 gets or sets first associated factor
  11343. * @param factor2 gets or sets second associated factor
  11344. */
  11345. constructor(
  11346. /**
  11347. * Gets or sets the gradient value (between 0 and 1)
  11348. */
  11349. gradient: number,
  11350. /**
  11351. * Gets or sets first associated factor
  11352. */
  11353. factor1: number,
  11354. /**
  11355. * Gets or sets second associated factor
  11356. */
  11357. factor2?: number | undefined);
  11358. /**
  11359. * Will get a number picked randomly between factor1 and factor2.
  11360. * If factor2 is undefined then factor1 will be used
  11361. * @returns the picked number
  11362. */
  11363. getFactor(): number;
  11364. }
  11365. /**
  11366. * Helper used to simplify some generic gradient tasks
  11367. */
  11368. export class GradientHelper {
  11369. /**
  11370. * Gets the current gradient from an array of IValueGradient
  11371. * @param ratio defines the current ratio to get
  11372. * @param gradients defines the array of IValueGradient
  11373. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11374. */
  11375. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11376. }
  11377. }
  11378. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11380. import { Nullable } from "babylonjs/types";
  11381. module "babylonjs/Engines/thinEngine" {
  11382. interface ThinEngine {
  11383. /**
  11384. * Creates a dynamic texture
  11385. * @param width defines the width of the texture
  11386. * @param height defines the height of the texture
  11387. * @param generateMipMaps defines if the engine should generate the mip levels
  11388. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11389. * @returns the dynamic texture inside an InternalTexture
  11390. */
  11391. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11392. /**
  11393. * Update the content of a dynamic texture
  11394. * @param texture defines the texture to update
  11395. * @param canvas defines the canvas containing the source
  11396. * @param invertY defines if data must be stored with Y axis inverted
  11397. * @param premulAlpha defines if alpha is stored as premultiplied
  11398. * @param format defines the format of the data
  11399. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11400. */
  11401. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11402. }
  11403. }
  11404. }
  11405. declare module "babylonjs/Misc/canvasGenerator" {
  11406. /**
  11407. * Helper class used to generate a canvas to manipulate images
  11408. */
  11409. export class CanvasGenerator {
  11410. /**
  11411. * Create a new canvas (or offscreen canvas depending on the context)
  11412. * @param width defines the expected width
  11413. * @param height defines the expected height
  11414. * @return a new canvas or offscreen canvas
  11415. */
  11416. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11417. }
  11418. }
  11419. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11420. import { Scene } from "babylonjs/scene";
  11421. import { Texture } from "babylonjs/Materials/Textures/texture";
  11422. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11423. /**
  11424. * A class extending Texture allowing drawing on a texture
  11425. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11426. */
  11427. export class DynamicTexture extends Texture {
  11428. private _generateMipMaps;
  11429. private _canvas;
  11430. private _context;
  11431. /**
  11432. * Creates a DynamicTexture
  11433. * @param name defines the name of the texture
  11434. * @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
  11435. * @param scene defines the scene where you want the texture
  11436. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11437. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11438. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11439. */
  11440. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11441. /**
  11442. * Get the current class name of the texture useful for serialization or dynamic coding.
  11443. * @returns "DynamicTexture"
  11444. */
  11445. getClassName(): string;
  11446. /**
  11447. * Gets the current state of canRescale
  11448. */
  11449. get canRescale(): boolean;
  11450. private _recreate;
  11451. /**
  11452. * Scales the texture
  11453. * @param ratio the scale factor to apply to both width and height
  11454. */
  11455. scale(ratio: number): void;
  11456. /**
  11457. * Resizes the texture
  11458. * @param width the new width
  11459. * @param height the new height
  11460. */
  11461. scaleTo(width: number, height: number): void;
  11462. /**
  11463. * Gets the context of the canvas used by the texture
  11464. * @returns the canvas context of the dynamic texture
  11465. */
  11466. getContext(): CanvasRenderingContext2D;
  11467. /**
  11468. * Clears the texture
  11469. */
  11470. clear(): void;
  11471. /**
  11472. * Updates the texture
  11473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11474. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11475. */
  11476. update(invertY?: boolean, premulAlpha?: boolean): void;
  11477. /**
  11478. * Draws text onto the texture
  11479. * @param text defines the text to be drawn
  11480. * @param x defines the placement of the text from the left
  11481. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11482. * @param font defines the font to be used with font-style, font-size, font-name
  11483. * @param color defines the color used for the text
  11484. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11485. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11486. * @param update defines whether texture is immediately update (default is true)
  11487. */
  11488. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11489. /**
  11490. * Clones the texture
  11491. * @returns the clone of the texture.
  11492. */
  11493. clone(): DynamicTexture;
  11494. /**
  11495. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11496. * @returns a serialized dynamic texture object
  11497. */
  11498. serialize(): any;
  11499. /** @hidden */
  11500. _rebuild(): void;
  11501. }
  11502. }
  11503. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11504. import { Nullable } from "babylonjs/types";
  11505. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11506. import { Scene } from "babylonjs/scene";
  11507. module "babylonjs/Engines/thinEngine" {
  11508. interface ThinEngine {
  11509. /**
  11510. * Creates a raw texture
  11511. * @param data defines the data to store in the texture
  11512. * @param width defines the width of the texture
  11513. * @param height defines the height of the texture
  11514. * @param format defines the format of the data
  11515. * @param generateMipMaps defines if the engine should generate the mip levels
  11516. * @param invertY defines if data must be stored with Y axis inverted
  11517. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11518. * @param compression defines the compression used (null by default)
  11519. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11520. * @returns the raw texture inside an InternalTexture
  11521. */
  11522. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11523. /**
  11524. * Update a raw texture
  11525. * @param texture defines the texture to update
  11526. * @param data defines the data to store in the texture
  11527. * @param format defines the format of the data
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. */
  11530. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11531. /**
  11532. * Update a raw texture
  11533. * @param texture defines the texture to update
  11534. * @param data defines the data to store in the texture
  11535. * @param format defines the format of the data
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. * @param compression defines the compression used (null by default)
  11538. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11539. */
  11540. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11541. /**
  11542. * Creates a new raw cube texture
  11543. * @param data defines the array of data to use to create each face
  11544. * @param size defines the size of the textures
  11545. * @param format defines the format of the data
  11546. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11547. * @param generateMipMaps defines if the engine should generate the mip levels
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11550. * @param compression defines the compression used (null by default)
  11551. * @returns the cube texture as an InternalTexture
  11552. */
  11553. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11554. /**
  11555. * Update a raw cube texture
  11556. * @param texture defines the texture to udpdate
  11557. * @param data defines the data to store
  11558. * @param format defines the data format
  11559. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. */
  11562. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11563. /**
  11564. * Update a raw cube texture
  11565. * @param texture defines the texture to udpdate
  11566. * @param data defines the data to store
  11567. * @param format defines the data format
  11568. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. * @param compression defines the compression used (null by default)
  11571. */
  11572. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11573. /**
  11574. * Update a raw cube texture
  11575. * @param texture defines the texture to udpdate
  11576. * @param data defines the data to store
  11577. * @param format defines the data format
  11578. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11579. * @param invertY defines if data must be stored with Y axis inverted
  11580. * @param compression defines the compression used (null by default)
  11581. * @param level defines which level of the texture to update
  11582. */
  11583. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11584. /**
  11585. * Creates a new raw cube texture from a specified url
  11586. * @param url defines the url where the data is located
  11587. * @param scene defines the current scene
  11588. * @param size defines the size of the textures
  11589. * @param format defines the format of the data
  11590. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11591. * @param noMipmap defines if the engine should avoid generating the mip levels
  11592. * @param callback defines a callback used to extract texture data from loaded data
  11593. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11594. * @param onLoad defines a callback called when texture is loaded
  11595. * @param onError defines a callback called if there is an error
  11596. * @returns the cube texture as an InternalTexture
  11597. */
  11598. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11599. /**
  11600. * Creates a new raw cube texture from a specified url
  11601. * @param url defines the url where the data is located
  11602. * @param scene defines the current scene
  11603. * @param size defines the size of the textures
  11604. * @param format defines the format of the data
  11605. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11606. * @param noMipmap defines if the engine should avoid generating the mip levels
  11607. * @param callback defines a callback used to extract texture data from loaded data
  11608. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11609. * @param onLoad defines a callback called when texture is loaded
  11610. * @param onError defines a callback called if there is an error
  11611. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11612. * @param invertY defines if data must be stored with Y axis inverted
  11613. * @returns the cube texture as an InternalTexture
  11614. */
  11615. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11616. /**
  11617. * Creates a new raw 3D texture
  11618. * @param data defines the data used to create the texture
  11619. * @param width defines the width of the texture
  11620. * @param height defines the height of the texture
  11621. * @param depth defines the depth of the texture
  11622. * @param format defines the format of the texture
  11623. * @param generateMipMaps defines if the engine must generate mip levels
  11624. * @param invertY defines if data must be stored with Y axis inverted
  11625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11626. * @param compression defines the compressed used (can be null)
  11627. * @param textureType defines the compressed used (can be null)
  11628. * @returns a new raw 3D texture (stored in an InternalTexture)
  11629. */
  11630. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11631. /**
  11632. * Update a raw 3D texture
  11633. * @param texture defines the texture to update
  11634. * @param data defines the data to store
  11635. * @param format defines the data format
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. */
  11638. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11639. /**
  11640. * Update a raw 3D texture
  11641. * @param texture defines the texture to update
  11642. * @param data defines the data to store
  11643. * @param format defines the data format
  11644. * @param invertY defines if data must be stored with Y axis inverted
  11645. * @param compression defines the used compression (can be null)
  11646. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11647. */
  11648. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11649. /**
  11650. * Creates a new raw 2D array texture
  11651. * @param data defines the data used to create the texture
  11652. * @param width defines the width of the texture
  11653. * @param height defines the height of the texture
  11654. * @param depth defines the number of layers of the texture
  11655. * @param format defines the format of the texture
  11656. * @param generateMipMaps defines if the engine must generate mip levels
  11657. * @param invertY defines if data must be stored with Y axis inverted
  11658. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11659. * @param compression defines the compressed used (can be null)
  11660. * @param textureType defines the compressed used (can be null)
  11661. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11662. */
  11663. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11664. /**
  11665. * Update a raw 2D array texture
  11666. * @param texture defines the texture to update
  11667. * @param data defines the data to store
  11668. * @param format defines the data format
  11669. * @param invertY defines if data must be stored with Y axis inverted
  11670. */
  11671. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11672. /**
  11673. * Update a raw 2D array texture
  11674. * @param texture defines the texture to update
  11675. * @param data defines the data to store
  11676. * @param format defines the data format
  11677. * @param invertY defines if data must be stored with Y axis inverted
  11678. * @param compression defines the used compression (can be null)
  11679. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11680. */
  11681. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11682. }
  11683. }
  11684. }
  11685. declare module "babylonjs/Materials/Textures/rawTexture" {
  11686. import { Scene } from "babylonjs/scene";
  11687. import { Texture } from "babylonjs/Materials/Textures/texture";
  11688. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11689. /**
  11690. * Raw texture can help creating a texture directly from an array of data.
  11691. * This can be super useful if you either get the data from an uncompressed source or
  11692. * if you wish to create your texture pixel by pixel.
  11693. */
  11694. export class RawTexture extends Texture {
  11695. /**
  11696. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11697. */
  11698. format: number;
  11699. /**
  11700. * Instantiates a new RawTexture.
  11701. * Raw texture can help creating a texture directly from an array of data.
  11702. * This can be super useful if you either get the data from an uncompressed source or
  11703. * if you wish to create your texture pixel by pixel.
  11704. * @param data define the array of data to use to create the texture
  11705. * @param width define the width of the texture
  11706. * @param height define the height of the texture
  11707. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11708. * @param scene define the scene the texture belongs to
  11709. * @param generateMipMaps define whether mip maps should be generated or not
  11710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11713. */
  11714. constructor(data: ArrayBufferView, width: number, height: number,
  11715. /**
  11716. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11717. */
  11718. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11719. /**
  11720. * Updates the texture underlying data.
  11721. * @param data Define the new data of the texture
  11722. */
  11723. update(data: ArrayBufferView): void;
  11724. /**
  11725. * Creates a luminance texture from some data.
  11726. * @param data Define the texture data
  11727. * @param width Define the width of the texture
  11728. * @param height Define the height of the texture
  11729. * @param scene Define the scene the texture belongs to
  11730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11733. * @returns the luminance texture
  11734. */
  11735. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11736. /**
  11737. * Creates a luminance alpha texture from some data.
  11738. * @param data Define the texture data
  11739. * @param width Define the width of the texture
  11740. * @param height Define the height of the texture
  11741. * @param scene Define the scene the texture belongs to
  11742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11745. * @returns the luminance alpha texture
  11746. */
  11747. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11748. /**
  11749. * Creates an alpha texture from some data.
  11750. * @param data Define the texture data
  11751. * @param width Define the width of the texture
  11752. * @param height Define the height of the texture
  11753. * @param scene Define the scene the texture belongs to
  11754. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11755. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11756. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11757. * @returns the alpha texture
  11758. */
  11759. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11760. /**
  11761. * Creates a RGB texture from some data.
  11762. * @param data Define the texture data
  11763. * @param width Define the width of the texture
  11764. * @param height Define the height of the texture
  11765. * @param scene Define the scene the texture belongs to
  11766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11770. * @returns the RGB alpha texture
  11771. */
  11772. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11773. /**
  11774. * Creates a RGBA texture from some data.
  11775. * @param data Define the texture data
  11776. * @param width Define the width of the texture
  11777. * @param height Define the height of the texture
  11778. * @param scene Define the scene the texture belongs to
  11779. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11780. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11781. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11782. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11783. * @returns the RGBA texture
  11784. */
  11785. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11786. /**
  11787. * Creates a R texture from some data.
  11788. * @param data Define the texture data
  11789. * @param width Define the width of the texture
  11790. * @param height Define the height of the texture
  11791. * @param scene Define the scene the texture belongs to
  11792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11795. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11796. * @returns the R texture
  11797. */
  11798. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11799. }
  11800. }
  11801. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11802. import { Scene } from "babylonjs/scene";
  11803. import { ISceneComponent } from "babylonjs/sceneComponent";
  11804. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11805. module "babylonjs/abstractScene" {
  11806. interface AbstractScene {
  11807. /**
  11808. * The list of procedural textures added to the scene
  11809. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11810. */
  11811. proceduralTextures: Array<ProceduralTexture>;
  11812. }
  11813. }
  11814. /**
  11815. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11816. * in a given scene.
  11817. */
  11818. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11819. /**
  11820. * The component name helpfull to identify the component in the list of scene components.
  11821. */
  11822. readonly name: string;
  11823. /**
  11824. * The scene the component belongs to.
  11825. */
  11826. scene: Scene;
  11827. /**
  11828. * Creates a new instance of the component for the given scene
  11829. * @param scene Defines the scene to register the component in
  11830. */
  11831. constructor(scene: Scene);
  11832. /**
  11833. * Registers the component in a given scene
  11834. */
  11835. register(): void;
  11836. /**
  11837. * Rebuilds the elements related to this component in case of
  11838. * context lost for instance.
  11839. */
  11840. rebuild(): void;
  11841. /**
  11842. * Disposes the component and the associated ressources.
  11843. */
  11844. dispose(): void;
  11845. private _beforeClear;
  11846. }
  11847. }
  11848. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11850. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11851. module "babylonjs/Engines/thinEngine" {
  11852. interface ThinEngine {
  11853. /**
  11854. * Creates a new render target cube texture
  11855. * @param size defines the size of the texture
  11856. * @param options defines the options used to create the texture
  11857. * @returns a new render target cube texture stored in an InternalTexture
  11858. */
  11859. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11860. }
  11861. }
  11862. }
  11863. declare module "babylonjs/Shaders/procedural.vertex" {
  11864. /** @hidden */
  11865. export var proceduralVertexShader: {
  11866. name: string;
  11867. shader: string;
  11868. };
  11869. }
  11870. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11871. import { Observable } from "babylonjs/Misc/observable";
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Scene } from "babylonjs/scene";
  11874. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11875. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11876. import { Effect } from "babylonjs/Materials/effect";
  11877. import { Texture } from "babylonjs/Materials/Textures/texture";
  11878. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11879. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11880. import "babylonjs/Shaders/procedural.vertex";
  11881. /**
  11882. * 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.
  11883. * This is the base class of any Procedural texture and contains most of the shareable code.
  11884. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11885. */
  11886. export class ProceduralTexture extends Texture {
  11887. isCube: boolean;
  11888. /**
  11889. * Define if the texture is enabled or not (disabled texture will not render)
  11890. */
  11891. isEnabled: boolean;
  11892. /**
  11893. * Define if the texture must be cleared before rendering (default is true)
  11894. */
  11895. autoClear: boolean;
  11896. /**
  11897. * Callback called when the texture is generated
  11898. */
  11899. onGenerated: () => void;
  11900. /**
  11901. * Event raised when the texture is generated
  11902. */
  11903. onGeneratedObservable: Observable<ProceduralTexture>;
  11904. /** @hidden */
  11905. _generateMipMaps: boolean;
  11906. /** @hidden **/
  11907. _effect: Effect;
  11908. /** @hidden */
  11909. _textures: {
  11910. [key: string]: Texture;
  11911. };
  11912. /** @hidden */
  11913. protected _fallbackTexture: Nullable<Texture>;
  11914. private _size;
  11915. private _currentRefreshId;
  11916. private _frameId;
  11917. private _refreshRate;
  11918. private _vertexBuffers;
  11919. private _indexBuffer;
  11920. private _uniforms;
  11921. private _samplers;
  11922. private _fragment;
  11923. private _floats;
  11924. private _ints;
  11925. private _floatsArrays;
  11926. private _colors3;
  11927. private _colors4;
  11928. private _vectors2;
  11929. private _vectors3;
  11930. private _matrices;
  11931. private _fallbackTextureUsed;
  11932. private _fullEngine;
  11933. private _cachedDefines;
  11934. private _contentUpdateId;
  11935. private _contentData;
  11936. /**
  11937. * Instantiates a new procedural texture.
  11938. * 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.
  11939. * This is the base class of any Procedural texture and contains most of the shareable code.
  11940. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11941. * @param name Define the name of the texture
  11942. * @param size Define the size of the texture to create
  11943. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11944. * @param scene Define the scene the texture belongs to
  11945. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11946. * @param generateMipMaps Define if the texture should creates mip maps or not
  11947. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11948. */
  11949. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11950. /**
  11951. * The effect that is created when initializing the post process.
  11952. * @returns The created effect corresponding the the postprocess.
  11953. */
  11954. getEffect(): Effect;
  11955. /**
  11956. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11957. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11958. */
  11959. getContent(): Nullable<ArrayBufferView>;
  11960. private _createIndexBuffer;
  11961. /** @hidden */
  11962. _rebuild(): void;
  11963. /**
  11964. * Resets the texture in order to recreate its associated resources.
  11965. * This can be called in case of context loss
  11966. */
  11967. reset(): void;
  11968. protected _getDefines(): string;
  11969. /**
  11970. * Is the texture ready to be used ? (rendered at least once)
  11971. * @returns true if ready, otherwise, false.
  11972. */
  11973. isReady(): boolean;
  11974. /**
  11975. * Resets the refresh counter of the texture and start bak from scratch.
  11976. * Could be useful to regenerate the texture if it is setup to render only once.
  11977. */
  11978. resetRefreshCounter(): void;
  11979. /**
  11980. * Set the fragment shader to use in order to render the texture.
  11981. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11982. */
  11983. setFragment(fragment: any): void;
  11984. /**
  11985. * Define the refresh rate of the texture or the rendering frequency.
  11986. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11987. */
  11988. get refreshRate(): number;
  11989. set refreshRate(value: number);
  11990. /** @hidden */
  11991. _shouldRender(): boolean;
  11992. /**
  11993. * Get the size the texture is rendering at.
  11994. * @returns the size (texture is always squared)
  11995. */
  11996. getRenderSize(): number;
  11997. /**
  11998. * Resize the texture to new value.
  11999. * @param size Define the new size the texture should have
  12000. * @param generateMipMaps Define whether the new texture should create mip maps
  12001. */
  12002. resize(size: number, generateMipMaps: boolean): void;
  12003. private _checkUniform;
  12004. /**
  12005. * Set a texture in the shader program used to render.
  12006. * @param name Define the name of the uniform samplers as defined in the shader
  12007. * @param texture Define the texture to bind to this sampler
  12008. * @return the texture itself allowing "fluent" like uniform updates
  12009. */
  12010. setTexture(name: string, texture: Texture): ProceduralTexture;
  12011. /**
  12012. * Set a float in the shader.
  12013. * @param name Define the name of the uniform as defined in the shader
  12014. * @param value Define the value to give to the uniform
  12015. * @return the texture itself allowing "fluent" like uniform updates
  12016. */
  12017. setFloat(name: string, value: number): ProceduralTexture;
  12018. /**
  12019. * Set a int in the shader.
  12020. * @param name Define the name of the uniform as defined in the shader
  12021. * @param value Define the value to give to the uniform
  12022. * @return the texture itself allowing "fluent" like uniform updates
  12023. */
  12024. setInt(name: string, value: number): ProceduralTexture;
  12025. /**
  12026. * Set an array of floats in the shader.
  12027. * @param name Define the name of the uniform as defined in the shader
  12028. * @param value Define the value to give to the uniform
  12029. * @return the texture itself allowing "fluent" like uniform updates
  12030. */
  12031. setFloats(name: string, value: number[]): ProceduralTexture;
  12032. /**
  12033. * Set a vec3 in the shader from a Color3.
  12034. * @param name Define the name of the uniform as defined in the shader
  12035. * @param value Define the value to give to the uniform
  12036. * @return the texture itself allowing "fluent" like uniform updates
  12037. */
  12038. setColor3(name: string, value: Color3): ProceduralTexture;
  12039. /**
  12040. * Set a vec4 in the shader from a Color4.
  12041. * @param name Define the name of the uniform as defined in the shader
  12042. * @param value Define the value to give to the uniform
  12043. * @return the texture itself allowing "fluent" like uniform updates
  12044. */
  12045. setColor4(name: string, value: Color4): ProceduralTexture;
  12046. /**
  12047. * Set a vec2 in the shader from a Vector2.
  12048. * @param name Define the name of the uniform as defined in the shader
  12049. * @param value Define the value to give to the uniform
  12050. * @return the texture itself allowing "fluent" like uniform updates
  12051. */
  12052. setVector2(name: string, value: Vector2): ProceduralTexture;
  12053. /**
  12054. * Set a vec3 in the shader from a Vector3.
  12055. * @param name Define the name of the uniform as defined in the shader
  12056. * @param value Define the value to give to the uniform
  12057. * @return the texture itself allowing "fluent" like uniform updates
  12058. */
  12059. setVector3(name: string, value: Vector3): ProceduralTexture;
  12060. /**
  12061. * Set a mat4 in the shader from a MAtrix.
  12062. * @param name Define the name of the uniform as defined in the shader
  12063. * @param value Define the value to give to the uniform
  12064. * @return the texture itself allowing "fluent" like uniform updates
  12065. */
  12066. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12067. /**
  12068. * Render the texture to its associated render target.
  12069. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12070. */
  12071. render(useCameraPostProcess?: boolean): void;
  12072. /**
  12073. * Clone the texture.
  12074. * @returns the cloned texture
  12075. */
  12076. clone(): ProceduralTexture;
  12077. /**
  12078. * Dispose the texture and release its asoociated resources.
  12079. */
  12080. dispose(): void;
  12081. }
  12082. }
  12083. declare module "babylonjs/Particles/baseParticleSystem" {
  12084. import { Nullable } from "babylonjs/types";
  12085. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12087. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12088. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12090. import { Scene } from "babylonjs/scene";
  12091. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12092. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12093. import { Texture } from "babylonjs/Materials/Textures/texture";
  12094. import { Color4 } from "babylonjs/Maths/math.color";
  12095. import { Animation } from "babylonjs/Animations/animation";
  12096. /**
  12097. * This represents the base class for particle system in Babylon.
  12098. * 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.
  12099. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12100. * @example https://doc.babylonjs.com/babylon101/particles
  12101. */
  12102. export class BaseParticleSystem {
  12103. /**
  12104. * Source color is added to the destination color without alpha affecting the result
  12105. */
  12106. static BLENDMODE_ONEONE: number;
  12107. /**
  12108. * Blend current color and particle color using particle’s alpha
  12109. */
  12110. static BLENDMODE_STANDARD: number;
  12111. /**
  12112. * Add current color and particle color multiplied by particle’s alpha
  12113. */
  12114. static BLENDMODE_ADD: number;
  12115. /**
  12116. * Multiply current color with particle color
  12117. */
  12118. static BLENDMODE_MULTIPLY: number;
  12119. /**
  12120. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12121. */
  12122. static BLENDMODE_MULTIPLYADD: number;
  12123. /**
  12124. * List of animations used by the particle system.
  12125. */
  12126. animations: Animation[];
  12127. /**
  12128. * Gets or sets the unique id of the particle system
  12129. */
  12130. uniqueId: number;
  12131. /**
  12132. * The id of the Particle system.
  12133. */
  12134. id: string;
  12135. /**
  12136. * The friendly name of the Particle system.
  12137. */
  12138. name: string;
  12139. /**
  12140. * Snippet ID if the particle system was created from the snippet server
  12141. */
  12142. snippetId: string;
  12143. /**
  12144. * The rendering group used by the Particle system to chose when to render.
  12145. */
  12146. renderingGroupId: number;
  12147. /**
  12148. * The emitter represents the Mesh or position we are attaching the particle system to.
  12149. */
  12150. emitter: Nullable<AbstractMesh | Vector3>;
  12151. /**
  12152. * The maximum number of particles to emit per frame
  12153. */
  12154. emitRate: number;
  12155. /**
  12156. * If you want to launch only a few particles at once, that can be done, as well.
  12157. */
  12158. manualEmitCount: number;
  12159. /**
  12160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12161. */
  12162. updateSpeed: number;
  12163. /**
  12164. * The amount of time the particle system is running (depends of the overall update speed).
  12165. */
  12166. targetStopDuration: number;
  12167. /**
  12168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12169. */
  12170. disposeOnStop: boolean;
  12171. /**
  12172. * Minimum power of emitting particles.
  12173. */
  12174. minEmitPower: number;
  12175. /**
  12176. * Maximum power of emitting particles.
  12177. */
  12178. maxEmitPower: number;
  12179. /**
  12180. * Minimum life time of emitting particles.
  12181. */
  12182. minLifeTime: number;
  12183. /**
  12184. * Maximum life time of emitting particles.
  12185. */
  12186. maxLifeTime: number;
  12187. /**
  12188. * Minimum Size of emitting particles.
  12189. */
  12190. minSize: number;
  12191. /**
  12192. * Maximum Size of emitting particles.
  12193. */
  12194. maxSize: number;
  12195. /**
  12196. * Minimum scale of emitting particles on X axis.
  12197. */
  12198. minScaleX: number;
  12199. /**
  12200. * Maximum scale of emitting particles on X axis.
  12201. */
  12202. maxScaleX: number;
  12203. /**
  12204. * Minimum scale of emitting particles on Y axis.
  12205. */
  12206. minScaleY: number;
  12207. /**
  12208. * Maximum scale of emitting particles on Y axis.
  12209. */
  12210. maxScaleY: number;
  12211. /**
  12212. * Gets or sets the minimal initial rotation in radians.
  12213. */
  12214. minInitialRotation: number;
  12215. /**
  12216. * Gets or sets the maximal initial rotation in radians.
  12217. */
  12218. maxInitialRotation: number;
  12219. /**
  12220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12221. */
  12222. minAngularSpeed: number;
  12223. /**
  12224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12225. */
  12226. maxAngularSpeed: number;
  12227. /**
  12228. * The texture used to render each particle. (this can be a spritesheet)
  12229. */
  12230. particleTexture: Nullable<Texture>;
  12231. /**
  12232. * The layer mask we are rendering the particles through.
  12233. */
  12234. layerMask: number;
  12235. /**
  12236. * This can help using your own shader to render the particle system.
  12237. * The according effect will be created
  12238. */
  12239. customShader: any;
  12240. /**
  12241. * By default particle system starts as soon as they are created. This prevents the
  12242. * automatic start to happen and let you decide when to start emitting particles.
  12243. */
  12244. preventAutoStart: boolean;
  12245. private _noiseTexture;
  12246. /**
  12247. * Gets or sets a texture used to add random noise to particle positions
  12248. */
  12249. get noiseTexture(): Nullable<ProceduralTexture>;
  12250. set noiseTexture(value: Nullable<ProceduralTexture>);
  12251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12252. noiseStrength: Vector3;
  12253. /**
  12254. * Callback triggered when the particle animation is ending.
  12255. */
  12256. onAnimationEnd: Nullable<() => void>;
  12257. /**
  12258. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12259. */
  12260. blendMode: number;
  12261. /**
  12262. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12263. * to override the particles.
  12264. */
  12265. forceDepthWrite: boolean;
  12266. /** 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 */
  12267. preWarmCycles: number;
  12268. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12269. preWarmStepOffset: number;
  12270. /**
  12271. * 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)
  12272. */
  12273. spriteCellChangeSpeed: number;
  12274. /**
  12275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12276. */
  12277. startSpriteCellID: number;
  12278. /**
  12279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12280. */
  12281. endSpriteCellID: number;
  12282. /**
  12283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12284. */
  12285. spriteCellWidth: number;
  12286. /**
  12287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12288. */
  12289. spriteCellHeight: number;
  12290. /**
  12291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12292. */
  12293. spriteRandomStartCell: boolean;
  12294. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12295. translationPivot: Vector2;
  12296. /** @hidden */
  12297. protected _isAnimationSheetEnabled: boolean;
  12298. /**
  12299. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12300. */
  12301. beginAnimationOnStart: boolean;
  12302. /**
  12303. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12304. */
  12305. beginAnimationFrom: number;
  12306. /**
  12307. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12308. */
  12309. beginAnimationTo: number;
  12310. /**
  12311. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12312. */
  12313. beginAnimationLoop: boolean;
  12314. /**
  12315. * Gets or sets a world offset applied to all particles
  12316. */
  12317. worldOffset: Vector3;
  12318. /**
  12319. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12320. */
  12321. get isAnimationSheetEnabled(): boolean;
  12322. set isAnimationSheetEnabled(value: boolean);
  12323. /**
  12324. * Get hosting scene
  12325. * @returns the scene
  12326. */
  12327. getScene(): Scene;
  12328. /**
  12329. * You can use gravity if you want to give an orientation to your particles.
  12330. */
  12331. gravity: Vector3;
  12332. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12333. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12334. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12335. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12336. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12337. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12338. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12339. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12340. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12341. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12342. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12343. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12344. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12345. /**
  12346. * Defines the delay in milliseconds before starting the system (0 by default)
  12347. */
  12348. startDelay: number;
  12349. /**
  12350. * Gets the current list of drag gradients.
  12351. * You must use addDragGradient and removeDragGradient to udpate this list
  12352. * @returns the list of drag gradients
  12353. */
  12354. getDragGradients(): Nullable<Array<FactorGradient>>;
  12355. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12356. limitVelocityDamping: number;
  12357. /**
  12358. * Gets the current list of limit velocity gradients.
  12359. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12360. * @returns the list of limit velocity gradients
  12361. */
  12362. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12363. /**
  12364. * Gets the current list of color gradients.
  12365. * You must use addColorGradient and removeColorGradient to udpate this list
  12366. * @returns the list of color gradients
  12367. */
  12368. getColorGradients(): Nullable<Array<ColorGradient>>;
  12369. /**
  12370. * Gets the current list of size gradients.
  12371. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12372. * @returns the list of size gradients
  12373. */
  12374. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12375. /**
  12376. * Gets the current list of color remap gradients.
  12377. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12378. * @returns the list of color remap gradients
  12379. */
  12380. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12381. /**
  12382. * Gets the current list of alpha remap gradients.
  12383. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12384. * @returns the list of alpha remap gradients
  12385. */
  12386. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12387. /**
  12388. * Gets the current list of life time gradients.
  12389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12390. * @returns the list of life time gradients
  12391. */
  12392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12393. /**
  12394. * Gets the current list of angular speed gradients.
  12395. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12396. * @returns the list of angular speed gradients
  12397. */
  12398. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12399. /**
  12400. * Gets the current list of velocity gradients.
  12401. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12402. * @returns the list of velocity gradients
  12403. */
  12404. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of start size gradients.
  12407. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12408. * @returns the list of start size gradients
  12409. */
  12410. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12411. /**
  12412. * Gets the current list of emit rate gradients.
  12413. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12414. * @returns the list of emit rate gradients
  12415. */
  12416. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12419. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12420. */
  12421. get direction1(): Vector3;
  12422. set direction1(value: Vector3);
  12423. /**
  12424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12425. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12426. */
  12427. get direction2(): Vector3;
  12428. set direction2(value: Vector3);
  12429. /**
  12430. * 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.
  12431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12432. */
  12433. get minEmitBox(): Vector3;
  12434. set minEmitBox(value: Vector3);
  12435. /**
  12436. * 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.
  12437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12438. */
  12439. get maxEmitBox(): Vector3;
  12440. set maxEmitBox(value: Vector3);
  12441. /**
  12442. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12443. */
  12444. color1: Color4;
  12445. /**
  12446. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12447. */
  12448. color2: Color4;
  12449. /**
  12450. * Color the particle will have at the end of its lifetime
  12451. */
  12452. colorDead: Color4;
  12453. /**
  12454. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12455. */
  12456. textureMask: Color4;
  12457. /**
  12458. * The particle emitter type defines the emitter used by the particle system.
  12459. * It can be for example box, sphere, or cone...
  12460. */
  12461. particleEmitterType: IParticleEmitterType;
  12462. /** @hidden */
  12463. _isSubEmitter: boolean;
  12464. /**
  12465. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12466. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12467. */
  12468. billboardMode: number;
  12469. protected _isBillboardBased: boolean;
  12470. /**
  12471. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12472. */
  12473. get isBillboardBased(): boolean;
  12474. set isBillboardBased(value: boolean);
  12475. /**
  12476. * The scene the particle system belongs to.
  12477. */
  12478. protected _scene: Scene;
  12479. /**
  12480. * Local cache of defines for image processing.
  12481. */
  12482. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12483. /**
  12484. * Default configuration related to image processing available in the standard Material.
  12485. */
  12486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12487. /**
  12488. * Gets the image processing configuration used either in this material.
  12489. */
  12490. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12491. /**
  12492. * Sets the Default image processing configuration used either in the this material.
  12493. *
  12494. * If sets to null, the scene one is in use.
  12495. */
  12496. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12497. /**
  12498. * Attaches a new image processing configuration to the Standard Material.
  12499. * @param configuration
  12500. */
  12501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12502. /** @hidden */
  12503. protected _reset(): void;
  12504. /** @hidden */
  12505. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12506. /**
  12507. * Instantiates a particle system.
  12508. * 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.
  12509. * @param name The name of the particle system
  12510. */
  12511. constructor(name: string);
  12512. /**
  12513. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12516. * @returns the emitter
  12517. */
  12518. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12519. /**
  12520. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12521. * @param radius The radius of the hemisphere to emit from
  12522. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12523. * @returns the emitter
  12524. */
  12525. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12526. /**
  12527. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12528. * @param radius The radius of the sphere to emit from
  12529. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12530. * @returns the emitter
  12531. */
  12532. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12533. /**
  12534. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12535. * @param radius The radius of the sphere to emit from
  12536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12538. * @returns the emitter
  12539. */
  12540. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12541. /**
  12542. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12543. * @param radius The radius of the emission cylinder
  12544. * @param height The height of the emission cylinder
  12545. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12546. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12547. * @returns the emitter
  12548. */
  12549. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12550. /**
  12551. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12552. * @param radius The radius of the cylinder to emit from
  12553. * @param height The height of the emission cylinder
  12554. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12557. * @returns the emitter
  12558. */
  12559. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12560. /**
  12561. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12562. * @param radius The radius of the cone to emit from
  12563. * @param angle The base angle of the cone
  12564. * @returns the emitter
  12565. */
  12566. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12567. /**
  12568. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12571. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12572. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12573. * @returns the emitter
  12574. */
  12575. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12576. }
  12577. }
  12578. declare module "babylonjs/Particles/subEmitter" {
  12579. import { Scene } from "babylonjs/scene";
  12580. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12581. /**
  12582. * Type of sub emitter
  12583. */
  12584. export enum SubEmitterType {
  12585. /**
  12586. * Attached to the particle over it's lifetime
  12587. */
  12588. ATTACHED = 0,
  12589. /**
  12590. * Created when the particle dies
  12591. */
  12592. END = 1
  12593. }
  12594. /**
  12595. * Sub emitter class used to emit particles from an existing particle
  12596. */
  12597. export class SubEmitter {
  12598. /**
  12599. * the particle system to be used by the sub emitter
  12600. */
  12601. particleSystem: ParticleSystem;
  12602. /**
  12603. * Type of the submitter (Default: END)
  12604. */
  12605. type: SubEmitterType;
  12606. /**
  12607. * 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)
  12608. * Note: This only is supported when using an emitter of type Mesh
  12609. */
  12610. inheritDirection: boolean;
  12611. /**
  12612. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12613. */
  12614. inheritedVelocityAmount: number;
  12615. /**
  12616. * Creates a sub emitter
  12617. * @param particleSystem the particle system to be used by the sub emitter
  12618. */
  12619. constructor(
  12620. /**
  12621. * the particle system to be used by the sub emitter
  12622. */
  12623. particleSystem: ParticleSystem);
  12624. /**
  12625. * Clones the sub emitter
  12626. * @returns the cloned sub emitter
  12627. */
  12628. clone(): SubEmitter;
  12629. /**
  12630. * Serialize current object to a JSON object
  12631. * @returns the serialized object
  12632. */
  12633. serialize(): any;
  12634. /** @hidden */
  12635. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12636. /**
  12637. * Creates a new SubEmitter from a serialized JSON version
  12638. * @param serializationObject defines the JSON object to read from
  12639. * @param scene defines the hosting scene
  12640. * @param rootUrl defines the rootUrl for data loading
  12641. * @returns a new SubEmitter
  12642. */
  12643. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12644. /** Release associated resources */
  12645. dispose(): void;
  12646. }
  12647. }
  12648. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12649. /** @hidden */
  12650. export var imageProcessingDeclaration: {
  12651. name: string;
  12652. shader: string;
  12653. };
  12654. }
  12655. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12656. /** @hidden */
  12657. export var imageProcessingFunctions: {
  12658. name: string;
  12659. shader: string;
  12660. };
  12661. }
  12662. declare module "babylonjs/Shaders/particles.fragment" {
  12663. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12664. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12666. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12667. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12668. /** @hidden */
  12669. export var particlesPixelShader: {
  12670. name: string;
  12671. shader: string;
  12672. };
  12673. }
  12674. declare module "babylonjs/Shaders/particles.vertex" {
  12675. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12676. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12677. /** @hidden */
  12678. export var particlesVertexShader: {
  12679. name: string;
  12680. shader: string;
  12681. };
  12682. }
  12683. declare module "babylonjs/Particles/particleSystem" {
  12684. import { Nullable } from "babylonjs/types";
  12685. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12686. import { Observable } from "babylonjs/Misc/observable";
  12687. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12688. import { Effect } from "babylonjs/Materials/effect";
  12689. import { Scene, IDisposable } from "babylonjs/scene";
  12690. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12691. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12692. import { Particle } from "babylonjs/Particles/particle";
  12693. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12694. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12695. import "babylonjs/Shaders/particles.fragment";
  12696. import "babylonjs/Shaders/particles.vertex";
  12697. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12698. /**
  12699. * This represents a particle system in Babylon.
  12700. * 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.
  12701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12702. * @example https://doc.babylonjs.com/babylon101/particles
  12703. */
  12704. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12705. /**
  12706. * Billboard mode will only apply to Y axis
  12707. */
  12708. static readonly BILLBOARDMODE_Y: number;
  12709. /**
  12710. * Billboard mode will apply to all axes
  12711. */
  12712. static readonly BILLBOARDMODE_ALL: number;
  12713. /**
  12714. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12715. */
  12716. static readonly BILLBOARDMODE_STRETCHED: number;
  12717. /**
  12718. * This function can be defined to provide custom update for active particles.
  12719. * This function will be called instead of regular update (age, position, color, etc.).
  12720. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12721. */
  12722. updateFunction: (particles: Particle[]) => void;
  12723. private _emitterWorldMatrix;
  12724. /**
  12725. * This function can be defined to specify initial direction for every new particle.
  12726. * It by default use the emitterType defined function
  12727. */
  12728. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12729. /**
  12730. * This function can be defined to specify initial position for every new particle.
  12731. * It by default use the emitterType defined function
  12732. */
  12733. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12734. /**
  12735. * @hidden
  12736. */
  12737. _inheritedVelocityOffset: Vector3;
  12738. /**
  12739. * An event triggered when the system is disposed
  12740. */
  12741. onDisposeObservable: Observable<IParticleSystem>;
  12742. private _onDisposeObserver;
  12743. /**
  12744. * Sets a callback that will be triggered when the system is disposed
  12745. */
  12746. set onDispose(callback: () => void);
  12747. private _particles;
  12748. private _epsilon;
  12749. private _capacity;
  12750. private _stockParticles;
  12751. private _newPartsExcess;
  12752. private _vertexData;
  12753. private _vertexBuffer;
  12754. private _vertexBuffers;
  12755. private _spriteBuffer;
  12756. private _indexBuffer;
  12757. private _effect;
  12758. private _customEffect;
  12759. private _cachedDefines;
  12760. private _scaledColorStep;
  12761. private _colorDiff;
  12762. private _scaledDirection;
  12763. private _scaledGravity;
  12764. private _currentRenderId;
  12765. private _alive;
  12766. private _useInstancing;
  12767. private _started;
  12768. private _stopped;
  12769. private _actualFrame;
  12770. private _scaledUpdateSpeed;
  12771. private _vertexBufferSize;
  12772. /** @hidden */
  12773. _currentEmitRateGradient: Nullable<FactorGradient>;
  12774. /** @hidden */
  12775. _currentEmitRate1: number;
  12776. /** @hidden */
  12777. _currentEmitRate2: number;
  12778. /** @hidden */
  12779. _currentStartSizeGradient: Nullable<FactorGradient>;
  12780. /** @hidden */
  12781. _currentStartSize1: number;
  12782. /** @hidden */
  12783. _currentStartSize2: number;
  12784. private readonly _rawTextureWidth;
  12785. private _rampGradientsTexture;
  12786. private _useRampGradients;
  12787. /** Gets or sets a boolean indicating that ramp gradients must be used
  12788. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12789. */
  12790. get useRampGradients(): boolean;
  12791. set useRampGradients(value: boolean);
  12792. /**
  12793. * 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.
  12794. * 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: [])
  12795. */
  12796. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12797. private _subEmitters;
  12798. /**
  12799. * @hidden
  12800. * If the particle systems emitter should be disposed when the particle system is disposed
  12801. */
  12802. _disposeEmitterOnDispose: boolean;
  12803. /**
  12804. * The current active Sub-systems, this property is used by the root particle system only.
  12805. */
  12806. activeSubSystems: Array<ParticleSystem>;
  12807. /**
  12808. * Specifies if the particles are updated in emitter local space or world space
  12809. */
  12810. isLocal: boolean;
  12811. private _rootParticleSystem;
  12812. /**
  12813. * Gets the current list of active particles
  12814. */
  12815. get particles(): Particle[];
  12816. /**
  12817. * Gets the number of particles active at the same time.
  12818. * @returns The number of active particles.
  12819. */
  12820. getActiveCount(): number;
  12821. /**
  12822. * Returns the string "ParticleSystem"
  12823. * @returns a string containing the class name
  12824. */
  12825. getClassName(): string;
  12826. /**
  12827. * Gets a boolean indicating that the system is stopping
  12828. * @returns true if the system is currently stopping
  12829. */
  12830. isStopping(): boolean;
  12831. /**
  12832. * Gets the custom effect used to render the particles
  12833. * @param blendMode Blend mode for which the effect should be retrieved
  12834. * @returns The effect
  12835. */
  12836. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12837. /**
  12838. * Sets the custom effect used to render the particles
  12839. * @param effect The effect to set
  12840. * @param blendMode Blend mode for which the effect should be set
  12841. */
  12842. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12843. /** @hidden */
  12844. private _onBeforeDrawParticlesObservable;
  12845. /**
  12846. * Observable that will be called just before the particles are drawn
  12847. */
  12848. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12849. /**
  12850. * Gets the name of the particle vertex shader
  12851. */
  12852. get vertexShaderName(): string;
  12853. /**
  12854. * Instantiates a particle system.
  12855. * 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.
  12856. * @param name The name of the particle system
  12857. * @param capacity The max number of particles alive at the same time
  12858. * @param scene The scene the particle system belongs to
  12859. * @param customEffect a custom effect used to change the way particles are rendered by default
  12860. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12861. * @param epsilon Offset used to render the particles
  12862. */
  12863. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12864. private _addFactorGradient;
  12865. private _removeFactorGradient;
  12866. /**
  12867. * Adds a new life time gradient
  12868. * @param gradient defines the gradient to use (between 0 and 1)
  12869. * @param factor defines the life time factor to affect to the specified gradient
  12870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12871. * @returns the current particle system
  12872. */
  12873. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12874. /**
  12875. * Remove a specific life time gradient
  12876. * @param gradient defines the gradient to remove
  12877. * @returns the current particle system
  12878. */
  12879. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12880. /**
  12881. * Adds a new size gradient
  12882. * @param gradient defines the gradient to use (between 0 and 1)
  12883. * @param factor defines the size factor to affect to the specified gradient
  12884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12885. * @returns the current particle system
  12886. */
  12887. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12888. /**
  12889. * Remove a specific size gradient
  12890. * @param gradient defines the gradient to remove
  12891. * @returns the current particle system
  12892. */
  12893. removeSizeGradient(gradient: number): IParticleSystem;
  12894. /**
  12895. * Adds a new color remap gradient
  12896. * @param gradient defines the gradient to use (between 0 and 1)
  12897. * @param min defines the color remap minimal range
  12898. * @param max defines the color remap maximal range
  12899. * @returns the current particle system
  12900. */
  12901. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12902. /**
  12903. * Remove a specific color remap gradient
  12904. * @param gradient defines the gradient to remove
  12905. * @returns the current particle system
  12906. */
  12907. removeColorRemapGradient(gradient: number): IParticleSystem;
  12908. /**
  12909. * Adds a new alpha remap gradient
  12910. * @param gradient defines the gradient to use (between 0 and 1)
  12911. * @param min defines the alpha remap minimal range
  12912. * @param max defines the alpha remap maximal range
  12913. * @returns the current particle system
  12914. */
  12915. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12916. /**
  12917. * Remove a specific alpha remap gradient
  12918. * @param gradient defines the gradient to remove
  12919. * @returns the current particle system
  12920. */
  12921. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12922. /**
  12923. * Adds a new angular speed gradient
  12924. * @param gradient defines the gradient to use (between 0 and 1)
  12925. * @param factor defines the angular speed to affect to the specified gradient
  12926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12927. * @returns the current particle system
  12928. */
  12929. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12930. /**
  12931. * Remove a specific angular speed gradient
  12932. * @param gradient defines the gradient to remove
  12933. * @returns the current particle system
  12934. */
  12935. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12936. /**
  12937. * Adds a new velocity gradient
  12938. * @param gradient defines the gradient to use (between 0 and 1)
  12939. * @param factor defines the velocity to affect to the specified gradient
  12940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12941. * @returns the current particle system
  12942. */
  12943. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12944. /**
  12945. * Remove a specific velocity gradient
  12946. * @param gradient defines the gradient to remove
  12947. * @returns the current particle system
  12948. */
  12949. removeVelocityGradient(gradient: number): IParticleSystem;
  12950. /**
  12951. * Adds a new limit velocity gradient
  12952. * @param gradient defines the gradient to use (between 0 and 1)
  12953. * @param factor defines the limit velocity value to affect to the specified gradient
  12954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12955. * @returns the current particle system
  12956. */
  12957. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12958. /**
  12959. * Remove a specific limit velocity gradient
  12960. * @param gradient defines the gradient to remove
  12961. * @returns the current particle system
  12962. */
  12963. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12964. /**
  12965. * Adds a new drag gradient
  12966. * @param gradient defines the gradient to use (between 0 and 1)
  12967. * @param factor defines the drag value to affect to the specified gradient
  12968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12969. * @returns the current particle system
  12970. */
  12971. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12972. /**
  12973. * Remove a specific drag gradient
  12974. * @param gradient defines the gradient to remove
  12975. * @returns the current particle system
  12976. */
  12977. removeDragGradient(gradient: number): IParticleSystem;
  12978. /**
  12979. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12980. * @param gradient defines the gradient to use (between 0 and 1)
  12981. * @param factor defines the emit rate value to affect to the specified gradient
  12982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12983. * @returns the current particle system
  12984. */
  12985. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12986. /**
  12987. * Remove a specific emit rate gradient
  12988. * @param gradient defines the gradient to remove
  12989. * @returns the current particle system
  12990. */
  12991. removeEmitRateGradient(gradient: number): IParticleSystem;
  12992. /**
  12993. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12994. * @param gradient defines the gradient to use (between 0 and 1)
  12995. * @param factor defines the start size value to affect to the specified gradient
  12996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12997. * @returns the current particle system
  12998. */
  12999. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13000. /**
  13001. * Remove a specific start size gradient
  13002. * @param gradient defines the gradient to remove
  13003. * @returns the current particle system
  13004. */
  13005. removeStartSizeGradient(gradient: number): IParticleSystem;
  13006. private _createRampGradientTexture;
  13007. /**
  13008. * Gets the current list of ramp gradients.
  13009. * You must use addRampGradient and removeRampGradient to udpate this list
  13010. * @returns the list of ramp gradients
  13011. */
  13012. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13013. /** Force the system to rebuild all gradients that need to be resync */
  13014. forceRefreshGradients(): void;
  13015. private _syncRampGradientTexture;
  13016. /**
  13017. * Adds a new ramp gradient used to remap particle colors
  13018. * @param gradient defines the gradient to use (between 0 and 1)
  13019. * @param color defines the color to affect to the specified gradient
  13020. * @returns the current particle system
  13021. */
  13022. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13023. /**
  13024. * Remove a specific ramp gradient
  13025. * @param gradient defines the gradient to remove
  13026. * @returns the current particle system
  13027. */
  13028. removeRampGradient(gradient: number): ParticleSystem;
  13029. /**
  13030. * Adds a new color gradient
  13031. * @param gradient defines the gradient to use (between 0 and 1)
  13032. * @param color1 defines the color to affect to the specified gradient
  13033. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13034. * @returns this particle system
  13035. */
  13036. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13037. /**
  13038. * Remove a specific color gradient
  13039. * @param gradient defines the gradient to remove
  13040. * @returns this particle system
  13041. */
  13042. removeColorGradient(gradient: number): IParticleSystem;
  13043. private _fetchR;
  13044. protected _reset(): void;
  13045. private _resetEffect;
  13046. private _createVertexBuffers;
  13047. private _createIndexBuffer;
  13048. /**
  13049. * Gets the maximum number of particles active at the same time.
  13050. * @returns The max number of active particles.
  13051. */
  13052. getCapacity(): number;
  13053. /**
  13054. * Gets whether there are still active particles in the system.
  13055. * @returns True if it is alive, otherwise false.
  13056. */
  13057. isAlive(): boolean;
  13058. /**
  13059. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13060. * @returns True if it has been started, otherwise false.
  13061. */
  13062. isStarted(): boolean;
  13063. private _prepareSubEmitterInternalArray;
  13064. /**
  13065. * Starts the particle system and begins to emit
  13066. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13067. */
  13068. start(delay?: number): void;
  13069. /**
  13070. * Stops the particle system.
  13071. * @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.
  13072. */
  13073. stop(stopSubEmitters?: boolean): void;
  13074. /**
  13075. * Remove all active particles
  13076. */
  13077. reset(): void;
  13078. /**
  13079. * @hidden (for internal use only)
  13080. */
  13081. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13082. /**
  13083. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13084. * Its lifetime will start back at 0.
  13085. */
  13086. recycleParticle: (particle: Particle) => void;
  13087. private _stopSubEmitters;
  13088. private _createParticle;
  13089. private _removeFromRoot;
  13090. private _emitFromParticle;
  13091. private _update;
  13092. /** @hidden */
  13093. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13094. /** @hidden */
  13095. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13096. /**
  13097. * Fill the defines array according to the current settings of the particle system
  13098. * @param defines Array to be updated
  13099. * @param blendMode blend mode to take into account when updating the array
  13100. */
  13101. fillDefines(defines: Array<string>, blendMode: number): void;
  13102. /**
  13103. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13104. * @param uniforms Uniforms array to fill
  13105. * @param attributes Attributes array to fill
  13106. * @param samplers Samplers array to fill
  13107. */
  13108. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13109. /** @hidden */
  13110. private _getEffect;
  13111. /**
  13112. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13113. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13114. */
  13115. animate(preWarmOnly?: boolean): void;
  13116. private _appendParticleVertices;
  13117. /**
  13118. * Rebuilds the particle system.
  13119. */
  13120. rebuild(): void;
  13121. /**
  13122. * Is this system ready to be used/rendered
  13123. * @return true if the system is ready
  13124. */
  13125. isReady(): boolean;
  13126. private _render;
  13127. /**
  13128. * Renders the particle system in its current state.
  13129. * @returns the current number of particles
  13130. */
  13131. render(): number;
  13132. /**
  13133. * Disposes the particle system and free the associated resources
  13134. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13135. */
  13136. dispose(disposeTexture?: boolean): void;
  13137. /**
  13138. * Clones the particle system.
  13139. * @param name The name of the cloned object
  13140. * @param newEmitter The new emitter to use
  13141. * @returns the cloned particle system
  13142. */
  13143. clone(name: string, newEmitter: any): ParticleSystem;
  13144. /**
  13145. * Serializes the particle system to a JSON object
  13146. * @param serializeTexture defines if the texture must be serialized as well
  13147. * @returns the JSON object
  13148. */
  13149. serialize(serializeTexture?: boolean): any;
  13150. /** @hidden */
  13151. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13152. /** @hidden */
  13153. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13154. /**
  13155. * Parses a JSON object to create a particle system.
  13156. * @param parsedParticleSystem The JSON object to parse
  13157. * @param scene The scene to create the particle system in
  13158. * @param rootUrl The root url to use to load external dependencies like texture
  13159. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13160. * @returns the Parsed particle system
  13161. */
  13162. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13163. }
  13164. }
  13165. declare module "babylonjs/Particles/particle" {
  13166. import { Nullable } from "babylonjs/types";
  13167. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13168. import { Color4 } from "babylonjs/Maths/math.color";
  13169. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13170. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13171. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13172. /**
  13173. * A particle represents one of the element emitted by a particle system.
  13174. * This is mainly define by its coordinates, direction, velocity and age.
  13175. */
  13176. export class Particle {
  13177. /**
  13178. * The particle system the particle belongs to.
  13179. */
  13180. particleSystem: ParticleSystem;
  13181. private static _Count;
  13182. /**
  13183. * Unique ID of the particle
  13184. */
  13185. id: number;
  13186. /**
  13187. * The world position of the particle in the scene.
  13188. */
  13189. position: Vector3;
  13190. /**
  13191. * The world direction of the particle in the scene.
  13192. */
  13193. direction: Vector3;
  13194. /**
  13195. * The color of the particle.
  13196. */
  13197. color: Color4;
  13198. /**
  13199. * The color change of the particle per step.
  13200. */
  13201. colorStep: Color4;
  13202. /**
  13203. * Defines how long will the life of the particle be.
  13204. */
  13205. lifeTime: number;
  13206. /**
  13207. * The current age of the particle.
  13208. */
  13209. age: number;
  13210. /**
  13211. * The current size of the particle.
  13212. */
  13213. size: number;
  13214. /**
  13215. * The current scale of the particle.
  13216. */
  13217. scale: Vector2;
  13218. /**
  13219. * The current angle of the particle.
  13220. */
  13221. angle: number;
  13222. /**
  13223. * Defines how fast is the angle changing.
  13224. */
  13225. angularSpeed: number;
  13226. /**
  13227. * Defines the cell index used by the particle to be rendered from a sprite.
  13228. */
  13229. cellIndex: number;
  13230. /**
  13231. * The information required to support color remapping
  13232. */
  13233. remapData: Vector4;
  13234. /** @hidden */
  13235. _randomCellOffset?: number;
  13236. /** @hidden */
  13237. _initialDirection: Nullable<Vector3>;
  13238. /** @hidden */
  13239. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13240. /** @hidden */
  13241. _initialStartSpriteCellID: number;
  13242. /** @hidden */
  13243. _initialEndSpriteCellID: number;
  13244. /** @hidden */
  13245. _currentColorGradient: Nullable<ColorGradient>;
  13246. /** @hidden */
  13247. _currentColor1: Color4;
  13248. /** @hidden */
  13249. _currentColor2: Color4;
  13250. /** @hidden */
  13251. _currentSizeGradient: Nullable<FactorGradient>;
  13252. /** @hidden */
  13253. _currentSize1: number;
  13254. /** @hidden */
  13255. _currentSize2: number;
  13256. /** @hidden */
  13257. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13258. /** @hidden */
  13259. _currentAngularSpeed1: number;
  13260. /** @hidden */
  13261. _currentAngularSpeed2: number;
  13262. /** @hidden */
  13263. _currentVelocityGradient: Nullable<FactorGradient>;
  13264. /** @hidden */
  13265. _currentVelocity1: number;
  13266. /** @hidden */
  13267. _currentVelocity2: number;
  13268. /** @hidden */
  13269. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13270. /** @hidden */
  13271. _currentLimitVelocity1: number;
  13272. /** @hidden */
  13273. _currentLimitVelocity2: number;
  13274. /** @hidden */
  13275. _currentDragGradient: Nullable<FactorGradient>;
  13276. /** @hidden */
  13277. _currentDrag1: number;
  13278. /** @hidden */
  13279. _currentDrag2: number;
  13280. /** @hidden */
  13281. _randomNoiseCoordinates1: Vector3;
  13282. /** @hidden */
  13283. _randomNoiseCoordinates2: Vector3;
  13284. /** @hidden */
  13285. _localPosition?: Vector3;
  13286. /**
  13287. * Creates a new instance Particle
  13288. * @param particleSystem the particle system the particle belongs to
  13289. */
  13290. constructor(
  13291. /**
  13292. * The particle system the particle belongs to.
  13293. */
  13294. particleSystem: ParticleSystem);
  13295. private updateCellInfoFromSystem;
  13296. /**
  13297. * Defines how the sprite cell index is updated for the particle
  13298. */
  13299. updateCellIndex(): void;
  13300. /** @hidden */
  13301. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13302. /** @hidden */
  13303. _inheritParticleInfoToSubEmitters(): void;
  13304. /** @hidden */
  13305. _reset(): void;
  13306. /**
  13307. * Copy the properties of particle to another one.
  13308. * @param other the particle to copy the information to.
  13309. */
  13310. copyTo(other: Particle): void;
  13311. }
  13312. }
  13313. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13314. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13315. import { Effect } from "babylonjs/Materials/effect";
  13316. import { Particle } from "babylonjs/Particles/particle";
  13317. import { Scene } from "babylonjs/scene";
  13318. /**
  13319. * Particle emitter represents a volume emitting particles.
  13320. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13321. */
  13322. export interface IParticleEmitterType {
  13323. /**
  13324. * Called by the particle System when the direction is computed for the created particle.
  13325. * @param worldMatrix is the world matrix of the particle system
  13326. * @param directionToUpdate is the direction vector to update with the result
  13327. * @param particle is the particle we are computed the direction for
  13328. * @param isLocal defines if the direction should be set in local space
  13329. */
  13330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13331. /**
  13332. * Called by the particle System when the position is computed for the created particle.
  13333. * @param worldMatrix is the world matrix of the particle system
  13334. * @param positionToUpdate is the position vector to update with the result
  13335. * @param particle is the particle we are computed the position for
  13336. * @param isLocal defines if the position should be set in local space
  13337. */
  13338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13339. /**
  13340. * Clones the current emitter and returns a copy of it
  13341. * @returns the new emitter
  13342. */
  13343. clone(): IParticleEmitterType;
  13344. /**
  13345. * Called by the GPUParticleSystem to setup the update shader
  13346. * @param effect defines the update shader
  13347. */
  13348. applyToShader(effect: Effect): void;
  13349. /**
  13350. * Returns a string to use to update the GPU particles update shader
  13351. * @returns the effect defines string
  13352. */
  13353. getEffectDefines(): string;
  13354. /**
  13355. * Returns a string representing the class name
  13356. * @returns a string containing the class name
  13357. */
  13358. getClassName(): string;
  13359. /**
  13360. * Serializes the particle system to a JSON object.
  13361. * @returns the JSON object
  13362. */
  13363. serialize(): any;
  13364. /**
  13365. * Parse properties from a JSON object
  13366. * @param serializationObject defines the JSON object
  13367. * @param scene defines the hosting scene
  13368. */
  13369. parse(serializationObject: any, scene: Scene): void;
  13370. }
  13371. }
  13372. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13373. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13374. import { Effect } from "babylonjs/Materials/effect";
  13375. import { Particle } from "babylonjs/Particles/particle";
  13376. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13377. /**
  13378. * Particle emitter emitting particles from the inside of a box.
  13379. * It emits the particles randomly between 2 given directions.
  13380. */
  13381. export class BoxParticleEmitter implements IParticleEmitterType {
  13382. /**
  13383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13384. */
  13385. direction1: Vector3;
  13386. /**
  13387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13388. */
  13389. direction2: Vector3;
  13390. /**
  13391. * 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.
  13392. */
  13393. minEmitBox: Vector3;
  13394. /**
  13395. * 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.
  13396. */
  13397. maxEmitBox: Vector3;
  13398. /**
  13399. * Creates a new instance BoxParticleEmitter
  13400. */
  13401. constructor();
  13402. /**
  13403. * Called by the particle System when the direction is computed for the created particle.
  13404. * @param worldMatrix is the world matrix of the particle system
  13405. * @param directionToUpdate is the direction vector to update with the result
  13406. * @param particle is the particle we are computed the direction for
  13407. * @param isLocal defines if the direction should be set in local space
  13408. */
  13409. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13410. /**
  13411. * Called by the particle System when the position is computed for the created particle.
  13412. * @param worldMatrix is the world matrix of the particle system
  13413. * @param positionToUpdate is the position vector to update with the result
  13414. * @param particle is the particle we are computed the position for
  13415. * @param isLocal defines if the position should be set in local space
  13416. */
  13417. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13418. /**
  13419. * Clones the current emitter and returns a copy of it
  13420. * @returns the new emitter
  13421. */
  13422. clone(): BoxParticleEmitter;
  13423. /**
  13424. * Called by the GPUParticleSystem to setup the update shader
  13425. * @param effect defines the update shader
  13426. */
  13427. applyToShader(effect: Effect): void;
  13428. /**
  13429. * Returns a string to use to update the GPU particles update shader
  13430. * @returns a string containng the defines string
  13431. */
  13432. getEffectDefines(): string;
  13433. /**
  13434. * Returns the string "BoxParticleEmitter"
  13435. * @returns a string containing the class name
  13436. */
  13437. getClassName(): string;
  13438. /**
  13439. * Serializes the particle system to a JSON object.
  13440. * @returns the JSON object
  13441. */
  13442. serialize(): any;
  13443. /**
  13444. * Parse properties from a JSON object
  13445. * @param serializationObject defines the JSON object
  13446. */
  13447. parse(serializationObject: any): void;
  13448. }
  13449. }
  13450. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13451. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13452. import { Effect } from "babylonjs/Materials/effect";
  13453. import { Particle } from "babylonjs/Particles/particle";
  13454. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13455. /**
  13456. * Particle emitter emitting particles from the inside of a cone.
  13457. * It emits the particles alongside the cone volume from the base to the particle.
  13458. * The emission direction might be randomized.
  13459. */
  13460. export class ConeParticleEmitter implements IParticleEmitterType {
  13461. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13462. directionRandomizer: number;
  13463. private _radius;
  13464. private _angle;
  13465. private _height;
  13466. /**
  13467. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13468. */
  13469. radiusRange: number;
  13470. /**
  13471. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13472. */
  13473. heightRange: number;
  13474. /**
  13475. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13476. */
  13477. emitFromSpawnPointOnly: boolean;
  13478. /**
  13479. * Gets or sets the radius of the emission cone
  13480. */
  13481. get radius(): number;
  13482. set radius(value: number);
  13483. /**
  13484. * Gets or sets the angle of the emission cone
  13485. */
  13486. get angle(): number;
  13487. set angle(value: number);
  13488. private _buildHeight;
  13489. /**
  13490. * Creates a new instance ConeParticleEmitter
  13491. * @param radius the radius of the emission cone (1 by default)
  13492. * @param angle the cone base angle (PI by default)
  13493. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13494. */
  13495. constructor(radius?: number, angle?: number,
  13496. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13497. directionRandomizer?: number);
  13498. /**
  13499. * Called by the particle System when the direction is computed for the created particle.
  13500. * @param worldMatrix is the world matrix of the particle system
  13501. * @param directionToUpdate is the direction vector to update with the result
  13502. * @param particle is the particle we are computed the direction for
  13503. * @param isLocal defines if the direction should be set in local space
  13504. */
  13505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13506. /**
  13507. * Called by the particle System when the position is computed for the created particle.
  13508. * @param worldMatrix is the world matrix of the particle system
  13509. * @param positionToUpdate is the position vector to update with the result
  13510. * @param particle is the particle we are computed the position for
  13511. * @param isLocal defines if the position should be set in local space
  13512. */
  13513. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13514. /**
  13515. * Clones the current emitter and returns a copy of it
  13516. * @returns the new emitter
  13517. */
  13518. clone(): ConeParticleEmitter;
  13519. /**
  13520. * Called by the GPUParticleSystem to setup the update shader
  13521. * @param effect defines the update shader
  13522. */
  13523. applyToShader(effect: Effect): void;
  13524. /**
  13525. * Returns a string to use to update the GPU particles update shader
  13526. * @returns a string containng the defines string
  13527. */
  13528. getEffectDefines(): string;
  13529. /**
  13530. * Returns the string "ConeParticleEmitter"
  13531. * @returns a string containing the class name
  13532. */
  13533. getClassName(): string;
  13534. /**
  13535. * Serializes the particle system to a JSON object.
  13536. * @returns the JSON object
  13537. */
  13538. serialize(): any;
  13539. /**
  13540. * Parse properties from a JSON object
  13541. * @param serializationObject defines the JSON object
  13542. */
  13543. parse(serializationObject: any): void;
  13544. }
  13545. }
  13546. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13547. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13548. import { Effect } from "babylonjs/Materials/effect";
  13549. import { Particle } from "babylonjs/Particles/particle";
  13550. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13551. /**
  13552. * Particle emitter emitting particles from the inside of a cylinder.
  13553. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13554. */
  13555. export class CylinderParticleEmitter implements IParticleEmitterType {
  13556. /**
  13557. * The radius of the emission cylinder.
  13558. */
  13559. radius: number;
  13560. /**
  13561. * The height of the emission cylinder.
  13562. */
  13563. height: number;
  13564. /**
  13565. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13566. */
  13567. radiusRange: number;
  13568. /**
  13569. * How much to randomize the particle direction [0-1].
  13570. */
  13571. directionRandomizer: number;
  13572. /**
  13573. * Creates a new instance CylinderParticleEmitter
  13574. * @param radius the radius of the emission cylinder (1 by default)
  13575. * @param height the height of the emission cylinder (1 by default)
  13576. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13577. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13578. */
  13579. constructor(
  13580. /**
  13581. * The radius of the emission cylinder.
  13582. */
  13583. radius?: number,
  13584. /**
  13585. * The height of the emission cylinder.
  13586. */
  13587. height?: number,
  13588. /**
  13589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13590. */
  13591. radiusRange?: number,
  13592. /**
  13593. * How much to randomize the particle direction [0-1].
  13594. */
  13595. directionRandomizer?: number);
  13596. /**
  13597. * Called by the particle System when the direction is computed for the created particle.
  13598. * @param worldMatrix is the world matrix of the particle system
  13599. * @param directionToUpdate is the direction vector to update with the result
  13600. * @param particle is the particle we are computed the direction for
  13601. * @param isLocal defines if the direction should be set in local space
  13602. */
  13603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13604. /**
  13605. * Called by the particle System when the position is computed for the created particle.
  13606. * @param worldMatrix is the world matrix of the particle system
  13607. * @param positionToUpdate is the position vector to update with the result
  13608. * @param particle is the particle we are computed the position for
  13609. * @param isLocal defines if the position should be set in local space
  13610. */
  13611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13612. /**
  13613. * Clones the current emitter and returns a copy of it
  13614. * @returns the new emitter
  13615. */
  13616. clone(): CylinderParticleEmitter;
  13617. /**
  13618. * Called by the GPUParticleSystem to setup the update shader
  13619. * @param effect defines the update shader
  13620. */
  13621. applyToShader(effect: Effect): void;
  13622. /**
  13623. * Returns a string to use to update the GPU particles update shader
  13624. * @returns a string containng the defines string
  13625. */
  13626. getEffectDefines(): string;
  13627. /**
  13628. * Returns the string "CylinderParticleEmitter"
  13629. * @returns a string containing the class name
  13630. */
  13631. getClassName(): string;
  13632. /**
  13633. * Serializes the particle system to a JSON object.
  13634. * @returns the JSON object
  13635. */
  13636. serialize(): any;
  13637. /**
  13638. * Parse properties from a JSON object
  13639. * @param serializationObject defines the JSON object
  13640. */
  13641. parse(serializationObject: any): void;
  13642. }
  13643. /**
  13644. * Particle emitter emitting particles from the inside of a cylinder.
  13645. * It emits the particles randomly between two vectors.
  13646. */
  13647. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13648. /**
  13649. * The min limit of the emission direction.
  13650. */
  13651. direction1: Vector3;
  13652. /**
  13653. * The max limit of the emission direction.
  13654. */
  13655. direction2: Vector3;
  13656. /**
  13657. * Creates a new instance CylinderDirectedParticleEmitter
  13658. * @param radius the radius of the emission cylinder (1 by default)
  13659. * @param height the height of the emission cylinder (1 by default)
  13660. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13661. * @param direction1 the min limit of the emission direction (up vector by default)
  13662. * @param direction2 the max limit of the emission direction (up vector by default)
  13663. */
  13664. constructor(radius?: number, height?: number, radiusRange?: number,
  13665. /**
  13666. * The min limit of the emission direction.
  13667. */
  13668. direction1?: Vector3,
  13669. /**
  13670. * The max limit of the emission direction.
  13671. */
  13672. direction2?: Vector3);
  13673. /**
  13674. * Called by the particle System when the direction is computed for the created particle.
  13675. * @param worldMatrix is the world matrix of the particle system
  13676. * @param directionToUpdate is the direction vector to update with the result
  13677. * @param particle is the particle we are computed the direction for
  13678. */
  13679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13680. /**
  13681. * Clones the current emitter and returns a copy of it
  13682. * @returns the new emitter
  13683. */
  13684. clone(): CylinderDirectedParticleEmitter;
  13685. /**
  13686. * Called by the GPUParticleSystem to setup the update shader
  13687. * @param effect defines the update shader
  13688. */
  13689. applyToShader(effect: Effect): void;
  13690. /**
  13691. * Returns a string to use to update the GPU particles update shader
  13692. * @returns a string containng the defines string
  13693. */
  13694. getEffectDefines(): string;
  13695. /**
  13696. * Returns the string "CylinderDirectedParticleEmitter"
  13697. * @returns a string containing the class name
  13698. */
  13699. getClassName(): string;
  13700. /**
  13701. * Serializes the particle system to a JSON object.
  13702. * @returns the JSON object
  13703. */
  13704. serialize(): any;
  13705. /**
  13706. * Parse properties from a JSON object
  13707. * @param serializationObject defines the JSON object
  13708. */
  13709. parse(serializationObject: any): void;
  13710. }
  13711. }
  13712. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13713. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13714. import { Effect } from "babylonjs/Materials/effect";
  13715. import { Particle } from "babylonjs/Particles/particle";
  13716. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13717. /**
  13718. * Particle emitter emitting particles from the inside of a hemisphere.
  13719. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13720. */
  13721. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13722. /**
  13723. * The radius of the emission hemisphere.
  13724. */
  13725. radius: number;
  13726. /**
  13727. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13728. */
  13729. radiusRange: number;
  13730. /**
  13731. * How much to randomize the particle direction [0-1].
  13732. */
  13733. directionRandomizer: number;
  13734. /**
  13735. * Creates a new instance HemisphericParticleEmitter
  13736. * @param radius the radius of the emission hemisphere (1 by default)
  13737. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13738. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13739. */
  13740. constructor(
  13741. /**
  13742. * The radius of the emission hemisphere.
  13743. */
  13744. radius?: number,
  13745. /**
  13746. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13747. */
  13748. radiusRange?: number,
  13749. /**
  13750. * How much to randomize the particle direction [0-1].
  13751. */
  13752. directionRandomizer?: number);
  13753. /**
  13754. * Called by the particle System when the direction is computed for the created particle.
  13755. * @param worldMatrix is the world matrix of the particle system
  13756. * @param directionToUpdate is the direction vector to update with the result
  13757. * @param particle is the particle we are computed the direction for
  13758. * @param isLocal defines if the direction should be set in local space
  13759. */
  13760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13761. /**
  13762. * Called by the particle System when the position is computed for the created particle.
  13763. * @param worldMatrix is the world matrix of the particle system
  13764. * @param positionToUpdate is the position vector to update with the result
  13765. * @param particle is the particle we are computed the position for
  13766. * @param isLocal defines if the position should be set in local space
  13767. */
  13768. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13769. /**
  13770. * Clones the current emitter and returns a copy of it
  13771. * @returns the new emitter
  13772. */
  13773. clone(): HemisphericParticleEmitter;
  13774. /**
  13775. * Called by the GPUParticleSystem to setup the update shader
  13776. * @param effect defines the update shader
  13777. */
  13778. applyToShader(effect: Effect): void;
  13779. /**
  13780. * Returns a string to use to update the GPU particles update shader
  13781. * @returns a string containng the defines string
  13782. */
  13783. getEffectDefines(): string;
  13784. /**
  13785. * Returns the string "HemisphericParticleEmitter"
  13786. * @returns a string containing the class name
  13787. */
  13788. getClassName(): string;
  13789. /**
  13790. * Serializes the particle system to a JSON object.
  13791. * @returns the JSON object
  13792. */
  13793. serialize(): any;
  13794. /**
  13795. * Parse properties from a JSON object
  13796. * @param serializationObject defines the JSON object
  13797. */
  13798. parse(serializationObject: any): void;
  13799. }
  13800. }
  13801. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13802. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13803. import { Effect } from "babylonjs/Materials/effect";
  13804. import { Particle } from "babylonjs/Particles/particle";
  13805. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13806. /**
  13807. * Particle emitter emitting particles from a point.
  13808. * It emits the particles randomly between 2 given directions.
  13809. */
  13810. export class PointParticleEmitter implements IParticleEmitterType {
  13811. /**
  13812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13813. */
  13814. direction1: Vector3;
  13815. /**
  13816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13817. */
  13818. direction2: Vector3;
  13819. /**
  13820. * Creates a new instance PointParticleEmitter
  13821. */
  13822. constructor();
  13823. /**
  13824. * Called by the particle System when the direction is computed for the created particle.
  13825. * @param worldMatrix is the world matrix of the particle system
  13826. * @param directionToUpdate is the direction vector to update with the result
  13827. * @param particle is the particle we are computed the direction for
  13828. * @param isLocal defines if the direction should be set in local space
  13829. */
  13830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13831. /**
  13832. * Called by the particle System when the position is computed for the created particle.
  13833. * @param worldMatrix is the world matrix of the particle system
  13834. * @param positionToUpdate is the position vector to update with the result
  13835. * @param particle is the particle we are computed the position for
  13836. * @param isLocal defines if the position should be set in local space
  13837. */
  13838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13839. /**
  13840. * Clones the current emitter and returns a copy of it
  13841. * @returns the new emitter
  13842. */
  13843. clone(): PointParticleEmitter;
  13844. /**
  13845. * Called by the GPUParticleSystem to setup the update shader
  13846. * @param effect defines the update shader
  13847. */
  13848. applyToShader(effect: Effect): void;
  13849. /**
  13850. * Returns a string to use to update the GPU particles update shader
  13851. * @returns a string containng the defines string
  13852. */
  13853. getEffectDefines(): string;
  13854. /**
  13855. * Returns the string "PointParticleEmitter"
  13856. * @returns a string containing the class name
  13857. */
  13858. getClassName(): string;
  13859. /**
  13860. * Serializes the particle system to a JSON object.
  13861. * @returns the JSON object
  13862. */
  13863. serialize(): any;
  13864. /**
  13865. * Parse properties from a JSON object
  13866. * @param serializationObject defines the JSON object
  13867. */
  13868. parse(serializationObject: any): void;
  13869. }
  13870. }
  13871. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13872. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13873. import { Effect } from "babylonjs/Materials/effect";
  13874. import { Particle } from "babylonjs/Particles/particle";
  13875. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13876. /**
  13877. * Particle emitter emitting particles from the inside of a sphere.
  13878. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13879. */
  13880. export class SphereParticleEmitter implements IParticleEmitterType {
  13881. /**
  13882. * The radius of the emission sphere.
  13883. */
  13884. radius: number;
  13885. /**
  13886. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13887. */
  13888. radiusRange: number;
  13889. /**
  13890. * How much to randomize the particle direction [0-1].
  13891. */
  13892. directionRandomizer: number;
  13893. /**
  13894. * Creates a new instance SphereParticleEmitter
  13895. * @param radius the radius of the emission sphere (1 by default)
  13896. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13897. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13898. */
  13899. constructor(
  13900. /**
  13901. * The radius of the emission sphere.
  13902. */
  13903. radius?: number,
  13904. /**
  13905. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13906. */
  13907. radiusRange?: number,
  13908. /**
  13909. * How much to randomize the particle direction [0-1].
  13910. */
  13911. directionRandomizer?: number);
  13912. /**
  13913. * Called by the particle System when the direction is computed for the created particle.
  13914. * @param worldMatrix is the world matrix of the particle system
  13915. * @param directionToUpdate is the direction vector to update with the result
  13916. * @param particle is the particle we are computed the direction for
  13917. * @param isLocal defines if the direction should be set in local space
  13918. */
  13919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13920. /**
  13921. * Called by the particle System when the position is computed for the created particle.
  13922. * @param worldMatrix is the world matrix of the particle system
  13923. * @param positionToUpdate is the position vector to update with the result
  13924. * @param particle is the particle we are computed the position for
  13925. * @param isLocal defines if the position should be set in local space
  13926. */
  13927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13928. /**
  13929. * Clones the current emitter and returns a copy of it
  13930. * @returns the new emitter
  13931. */
  13932. clone(): SphereParticleEmitter;
  13933. /**
  13934. * Called by the GPUParticleSystem to setup the update shader
  13935. * @param effect defines the update shader
  13936. */
  13937. applyToShader(effect: Effect): void;
  13938. /**
  13939. * Returns a string to use to update the GPU particles update shader
  13940. * @returns a string containng the defines string
  13941. */
  13942. getEffectDefines(): string;
  13943. /**
  13944. * Returns the string "SphereParticleEmitter"
  13945. * @returns a string containing the class name
  13946. */
  13947. getClassName(): string;
  13948. /**
  13949. * Serializes the particle system to a JSON object.
  13950. * @returns the JSON object
  13951. */
  13952. serialize(): any;
  13953. /**
  13954. * Parse properties from a JSON object
  13955. * @param serializationObject defines the JSON object
  13956. */
  13957. parse(serializationObject: any): void;
  13958. }
  13959. /**
  13960. * Particle emitter emitting particles from the inside of a sphere.
  13961. * It emits the particles randomly between two vectors.
  13962. */
  13963. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13964. /**
  13965. * The min limit of the emission direction.
  13966. */
  13967. direction1: Vector3;
  13968. /**
  13969. * The max limit of the emission direction.
  13970. */
  13971. direction2: Vector3;
  13972. /**
  13973. * Creates a new instance SphereDirectedParticleEmitter
  13974. * @param radius the radius of the emission sphere (1 by default)
  13975. * @param direction1 the min limit of the emission direction (up vector by default)
  13976. * @param direction2 the max limit of the emission direction (up vector by default)
  13977. */
  13978. constructor(radius?: number,
  13979. /**
  13980. * The min limit of the emission direction.
  13981. */
  13982. direction1?: Vector3,
  13983. /**
  13984. * The max limit of the emission direction.
  13985. */
  13986. direction2?: Vector3);
  13987. /**
  13988. * Called by the particle System when the direction is computed for the created particle.
  13989. * @param worldMatrix is the world matrix of the particle system
  13990. * @param directionToUpdate is the direction vector to update with the result
  13991. * @param particle is the particle we are computed the direction for
  13992. */
  13993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13994. /**
  13995. * Clones the current emitter and returns a copy of it
  13996. * @returns the new emitter
  13997. */
  13998. clone(): SphereDirectedParticleEmitter;
  13999. /**
  14000. * Called by the GPUParticleSystem to setup the update shader
  14001. * @param effect defines the update shader
  14002. */
  14003. applyToShader(effect: Effect): void;
  14004. /**
  14005. * Returns a string to use to update the GPU particles update shader
  14006. * @returns a string containng the defines string
  14007. */
  14008. getEffectDefines(): string;
  14009. /**
  14010. * Returns the string "SphereDirectedParticleEmitter"
  14011. * @returns a string containing the class name
  14012. */
  14013. getClassName(): string;
  14014. /**
  14015. * Serializes the particle system to a JSON object.
  14016. * @returns the JSON object
  14017. */
  14018. serialize(): any;
  14019. /**
  14020. * Parse properties from a JSON object
  14021. * @param serializationObject defines the JSON object
  14022. */
  14023. parse(serializationObject: any): void;
  14024. }
  14025. }
  14026. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14027. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14028. import { Effect } from "babylonjs/Materials/effect";
  14029. import { Particle } from "babylonjs/Particles/particle";
  14030. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14031. import { Nullable } from "babylonjs/types";
  14032. /**
  14033. * Particle emitter emitting particles from a custom list of positions.
  14034. */
  14035. export class CustomParticleEmitter implements IParticleEmitterType {
  14036. /**
  14037. * Gets or sets the position generator that will create the inital position of each particle.
  14038. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14039. */
  14040. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14041. /**
  14042. * Gets or sets the destination generator that will create the final destination of each particle.
  14043. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14044. */
  14045. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14046. /**
  14047. * Creates a new instance CustomParticleEmitter
  14048. */
  14049. constructor();
  14050. /**
  14051. * Called by the particle System when the direction is computed for the created particle.
  14052. * @param worldMatrix is the world matrix of the particle system
  14053. * @param directionToUpdate is the direction vector to update with the result
  14054. * @param particle is the particle we are computed the direction for
  14055. * @param isLocal defines if the direction should be set in local space
  14056. */
  14057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14058. /**
  14059. * Called by the particle System when the position is computed for the created particle.
  14060. * @param worldMatrix is the world matrix of the particle system
  14061. * @param positionToUpdate is the position vector to update with the result
  14062. * @param particle is the particle we are computed the position for
  14063. * @param isLocal defines if the position should be set in local space
  14064. */
  14065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14066. /**
  14067. * Clones the current emitter and returns a copy of it
  14068. * @returns the new emitter
  14069. */
  14070. clone(): CustomParticleEmitter;
  14071. /**
  14072. * Called by the GPUParticleSystem to setup the update shader
  14073. * @param effect defines the update shader
  14074. */
  14075. applyToShader(effect: Effect): void;
  14076. /**
  14077. * Returns a string to use to update the GPU particles update shader
  14078. * @returns a string containng the defines string
  14079. */
  14080. getEffectDefines(): string;
  14081. /**
  14082. * Returns the string "PointParticleEmitter"
  14083. * @returns a string containing the class name
  14084. */
  14085. getClassName(): string;
  14086. /**
  14087. * Serializes the particle system to a JSON object.
  14088. * @returns the JSON object
  14089. */
  14090. serialize(): any;
  14091. /**
  14092. * Parse properties from a JSON object
  14093. * @param serializationObject defines the JSON object
  14094. */
  14095. parse(serializationObject: any): void;
  14096. }
  14097. }
  14098. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14099. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14100. import { Effect } from "babylonjs/Materials/effect";
  14101. import { Particle } from "babylonjs/Particles/particle";
  14102. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14103. import { Nullable } from "babylonjs/types";
  14104. import { Scene } from "babylonjs/scene";
  14105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14106. /**
  14107. * Particle emitter emitting particles from the inside of a box.
  14108. * It emits the particles randomly between 2 given directions.
  14109. */
  14110. export class MeshParticleEmitter implements IParticleEmitterType {
  14111. private _indices;
  14112. private _positions;
  14113. private _normals;
  14114. private _storedNormal;
  14115. private _mesh;
  14116. /**
  14117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14118. */
  14119. direction1: Vector3;
  14120. /**
  14121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14122. */
  14123. direction2: Vector3;
  14124. /**
  14125. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14126. */
  14127. useMeshNormalsForDirection: boolean;
  14128. /** Defines the mesh to use as source */
  14129. get mesh(): Nullable<AbstractMesh>;
  14130. set mesh(value: Nullable<AbstractMesh>);
  14131. /**
  14132. * Creates a new instance MeshParticleEmitter
  14133. * @param mesh defines the mesh to use as source
  14134. */
  14135. constructor(mesh?: Nullable<AbstractMesh>);
  14136. /**
  14137. * Called by the particle System when the direction is computed for the created particle.
  14138. * @param worldMatrix is the world matrix of the particle system
  14139. * @param directionToUpdate is the direction vector to update with the result
  14140. * @param particle is the particle we are computed the direction for
  14141. * @param isLocal defines if the direction should be set in local space
  14142. */
  14143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14144. /**
  14145. * Called by the particle System when the position is computed for the created particle.
  14146. * @param worldMatrix is the world matrix of the particle system
  14147. * @param positionToUpdate is the position vector to update with the result
  14148. * @param particle is the particle we are computed the position for
  14149. * @param isLocal defines if the position should be set in local space
  14150. */
  14151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14152. /**
  14153. * Clones the current emitter and returns a copy of it
  14154. * @returns the new emitter
  14155. */
  14156. clone(): MeshParticleEmitter;
  14157. /**
  14158. * Called by the GPUParticleSystem to setup the update shader
  14159. * @param effect defines the update shader
  14160. */
  14161. applyToShader(effect: Effect): void;
  14162. /**
  14163. * Returns a string to use to update the GPU particles update shader
  14164. * @returns a string containng the defines string
  14165. */
  14166. getEffectDefines(): string;
  14167. /**
  14168. * Returns the string "BoxParticleEmitter"
  14169. * @returns a string containing the class name
  14170. */
  14171. getClassName(): string;
  14172. /**
  14173. * Serializes the particle system to a JSON object.
  14174. * @returns the JSON object
  14175. */
  14176. serialize(): any;
  14177. /**
  14178. * Parse properties from a JSON object
  14179. * @param serializationObject defines the JSON object
  14180. * @param scene defines the hosting scene
  14181. */
  14182. parse(serializationObject: any, scene: Scene): void;
  14183. }
  14184. }
  14185. declare module "babylonjs/Particles/EmitterTypes/index" {
  14186. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14187. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14188. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14189. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14190. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14191. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14192. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14193. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14194. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14195. }
  14196. declare module "babylonjs/Particles/IParticleSystem" {
  14197. import { Nullable } from "babylonjs/types";
  14198. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14199. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14202. import { Texture } from "babylonjs/Materials/Textures/texture";
  14203. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14204. import { Scene } from "babylonjs/scene";
  14205. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14206. import { Effect } from "babylonjs/Materials/effect";
  14207. import { Observable } from "babylonjs/Misc/observable";
  14208. import { Animation } from "babylonjs/Animations/animation";
  14209. /**
  14210. * Interface representing a particle system in Babylon.js.
  14211. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14212. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14213. */
  14214. export interface IParticleSystem {
  14215. /**
  14216. * List of animations used by the particle system.
  14217. */
  14218. animations: Animation[];
  14219. /**
  14220. * The id of the Particle system.
  14221. */
  14222. id: string;
  14223. /**
  14224. * The name of the Particle system.
  14225. */
  14226. name: string;
  14227. /**
  14228. * The emitter represents the Mesh or position we are attaching the particle system to.
  14229. */
  14230. emitter: Nullable<AbstractMesh | Vector3>;
  14231. /**
  14232. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14233. */
  14234. isBillboardBased: boolean;
  14235. /**
  14236. * The rendering group used by the Particle system to chose when to render.
  14237. */
  14238. renderingGroupId: number;
  14239. /**
  14240. * The layer mask we are rendering the particles through.
  14241. */
  14242. layerMask: number;
  14243. /**
  14244. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14245. */
  14246. updateSpeed: number;
  14247. /**
  14248. * The amount of time the particle system is running (depends of the overall update speed).
  14249. */
  14250. targetStopDuration: number;
  14251. /**
  14252. * The texture used to render each particle. (this can be a spritesheet)
  14253. */
  14254. particleTexture: Nullable<Texture>;
  14255. /**
  14256. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14257. */
  14258. blendMode: number;
  14259. /**
  14260. * Minimum life time of emitting particles.
  14261. */
  14262. minLifeTime: number;
  14263. /**
  14264. * Maximum life time of emitting particles.
  14265. */
  14266. maxLifeTime: number;
  14267. /**
  14268. * Minimum Size of emitting particles.
  14269. */
  14270. minSize: number;
  14271. /**
  14272. * Maximum Size of emitting particles.
  14273. */
  14274. maxSize: number;
  14275. /**
  14276. * Minimum scale of emitting particles on X axis.
  14277. */
  14278. minScaleX: number;
  14279. /**
  14280. * Maximum scale of emitting particles on X axis.
  14281. */
  14282. maxScaleX: number;
  14283. /**
  14284. * Minimum scale of emitting particles on Y axis.
  14285. */
  14286. minScaleY: number;
  14287. /**
  14288. * Maximum scale of emitting particles on Y axis.
  14289. */
  14290. maxScaleY: number;
  14291. /**
  14292. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14293. */
  14294. color1: Color4;
  14295. /**
  14296. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14297. */
  14298. color2: Color4;
  14299. /**
  14300. * Color the particle will have at the end of its lifetime.
  14301. */
  14302. colorDead: Color4;
  14303. /**
  14304. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14305. */
  14306. emitRate: number;
  14307. /**
  14308. * You can use gravity if you want to give an orientation to your particles.
  14309. */
  14310. gravity: Vector3;
  14311. /**
  14312. * Minimum power of emitting particles.
  14313. */
  14314. minEmitPower: number;
  14315. /**
  14316. * Maximum power of emitting particles.
  14317. */
  14318. maxEmitPower: number;
  14319. /**
  14320. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14321. */
  14322. minAngularSpeed: number;
  14323. /**
  14324. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14325. */
  14326. maxAngularSpeed: number;
  14327. /**
  14328. * Gets or sets the minimal initial rotation in radians.
  14329. */
  14330. minInitialRotation: number;
  14331. /**
  14332. * Gets or sets the maximal initial rotation in radians.
  14333. */
  14334. maxInitialRotation: number;
  14335. /**
  14336. * The particle emitter type defines the emitter used by the particle system.
  14337. * It can be for example box, sphere, or cone...
  14338. */
  14339. particleEmitterType: Nullable<IParticleEmitterType>;
  14340. /**
  14341. * Defines the delay in milliseconds before starting the system (0 by default)
  14342. */
  14343. startDelay: number;
  14344. /**
  14345. * 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
  14346. */
  14347. preWarmCycles: number;
  14348. /**
  14349. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14350. */
  14351. preWarmStepOffset: number;
  14352. /**
  14353. * 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)
  14354. */
  14355. spriteCellChangeSpeed: number;
  14356. /**
  14357. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14358. */
  14359. startSpriteCellID: number;
  14360. /**
  14361. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14362. */
  14363. endSpriteCellID: number;
  14364. /**
  14365. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14366. */
  14367. spriteCellWidth: number;
  14368. /**
  14369. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14370. */
  14371. spriteCellHeight: number;
  14372. /**
  14373. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14374. */
  14375. spriteRandomStartCell: boolean;
  14376. /**
  14377. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14378. */
  14379. isAnimationSheetEnabled: boolean;
  14380. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14381. translationPivot: Vector2;
  14382. /**
  14383. * Gets or sets a texture used to add random noise to particle positions
  14384. */
  14385. noiseTexture: Nullable<BaseTexture>;
  14386. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14387. noiseStrength: Vector3;
  14388. /**
  14389. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14390. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14391. */
  14392. billboardMode: number;
  14393. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14394. limitVelocityDamping: number;
  14395. /**
  14396. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14397. */
  14398. beginAnimationOnStart: boolean;
  14399. /**
  14400. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14401. */
  14402. beginAnimationFrom: number;
  14403. /**
  14404. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14405. */
  14406. beginAnimationTo: number;
  14407. /**
  14408. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14409. */
  14410. beginAnimationLoop: boolean;
  14411. /**
  14412. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14413. */
  14414. disposeOnStop: boolean;
  14415. /**
  14416. * Specifies if the particles are updated in emitter local space or world space
  14417. */
  14418. isLocal: boolean;
  14419. /** Snippet ID if the particle system was created from the snippet server */
  14420. snippetId: string;
  14421. /**
  14422. * Gets the maximum number of particles active at the same time.
  14423. * @returns The max number of active particles.
  14424. */
  14425. getCapacity(): number;
  14426. /**
  14427. * Gets the number of particles active at the same time.
  14428. * @returns The number of active particles.
  14429. */
  14430. getActiveCount(): number;
  14431. /**
  14432. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14433. * @returns True if it has been started, otherwise false.
  14434. */
  14435. isStarted(): boolean;
  14436. /**
  14437. * Animates the particle system for this frame.
  14438. */
  14439. animate(): void;
  14440. /**
  14441. * Renders the particle system in its current state.
  14442. * @returns the current number of particles
  14443. */
  14444. render(): number;
  14445. /**
  14446. * Dispose the particle system and frees its associated resources.
  14447. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14448. */
  14449. dispose(disposeTexture?: boolean): void;
  14450. /**
  14451. * An event triggered when the system is disposed
  14452. */
  14453. onDisposeObservable: Observable<IParticleSystem>;
  14454. /**
  14455. * Clones the particle system.
  14456. * @param name The name of the cloned object
  14457. * @param newEmitter The new emitter to use
  14458. * @returns the cloned particle system
  14459. */
  14460. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14461. /**
  14462. * Serializes the particle system to a JSON object
  14463. * @param serializeTexture defines if the texture must be serialized as well
  14464. * @returns the JSON object
  14465. */
  14466. serialize(serializeTexture: boolean): any;
  14467. /**
  14468. * Rebuild the particle system
  14469. */
  14470. rebuild(): void;
  14471. /** Force the system to rebuild all gradients that need to be resync */
  14472. forceRefreshGradients(): void;
  14473. /**
  14474. * Starts the particle system and begins to emit
  14475. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14476. */
  14477. start(delay?: number): void;
  14478. /**
  14479. * Stops the particle system.
  14480. */
  14481. stop(): void;
  14482. /**
  14483. * Remove all active particles
  14484. */
  14485. reset(): void;
  14486. /**
  14487. * Gets a boolean indicating that the system is stopping
  14488. * @returns true if the system is currently stopping
  14489. */
  14490. isStopping(): boolean;
  14491. /**
  14492. * Is this system ready to be used/rendered
  14493. * @return true if the system is ready
  14494. */
  14495. isReady(): boolean;
  14496. /**
  14497. * Returns the string "ParticleSystem"
  14498. * @returns a string containing the class name
  14499. */
  14500. getClassName(): string;
  14501. /**
  14502. * Gets the custom effect used to render the particles
  14503. * @param blendMode Blend mode for which the effect should be retrieved
  14504. * @returns The effect
  14505. */
  14506. getCustomEffect(blendMode: number): Nullable<Effect>;
  14507. /**
  14508. * Sets the custom effect used to render the particles
  14509. * @param effect The effect to set
  14510. * @param blendMode Blend mode for which the effect should be set
  14511. */
  14512. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14513. /**
  14514. * Fill the defines array according to the current settings of the particle system
  14515. * @param defines Array to be updated
  14516. * @param blendMode blend mode to take into account when updating the array
  14517. */
  14518. fillDefines(defines: Array<string>, blendMode: number): void;
  14519. /**
  14520. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14521. * @param uniforms Uniforms array to fill
  14522. * @param attributes Attributes array to fill
  14523. * @param samplers Samplers array to fill
  14524. */
  14525. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14526. /**
  14527. * Observable that will be called just before the particles are drawn
  14528. */
  14529. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14530. /**
  14531. * Gets the name of the particle vertex shader
  14532. */
  14533. vertexShaderName: string;
  14534. /**
  14535. * Adds a new color gradient
  14536. * @param gradient defines the gradient to use (between 0 and 1)
  14537. * @param color1 defines the color to affect to the specified gradient
  14538. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14539. * @returns the current particle system
  14540. */
  14541. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14542. /**
  14543. * Remove a specific color gradient
  14544. * @param gradient defines the gradient to remove
  14545. * @returns the current particle system
  14546. */
  14547. removeColorGradient(gradient: number): IParticleSystem;
  14548. /**
  14549. * Adds a new size gradient
  14550. * @param gradient defines the gradient to use (between 0 and 1)
  14551. * @param factor defines the size factor to affect to the specified gradient
  14552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14553. * @returns the current particle system
  14554. */
  14555. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14556. /**
  14557. * Remove a specific size gradient
  14558. * @param gradient defines the gradient to remove
  14559. * @returns the current particle system
  14560. */
  14561. removeSizeGradient(gradient: number): IParticleSystem;
  14562. /**
  14563. * Gets the current list of color gradients.
  14564. * You must use addColorGradient and removeColorGradient to udpate this list
  14565. * @returns the list of color gradients
  14566. */
  14567. getColorGradients(): Nullable<Array<ColorGradient>>;
  14568. /**
  14569. * Gets the current list of size gradients.
  14570. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14571. * @returns the list of size gradients
  14572. */
  14573. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14574. /**
  14575. * Gets the current list of angular speed gradients.
  14576. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14577. * @returns the list of angular speed gradients
  14578. */
  14579. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14580. /**
  14581. * Adds a new angular speed gradient
  14582. * @param gradient defines the gradient to use (between 0 and 1)
  14583. * @param factor defines the angular speed to affect to the specified gradient
  14584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14585. * @returns the current particle system
  14586. */
  14587. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14588. /**
  14589. * Remove a specific angular speed gradient
  14590. * @param gradient defines the gradient to remove
  14591. * @returns the current particle system
  14592. */
  14593. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14594. /**
  14595. * Gets the current list of velocity gradients.
  14596. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14597. * @returns the list of velocity gradients
  14598. */
  14599. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14600. /**
  14601. * Adds a new velocity gradient
  14602. * @param gradient defines the gradient to use (between 0 and 1)
  14603. * @param factor defines the velocity to affect to the specified gradient
  14604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14605. * @returns the current particle system
  14606. */
  14607. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14608. /**
  14609. * Remove a specific velocity gradient
  14610. * @param gradient defines the gradient to remove
  14611. * @returns the current particle system
  14612. */
  14613. removeVelocityGradient(gradient: number): IParticleSystem;
  14614. /**
  14615. * Gets the current list of limit velocity gradients.
  14616. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14617. * @returns the list of limit velocity gradients
  14618. */
  14619. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14620. /**
  14621. * Adds a new limit velocity gradient
  14622. * @param gradient defines the gradient to use (between 0 and 1)
  14623. * @param factor defines the limit velocity to affect to the specified gradient
  14624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14625. * @returns the current particle system
  14626. */
  14627. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14628. /**
  14629. * Remove a specific limit velocity gradient
  14630. * @param gradient defines the gradient to remove
  14631. * @returns the current particle system
  14632. */
  14633. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14634. /**
  14635. * Adds a new drag gradient
  14636. * @param gradient defines the gradient to use (between 0 and 1)
  14637. * @param factor defines the drag to affect to the specified gradient
  14638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14639. * @returns the current particle system
  14640. */
  14641. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14642. /**
  14643. * Remove a specific drag gradient
  14644. * @param gradient defines the gradient to remove
  14645. * @returns the current particle system
  14646. */
  14647. removeDragGradient(gradient: number): IParticleSystem;
  14648. /**
  14649. * Gets the current list of drag gradients.
  14650. * You must use addDragGradient and removeDragGradient to udpate this list
  14651. * @returns the list of drag gradients
  14652. */
  14653. getDragGradients(): Nullable<Array<FactorGradient>>;
  14654. /**
  14655. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14656. * @param gradient defines the gradient to use (between 0 and 1)
  14657. * @param factor defines the emit rate to affect to the specified gradient
  14658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14659. * @returns the current particle system
  14660. */
  14661. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14662. /**
  14663. * Remove a specific emit rate gradient
  14664. * @param gradient defines the gradient to remove
  14665. * @returns the current particle system
  14666. */
  14667. removeEmitRateGradient(gradient: number): IParticleSystem;
  14668. /**
  14669. * Gets the current list of emit rate gradients.
  14670. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14671. * @returns the list of emit rate gradients
  14672. */
  14673. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14674. /**
  14675. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14676. * @param gradient defines the gradient to use (between 0 and 1)
  14677. * @param factor defines the start size to affect to the specified gradient
  14678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14679. * @returns the current particle system
  14680. */
  14681. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14682. /**
  14683. * Remove a specific start size gradient
  14684. * @param gradient defines the gradient to remove
  14685. * @returns the current particle system
  14686. */
  14687. removeStartSizeGradient(gradient: number): IParticleSystem;
  14688. /**
  14689. * Gets the current list of start size gradients.
  14690. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14691. * @returns the list of start size gradients
  14692. */
  14693. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14694. /**
  14695. * Adds a new life time gradient
  14696. * @param gradient defines the gradient to use (between 0 and 1)
  14697. * @param factor defines the life time factor to affect to the specified gradient
  14698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14699. * @returns the current particle system
  14700. */
  14701. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14702. /**
  14703. * Remove a specific life time gradient
  14704. * @param gradient defines the gradient to remove
  14705. * @returns the current particle system
  14706. */
  14707. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14708. /**
  14709. * Gets the current list of life time gradients.
  14710. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14711. * @returns the list of life time gradients
  14712. */
  14713. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14714. /**
  14715. * Gets the current list of color gradients.
  14716. * You must use addColorGradient and removeColorGradient to udpate this list
  14717. * @returns the list of color gradients
  14718. */
  14719. getColorGradients(): Nullable<Array<ColorGradient>>;
  14720. /**
  14721. * Adds a new ramp gradient used to remap particle colors
  14722. * @param gradient defines the gradient to use (between 0 and 1)
  14723. * @param color defines the color to affect to the specified gradient
  14724. * @returns the current particle system
  14725. */
  14726. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14727. /**
  14728. * Gets the current list of ramp gradients.
  14729. * You must use addRampGradient and removeRampGradient to udpate this list
  14730. * @returns the list of ramp gradients
  14731. */
  14732. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14733. /** Gets or sets a boolean indicating that ramp gradients must be used
  14734. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14735. */
  14736. useRampGradients: boolean;
  14737. /**
  14738. * Adds a new color remap gradient
  14739. * @param gradient defines the gradient to use (between 0 and 1)
  14740. * @param min defines the color remap minimal range
  14741. * @param max defines the color remap maximal range
  14742. * @returns the current particle system
  14743. */
  14744. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14745. /**
  14746. * Gets the current list of color remap gradients.
  14747. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14748. * @returns the list of color remap gradients
  14749. */
  14750. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14751. /**
  14752. * Adds a new alpha remap gradient
  14753. * @param gradient defines the gradient to use (between 0 and 1)
  14754. * @param min defines the alpha remap minimal range
  14755. * @param max defines the alpha remap maximal range
  14756. * @returns the current particle system
  14757. */
  14758. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14759. /**
  14760. * Gets the current list of alpha remap gradients.
  14761. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14762. * @returns the list of alpha remap gradients
  14763. */
  14764. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14765. /**
  14766. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14769. * @returns the emitter
  14770. */
  14771. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14772. /**
  14773. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14774. * @param radius The radius of the hemisphere to emit from
  14775. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14776. * @returns the emitter
  14777. */
  14778. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14779. /**
  14780. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14781. * @param radius The radius of the sphere to emit from
  14782. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14783. * @returns the emitter
  14784. */
  14785. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14786. /**
  14787. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14788. * @param radius The radius of the sphere to emit from
  14789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14791. * @returns the emitter
  14792. */
  14793. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14794. /**
  14795. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14796. * @param radius The radius of the emission cylinder
  14797. * @param height The height of the emission cylinder
  14798. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14799. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14800. * @returns the emitter
  14801. */
  14802. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14803. /**
  14804. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14805. * @param radius The radius of the cylinder to emit from
  14806. * @param height The height of the emission cylinder
  14807. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14810. * @returns the emitter
  14811. */
  14812. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14813. /**
  14814. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14815. * @param radius The radius of the cone to emit from
  14816. * @param angle The base angle of the cone
  14817. * @returns the emitter
  14818. */
  14819. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14820. /**
  14821. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14824. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14825. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14826. * @returns the emitter
  14827. */
  14828. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14829. /**
  14830. * Get hosting scene
  14831. * @returns the scene
  14832. */
  14833. getScene(): Scene;
  14834. }
  14835. }
  14836. declare module "babylonjs/Meshes/transformNode" {
  14837. import { DeepImmutable } from "babylonjs/types";
  14838. import { Observable } from "babylonjs/Misc/observable";
  14839. import { Nullable } from "babylonjs/types";
  14840. import { Camera } from "babylonjs/Cameras/camera";
  14841. import { Scene } from "babylonjs/scene";
  14842. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14843. import { Node } from "babylonjs/node";
  14844. import { Bone } from "babylonjs/Bones/bone";
  14845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14846. import { Space } from "babylonjs/Maths/math.axis";
  14847. /**
  14848. * 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.
  14849. * @see https://doc.babylonjs.com/how_to/transformnode
  14850. */
  14851. export class TransformNode extends Node {
  14852. /**
  14853. * Object will not rotate to face the camera
  14854. */
  14855. static BILLBOARDMODE_NONE: number;
  14856. /**
  14857. * Object will rotate to face the camera but only on the x axis
  14858. */
  14859. static BILLBOARDMODE_X: number;
  14860. /**
  14861. * Object will rotate to face the camera but only on the y axis
  14862. */
  14863. static BILLBOARDMODE_Y: number;
  14864. /**
  14865. * Object will rotate to face the camera but only on the z axis
  14866. */
  14867. static BILLBOARDMODE_Z: number;
  14868. /**
  14869. * Object will rotate to face the camera
  14870. */
  14871. static BILLBOARDMODE_ALL: number;
  14872. /**
  14873. * Object will rotate to face the camera's position instead of orientation
  14874. */
  14875. static BILLBOARDMODE_USE_POSITION: number;
  14876. private _forward;
  14877. private _forwardInverted;
  14878. private _up;
  14879. private _right;
  14880. private _rightInverted;
  14881. private _position;
  14882. private _rotation;
  14883. private _rotationQuaternion;
  14884. protected _scaling: Vector3;
  14885. protected _isDirty: boolean;
  14886. private _transformToBoneReferal;
  14887. private _isAbsoluteSynced;
  14888. private _billboardMode;
  14889. /**
  14890. * Gets or sets the billboard mode. Default is 0.
  14891. *
  14892. * | Value | Type | Description |
  14893. * | --- | --- | --- |
  14894. * | 0 | BILLBOARDMODE_NONE | |
  14895. * | 1 | BILLBOARDMODE_X | |
  14896. * | 2 | BILLBOARDMODE_Y | |
  14897. * | 4 | BILLBOARDMODE_Z | |
  14898. * | 7 | BILLBOARDMODE_ALL | |
  14899. *
  14900. */
  14901. get billboardMode(): number;
  14902. set billboardMode(value: number);
  14903. private _preserveParentRotationForBillboard;
  14904. /**
  14905. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14906. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14907. */
  14908. get preserveParentRotationForBillboard(): boolean;
  14909. set preserveParentRotationForBillboard(value: boolean);
  14910. /**
  14911. * 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
  14912. */
  14913. scalingDeterminant: number;
  14914. private _infiniteDistance;
  14915. /**
  14916. * Gets or sets the distance of the object to max, often used by skybox
  14917. */
  14918. get infiniteDistance(): boolean;
  14919. set infiniteDistance(value: boolean);
  14920. /**
  14921. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14922. * By default the system will update normals to compensate
  14923. */
  14924. ignoreNonUniformScaling: boolean;
  14925. /**
  14926. * 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
  14927. */
  14928. reIntegrateRotationIntoRotationQuaternion: boolean;
  14929. /** @hidden */
  14930. _poseMatrix: Nullable<Matrix>;
  14931. /** @hidden */
  14932. _localMatrix: Matrix;
  14933. private _usePivotMatrix;
  14934. private _absolutePosition;
  14935. private _absoluteScaling;
  14936. private _absoluteRotationQuaternion;
  14937. private _pivotMatrix;
  14938. private _pivotMatrixInverse;
  14939. protected _postMultiplyPivotMatrix: boolean;
  14940. protected _isWorldMatrixFrozen: boolean;
  14941. /** @hidden */
  14942. _indexInSceneTransformNodesArray: number;
  14943. /**
  14944. * An event triggered after the world matrix is updated
  14945. */
  14946. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14947. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14948. /**
  14949. * Gets a string identifying the name of the class
  14950. * @returns "TransformNode" string
  14951. */
  14952. getClassName(): string;
  14953. /**
  14954. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14955. */
  14956. get position(): Vector3;
  14957. set position(newPosition: Vector3);
  14958. /**
  14959. * 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)).
  14960. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14961. */
  14962. get rotation(): Vector3;
  14963. set rotation(newRotation: Vector3);
  14964. /**
  14965. * 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)).
  14966. */
  14967. get scaling(): Vector3;
  14968. set scaling(newScaling: Vector3);
  14969. /**
  14970. * 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).
  14971. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14972. */
  14973. get rotationQuaternion(): Nullable<Quaternion>;
  14974. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14975. /**
  14976. * The forward direction of that transform in world space.
  14977. */
  14978. get forward(): Vector3;
  14979. /**
  14980. * The up direction of that transform in world space.
  14981. */
  14982. get up(): Vector3;
  14983. /**
  14984. * The right direction of that transform in world space.
  14985. */
  14986. get right(): Vector3;
  14987. /**
  14988. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14989. * @param matrix the matrix to copy the pose from
  14990. * @returns this TransformNode.
  14991. */
  14992. updatePoseMatrix(matrix: Matrix): TransformNode;
  14993. /**
  14994. * Returns the mesh Pose matrix.
  14995. * @returns the pose matrix
  14996. */
  14997. getPoseMatrix(): Matrix;
  14998. /** @hidden */
  14999. _isSynchronized(): boolean;
  15000. /** @hidden */
  15001. _initCache(): void;
  15002. /**
  15003. * Flag the transform node as dirty (Forcing it to update everything)
  15004. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15005. * @returns this transform node
  15006. */
  15007. markAsDirty(property: string): TransformNode;
  15008. /**
  15009. * Returns the current mesh absolute position.
  15010. * Returns a Vector3.
  15011. */
  15012. get absolutePosition(): Vector3;
  15013. /**
  15014. * Returns the current mesh absolute scaling.
  15015. * Returns a Vector3.
  15016. */
  15017. get absoluteScaling(): Vector3;
  15018. /**
  15019. * Returns the current mesh absolute rotation.
  15020. * Returns a Quaternion.
  15021. */
  15022. get absoluteRotationQuaternion(): Quaternion;
  15023. /**
  15024. * Sets a new matrix to apply before all other transformation
  15025. * @param matrix defines the transform matrix
  15026. * @returns the current TransformNode
  15027. */
  15028. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15029. /**
  15030. * Sets a new pivot matrix to the current node
  15031. * @param matrix defines the new pivot matrix to use
  15032. * @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
  15033. * @returns the current TransformNode
  15034. */
  15035. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15036. /**
  15037. * Returns the mesh pivot matrix.
  15038. * Default : Identity.
  15039. * @returns the matrix
  15040. */
  15041. getPivotMatrix(): Matrix;
  15042. /**
  15043. * Instantiate (when possible) or clone that node with its hierarchy
  15044. * @param newParent defines the new parent to use for the instance (or clone)
  15045. * @param options defines options to configure how copy is done
  15046. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15047. * @returns an instance (or a clone) of the current node with its hiearchy
  15048. */
  15049. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15050. doNotInstantiate: boolean;
  15051. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15052. /**
  15053. * Prevents the World matrix to be computed any longer
  15054. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15055. * @returns the TransformNode.
  15056. */
  15057. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15058. /**
  15059. * Allows back the World matrix computation.
  15060. * @returns the TransformNode.
  15061. */
  15062. unfreezeWorldMatrix(): this;
  15063. /**
  15064. * True if the World matrix has been frozen.
  15065. */
  15066. get isWorldMatrixFrozen(): boolean;
  15067. /**
  15068. * Retuns the mesh absolute position in the World.
  15069. * @returns a Vector3.
  15070. */
  15071. getAbsolutePosition(): Vector3;
  15072. /**
  15073. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15074. * @param absolutePosition the absolute position to set
  15075. * @returns the TransformNode.
  15076. */
  15077. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15078. /**
  15079. * Sets the mesh position in its local space.
  15080. * @param vector3 the position to set in localspace
  15081. * @returns the TransformNode.
  15082. */
  15083. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15084. /**
  15085. * Returns the mesh position in the local space from the current World matrix values.
  15086. * @returns a new Vector3.
  15087. */
  15088. getPositionExpressedInLocalSpace(): Vector3;
  15089. /**
  15090. * Translates the mesh along the passed Vector3 in its local space.
  15091. * @param vector3 the distance to translate in localspace
  15092. * @returns the TransformNode.
  15093. */
  15094. locallyTranslate(vector3: Vector3): TransformNode;
  15095. private static _lookAtVectorCache;
  15096. /**
  15097. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15098. * @param targetPoint the position (must be in same space as current mesh) to look at
  15099. * @param yawCor optional yaw (y-axis) correction in radians
  15100. * @param pitchCor optional pitch (x-axis) correction in radians
  15101. * @param rollCor optional roll (z-axis) correction in radians
  15102. * @param space the choosen space of the target
  15103. * @returns the TransformNode.
  15104. */
  15105. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15106. /**
  15107. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15108. * This Vector3 is expressed in the World space.
  15109. * @param localAxis axis to rotate
  15110. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15111. */
  15112. getDirection(localAxis: Vector3): Vector3;
  15113. /**
  15114. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15115. * localAxis is expressed in the mesh local space.
  15116. * result is computed in the Wordl space from the mesh World matrix.
  15117. * @param localAxis axis to rotate
  15118. * @param result the resulting transformnode
  15119. * @returns this TransformNode.
  15120. */
  15121. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15122. /**
  15123. * Sets this transform node rotation to the given local axis.
  15124. * @param localAxis the axis in local space
  15125. * @param yawCor optional yaw (y-axis) correction in radians
  15126. * @param pitchCor optional pitch (x-axis) correction in radians
  15127. * @param rollCor optional roll (z-axis) correction in radians
  15128. * @returns this TransformNode
  15129. */
  15130. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15131. /**
  15132. * Sets a new pivot point to the current node
  15133. * @param point defines the new pivot point to use
  15134. * @param space defines if the point is in world or local space (local by default)
  15135. * @returns the current TransformNode
  15136. */
  15137. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15138. /**
  15139. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15140. * @returns the pivot point
  15141. */
  15142. getPivotPoint(): Vector3;
  15143. /**
  15144. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15145. * @param result the vector3 to store the result
  15146. * @returns this TransformNode.
  15147. */
  15148. getPivotPointToRef(result: Vector3): TransformNode;
  15149. /**
  15150. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15151. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15152. */
  15153. getAbsolutePivotPoint(): Vector3;
  15154. /**
  15155. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15156. * @param result vector3 to store the result
  15157. * @returns this TransformNode.
  15158. */
  15159. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15160. /**
  15161. * Defines the passed node as the parent of the current node.
  15162. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15163. * @see https://doc.babylonjs.com/how_to/parenting
  15164. * @param node the node ot set as the parent
  15165. * @returns this TransformNode.
  15166. */
  15167. setParent(node: Nullable<Node>): TransformNode;
  15168. private _nonUniformScaling;
  15169. /**
  15170. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15171. */
  15172. get nonUniformScaling(): boolean;
  15173. /** @hidden */
  15174. _updateNonUniformScalingState(value: boolean): boolean;
  15175. /**
  15176. * Attach the current TransformNode to another TransformNode associated with a bone
  15177. * @param bone Bone affecting the TransformNode
  15178. * @param affectedTransformNode TransformNode associated with the bone
  15179. * @returns this object
  15180. */
  15181. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15182. /**
  15183. * Detach the transform node if its associated with a bone
  15184. * @returns this object
  15185. */
  15186. detachFromBone(): TransformNode;
  15187. private static _rotationAxisCache;
  15188. /**
  15189. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15190. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15191. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15192. * The passed axis is also normalized.
  15193. * @param axis the axis to rotate around
  15194. * @param amount the amount to rotate in radians
  15195. * @param space Space to rotate in (Default: local)
  15196. * @returns the TransformNode.
  15197. */
  15198. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15199. /**
  15200. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15201. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15202. * The passed axis is also normalized. .
  15203. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15204. * @param point the point to rotate around
  15205. * @param axis the axis to rotate around
  15206. * @param amount the amount to rotate in radians
  15207. * @returns the TransformNode
  15208. */
  15209. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15210. /**
  15211. * Translates the mesh along the axis vector for the passed distance in the given space.
  15212. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15213. * @param axis the axis to translate in
  15214. * @param distance the distance to translate
  15215. * @param space Space to rotate in (Default: local)
  15216. * @returns the TransformNode.
  15217. */
  15218. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15219. /**
  15220. * Adds a rotation step to the mesh current rotation.
  15221. * x, y, z are Euler angles expressed in radians.
  15222. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15223. * This means this rotation is made in the mesh local space only.
  15224. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15225. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15226. * ```javascript
  15227. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15228. * ```
  15229. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15230. * 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.
  15231. * @param x Rotation to add
  15232. * @param y Rotation to add
  15233. * @param z Rotation to add
  15234. * @returns the TransformNode.
  15235. */
  15236. addRotation(x: number, y: number, z: number): TransformNode;
  15237. /**
  15238. * @hidden
  15239. */
  15240. protected _getEffectiveParent(): Nullable<Node>;
  15241. /**
  15242. * Computes the world matrix of the node
  15243. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15244. * @returns the world matrix
  15245. */
  15246. computeWorldMatrix(force?: boolean): Matrix;
  15247. /**
  15248. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15249. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15250. */
  15251. resetLocalMatrix(independentOfChildren?: boolean): void;
  15252. protected _afterComputeWorldMatrix(): void;
  15253. /**
  15254. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15255. * @param func callback function to add
  15256. *
  15257. * @returns the TransformNode.
  15258. */
  15259. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15260. /**
  15261. * Removes a registered callback function.
  15262. * @param func callback function to remove
  15263. * @returns the TransformNode.
  15264. */
  15265. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15266. /**
  15267. * Gets the position of the current mesh in camera space
  15268. * @param camera defines the camera to use
  15269. * @returns a position
  15270. */
  15271. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15272. /**
  15273. * Returns the distance from the mesh to the active camera
  15274. * @param camera defines the camera to use
  15275. * @returns the distance
  15276. */
  15277. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15278. /**
  15279. * Clone the current transform node
  15280. * @param name Name of the new clone
  15281. * @param newParent New parent for the clone
  15282. * @param doNotCloneChildren Do not clone children hierarchy
  15283. * @returns the new transform node
  15284. */
  15285. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15286. /**
  15287. * Serializes the objects information.
  15288. * @param currentSerializationObject defines the object to serialize in
  15289. * @returns the serialized object
  15290. */
  15291. serialize(currentSerializationObject?: any): any;
  15292. /**
  15293. * Returns a new TransformNode object parsed from the source provided.
  15294. * @param parsedTransformNode is the source.
  15295. * @param scene the scne the object belongs to
  15296. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15297. * @returns a new TransformNode object parsed from the source provided.
  15298. */
  15299. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15300. /**
  15301. * Get all child-transformNodes of this node
  15302. * @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
  15303. * @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
  15304. * @returns an array of TransformNode
  15305. */
  15306. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15307. /**
  15308. * Releases resources associated with this transform node.
  15309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15311. */
  15312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15313. /**
  15314. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15315. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15316. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15317. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15318. * @returns the current mesh
  15319. */
  15320. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15321. private _syncAbsoluteScalingAndRotation;
  15322. }
  15323. }
  15324. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15325. /**
  15326. * Class used to override all child animations of a given target
  15327. */
  15328. export class AnimationPropertiesOverride {
  15329. /**
  15330. * Gets or sets a value indicating if animation blending must be used
  15331. */
  15332. enableBlending: boolean;
  15333. /**
  15334. * Gets or sets the blending speed to use when enableBlending is true
  15335. */
  15336. blendingSpeed: number;
  15337. /**
  15338. * Gets or sets the default loop mode to use
  15339. */
  15340. loopMode: number;
  15341. }
  15342. }
  15343. declare module "babylonjs/Bones/bone" {
  15344. import { Skeleton } from "babylonjs/Bones/skeleton";
  15345. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15346. import { Nullable } from "babylonjs/types";
  15347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15349. import { Node } from "babylonjs/node";
  15350. import { Space } from "babylonjs/Maths/math.axis";
  15351. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15352. /**
  15353. * Class used to store bone information
  15354. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15355. */
  15356. export class Bone extends Node {
  15357. /**
  15358. * defines the bone name
  15359. */
  15360. name: string;
  15361. private static _tmpVecs;
  15362. private static _tmpQuat;
  15363. private static _tmpMats;
  15364. /**
  15365. * Gets the list of child bones
  15366. */
  15367. children: Bone[];
  15368. /** Gets the animations associated with this bone */
  15369. animations: import("babylonjs/Animations/animation").Animation[];
  15370. /**
  15371. * Gets or sets bone length
  15372. */
  15373. length: number;
  15374. /**
  15375. * @hidden Internal only
  15376. * Set this value to map this bone to a different index in the transform matrices
  15377. * Set this value to -1 to exclude the bone from the transform matrices
  15378. */
  15379. _index: Nullable<number>;
  15380. private _skeleton;
  15381. private _localMatrix;
  15382. private _restPose;
  15383. private _baseMatrix;
  15384. private _absoluteTransform;
  15385. private _invertedAbsoluteTransform;
  15386. private _parent;
  15387. private _scalingDeterminant;
  15388. private _worldTransform;
  15389. private _localScaling;
  15390. private _localRotation;
  15391. private _localPosition;
  15392. private _needToDecompose;
  15393. private _needToCompose;
  15394. /** @hidden */
  15395. _linkedTransformNode: Nullable<TransformNode>;
  15396. /** @hidden */
  15397. _waitingTransformNodeId: Nullable<string>;
  15398. /** @hidden */
  15399. get _matrix(): Matrix;
  15400. /** @hidden */
  15401. set _matrix(value: Matrix);
  15402. /**
  15403. * Create a new bone
  15404. * @param name defines the bone name
  15405. * @param skeleton defines the parent skeleton
  15406. * @param parentBone defines the parent (can be null if the bone is the root)
  15407. * @param localMatrix defines the local matrix
  15408. * @param restPose defines the rest pose matrix
  15409. * @param baseMatrix defines the base matrix
  15410. * @param index defines index of the bone in the hiearchy
  15411. */
  15412. constructor(
  15413. /**
  15414. * defines the bone name
  15415. */
  15416. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15417. /**
  15418. * Gets the current object class name.
  15419. * @return the class name
  15420. */
  15421. getClassName(): string;
  15422. /**
  15423. * Gets the parent skeleton
  15424. * @returns a skeleton
  15425. */
  15426. getSkeleton(): Skeleton;
  15427. /**
  15428. * Gets parent bone
  15429. * @returns a bone or null if the bone is the root of the bone hierarchy
  15430. */
  15431. getParent(): Nullable<Bone>;
  15432. /**
  15433. * Returns an array containing the root bones
  15434. * @returns an array containing the root bones
  15435. */
  15436. getChildren(): Array<Bone>;
  15437. /**
  15438. * Gets the node index in matrix array generated for rendering
  15439. * @returns the node index
  15440. */
  15441. getIndex(): number;
  15442. /**
  15443. * Sets the parent bone
  15444. * @param parent defines the parent (can be null if the bone is the root)
  15445. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15446. */
  15447. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15448. /**
  15449. * Gets the local matrix
  15450. * @returns a matrix
  15451. */
  15452. getLocalMatrix(): Matrix;
  15453. /**
  15454. * Gets the base matrix (initial matrix which remains unchanged)
  15455. * @returns a matrix
  15456. */
  15457. getBaseMatrix(): Matrix;
  15458. /**
  15459. * Gets the rest pose matrix
  15460. * @returns a matrix
  15461. */
  15462. getRestPose(): Matrix;
  15463. /**
  15464. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15465. */
  15466. getWorldMatrix(): Matrix;
  15467. /**
  15468. * Sets the local matrix to rest pose matrix
  15469. */
  15470. returnToRest(): void;
  15471. /**
  15472. * Gets the inverse of the absolute transform matrix.
  15473. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15474. * @returns a matrix
  15475. */
  15476. getInvertedAbsoluteTransform(): Matrix;
  15477. /**
  15478. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15479. * @returns a matrix
  15480. */
  15481. getAbsoluteTransform(): Matrix;
  15482. /**
  15483. * Links with the given transform node.
  15484. * The local matrix of this bone is copied from the transform node every frame.
  15485. * @param transformNode defines the transform node to link to
  15486. */
  15487. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15488. /**
  15489. * Gets the node used to drive the bone's transformation
  15490. * @returns a transform node or null
  15491. */
  15492. getTransformNode(): Nullable<TransformNode>;
  15493. /** Gets or sets current position (in local space) */
  15494. get position(): Vector3;
  15495. set position(newPosition: Vector3);
  15496. /** Gets or sets current rotation (in local space) */
  15497. get rotation(): Vector3;
  15498. set rotation(newRotation: Vector3);
  15499. /** Gets or sets current rotation quaternion (in local space) */
  15500. get rotationQuaternion(): Quaternion;
  15501. set rotationQuaternion(newRotation: Quaternion);
  15502. /** Gets or sets current scaling (in local space) */
  15503. get scaling(): Vector3;
  15504. set scaling(newScaling: Vector3);
  15505. /**
  15506. * Gets the animation properties override
  15507. */
  15508. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15509. private _decompose;
  15510. private _compose;
  15511. /**
  15512. * Update the base and local matrices
  15513. * @param matrix defines the new base or local matrix
  15514. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15515. * @param updateLocalMatrix defines if the local matrix should be updated
  15516. */
  15517. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15518. /** @hidden */
  15519. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15520. /**
  15521. * Flag the bone as dirty (Forcing it to update everything)
  15522. */
  15523. markAsDirty(): void;
  15524. /** @hidden */
  15525. _markAsDirtyAndCompose(): void;
  15526. private _markAsDirtyAndDecompose;
  15527. /**
  15528. * Translate the bone in local or world space
  15529. * @param vec The amount to translate the bone
  15530. * @param space The space that the translation is in
  15531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15532. */
  15533. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15534. /**
  15535. * Set the postion of the bone in local or world space
  15536. * @param position The position to set the bone
  15537. * @param space The space that the position is in
  15538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15539. */
  15540. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15541. /**
  15542. * Set the absolute position of the bone (world space)
  15543. * @param position The position to set the bone
  15544. * @param mesh The mesh that this bone is attached to
  15545. */
  15546. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15547. /**
  15548. * Scale the bone on the x, y and z axes (in local space)
  15549. * @param x The amount to scale the bone on the x axis
  15550. * @param y The amount to scale the bone on the y axis
  15551. * @param z The amount to scale the bone on the z axis
  15552. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15553. */
  15554. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15555. /**
  15556. * Set the bone scaling in local space
  15557. * @param scale defines the scaling vector
  15558. */
  15559. setScale(scale: Vector3): void;
  15560. /**
  15561. * Gets the current scaling in local space
  15562. * @returns the current scaling vector
  15563. */
  15564. getScale(): Vector3;
  15565. /**
  15566. * Gets the current scaling in local space and stores it in a target vector
  15567. * @param result defines the target vector
  15568. */
  15569. getScaleToRef(result: Vector3): void;
  15570. /**
  15571. * Set the yaw, pitch, and roll of the bone in local or world space
  15572. * @param yaw The rotation of the bone on the y axis
  15573. * @param pitch The rotation of the bone on the x axis
  15574. * @param roll The rotation of the bone on the z axis
  15575. * @param space The space that the axes of rotation are in
  15576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15577. */
  15578. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15579. /**
  15580. * Add a rotation to the bone on an axis in local or world space
  15581. * @param axis The axis to rotate the bone on
  15582. * @param amount The amount to rotate the bone
  15583. * @param space The space that the axis is in
  15584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15585. */
  15586. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15587. /**
  15588. * Set the rotation of the bone to a particular axis angle in local or world space
  15589. * @param axis The axis to rotate the bone on
  15590. * @param angle The angle that the bone should be rotated to
  15591. * @param space The space that the axis is in
  15592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15593. */
  15594. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15595. /**
  15596. * Set the euler rotation of the bone in local of world space
  15597. * @param rotation The euler rotation that the bone should be set to
  15598. * @param space The space that the rotation is in
  15599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15600. */
  15601. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15602. /**
  15603. * Set the quaternion rotation of the bone in local of world space
  15604. * @param quat The quaternion rotation that the bone should be set to
  15605. * @param space The space that the rotation is in
  15606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15607. */
  15608. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15609. /**
  15610. * Set the rotation matrix of the bone in local of world space
  15611. * @param rotMat The rotation matrix that the bone should be set to
  15612. * @param space The space that the rotation is in
  15613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15614. */
  15615. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15616. private _rotateWithMatrix;
  15617. private _getNegativeRotationToRef;
  15618. /**
  15619. * Get the position of the bone in local or world space
  15620. * @param space The space that the returned position is in
  15621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15622. * @returns The position of the bone
  15623. */
  15624. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15625. /**
  15626. * Copy the position of the bone to a vector3 in local or world space
  15627. * @param space The space that the returned position is in
  15628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15629. * @param result The vector3 to copy the position to
  15630. */
  15631. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15632. /**
  15633. * Get the absolute position of the bone (world space)
  15634. * @param mesh The mesh that this bone is attached to
  15635. * @returns The absolute position of the bone
  15636. */
  15637. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15638. /**
  15639. * Copy the absolute position of the bone (world space) to the result param
  15640. * @param mesh The mesh that this bone is attached to
  15641. * @param result The vector3 to copy the absolute position to
  15642. */
  15643. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15644. /**
  15645. * Compute the absolute transforms of this bone and its children
  15646. */
  15647. computeAbsoluteTransforms(): void;
  15648. /**
  15649. * Get the world direction from an axis that is in the local space of the bone
  15650. * @param localAxis The local direction that is used to compute the world direction
  15651. * @param mesh The mesh that this bone is attached to
  15652. * @returns The world direction
  15653. */
  15654. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15655. /**
  15656. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15657. * @param localAxis The local direction that is used to compute the world direction
  15658. * @param mesh The mesh that this bone is attached to
  15659. * @param result The vector3 that the world direction will be copied to
  15660. */
  15661. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15662. /**
  15663. * Get the euler rotation of the bone in local or world space
  15664. * @param space The space that the rotation should be in
  15665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15666. * @returns The euler rotation
  15667. */
  15668. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15669. /**
  15670. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15671. * @param space The space that the rotation should be in
  15672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15673. * @param result The vector3 that the rotation should be copied to
  15674. */
  15675. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15676. /**
  15677. * Get the quaternion rotation of the bone in either local or world space
  15678. * @param space The space that the rotation should be in
  15679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15680. * @returns The quaternion rotation
  15681. */
  15682. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15683. /**
  15684. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15685. * @param space The space that the rotation should be in
  15686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15687. * @param result The quaternion that the rotation should be copied to
  15688. */
  15689. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15690. /**
  15691. * Get the rotation matrix of the bone in local or world space
  15692. * @param space The space that the rotation should be in
  15693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15694. * @returns The rotation matrix
  15695. */
  15696. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15697. /**
  15698. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15699. * @param space The space that the rotation should be in
  15700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15701. * @param result The quaternion that the rotation should be copied to
  15702. */
  15703. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15704. /**
  15705. * Get the world position of a point that is in the local space of the bone
  15706. * @param position The local position
  15707. * @param mesh The mesh that this bone is attached to
  15708. * @returns The world position
  15709. */
  15710. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15711. /**
  15712. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15713. * @param position The local position
  15714. * @param mesh The mesh that this bone is attached to
  15715. * @param result The vector3 that the world position should be copied to
  15716. */
  15717. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15718. /**
  15719. * Get the local position of a point that is in world space
  15720. * @param position The world position
  15721. * @param mesh The mesh that this bone is attached to
  15722. * @returns The local position
  15723. */
  15724. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15725. /**
  15726. * Get the local position of a point that is in world space and copy it to the result param
  15727. * @param position The world position
  15728. * @param mesh The mesh that this bone is attached to
  15729. * @param result The vector3 that the local position should be copied to
  15730. */
  15731. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15732. }
  15733. }
  15734. declare module "babylonjs/Animations/runtimeAnimation" {
  15735. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15736. import { Animatable } from "babylonjs/Animations/animatable";
  15737. import { Scene } from "babylonjs/scene";
  15738. /**
  15739. * Defines a runtime animation
  15740. */
  15741. export class RuntimeAnimation {
  15742. private _events;
  15743. /**
  15744. * The current frame of the runtime animation
  15745. */
  15746. private _currentFrame;
  15747. /**
  15748. * The animation used by the runtime animation
  15749. */
  15750. private _animation;
  15751. /**
  15752. * The target of the runtime animation
  15753. */
  15754. private _target;
  15755. /**
  15756. * The initiating animatable
  15757. */
  15758. private _host;
  15759. /**
  15760. * The original value of the runtime animation
  15761. */
  15762. private _originalValue;
  15763. /**
  15764. * The original blend value of the runtime animation
  15765. */
  15766. private _originalBlendValue;
  15767. /**
  15768. * The offsets cache of the runtime animation
  15769. */
  15770. private _offsetsCache;
  15771. /**
  15772. * The high limits cache of the runtime animation
  15773. */
  15774. private _highLimitsCache;
  15775. /**
  15776. * Specifies if the runtime animation has been stopped
  15777. */
  15778. private _stopped;
  15779. /**
  15780. * The blending factor of the runtime animation
  15781. */
  15782. private _blendingFactor;
  15783. /**
  15784. * The BabylonJS scene
  15785. */
  15786. private _scene;
  15787. /**
  15788. * The current value of the runtime animation
  15789. */
  15790. private _currentValue;
  15791. /** @hidden */
  15792. _animationState: _IAnimationState;
  15793. /**
  15794. * The active target of the runtime animation
  15795. */
  15796. private _activeTargets;
  15797. private _currentActiveTarget;
  15798. private _directTarget;
  15799. /**
  15800. * The target path of the runtime animation
  15801. */
  15802. private _targetPath;
  15803. /**
  15804. * The weight of the runtime animation
  15805. */
  15806. private _weight;
  15807. /**
  15808. * The ratio offset of the runtime animation
  15809. */
  15810. private _ratioOffset;
  15811. /**
  15812. * The previous delay of the runtime animation
  15813. */
  15814. private _previousDelay;
  15815. /**
  15816. * The previous ratio of the runtime animation
  15817. */
  15818. private _previousRatio;
  15819. private _enableBlending;
  15820. private _keys;
  15821. private _minFrame;
  15822. private _maxFrame;
  15823. private _minValue;
  15824. private _maxValue;
  15825. private _targetIsArray;
  15826. /**
  15827. * Gets the current frame of the runtime animation
  15828. */
  15829. get currentFrame(): number;
  15830. /**
  15831. * Gets the weight of the runtime animation
  15832. */
  15833. get weight(): number;
  15834. /**
  15835. * Gets the current value of the runtime animation
  15836. */
  15837. get currentValue(): any;
  15838. /**
  15839. * Gets the target path of the runtime animation
  15840. */
  15841. get targetPath(): string;
  15842. /**
  15843. * Gets the actual target of the runtime animation
  15844. */
  15845. get target(): any;
  15846. /**
  15847. * Gets the additive state of the runtime animation
  15848. */
  15849. get isAdditive(): boolean;
  15850. /** @hidden */
  15851. _onLoop: () => void;
  15852. /**
  15853. * Create a new RuntimeAnimation object
  15854. * @param target defines the target of the animation
  15855. * @param animation defines the source animation object
  15856. * @param scene defines the hosting scene
  15857. * @param host defines the initiating Animatable
  15858. */
  15859. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15860. private _preparePath;
  15861. /**
  15862. * Gets the animation from the runtime animation
  15863. */
  15864. get animation(): Animation;
  15865. /**
  15866. * Resets the runtime animation to the beginning
  15867. * @param restoreOriginal defines whether to restore the target property to the original value
  15868. */
  15869. reset(restoreOriginal?: boolean): void;
  15870. /**
  15871. * Specifies if the runtime animation is stopped
  15872. * @returns Boolean specifying if the runtime animation is stopped
  15873. */
  15874. isStopped(): boolean;
  15875. /**
  15876. * Disposes of the runtime animation
  15877. */
  15878. dispose(): void;
  15879. /**
  15880. * Apply the interpolated value to the target
  15881. * @param currentValue defines the value computed by the animation
  15882. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15883. */
  15884. setValue(currentValue: any, weight: number): void;
  15885. private _getOriginalValues;
  15886. private _setValue;
  15887. /**
  15888. * Gets the loop pmode of the runtime animation
  15889. * @returns Loop Mode
  15890. */
  15891. private _getCorrectLoopMode;
  15892. /**
  15893. * Move the current animation to a given frame
  15894. * @param frame defines the frame to move to
  15895. */
  15896. goToFrame(frame: number): void;
  15897. /**
  15898. * @hidden Internal use only
  15899. */
  15900. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15901. /**
  15902. * Execute the current animation
  15903. * @param delay defines the delay to add to the current frame
  15904. * @param from defines the lower bound of the animation range
  15905. * @param to defines the upper bound of the animation range
  15906. * @param loop defines if the current animation must loop
  15907. * @param speedRatio defines the current speed ratio
  15908. * @param weight defines the weight of the animation (default is -1 so no weight)
  15909. * @param onLoop optional callback called when animation loops
  15910. * @returns a boolean indicating if the animation is running
  15911. */
  15912. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15913. }
  15914. }
  15915. declare module "babylonjs/Animations/animatable" {
  15916. import { Animation } from "babylonjs/Animations/animation";
  15917. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15918. import { Nullable } from "babylonjs/types";
  15919. import { Observable } from "babylonjs/Misc/observable";
  15920. import { Scene } from "babylonjs/scene";
  15921. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15922. import { Node } from "babylonjs/node";
  15923. /**
  15924. * Class used to store an actual running animation
  15925. */
  15926. export class Animatable {
  15927. /** defines the target object */
  15928. target: any;
  15929. /** defines the starting frame number (default is 0) */
  15930. fromFrame: number;
  15931. /** defines the ending frame number (default is 100) */
  15932. toFrame: number;
  15933. /** defines if the animation must loop (default is false) */
  15934. loopAnimation: boolean;
  15935. /** defines a callback to call when animation ends if it is not looping */
  15936. onAnimationEnd?: (() => void) | null | undefined;
  15937. /** defines a callback to call when animation loops */
  15938. onAnimationLoop?: (() => void) | null | undefined;
  15939. /** defines whether the animation should be evaluated additively */
  15940. isAdditive: boolean;
  15941. private _localDelayOffset;
  15942. private _pausedDelay;
  15943. private _runtimeAnimations;
  15944. private _paused;
  15945. private _scene;
  15946. private _speedRatio;
  15947. private _weight;
  15948. private _syncRoot;
  15949. /**
  15950. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15951. * This will only apply for non looping animation (default is true)
  15952. */
  15953. disposeOnEnd: boolean;
  15954. /**
  15955. * Gets a boolean indicating if the animation has started
  15956. */
  15957. animationStarted: boolean;
  15958. /**
  15959. * Observer raised when the animation ends
  15960. */
  15961. onAnimationEndObservable: Observable<Animatable>;
  15962. /**
  15963. * Observer raised when the animation loops
  15964. */
  15965. onAnimationLoopObservable: Observable<Animatable>;
  15966. /**
  15967. * Gets the root Animatable used to synchronize and normalize animations
  15968. */
  15969. get syncRoot(): Nullable<Animatable>;
  15970. /**
  15971. * Gets the current frame of the first RuntimeAnimation
  15972. * Used to synchronize Animatables
  15973. */
  15974. get masterFrame(): number;
  15975. /**
  15976. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15977. */
  15978. get weight(): number;
  15979. set weight(value: number);
  15980. /**
  15981. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15982. */
  15983. get speedRatio(): number;
  15984. set speedRatio(value: number);
  15985. /**
  15986. * Creates a new Animatable
  15987. * @param scene defines the hosting scene
  15988. * @param target defines the target object
  15989. * @param fromFrame defines the starting frame number (default is 0)
  15990. * @param toFrame defines the ending frame number (default is 100)
  15991. * @param loopAnimation defines if the animation must loop (default is false)
  15992. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15993. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15994. * @param animations defines a group of animation to add to the new Animatable
  15995. * @param onAnimationLoop defines a callback to call when animation loops
  15996. * @param isAdditive defines whether the animation should be evaluated additively
  15997. */
  15998. constructor(scene: Scene,
  15999. /** defines the target object */
  16000. target: any,
  16001. /** defines the starting frame number (default is 0) */
  16002. fromFrame?: number,
  16003. /** defines the ending frame number (default is 100) */
  16004. toFrame?: number,
  16005. /** defines if the animation must loop (default is false) */
  16006. loopAnimation?: boolean, speedRatio?: number,
  16007. /** defines a callback to call when animation ends if it is not looping */
  16008. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16009. /** defines a callback to call when animation loops */
  16010. onAnimationLoop?: (() => void) | null | undefined,
  16011. /** defines whether the animation should be evaluated additively */
  16012. isAdditive?: boolean);
  16013. /**
  16014. * Synchronize and normalize current Animatable with a source Animatable
  16015. * This is useful when using animation weights and when animations are not of the same length
  16016. * @param root defines the root Animatable to synchronize with
  16017. * @returns the current Animatable
  16018. */
  16019. syncWith(root: Animatable): Animatable;
  16020. /**
  16021. * Gets the list of runtime animations
  16022. * @returns an array of RuntimeAnimation
  16023. */
  16024. getAnimations(): RuntimeAnimation[];
  16025. /**
  16026. * Adds more animations to the current animatable
  16027. * @param target defines the target of the animations
  16028. * @param animations defines the new animations to add
  16029. */
  16030. appendAnimations(target: any, animations: Animation[]): void;
  16031. /**
  16032. * Gets the source animation for a specific property
  16033. * @param property defines the propertyu to look for
  16034. * @returns null or the source animation for the given property
  16035. */
  16036. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16037. /**
  16038. * Gets the runtime animation for a specific property
  16039. * @param property defines the propertyu to look for
  16040. * @returns null or the runtime animation for the given property
  16041. */
  16042. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16043. /**
  16044. * Resets the animatable to its original state
  16045. */
  16046. reset(): void;
  16047. /**
  16048. * Allows the animatable to blend with current running animations
  16049. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16050. * @param blendingSpeed defines the blending speed to use
  16051. */
  16052. enableBlending(blendingSpeed: number): void;
  16053. /**
  16054. * Disable animation blending
  16055. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16056. */
  16057. disableBlending(): void;
  16058. /**
  16059. * Jump directly to a given frame
  16060. * @param frame defines the frame to jump to
  16061. */
  16062. goToFrame(frame: number): void;
  16063. /**
  16064. * Pause the animation
  16065. */
  16066. pause(): void;
  16067. /**
  16068. * Restart the animation
  16069. */
  16070. restart(): void;
  16071. private _raiseOnAnimationEnd;
  16072. /**
  16073. * Stop and delete the current animation
  16074. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16075. * @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)
  16076. */
  16077. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16078. /**
  16079. * Wait asynchronously for the animation to end
  16080. * @returns a promise which will be fullfilled when the animation ends
  16081. */
  16082. waitAsync(): Promise<Animatable>;
  16083. /** @hidden */
  16084. _animate(delay: number): boolean;
  16085. }
  16086. module "babylonjs/scene" {
  16087. interface Scene {
  16088. /** @hidden */
  16089. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16090. /** @hidden */
  16091. _processLateAnimationBindingsForMatrices(holder: {
  16092. totalWeight: number;
  16093. totalAdditiveWeight: number;
  16094. animations: RuntimeAnimation[];
  16095. additiveAnimations: RuntimeAnimation[];
  16096. originalValue: Matrix;
  16097. }): any;
  16098. /** @hidden */
  16099. _processLateAnimationBindingsForQuaternions(holder: {
  16100. totalWeight: number;
  16101. totalAdditiveWeight: number;
  16102. animations: RuntimeAnimation[];
  16103. additiveAnimations: RuntimeAnimation[];
  16104. originalValue: Quaternion;
  16105. }, refQuaternion: Quaternion): Quaternion;
  16106. /** @hidden */
  16107. _processLateAnimationBindings(): void;
  16108. /**
  16109. * Will start the animation sequence of a given target
  16110. * @param target defines the target
  16111. * @param from defines from which frame should animation start
  16112. * @param to defines until which frame should animation run.
  16113. * @param weight defines the weight to apply to the animation (1.0 by default)
  16114. * @param loop defines if the animation loops
  16115. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16116. * @param onAnimationEnd defines the function to be executed when the animation ends
  16117. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16119. * @param onAnimationLoop defines the callback to call when an animation loops
  16120. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16121. * @returns the animatable object created for this animation
  16122. */
  16123. 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;
  16124. /**
  16125. * Will start the animation sequence of a given target
  16126. * @param target defines the target
  16127. * @param from defines from which frame should animation start
  16128. * @param to defines until which frame should animation run.
  16129. * @param loop defines if the animation loops
  16130. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16131. * @param onAnimationEnd defines the function to be executed when the animation ends
  16132. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16133. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16134. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16135. * @param onAnimationLoop defines the callback to call when an animation loops
  16136. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16137. * @returns the animatable object created for this animation
  16138. */
  16139. 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;
  16140. /**
  16141. * Will start the animation sequence of a given target and its hierarchy
  16142. * @param target defines the target
  16143. * @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.
  16144. * @param from defines from which frame should animation start
  16145. * @param to defines until which frame should animation run.
  16146. * @param loop defines if the animation loops
  16147. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16148. * @param onAnimationEnd defines the function to be executed when the animation ends
  16149. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16150. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16151. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16152. * @param onAnimationLoop defines the callback to call when an animation loops
  16153. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16154. * @returns the list of created animatables
  16155. */
  16156. 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[];
  16157. /**
  16158. * Begin a new animation on a given node
  16159. * @param target defines the target where the animation will take place
  16160. * @param animations defines the list of animations to start
  16161. * @param from defines the initial value
  16162. * @param to defines the final value
  16163. * @param loop defines if you want animation to loop (off by default)
  16164. * @param speedRatio defines the speed ratio to apply to all animations
  16165. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16166. * @param onAnimationLoop defines the callback to call when an animation loops
  16167. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16168. * @returns the list of created animatables
  16169. */
  16170. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16171. /**
  16172. * Begin a new animation on a given node and its hierarchy
  16173. * @param target defines the root node where the animation will take place
  16174. * @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.
  16175. * @param animations defines the list of animations to start
  16176. * @param from defines the initial value
  16177. * @param to defines the final value
  16178. * @param loop defines if you want animation to loop (off by default)
  16179. * @param speedRatio defines the speed ratio to apply to all animations
  16180. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16181. * @param onAnimationLoop defines the callback to call when an animation loops
  16182. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16183. * @returns the list of animatables created for all nodes
  16184. */
  16185. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16186. /**
  16187. * Gets the animatable associated with a specific target
  16188. * @param target defines the target of the animatable
  16189. * @returns the required animatable if found
  16190. */
  16191. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16192. /**
  16193. * Gets all animatables associated with a given target
  16194. * @param target defines the target to look animatables for
  16195. * @returns an array of Animatables
  16196. */
  16197. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16198. /**
  16199. * Stops and removes all animations that have been applied to the scene
  16200. */
  16201. stopAllAnimations(): void;
  16202. /**
  16203. * Gets the current delta time used by animation engine
  16204. */
  16205. deltaTime: number;
  16206. }
  16207. }
  16208. module "babylonjs/Bones/bone" {
  16209. interface Bone {
  16210. /**
  16211. * Copy an animation range from another bone
  16212. * @param source defines the source bone
  16213. * @param rangeName defines the range name to copy
  16214. * @param frameOffset defines the frame offset
  16215. * @param rescaleAsRequired defines if rescaling must be applied if required
  16216. * @param skelDimensionsRatio defines the scaling ratio
  16217. * @returns true if operation was successful
  16218. */
  16219. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16220. }
  16221. }
  16222. }
  16223. declare module "babylonjs/Bones/skeleton" {
  16224. import { Bone } from "babylonjs/Bones/bone";
  16225. import { Observable } from "babylonjs/Misc/observable";
  16226. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16227. import { Scene } from "babylonjs/scene";
  16228. import { Nullable } from "babylonjs/types";
  16229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16230. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16231. import { Animatable } from "babylonjs/Animations/animatable";
  16232. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16233. import { Animation } from "babylonjs/Animations/animation";
  16234. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16235. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16236. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16237. /**
  16238. * Class used to handle skinning animations
  16239. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16240. */
  16241. export class Skeleton implements IAnimatable {
  16242. /** defines the skeleton name */
  16243. name: string;
  16244. /** defines the skeleton Id */
  16245. id: string;
  16246. /**
  16247. * Defines the list of child bones
  16248. */
  16249. bones: Bone[];
  16250. /**
  16251. * Defines an estimate of the dimension of the skeleton at rest
  16252. */
  16253. dimensionsAtRest: Vector3;
  16254. /**
  16255. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16256. */
  16257. needInitialSkinMatrix: boolean;
  16258. /**
  16259. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16260. */
  16261. overrideMesh: Nullable<AbstractMesh>;
  16262. /**
  16263. * Gets the list of animations attached to this skeleton
  16264. */
  16265. animations: Array<Animation>;
  16266. private _scene;
  16267. private _isDirty;
  16268. private _transformMatrices;
  16269. private _transformMatrixTexture;
  16270. private _meshesWithPoseMatrix;
  16271. private _animatables;
  16272. private _identity;
  16273. private _synchronizedWithMesh;
  16274. private _ranges;
  16275. private _lastAbsoluteTransformsUpdateId;
  16276. private _canUseTextureForBones;
  16277. private _uniqueId;
  16278. /** @hidden */
  16279. _numBonesWithLinkedTransformNode: number;
  16280. /** @hidden */
  16281. _hasWaitingData: Nullable<boolean>;
  16282. /**
  16283. * Specifies if the skeleton should be serialized
  16284. */
  16285. doNotSerialize: boolean;
  16286. private _useTextureToStoreBoneMatrices;
  16287. /**
  16288. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16289. * Please note that this option is not available if the hardware does not support it
  16290. */
  16291. get useTextureToStoreBoneMatrices(): boolean;
  16292. set useTextureToStoreBoneMatrices(value: boolean);
  16293. private _animationPropertiesOverride;
  16294. /**
  16295. * Gets or sets the animation properties override
  16296. */
  16297. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16298. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16299. /**
  16300. * List of inspectable custom properties (used by the Inspector)
  16301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16302. */
  16303. inspectableCustomProperties: IInspectable[];
  16304. /**
  16305. * An observable triggered before computing the skeleton's matrices
  16306. */
  16307. onBeforeComputeObservable: Observable<Skeleton>;
  16308. /**
  16309. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16310. */
  16311. get isUsingTextureForMatrices(): boolean;
  16312. /**
  16313. * Gets the unique ID of this skeleton
  16314. */
  16315. get uniqueId(): number;
  16316. /**
  16317. * Creates a new skeleton
  16318. * @param name defines the skeleton name
  16319. * @param id defines the skeleton Id
  16320. * @param scene defines the hosting scene
  16321. */
  16322. constructor(
  16323. /** defines the skeleton name */
  16324. name: string,
  16325. /** defines the skeleton Id */
  16326. id: string, scene: Scene);
  16327. /**
  16328. * Gets the current object class name.
  16329. * @return the class name
  16330. */
  16331. getClassName(): string;
  16332. /**
  16333. * Returns an array containing the root bones
  16334. * @returns an array containing the root bones
  16335. */
  16336. getChildren(): Array<Bone>;
  16337. /**
  16338. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16339. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16340. * @returns a Float32Array containing matrices data
  16341. */
  16342. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16343. /**
  16344. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16345. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16346. * @returns a raw texture containing the data
  16347. */
  16348. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16349. /**
  16350. * Gets the current hosting scene
  16351. * @returns a scene object
  16352. */
  16353. getScene(): Scene;
  16354. /**
  16355. * Gets a string representing the current skeleton data
  16356. * @param fullDetails defines a boolean indicating if we want a verbose version
  16357. * @returns a string representing the current skeleton data
  16358. */
  16359. toString(fullDetails?: boolean): string;
  16360. /**
  16361. * Get bone's index searching by name
  16362. * @param name defines bone's name to search for
  16363. * @return the indice of the bone. Returns -1 if not found
  16364. */
  16365. getBoneIndexByName(name: string): number;
  16366. /**
  16367. * Creater a new animation range
  16368. * @param name defines the name of the range
  16369. * @param from defines the start key
  16370. * @param to defines the end key
  16371. */
  16372. createAnimationRange(name: string, from: number, to: number): void;
  16373. /**
  16374. * Delete a specific animation range
  16375. * @param name defines the name of the range
  16376. * @param deleteFrames defines if frames must be removed as well
  16377. */
  16378. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16379. /**
  16380. * Gets a specific animation range
  16381. * @param name defines the name of the range to look for
  16382. * @returns the requested animation range or null if not found
  16383. */
  16384. getAnimationRange(name: string): Nullable<AnimationRange>;
  16385. /**
  16386. * Gets the list of all animation ranges defined on this skeleton
  16387. * @returns an array
  16388. */
  16389. getAnimationRanges(): Nullable<AnimationRange>[];
  16390. /**
  16391. * Copy animation range from a source skeleton.
  16392. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16393. * @param source defines the source skeleton
  16394. * @param name defines the name of the range to copy
  16395. * @param rescaleAsRequired defines if rescaling must be applied if required
  16396. * @returns true if operation was successful
  16397. */
  16398. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16399. /**
  16400. * Forces the skeleton to go to rest pose
  16401. */
  16402. returnToRest(): void;
  16403. private _getHighestAnimationFrame;
  16404. /**
  16405. * Begin a specific animation range
  16406. * @param name defines the name of the range to start
  16407. * @param loop defines if looping must be turned on (false by default)
  16408. * @param speedRatio defines the speed ratio to apply (1 by default)
  16409. * @param onAnimationEnd defines a callback which will be called when animation will end
  16410. * @returns a new animatable
  16411. */
  16412. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16413. /**
  16414. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16415. * @param skeleton defines the Skeleton containing the animation range to convert
  16416. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16417. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16418. * @returns the original skeleton
  16419. */
  16420. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16421. /** @hidden */
  16422. _markAsDirty(): void;
  16423. /** @hidden */
  16424. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16425. /** @hidden */
  16426. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16427. private _computeTransformMatrices;
  16428. /**
  16429. * Build all resources required to render a skeleton
  16430. */
  16431. prepare(): void;
  16432. /**
  16433. * Gets the list of animatables currently running for this skeleton
  16434. * @returns an array of animatables
  16435. */
  16436. getAnimatables(): IAnimatable[];
  16437. /**
  16438. * Clone the current skeleton
  16439. * @param name defines the name of the new skeleton
  16440. * @param id defines the id of the new skeleton
  16441. * @returns the new skeleton
  16442. */
  16443. clone(name: string, id?: string): Skeleton;
  16444. /**
  16445. * Enable animation blending for this skeleton
  16446. * @param blendingSpeed defines the blending speed to apply
  16447. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16448. */
  16449. enableBlending(blendingSpeed?: number): void;
  16450. /**
  16451. * Releases all resources associated with the current skeleton
  16452. */
  16453. dispose(): void;
  16454. /**
  16455. * Serialize the skeleton in a JSON object
  16456. * @returns a JSON object
  16457. */
  16458. serialize(): any;
  16459. /**
  16460. * Creates a new skeleton from serialized data
  16461. * @param parsedSkeleton defines the serialized data
  16462. * @param scene defines the hosting scene
  16463. * @returns a new skeleton
  16464. */
  16465. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16466. /**
  16467. * Compute all node absolute transforms
  16468. * @param forceUpdate defines if computation must be done even if cache is up to date
  16469. */
  16470. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16471. /**
  16472. * Gets the root pose matrix
  16473. * @returns a matrix
  16474. */
  16475. getPoseMatrix(): Nullable<Matrix>;
  16476. /**
  16477. * Sorts bones per internal index
  16478. */
  16479. sortBones(): void;
  16480. private _sortBones;
  16481. }
  16482. }
  16483. declare module "babylonjs/Meshes/instancedMesh" {
  16484. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16485. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16486. import { Camera } from "babylonjs/Cameras/camera";
  16487. import { Node } from "babylonjs/node";
  16488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16489. import { Mesh } from "babylonjs/Meshes/mesh";
  16490. import { Material } from "babylonjs/Materials/material";
  16491. import { Skeleton } from "babylonjs/Bones/skeleton";
  16492. import { Light } from "babylonjs/Lights/light";
  16493. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16494. /**
  16495. * Creates an instance based on a source mesh.
  16496. */
  16497. export class InstancedMesh extends AbstractMesh {
  16498. private _sourceMesh;
  16499. private _currentLOD;
  16500. /** @hidden */
  16501. _indexInSourceMeshInstanceArray: number;
  16502. constructor(name: string, source: Mesh);
  16503. /**
  16504. * Returns the string "InstancedMesh".
  16505. */
  16506. getClassName(): string;
  16507. /** Gets the list of lights affecting that mesh */
  16508. get lightSources(): Light[];
  16509. _resyncLightSources(): void;
  16510. _resyncLightSource(light: Light): void;
  16511. _removeLightSource(light: Light, dispose: boolean): void;
  16512. /**
  16513. * If the source mesh receives shadows
  16514. */
  16515. get receiveShadows(): boolean;
  16516. /**
  16517. * The material of the source mesh
  16518. */
  16519. get material(): Nullable<Material>;
  16520. /**
  16521. * Visibility of the source mesh
  16522. */
  16523. get visibility(): number;
  16524. /**
  16525. * Skeleton of the source mesh
  16526. */
  16527. get skeleton(): Nullable<Skeleton>;
  16528. /**
  16529. * Rendering ground id of the source mesh
  16530. */
  16531. get renderingGroupId(): number;
  16532. set renderingGroupId(value: number);
  16533. /**
  16534. * Returns the total number of vertices (integer).
  16535. */
  16536. getTotalVertices(): number;
  16537. /**
  16538. * Returns a positive integer : the total number of indices in this mesh geometry.
  16539. * @returns the numner of indices or zero if the mesh has no geometry.
  16540. */
  16541. getTotalIndices(): number;
  16542. /**
  16543. * The source mesh of the instance
  16544. */
  16545. get sourceMesh(): Mesh;
  16546. /**
  16547. * Is this node ready to be used/rendered
  16548. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16549. * @return {boolean} is it ready
  16550. */
  16551. isReady(completeCheck?: boolean): boolean;
  16552. /**
  16553. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16554. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16555. * @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.
  16556. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16557. */
  16558. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16559. /**
  16560. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16561. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16562. * The `data` are either a numeric array either a Float32Array.
  16563. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16564. * 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).
  16565. * Note that a new underlying VertexBuffer object is created each call.
  16566. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16567. *
  16568. * Possible `kind` values :
  16569. * - VertexBuffer.PositionKind
  16570. * - VertexBuffer.UVKind
  16571. * - VertexBuffer.UV2Kind
  16572. * - VertexBuffer.UV3Kind
  16573. * - VertexBuffer.UV4Kind
  16574. * - VertexBuffer.UV5Kind
  16575. * - VertexBuffer.UV6Kind
  16576. * - VertexBuffer.ColorKind
  16577. * - VertexBuffer.MatricesIndicesKind
  16578. * - VertexBuffer.MatricesIndicesExtraKind
  16579. * - VertexBuffer.MatricesWeightsKind
  16580. * - VertexBuffer.MatricesWeightsExtraKind
  16581. *
  16582. * Returns the Mesh.
  16583. */
  16584. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16585. /**
  16586. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16587. * If the mesh has no geometry, it is simply returned as it is.
  16588. * The `data` are either a numeric array either a Float32Array.
  16589. * No new underlying VertexBuffer object is created.
  16590. * 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.
  16591. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16592. *
  16593. * Possible `kind` values :
  16594. * - VertexBuffer.PositionKind
  16595. * - VertexBuffer.UVKind
  16596. * - VertexBuffer.UV2Kind
  16597. * - VertexBuffer.UV3Kind
  16598. * - VertexBuffer.UV4Kind
  16599. * - VertexBuffer.UV5Kind
  16600. * - VertexBuffer.UV6Kind
  16601. * - VertexBuffer.ColorKind
  16602. * - VertexBuffer.MatricesIndicesKind
  16603. * - VertexBuffer.MatricesIndicesExtraKind
  16604. * - VertexBuffer.MatricesWeightsKind
  16605. * - VertexBuffer.MatricesWeightsExtraKind
  16606. *
  16607. * Returns the Mesh.
  16608. */
  16609. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16610. /**
  16611. * Sets the mesh indices.
  16612. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16613. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16614. * This method creates a new index buffer each call.
  16615. * Returns the Mesh.
  16616. */
  16617. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16618. /**
  16619. * Boolean : True if the mesh owns the requested kind of data.
  16620. */
  16621. isVerticesDataPresent(kind: string): boolean;
  16622. /**
  16623. * Returns an array of indices (IndicesArray).
  16624. */
  16625. getIndices(): Nullable<IndicesArray>;
  16626. get _positions(): Nullable<Vector3[]>;
  16627. /**
  16628. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16629. * This means the mesh underlying bounding box and sphere are recomputed.
  16630. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16631. * @returns the current mesh
  16632. */
  16633. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16634. /** @hidden */
  16635. _preActivate(): InstancedMesh;
  16636. /** @hidden */
  16637. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16638. /** @hidden */
  16639. _postActivate(): void;
  16640. getWorldMatrix(): Matrix;
  16641. get isAnInstance(): boolean;
  16642. /**
  16643. * Returns the current associated LOD AbstractMesh.
  16644. */
  16645. getLOD(camera: Camera): AbstractMesh;
  16646. /** @hidden */
  16647. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16648. /** @hidden */
  16649. _syncSubMeshes(): InstancedMesh;
  16650. /** @hidden */
  16651. _generatePointsArray(): boolean;
  16652. /**
  16653. * Creates a new InstancedMesh from the current mesh.
  16654. * - name (string) : the cloned mesh name
  16655. * - newParent (optional Node) : the optional Node to parent the clone to.
  16656. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16657. *
  16658. * Returns the clone.
  16659. */
  16660. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16661. /**
  16662. * Disposes the InstancedMesh.
  16663. * Returns nothing.
  16664. */
  16665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16666. }
  16667. module "babylonjs/Meshes/mesh" {
  16668. interface Mesh {
  16669. /**
  16670. * Register a custom buffer that will be instanced
  16671. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16672. * @param kind defines the buffer kind
  16673. * @param stride defines the stride in floats
  16674. */
  16675. registerInstancedBuffer(kind: string, stride: number): void;
  16676. /** @hidden */
  16677. _userInstancedBuffersStorage: {
  16678. data: {
  16679. [key: string]: Float32Array;
  16680. };
  16681. sizes: {
  16682. [key: string]: number;
  16683. };
  16684. vertexBuffers: {
  16685. [key: string]: Nullable<VertexBuffer>;
  16686. };
  16687. strides: {
  16688. [key: string]: number;
  16689. };
  16690. };
  16691. }
  16692. }
  16693. module "babylonjs/Meshes/abstractMesh" {
  16694. interface AbstractMesh {
  16695. /**
  16696. * Object used to store instanced buffers defined by user
  16697. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16698. */
  16699. instancedBuffers: {
  16700. [key: string]: any;
  16701. };
  16702. }
  16703. }
  16704. }
  16705. declare module "babylonjs/Materials/shaderMaterial" {
  16706. import { Nullable } from "babylonjs/types";
  16707. import { Scene } from "babylonjs/scene";
  16708. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16710. import { Mesh } from "babylonjs/Meshes/mesh";
  16711. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  16712. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16713. import { Effect } from "babylonjs/Materials/effect";
  16714. import { Material } from "babylonjs/Materials/material";
  16715. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16716. /**
  16717. * Defines the options associated with the creation of a shader material.
  16718. */
  16719. export interface IShaderMaterialOptions {
  16720. /**
  16721. * Does the material work in alpha blend mode
  16722. */
  16723. needAlphaBlending: boolean;
  16724. /**
  16725. * Does the material work in alpha test mode
  16726. */
  16727. needAlphaTesting: boolean;
  16728. /**
  16729. * The list of attribute names used in the shader
  16730. */
  16731. attributes: string[];
  16732. /**
  16733. * The list of unifrom names used in the shader
  16734. */
  16735. uniforms: string[];
  16736. /**
  16737. * The list of UBO names used in the shader
  16738. */
  16739. uniformBuffers: string[];
  16740. /**
  16741. * The list of sampler names used in the shader
  16742. */
  16743. samplers: string[];
  16744. /**
  16745. * The list of defines used in the shader
  16746. */
  16747. defines: string[];
  16748. }
  16749. /**
  16750. * 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.
  16751. *
  16752. * This returned material effects how the mesh will look based on the code in the shaders.
  16753. *
  16754. * @see http://doc.babylonjs.com/how_to/shader_material
  16755. */
  16756. export class ShaderMaterial extends Material {
  16757. private _shaderPath;
  16758. private _options;
  16759. private _textures;
  16760. private _textureArrays;
  16761. private _floats;
  16762. private _ints;
  16763. private _floatsArrays;
  16764. private _colors3;
  16765. private _colors3Arrays;
  16766. private _colors4;
  16767. private _colors4Arrays;
  16768. private _vectors2;
  16769. private _vectors3;
  16770. private _vectors4;
  16771. private _matrices;
  16772. private _matrixArrays;
  16773. private _matrices3x3;
  16774. private _matrices2x2;
  16775. private _vectors2Arrays;
  16776. private _vectors3Arrays;
  16777. private _vectors4Arrays;
  16778. private _cachedWorldViewMatrix;
  16779. private _cachedWorldViewProjectionMatrix;
  16780. private _renderId;
  16781. private _multiview;
  16782. private _cachedDefines;
  16783. /**
  16784. * Instantiate a new shader material.
  16785. * 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.
  16786. * This returned material effects how the mesh will look based on the code in the shaders.
  16787. * @see http://doc.babylonjs.com/how_to/shader_material
  16788. * @param name Define the name of the material in the scene
  16789. * @param scene Define the scene the material belongs to
  16790. * @param shaderPath Defines the route to the shader code in one of three ways:
  16791. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16792. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16793. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16794. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16795. * @param options Define the options used to create the shader
  16796. */
  16797. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16798. /**
  16799. * Gets the shader path used to define the shader code
  16800. * It can be modified to trigger a new compilation
  16801. */
  16802. get shaderPath(): any;
  16803. /**
  16804. * Sets the shader path used to define the shader code
  16805. * It can be modified to trigger a new compilation
  16806. */
  16807. set shaderPath(shaderPath: any);
  16808. /**
  16809. * Gets the options used to compile the shader.
  16810. * They can be modified to trigger a new compilation
  16811. */
  16812. get options(): IShaderMaterialOptions;
  16813. /**
  16814. * Gets the current class name of the material e.g. "ShaderMaterial"
  16815. * Mainly use in serialization.
  16816. * @returns the class name
  16817. */
  16818. getClassName(): string;
  16819. /**
  16820. * Specifies if the material will require alpha blending
  16821. * @returns a boolean specifying if alpha blending is needed
  16822. */
  16823. needAlphaBlending(): boolean;
  16824. /**
  16825. * Specifies if this material should be rendered in alpha test mode
  16826. * @returns a boolean specifying if an alpha test is needed.
  16827. */
  16828. needAlphaTesting(): boolean;
  16829. private _checkUniform;
  16830. /**
  16831. * Set a texture in the shader.
  16832. * @param name Define the name of the uniform samplers as defined in the shader
  16833. * @param texture Define the texture to bind to this sampler
  16834. * @return the material itself allowing "fluent" like uniform updates
  16835. */
  16836. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16837. /**
  16838. * Set a texture array in the shader.
  16839. * @param name Define the name of the uniform sampler array as defined in the shader
  16840. * @param textures Define the list of textures to bind to this sampler
  16841. * @return the material itself allowing "fluent" like uniform updates
  16842. */
  16843. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16844. /**
  16845. * Set a float in the shader.
  16846. * @param name Define the name of the uniform as defined in the shader
  16847. * @param value Define the value to give to the uniform
  16848. * @return the material itself allowing "fluent" like uniform updates
  16849. */
  16850. setFloat(name: string, value: number): ShaderMaterial;
  16851. /**
  16852. * Set a int in the shader.
  16853. * @param name Define the name of the uniform as defined in the shader
  16854. * @param value Define the value to give to the uniform
  16855. * @return the material itself allowing "fluent" like uniform updates
  16856. */
  16857. setInt(name: string, value: number): ShaderMaterial;
  16858. /**
  16859. * Set an array of floats in the shader.
  16860. * @param name Define the name of the uniform as defined in the shader
  16861. * @param value Define the value to give to the uniform
  16862. * @return the material itself allowing "fluent" like uniform updates
  16863. */
  16864. setFloats(name: string, value: number[]): ShaderMaterial;
  16865. /**
  16866. * Set a vec3 in the shader from a Color3.
  16867. * @param name Define the name of the uniform as defined in the shader
  16868. * @param value Define the value to give to the uniform
  16869. * @return the material itself allowing "fluent" like uniform updates
  16870. */
  16871. setColor3(name: string, value: Color3): ShaderMaterial;
  16872. /**
  16873. * Set a vec3 array in the shader from a Color3 array.
  16874. * @param name Define the name of the uniform as defined in the shader
  16875. * @param value Define the value to give to the uniform
  16876. * @return the material itself allowing "fluent" like uniform updates
  16877. */
  16878. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16879. /**
  16880. * Set a vec4 in the shader from a Color4.
  16881. * @param name Define the name of the uniform as defined in the shader
  16882. * @param value Define the value to give to the uniform
  16883. * @return the material itself allowing "fluent" like uniform updates
  16884. */
  16885. setColor4(name: string, value: Color4): ShaderMaterial;
  16886. /**
  16887. * Set a vec4 array in the shader from a Color4 array.
  16888. * @param name Define the name of the uniform as defined in the shader
  16889. * @param value Define the value to give to the uniform
  16890. * @return the material itself allowing "fluent" like uniform updates
  16891. */
  16892. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16893. /**
  16894. * Set a vec2 in the shader from a Vector2.
  16895. * @param name Define the name of the uniform as defined in the shader
  16896. * @param value Define the value to give to the uniform
  16897. * @return the material itself allowing "fluent" like uniform updates
  16898. */
  16899. setVector2(name: string, value: Vector2): ShaderMaterial;
  16900. /**
  16901. * Set a vec3 in the shader from a Vector3.
  16902. * @param name Define the name of the uniform as defined in the shader
  16903. * @param value Define the value to give to the uniform
  16904. * @return the material itself allowing "fluent" like uniform updates
  16905. */
  16906. setVector3(name: string, value: Vector3): ShaderMaterial;
  16907. /**
  16908. * Set a vec4 in the shader from a Vector4.
  16909. * @param name Define the name of the uniform as defined in the shader
  16910. * @param value Define the value to give to the uniform
  16911. * @return the material itself allowing "fluent" like uniform updates
  16912. */
  16913. setVector4(name: string, value: Vector4): ShaderMaterial;
  16914. /**
  16915. * Set a mat4 in the shader from a Matrix.
  16916. * @param name Define the name of the uniform as defined in the shader
  16917. * @param value Define the value to give to the uniform
  16918. * @return the material itself allowing "fluent" like uniform updates
  16919. */
  16920. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16921. /**
  16922. * Set a float32Array in the shader from a matrix array.
  16923. * @param name Define the name of the uniform as defined in the shader
  16924. * @param value Define the value to give to the uniform
  16925. * @return the material itself allowing "fluent" like uniform updates
  16926. */
  16927. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16928. /**
  16929. * Set a mat3 in the shader from a Float32Array.
  16930. * @param name Define the name of the uniform as defined in the shader
  16931. * @param value Define the value to give to the uniform
  16932. * @return the material itself allowing "fluent" like uniform updates
  16933. */
  16934. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16935. /**
  16936. * Set a mat2 in the shader from a Float32Array.
  16937. * @param name Define the name of the uniform as defined in the shader
  16938. * @param value Define the value to give to the uniform
  16939. * @return the material itself allowing "fluent" like uniform updates
  16940. */
  16941. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16942. /**
  16943. * Set a vec2 array in the shader from a number array.
  16944. * @param name Define the name of the uniform as defined in the shader
  16945. * @param value Define the value to give to the uniform
  16946. * @return the material itself allowing "fluent" like uniform updates
  16947. */
  16948. setArray2(name: string, value: number[]): ShaderMaterial;
  16949. /**
  16950. * Set a vec3 array in the shader from a number array.
  16951. * @param name Define the name of the uniform as defined in the shader
  16952. * @param value Define the value to give to the uniform
  16953. * @return the material itself allowing "fluent" like uniform updates
  16954. */
  16955. setArray3(name: string, value: number[]): ShaderMaterial;
  16956. /**
  16957. * Set a vec4 array in the shader from a number array.
  16958. * @param name Define the name of the uniform as defined in the shader
  16959. * @param value Define the value to give to the uniform
  16960. * @return the material itself allowing "fluent" like uniform updates
  16961. */
  16962. setArray4(name: string, value: number[]): ShaderMaterial;
  16963. private _checkCache;
  16964. /**
  16965. * Specifies that the submesh is ready to be used
  16966. * @param mesh defines the mesh to check
  16967. * @param subMesh defines which submesh to check
  16968. * @param useInstances specifies that instances should be used
  16969. * @returns a boolean indicating that the submesh is ready or not
  16970. */
  16971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16972. /**
  16973. * Checks if the material is ready to render the requested mesh
  16974. * @param mesh Define the mesh to render
  16975. * @param useInstances Define whether or not the material is used with instances
  16976. * @returns true if ready, otherwise false
  16977. */
  16978. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16979. /**
  16980. * Binds the world matrix to the material
  16981. * @param world defines the world transformation matrix
  16982. * @param effectOverride - If provided, use this effect instead of internal effect
  16983. */
  16984. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16985. /**
  16986. * Binds the submesh to this material by preparing the effect and shader to draw
  16987. * @param world defines the world transformation matrix
  16988. * @param mesh defines the mesh containing the submesh
  16989. * @param subMesh defines the submesh to bind the material to
  16990. */
  16991. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16992. /**
  16993. * Binds the material to the mesh
  16994. * @param world defines the world transformation matrix
  16995. * @param mesh defines the mesh to bind the material to
  16996. * @param effectOverride - If provided, use this effect instead of internal effect
  16997. */
  16998. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16999. protected _afterBind(mesh?: Mesh): void;
  17000. /**
  17001. * Gets the active textures from the material
  17002. * @returns an array of textures
  17003. */
  17004. getActiveTextures(): BaseTexture[];
  17005. /**
  17006. * Specifies if the material uses a texture
  17007. * @param texture defines the texture to check against the material
  17008. * @returns a boolean specifying if the material uses the texture
  17009. */
  17010. hasTexture(texture: BaseTexture): boolean;
  17011. /**
  17012. * Makes a duplicate of the material, and gives it a new name
  17013. * @param name defines the new name for the duplicated material
  17014. * @returns the cloned material
  17015. */
  17016. clone(name: string): ShaderMaterial;
  17017. /**
  17018. * Disposes the material
  17019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17021. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17022. */
  17023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17024. /**
  17025. * Serializes this material in a JSON representation
  17026. * @returns the serialized material object
  17027. */
  17028. serialize(): any;
  17029. /**
  17030. * Creates a shader material from parsed shader material data
  17031. * @param source defines the JSON represnetation of the material
  17032. * @param scene defines the hosting scene
  17033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17034. * @returns a new material
  17035. */
  17036. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17037. }
  17038. }
  17039. declare module "babylonjs/Shaders/color.fragment" {
  17040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17041. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17042. /** @hidden */
  17043. export var colorPixelShader: {
  17044. name: string;
  17045. shader: string;
  17046. };
  17047. }
  17048. declare module "babylonjs/Shaders/color.vertex" {
  17049. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17051. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17052. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17053. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17054. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17055. /** @hidden */
  17056. export var colorVertexShader: {
  17057. name: string;
  17058. shader: string;
  17059. };
  17060. }
  17061. declare module "babylonjs/Meshes/linesMesh" {
  17062. import { Nullable } from "babylonjs/types";
  17063. import { Scene } from "babylonjs/scene";
  17064. import { Color3 } from "babylonjs/Maths/math.color";
  17065. import { Node } from "babylonjs/node";
  17066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17067. import { Mesh } from "babylonjs/Meshes/mesh";
  17068. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17069. import { Effect } from "babylonjs/Materials/effect";
  17070. import { Material } from "babylonjs/Materials/material";
  17071. import "babylonjs/Shaders/color.fragment";
  17072. import "babylonjs/Shaders/color.vertex";
  17073. /**
  17074. * Line mesh
  17075. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17076. */
  17077. export class LinesMesh extends Mesh {
  17078. /**
  17079. * If vertex color should be applied to the mesh
  17080. */
  17081. readonly useVertexColor?: boolean | undefined;
  17082. /**
  17083. * If vertex alpha should be applied to the mesh
  17084. */
  17085. readonly useVertexAlpha?: boolean | undefined;
  17086. /**
  17087. * Color of the line (Default: White)
  17088. */
  17089. color: Color3;
  17090. /**
  17091. * Alpha of the line (Default: 1)
  17092. */
  17093. alpha: number;
  17094. /**
  17095. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17096. * This margin is expressed in world space coordinates, so its value may vary.
  17097. * Default value is 0.1
  17098. */
  17099. intersectionThreshold: number;
  17100. private _colorShader;
  17101. private color4;
  17102. /**
  17103. * Creates a new LinesMesh
  17104. * @param name defines the name
  17105. * @param scene defines the hosting scene
  17106. * @param parent defines the parent mesh if any
  17107. * @param source defines the optional source LinesMesh used to clone data from
  17108. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17109. * When false, achieved by calling a clone(), also passing False.
  17110. * This will make creation of children, recursive.
  17111. * @param useVertexColor defines if this LinesMesh supports vertex color
  17112. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17113. */
  17114. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17115. /**
  17116. * If vertex color should be applied to the mesh
  17117. */
  17118. useVertexColor?: boolean | undefined,
  17119. /**
  17120. * If vertex alpha should be applied to the mesh
  17121. */
  17122. useVertexAlpha?: boolean | undefined);
  17123. private _addClipPlaneDefine;
  17124. private _removeClipPlaneDefine;
  17125. isReady(): boolean;
  17126. /**
  17127. * Returns the string "LineMesh"
  17128. */
  17129. getClassName(): string;
  17130. /**
  17131. * @hidden
  17132. */
  17133. get material(): Material;
  17134. /**
  17135. * @hidden
  17136. */
  17137. set material(value: Material);
  17138. /**
  17139. * @hidden
  17140. */
  17141. get checkCollisions(): boolean;
  17142. /** @hidden */
  17143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17144. /** @hidden */
  17145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17146. /**
  17147. * Disposes of the line mesh
  17148. * @param doNotRecurse If children should be disposed
  17149. */
  17150. dispose(doNotRecurse?: boolean): void;
  17151. /**
  17152. * Returns a new LineMesh object cloned from the current one.
  17153. */
  17154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17155. /**
  17156. * Creates a new InstancedLinesMesh object from the mesh model.
  17157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17158. * @param name defines the name of the new instance
  17159. * @returns a new InstancedLinesMesh
  17160. */
  17161. createInstance(name: string): InstancedLinesMesh;
  17162. }
  17163. /**
  17164. * Creates an instance based on a source LinesMesh
  17165. */
  17166. export class InstancedLinesMesh extends InstancedMesh {
  17167. /**
  17168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17169. * This margin is expressed in world space coordinates, so its value may vary.
  17170. * Initilized with the intersectionThreshold value of the source LinesMesh
  17171. */
  17172. intersectionThreshold: number;
  17173. constructor(name: string, source: LinesMesh);
  17174. /**
  17175. * Returns the string "InstancedLinesMesh".
  17176. */
  17177. getClassName(): string;
  17178. }
  17179. }
  17180. declare module "babylonjs/Shaders/line.fragment" {
  17181. /** @hidden */
  17182. export var linePixelShader: {
  17183. name: string;
  17184. shader: string;
  17185. };
  17186. }
  17187. declare module "babylonjs/Shaders/line.vertex" {
  17188. /** @hidden */
  17189. export var lineVertexShader: {
  17190. name: string;
  17191. shader: string;
  17192. };
  17193. }
  17194. declare module "babylonjs/Rendering/edgesRenderer" {
  17195. import { Nullable } from "babylonjs/types";
  17196. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17198. import { Vector3 } from "babylonjs/Maths/math.vector";
  17199. import { IDisposable } from "babylonjs/scene";
  17200. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17201. import "babylonjs/Shaders/line.fragment";
  17202. import "babylonjs/Shaders/line.vertex";
  17203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17204. module "babylonjs/Meshes/abstractMesh" {
  17205. interface AbstractMesh {
  17206. /**
  17207. * Gets the edgesRenderer associated with the mesh
  17208. */
  17209. edgesRenderer: Nullable<EdgesRenderer>;
  17210. }
  17211. }
  17212. module "babylonjs/Meshes/linesMesh" {
  17213. interface LinesMesh {
  17214. /**
  17215. * Enables the edge rendering mode on the mesh.
  17216. * This mode makes the mesh edges visible
  17217. * @param epsilon defines the maximal distance between two angles to detect a face
  17218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17219. * @returns the currentAbstractMesh
  17220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17221. */
  17222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17223. }
  17224. }
  17225. module "babylonjs/Meshes/linesMesh" {
  17226. interface InstancedLinesMesh {
  17227. /**
  17228. * Enables the edge rendering mode on the mesh.
  17229. * This mode makes the mesh edges visible
  17230. * @param epsilon defines the maximal distance between two angles to detect a face
  17231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17232. * @returns the current InstancedLinesMesh
  17233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17234. */
  17235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17236. }
  17237. }
  17238. /**
  17239. * Defines the minimum contract an Edges renderer should follow.
  17240. */
  17241. export interface IEdgesRenderer extends IDisposable {
  17242. /**
  17243. * Gets or sets a boolean indicating if the edgesRenderer is active
  17244. */
  17245. isEnabled: boolean;
  17246. /**
  17247. * Renders the edges of the attached mesh,
  17248. */
  17249. render(): void;
  17250. /**
  17251. * Checks wether or not the edges renderer is ready to render.
  17252. * @return true if ready, otherwise false.
  17253. */
  17254. isReady(): boolean;
  17255. }
  17256. /**
  17257. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17258. */
  17259. export class EdgesRenderer implements IEdgesRenderer {
  17260. /**
  17261. * Define the size of the edges with an orthographic camera
  17262. */
  17263. edgesWidthScalerForOrthographic: number;
  17264. /**
  17265. * Define the size of the edges with a perspective camera
  17266. */
  17267. edgesWidthScalerForPerspective: number;
  17268. protected _source: AbstractMesh;
  17269. protected _linesPositions: number[];
  17270. protected _linesNormals: number[];
  17271. protected _linesIndices: number[];
  17272. protected _epsilon: number;
  17273. protected _indicesCount: number;
  17274. protected _lineShader: ShaderMaterial;
  17275. protected _ib: DataBuffer;
  17276. protected _buffers: {
  17277. [key: string]: Nullable<VertexBuffer>;
  17278. };
  17279. protected _checkVerticesInsteadOfIndices: boolean;
  17280. private _meshRebuildObserver;
  17281. private _meshDisposeObserver;
  17282. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17283. isEnabled: boolean;
  17284. /**
  17285. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17286. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17287. * @param source Mesh used to create edges
  17288. * @param epsilon sum of angles in adjacency to check for edge
  17289. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17290. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17291. */
  17292. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17293. protected _prepareRessources(): void;
  17294. /** @hidden */
  17295. _rebuild(): void;
  17296. /**
  17297. * Releases the required resources for the edges renderer
  17298. */
  17299. dispose(): void;
  17300. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17301. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17302. /**
  17303. * Checks if the pair of p0 and p1 is en edge
  17304. * @param faceIndex
  17305. * @param edge
  17306. * @param faceNormals
  17307. * @param p0
  17308. * @param p1
  17309. * @private
  17310. */
  17311. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17312. /**
  17313. * push line into the position, normal and index buffer
  17314. * @protected
  17315. */
  17316. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17317. /**
  17318. * Generates lines edges from adjacencjes
  17319. * @private
  17320. */
  17321. _generateEdgesLines(): void;
  17322. /**
  17323. * Checks wether or not the edges renderer is ready to render.
  17324. * @return true if ready, otherwise false.
  17325. */
  17326. isReady(): boolean;
  17327. /**
  17328. * Renders the edges of the attached mesh,
  17329. */
  17330. render(): void;
  17331. }
  17332. /**
  17333. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17334. */
  17335. export class LineEdgesRenderer extends EdgesRenderer {
  17336. /**
  17337. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17338. * @param source LineMesh used to generate edges
  17339. * @param epsilon not important (specified angle for edge detection)
  17340. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17341. */
  17342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17343. /**
  17344. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17345. */
  17346. _generateEdgesLines(): void;
  17347. }
  17348. }
  17349. declare module "babylonjs/Rendering/renderingGroup" {
  17350. import { SmartArray } from "babylonjs/Misc/smartArray";
  17351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17353. import { Nullable } from "babylonjs/types";
  17354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17355. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17356. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17357. import { Material } from "babylonjs/Materials/material";
  17358. import { Scene } from "babylonjs/scene";
  17359. /**
  17360. * This represents the object necessary to create a rendering group.
  17361. * This is exclusively used and created by the rendering manager.
  17362. * To modify the behavior, you use the available helpers in your scene or meshes.
  17363. * @hidden
  17364. */
  17365. export class RenderingGroup {
  17366. index: number;
  17367. private static _zeroVector;
  17368. private _scene;
  17369. private _opaqueSubMeshes;
  17370. private _transparentSubMeshes;
  17371. private _alphaTestSubMeshes;
  17372. private _depthOnlySubMeshes;
  17373. private _particleSystems;
  17374. private _spriteManagers;
  17375. private _opaqueSortCompareFn;
  17376. private _alphaTestSortCompareFn;
  17377. private _transparentSortCompareFn;
  17378. private _renderOpaque;
  17379. private _renderAlphaTest;
  17380. private _renderTransparent;
  17381. /** @hidden */
  17382. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17383. onBeforeTransparentRendering: () => void;
  17384. /**
  17385. * Set the opaque sort comparison function.
  17386. * If null the sub meshes will be render in the order they were created
  17387. */
  17388. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17389. /**
  17390. * Set the alpha test sort comparison function.
  17391. * If null the sub meshes will be render in the order they were created
  17392. */
  17393. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17394. /**
  17395. * Set the transparent sort comparison function.
  17396. * If null the sub meshes will be render in the order they were created
  17397. */
  17398. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17399. /**
  17400. * Creates a new rendering group.
  17401. * @param index The rendering group index
  17402. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17403. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17404. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17405. */
  17406. 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>);
  17407. /**
  17408. * Render all the sub meshes contained in the group.
  17409. * @param customRenderFunction Used to override the default render behaviour of the group.
  17410. * @returns true if rendered some submeshes.
  17411. */
  17412. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17413. /**
  17414. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17415. * @param subMeshes The submeshes to render
  17416. */
  17417. private renderOpaqueSorted;
  17418. /**
  17419. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17420. * @param subMeshes The submeshes to render
  17421. */
  17422. private renderAlphaTestSorted;
  17423. /**
  17424. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17425. * @param subMeshes The submeshes to render
  17426. */
  17427. private renderTransparentSorted;
  17428. /**
  17429. * Renders the submeshes in a specified order.
  17430. * @param subMeshes The submeshes to sort before render
  17431. * @param sortCompareFn The comparison function use to sort
  17432. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17433. * @param transparent Specifies to activate blending if true
  17434. */
  17435. private static renderSorted;
  17436. /**
  17437. * Renders the submeshes in the order they were dispatched (no sort applied).
  17438. * @param subMeshes The submeshes to render
  17439. */
  17440. private static renderUnsorted;
  17441. /**
  17442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17443. * are rendered back to front if in the same alpha index.
  17444. *
  17445. * @param a The first submesh
  17446. * @param b The second submesh
  17447. * @returns The result of the comparison
  17448. */
  17449. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17450. /**
  17451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17452. * are rendered back to front.
  17453. *
  17454. * @param a The first submesh
  17455. * @param b The second submesh
  17456. * @returns The result of the comparison
  17457. */
  17458. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17459. /**
  17460. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17461. * are rendered front to back (prevent overdraw).
  17462. *
  17463. * @param a The first submesh
  17464. * @param b The second submesh
  17465. * @returns The result of the comparison
  17466. */
  17467. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17468. /**
  17469. * Resets the different lists of submeshes to prepare a new frame.
  17470. */
  17471. prepare(): void;
  17472. dispose(): void;
  17473. /**
  17474. * Inserts the submesh in its correct queue depending on its material.
  17475. * @param subMesh The submesh to dispatch
  17476. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17477. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17478. */
  17479. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17480. dispatchSprites(spriteManager: ISpriteManager): void;
  17481. dispatchParticles(particleSystem: IParticleSystem): void;
  17482. private _renderParticles;
  17483. private _renderSprites;
  17484. }
  17485. }
  17486. declare module "babylonjs/Rendering/renderingManager" {
  17487. import { Nullable } from "babylonjs/types";
  17488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17490. import { SmartArray } from "babylonjs/Misc/smartArray";
  17491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17492. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17493. import { Material } from "babylonjs/Materials/material";
  17494. import { Scene } from "babylonjs/scene";
  17495. import { Camera } from "babylonjs/Cameras/camera";
  17496. /**
  17497. * Interface describing the different options available in the rendering manager
  17498. * regarding Auto Clear between groups.
  17499. */
  17500. export interface IRenderingManagerAutoClearSetup {
  17501. /**
  17502. * Defines whether or not autoclear is enable.
  17503. */
  17504. autoClear: boolean;
  17505. /**
  17506. * Defines whether or not to autoclear the depth buffer.
  17507. */
  17508. depth: boolean;
  17509. /**
  17510. * Defines whether or not to autoclear the stencil buffer.
  17511. */
  17512. stencil: boolean;
  17513. }
  17514. /**
  17515. * This class is used by the onRenderingGroupObservable
  17516. */
  17517. export class RenderingGroupInfo {
  17518. /**
  17519. * The Scene that being rendered
  17520. */
  17521. scene: Scene;
  17522. /**
  17523. * The camera currently used for the rendering pass
  17524. */
  17525. camera: Nullable<Camera>;
  17526. /**
  17527. * The ID of the renderingGroup being processed
  17528. */
  17529. renderingGroupId: number;
  17530. }
  17531. /**
  17532. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17533. * It is enable to manage the different groups as well as the different necessary sort functions.
  17534. * This should not be used directly aside of the few static configurations
  17535. */
  17536. export class RenderingManager {
  17537. /**
  17538. * The max id used for rendering groups (not included)
  17539. */
  17540. static MAX_RENDERINGGROUPS: number;
  17541. /**
  17542. * The min id used for rendering groups (included)
  17543. */
  17544. static MIN_RENDERINGGROUPS: number;
  17545. /**
  17546. * Used to globally prevent autoclearing scenes.
  17547. */
  17548. static AUTOCLEAR: boolean;
  17549. /**
  17550. * @hidden
  17551. */
  17552. _useSceneAutoClearSetup: boolean;
  17553. private _scene;
  17554. private _renderingGroups;
  17555. private _depthStencilBufferAlreadyCleaned;
  17556. private _autoClearDepthStencil;
  17557. private _customOpaqueSortCompareFn;
  17558. private _customAlphaTestSortCompareFn;
  17559. private _customTransparentSortCompareFn;
  17560. private _renderingGroupInfo;
  17561. /**
  17562. * Instantiates a new rendering group for a particular scene
  17563. * @param scene Defines the scene the groups belongs to
  17564. */
  17565. constructor(scene: Scene);
  17566. private _clearDepthStencilBuffer;
  17567. /**
  17568. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17569. * @hidden
  17570. */
  17571. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17572. /**
  17573. * Resets the different information of the group to prepare a new frame
  17574. * @hidden
  17575. */
  17576. reset(): void;
  17577. /**
  17578. * Dispose and release the group and its associated resources.
  17579. * @hidden
  17580. */
  17581. dispose(): void;
  17582. /**
  17583. * Clear the info related to rendering groups preventing retention points during dispose.
  17584. */
  17585. freeRenderingGroups(): void;
  17586. private _prepareRenderingGroup;
  17587. /**
  17588. * Add a sprite manager to the rendering manager in order to render it this frame.
  17589. * @param spriteManager Define the sprite manager to render
  17590. */
  17591. dispatchSprites(spriteManager: ISpriteManager): void;
  17592. /**
  17593. * Add a particle system to the rendering manager in order to render it this frame.
  17594. * @param particleSystem Define the particle system to render
  17595. */
  17596. dispatchParticles(particleSystem: IParticleSystem): void;
  17597. /**
  17598. * Add a submesh to the manager in order to render it this frame
  17599. * @param subMesh The submesh to dispatch
  17600. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17601. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17602. */
  17603. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17604. /**
  17605. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17606. * This allowed control for front to back rendering or reversly depending of the special needs.
  17607. *
  17608. * @param renderingGroupId The rendering group id corresponding to its index
  17609. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17610. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17611. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17612. */
  17613. 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;
  17614. /**
  17615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17616. *
  17617. * @param renderingGroupId The rendering group id corresponding to its index
  17618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17619. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17620. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17621. */
  17622. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17623. /**
  17624. * Gets the current auto clear configuration for one rendering group of the rendering
  17625. * manager.
  17626. * @param index the rendering group index to get the information for
  17627. * @returns The auto clear setup for the requested rendering group
  17628. */
  17629. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17630. }
  17631. }
  17632. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17633. import { SmartArray } from "babylonjs/Misc/smartArray";
  17634. import { Nullable } from "babylonjs/types";
  17635. import { Scene } from "babylonjs/scene";
  17636. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17639. import { Mesh } from "babylonjs/Meshes/mesh";
  17640. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17641. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17642. import { Effect } from "babylonjs/Materials/effect";
  17643. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17644. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17645. import "babylonjs/Shaders/shadowMap.fragment";
  17646. import "babylonjs/Shaders/shadowMap.vertex";
  17647. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17648. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17649. import { Observable } from "babylonjs/Misc/observable";
  17650. /**
  17651. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17652. */
  17653. export interface ICustomShaderOptions {
  17654. /**
  17655. * Gets or sets the custom shader name to use
  17656. */
  17657. shaderName: string;
  17658. /**
  17659. * The list of attribute names used in the shader
  17660. */
  17661. attributes?: string[];
  17662. /**
  17663. * The list of unifrom names used in the shader
  17664. */
  17665. uniforms?: string[];
  17666. /**
  17667. * The list of sampler names used in the shader
  17668. */
  17669. samplers?: string[];
  17670. /**
  17671. * The list of defines used in the shader
  17672. */
  17673. defines?: string[];
  17674. }
  17675. /**
  17676. * Interface to implement to create a shadow generator compatible with BJS.
  17677. */
  17678. export interface IShadowGenerator {
  17679. /**
  17680. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17681. * @returns The render target texture if present otherwise, null
  17682. */
  17683. getShadowMap(): Nullable<RenderTargetTexture>;
  17684. /**
  17685. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17686. * @param subMesh The submesh we want to render in the shadow map
  17687. * @param useInstances Defines wether will draw in the map using instances
  17688. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17689. * @returns true if ready otherwise, false
  17690. */
  17691. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17692. /**
  17693. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17694. * @param defines Defines of the material we want to update
  17695. * @param lightIndex Index of the light in the enabled light list of the material
  17696. */
  17697. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17698. /**
  17699. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17700. * defined in the generator but impacting the effect).
  17701. * It implies the unifroms available on the materials are the standard BJS ones.
  17702. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17703. * @param effect The effect we are binfing the information for
  17704. */
  17705. bindShadowLight(lightIndex: string, effect: Effect): void;
  17706. /**
  17707. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17708. * (eq to shadow prjection matrix * light transform matrix)
  17709. * @returns The transform matrix used to create the shadow map
  17710. */
  17711. getTransformMatrix(): Matrix;
  17712. /**
  17713. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17714. * Cube and 2D textures for instance.
  17715. */
  17716. recreateShadowMap(): void;
  17717. /**
  17718. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17719. * @param onCompiled Callback triggered at the and of the effects compilation
  17720. * @param options Sets of optional options forcing the compilation with different modes
  17721. */
  17722. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17723. useInstances: boolean;
  17724. }>): void;
  17725. /**
  17726. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17727. * @param options Sets of optional options forcing the compilation with different modes
  17728. * @returns A promise that resolves when the compilation completes
  17729. */
  17730. forceCompilationAsync(options?: Partial<{
  17731. useInstances: boolean;
  17732. }>): Promise<void>;
  17733. /**
  17734. * Serializes the shadow generator setup to a json object.
  17735. * @returns The serialized JSON object
  17736. */
  17737. serialize(): any;
  17738. /**
  17739. * Disposes the Shadow map and related Textures and effects.
  17740. */
  17741. dispose(): void;
  17742. }
  17743. /**
  17744. * Default implementation IShadowGenerator.
  17745. * This is the main object responsible of generating shadows in the framework.
  17746. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17747. */
  17748. export class ShadowGenerator implements IShadowGenerator {
  17749. /**
  17750. * Name of the shadow generator class
  17751. */
  17752. static CLASSNAME: string;
  17753. /**
  17754. * Shadow generator mode None: no filtering applied.
  17755. */
  17756. static readonly FILTER_NONE: number;
  17757. /**
  17758. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17759. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17760. */
  17761. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17762. /**
  17763. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17764. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17765. */
  17766. static readonly FILTER_POISSONSAMPLING: number;
  17767. /**
  17768. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17769. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17770. */
  17771. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17772. /**
  17773. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17774. * edge artifacts on steep falloff.
  17775. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17776. */
  17777. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17778. /**
  17779. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17780. * edge artifacts on steep falloff.
  17781. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17782. */
  17783. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17784. /**
  17785. * Shadow generator mode PCF: Percentage Closer Filtering
  17786. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17787. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17788. */
  17789. static readonly FILTER_PCF: number;
  17790. /**
  17791. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17792. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17793. * Contact Hardening
  17794. */
  17795. static readonly FILTER_PCSS: number;
  17796. /**
  17797. * Reserved for PCF and PCSS
  17798. * Highest Quality.
  17799. *
  17800. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17801. *
  17802. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17803. */
  17804. static readonly QUALITY_HIGH: number;
  17805. /**
  17806. * Reserved for PCF and PCSS
  17807. * Good tradeoff for quality/perf cross devices
  17808. *
  17809. * Execute PCF on a 3*3 kernel.
  17810. *
  17811. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17812. */
  17813. static readonly QUALITY_MEDIUM: number;
  17814. /**
  17815. * Reserved for PCF and PCSS
  17816. * The lowest quality but the fastest.
  17817. *
  17818. * Execute PCF on a 1*1 kernel.
  17819. *
  17820. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17821. */
  17822. static readonly QUALITY_LOW: number;
  17823. /** Gets or sets the custom shader name to use */
  17824. customShaderOptions: ICustomShaderOptions;
  17825. /**
  17826. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17827. */
  17828. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17829. /**
  17830. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17831. */
  17832. onAfterShadowMapRenderObservable: Observable<Effect>;
  17833. /**
  17834. * Observable triggered before a mesh is rendered in the shadow map.
  17835. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17836. */
  17837. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17838. /**
  17839. * Observable triggered after a mesh is rendered in the shadow map.
  17840. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17841. */
  17842. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17843. protected _bias: number;
  17844. /**
  17845. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17846. */
  17847. get bias(): number;
  17848. /**
  17849. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17850. */
  17851. set bias(bias: number);
  17852. protected _normalBias: number;
  17853. /**
  17854. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17855. */
  17856. get normalBias(): number;
  17857. /**
  17858. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17859. */
  17860. set normalBias(normalBias: number);
  17861. protected _blurBoxOffset: number;
  17862. /**
  17863. * Gets the blur box offset: offset applied during the blur pass.
  17864. * Only useful if useKernelBlur = false
  17865. */
  17866. get blurBoxOffset(): number;
  17867. /**
  17868. * Sets the blur box offset: offset applied during the blur pass.
  17869. * Only useful if useKernelBlur = false
  17870. */
  17871. set blurBoxOffset(value: number);
  17872. protected _blurScale: number;
  17873. /**
  17874. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17875. * 2 means half of the size.
  17876. */
  17877. get blurScale(): number;
  17878. /**
  17879. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17880. * 2 means half of the size.
  17881. */
  17882. set blurScale(value: number);
  17883. protected _blurKernel: number;
  17884. /**
  17885. * Gets the blur kernel: kernel size of the blur pass.
  17886. * Only useful if useKernelBlur = true
  17887. */
  17888. get blurKernel(): number;
  17889. /**
  17890. * Sets the blur kernel: kernel size of the blur pass.
  17891. * Only useful if useKernelBlur = true
  17892. */
  17893. set blurKernel(value: number);
  17894. protected _useKernelBlur: boolean;
  17895. /**
  17896. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17897. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17898. */
  17899. get useKernelBlur(): boolean;
  17900. /**
  17901. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17902. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17903. */
  17904. set useKernelBlur(value: boolean);
  17905. protected _depthScale: number;
  17906. /**
  17907. * Gets the depth scale used in ESM mode.
  17908. */
  17909. get depthScale(): number;
  17910. /**
  17911. * Sets the depth scale used in ESM mode.
  17912. * This can override the scale stored on the light.
  17913. */
  17914. set depthScale(value: number);
  17915. protected _validateFilter(filter: number): number;
  17916. protected _filter: number;
  17917. /**
  17918. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17919. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17920. */
  17921. get filter(): number;
  17922. /**
  17923. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17924. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17925. */
  17926. set filter(value: number);
  17927. /**
  17928. * Gets if the current filter is set to Poisson Sampling.
  17929. */
  17930. get usePoissonSampling(): boolean;
  17931. /**
  17932. * Sets the current filter to Poisson Sampling.
  17933. */
  17934. set usePoissonSampling(value: boolean);
  17935. /**
  17936. * Gets if the current filter is set to ESM.
  17937. */
  17938. get useExponentialShadowMap(): boolean;
  17939. /**
  17940. * Sets the current filter is to ESM.
  17941. */
  17942. set useExponentialShadowMap(value: boolean);
  17943. /**
  17944. * Gets if the current filter is set to filtered ESM.
  17945. */
  17946. get useBlurExponentialShadowMap(): boolean;
  17947. /**
  17948. * Gets if the current filter is set to filtered ESM.
  17949. */
  17950. set useBlurExponentialShadowMap(value: boolean);
  17951. /**
  17952. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17953. * exponential to prevent steep falloff artifacts).
  17954. */
  17955. get useCloseExponentialShadowMap(): boolean;
  17956. /**
  17957. * Sets the current filter to "close ESM" (using the inverse of the
  17958. * exponential to prevent steep falloff artifacts).
  17959. */
  17960. set useCloseExponentialShadowMap(value: boolean);
  17961. /**
  17962. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17963. * exponential to prevent steep falloff artifacts).
  17964. */
  17965. get useBlurCloseExponentialShadowMap(): boolean;
  17966. /**
  17967. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17968. * exponential to prevent steep falloff artifacts).
  17969. */
  17970. set useBlurCloseExponentialShadowMap(value: boolean);
  17971. /**
  17972. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17973. */
  17974. get usePercentageCloserFiltering(): boolean;
  17975. /**
  17976. * Sets the current filter to "PCF" (percentage closer filtering).
  17977. */
  17978. set usePercentageCloserFiltering(value: boolean);
  17979. protected _filteringQuality: number;
  17980. /**
  17981. * Gets the PCF or PCSS Quality.
  17982. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17983. */
  17984. get filteringQuality(): number;
  17985. /**
  17986. * Sets the PCF or PCSS Quality.
  17987. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17988. */
  17989. set filteringQuality(filteringQuality: number);
  17990. /**
  17991. * Gets if the current filter is set to "PCSS" (contact hardening).
  17992. */
  17993. get useContactHardeningShadow(): boolean;
  17994. /**
  17995. * Sets the current filter to "PCSS" (contact hardening).
  17996. */
  17997. set useContactHardeningShadow(value: boolean);
  17998. protected _contactHardeningLightSizeUVRatio: number;
  17999. /**
  18000. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18001. * Using a ratio helps keeping shape stability independently of the map size.
  18002. *
  18003. * It does not account for the light projection as it was having too much
  18004. * instability during the light setup or during light position changes.
  18005. *
  18006. * Only valid if useContactHardeningShadow is true.
  18007. */
  18008. get contactHardeningLightSizeUVRatio(): number;
  18009. /**
  18010. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18011. * Using a ratio helps keeping shape stability independently of the map size.
  18012. *
  18013. * It does not account for the light projection as it was having too much
  18014. * instability during the light setup or during light position changes.
  18015. *
  18016. * Only valid if useContactHardeningShadow is true.
  18017. */
  18018. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18019. protected _darkness: number;
  18020. /** Gets or sets the actual darkness of a shadow */
  18021. get darkness(): number;
  18022. set darkness(value: number);
  18023. /**
  18024. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18025. * 0 means strongest and 1 would means no shadow.
  18026. * @returns the darkness.
  18027. */
  18028. getDarkness(): number;
  18029. /**
  18030. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18031. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18032. * @returns the shadow generator allowing fluent coding.
  18033. */
  18034. setDarkness(darkness: number): ShadowGenerator;
  18035. protected _transparencyShadow: boolean;
  18036. /** Gets or sets the ability to have transparent shadow */
  18037. get transparencyShadow(): boolean;
  18038. set transparencyShadow(value: boolean);
  18039. /**
  18040. * Sets the ability to have transparent shadow (boolean).
  18041. * @param transparent True if transparent else False
  18042. * @returns the shadow generator allowing fluent coding
  18043. */
  18044. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18045. /**
  18046. * Enables or disables shadows with varying strength based on the transparency
  18047. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18048. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18049. * mesh.visibility * alphaTexture.a
  18050. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18051. */
  18052. enableSoftTransparentShadow: boolean;
  18053. protected _shadowMap: Nullable<RenderTargetTexture>;
  18054. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18055. /**
  18056. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18057. * @returns The render target texture if present otherwise, null
  18058. */
  18059. getShadowMap(): Nullable<RenderTargetTexture>;
  18060. /**
  18061. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18062. * @returns The render target texture if the shadow map is present otherwise, null
  18063. */
  18064. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18065. /**
  18066. * Gets the class name of that object
  18067. * @returns "ShadowGenerator"
  18068. */
  18069. getClassName(): string;
  18070. /**
  18071. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18072. * @param mesh Mesh to add
  18073. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18074. * @returns the Shadow Generator itself
  18075. */
  18076. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18077. /**
  18078. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18079. * @param mesh Mesh to remove
  18080. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18081. * @returns the Shadow Generator itself
  18082. */
  18083. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18084. /**
  18085. * Controls the extent to which the shadows fade out at the edge of the frustum
  18086. */
  18087. frustumEdgeFalloff: number;
  18088. protected _light: IShadowLight;
  18089. /**
  18090. * Returns the associated light object.
  18091. * @returns the light generating the shadow
  18092. */
  18093. getLight(): IShadowLight;
  18094. /**
  18095. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18096. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18097. * It might on the other hand introduce peter panning.
  18098. */
  18099. forceBackFacesOnly: boolean;
  18100. protected _scene: Scene;
  18101. protected _lightDirection: Vector3;
  18102. protected _effect: Effect;
  18103. protected _viewMatrix: Matrix;
  18104. protected _projectionMatrix: Matrix;
  18105. protected _transformMatrix: Matrix;
  18106. protected _cachedPosition: Vector3;
  18107. protected _cachedDirection: Vector3;
  18108. protected _cachedDefines: string;
  18109. protected _currentRenderID: number;
  18110. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18111. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18112. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18113. protected _blurPostProcesses: PostProcess[];
  18114. protected _mapSize: number;
  18115. protected _currentFaceIndex: number;
  18116. protected _currentFaceIndexCache: number;
  18117. protected _textureType: number;
  18118. protected _defaultTextureMatrix: Matrix;
  18119. protected _storedUniqueId: Nullable<number>;
  18120. /** @hidden */
  18121. static _SceneComponentInitialization: (scene: Scene) => void;
  18122. /**
  18123. * Creates a ShadowGenerator object.
  18124. * A ShadowGenerator is the required tool to use the shadows.
  18125. * Each light casting shadows needs to use its own ShadowGenerator.
  18126. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18127. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18128. * @param light The light object generating the shadows.
  18129. * @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.
  18130. */
  18131. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18132. protected _initializeGenerator(): void;
  18133. protected _createTargetRenderTexture(): void;
  18134. protected _initializeShadowMap(): void;
  18135. protected _initializeBlurRTTAndPostProcesses(): void;
  18136. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18137. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18138. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18139. protected _applyFilterValues(): void;
  18140. /**
  18141. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18142. * @param onCompiled Callback triggered at the and of the effects compilation
  18143. * @param options Sets of optional options forcing the compilation with different modes
  18144. */
  18145. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18146. useInstances: boolean;
  18147. }>): void;
  18148. /**
  18149. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18150. * @param options Sets of optional options forcing the compilation with different modes
  18151. * @returns A promise that resolves when the compilation completes
  18152. */
  18153. forceCompilationAsync(options?: Partial<{
  18154. useInstances: boolean;
  18155. }>): Promise<void>;
  18156. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18157. private _prepareShadowDefines;
  18158. /**
  18159. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18160. * @param subMesh The submesh we want to render in the shadow map
  18161. * @param useInstances Defines wether will draw in the map using instances
  18162. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18163. * @returns true if ready otherwise, false
  18164. */
  18165. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18166. /**
  18167. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18168. * @param defines Defines of the material we want to update
  18169. * @param lightIndex Index of the light in the enabled light list of the material
  18170. */
  18171. prepareDefines(defines: any, lightIndex: number): void;
  18172. /**
  18173. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18174. * defined in the generator but impacting the effect).
  18175. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18176. * @param effect The effect we are binfing the information for
  18177. */
  18178. bindShadowLight(lightIndex: string, effect: Effect): void;
  18179. /**
  18180. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18181. * (eq to shadow prjection matrix * light transform matrix)
  18182. * @returns The transform matrix used to create the shadow map
  18183. */
  18184. getTransformMatrix(): Matrix;
  18185. /**
  18186. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18187. * Cube and 2D textures for instance.
  18188. */
  18189. recreateShadowMap(): void;
  18190. protected _disposeBlurPostProcesses(): void;
  18191. protected _disposeRTTandPostProcesses(): void;
  18192. /**
  18193. * Disposes the ShadowGenerator.
  18194. * Returns nothing.
  18195. */
  18196. dispose(): void;
  18197. /**
  18198. * Serializes the shadow generator setup to a json object.
  18199. * @returns The serialized JSON object
  18200. */
  18201. serialize(): any;
  18202. /**
  18203. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18204. * @param parsedShadowGenerator The JSON object to parse
  18205. * @param scene The scene to create the shadow map for
  18206. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18207. * @returns The parsed shadow generator
  18208. */
  18209. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18210. }
  18211. }
  18212. declare module "babylonjs/Lights/light" {
  18213. import { Nullable } from "babylonjs/types";
  18214. import { Scene } from "babylonjs/scene";
  18215. import { Vector3 } from "babylonjs/Maths/math.vector";
  18216. import { Color3 } from "babylonjs/Maths/math.color";
  18217. import { Node } from "babylonjs/node";
  18218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18219. import { Effect } from "babylonjs/Materials/effect";
  18220. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18221. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18222. /**
  18223. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18224. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18225. * 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.
  18226. */
  18227. export abstract class Light extends Node {
  18228. /**
  18229. * Falloff Default: light is falling off following the material specification:
  18230. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18231. */
  18232. static readonly FALLOFF_DEFAULT: number;
  18233. /**
  18234. * Falloff Physical: light is falling off following the inverse squared distance law.
  18235. */
  18236. static readonly FALLOFF_PHYSICAL: number;
  18237. /**
  18238. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18239. * to enhance interoperability with other engines.
  18240. */
  18241. static readonly FALLOFF_GLTF: number;
  18242. /**
  18243. * Falloff Standard: light is falling off like in the standard material
  18244. * to enhance interoperability with other materials.
  18245. */
  18246. static readonly FALLOFF_STANDARD: number;
  18247. /**
  18248. * If every light affecting the material is in this lightmapMode,
  18249. * material.lightmapTexture adds or multiplies
  18250. * (depends on material.useLightmapAsShadowmap)
  18251. * after every other light calculations.
  18252. */
  18253. static readonly LIGHTMAP_DEFAULT: number;
  18254. /**
  18255. * material.lightmapTexture as only diffuse lighting from this light
  18256. * adds only specular lighting from this light
  18257. * adds dynamic shadows
  18258. */
  18259. static readonly LIGHTMAP_SPECULAR: number;
  18260. /**
  18261. * material.lightmapTexture as only lighting
  18262. * no light calculation from this light
  18263. * only adds dynamic shadows from this light
  18264. */
  18265. static readonly LIGHTMAP_SHADOWSONLY: number;
  18266. /**
  18267. * Each light type uses the default quantity according to its type:
  18268. * point/spot lights use luminous intensity
  18269. * directional lights use illuminance
  18270. */
  18271. static readonly INTENSITYMODE_AUTOMATIC: number;
  18272. /**
  18273. * lumen (lm)
  18274. */
  18275. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18276. /**
  18277. * candela (lm/sr)
  18278. */
  18279. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18280. /**
  18281. * lux (lm/m^2)
  18282. */
  18283. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18284. /**
  18285. * nit (cd/m^2)
  18286. */
  18287. static readonly INTENSITYMODE_LUMINANCE: number;
  18288. /**
  18289. * Light type const id of the point light.
  18290. */
  18291. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18292. /**
  18293. * Light type const id of the directional light.
  18294. */
  18295. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18296. /**
  18297. * Light type const id of the spot light.
  18298. */
  18299. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18300. /**
  18301. * Light type const id of the hemispheric light.
  18302. */
  18303. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18304. /**
  18305. * Diffuse gives the basic color to an object.
  18306. */
  18307. diffuse: Color3;
  18308. /**
  18309. * Specular produces a highlight color on an object.
  18310. * Note: This is note affecting PBR materials.
  18311. */
  18312. specular: Color3;
  18313. /**
  18314. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18315. * falling off base on range or angle.
  18316. * This can be set to any values in Light.FALLOFF_x.
  18317. *
  18318. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18319. * other types of materials.
  18320. */
  18321. falloffType: number;
  18322. /**
  18323. * Strength of the light.
  18324. * Note: By default it is define in the framework own unit.
  18325. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18326. */
  18327. intensity: number;
  18328. private _range;
  18329. protected _inverseSquaredRange: number;
  18330. /**
  18331. * Defines how far from the source the light is impacting in scene units.
  18332. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18333. */
  18334. get range(): number;
  18335. /**
  18336. * Defines how far from the source the light is impacting in scene units.
  18337. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18338. */
  18339. set range(value: number);
  18340. /**
  18341. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18342. * of light.
  18343. */
  18344. private _photometricScale;
  18345. private _intensityMode;
  18346. /**
  18347. * Gets the photometric scale used to interpret the intensity.
  18348. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18349. */
  18350. get intensityMode(): number;
  18351. /**
  18352. * Sets the photometric scale used to interpret the intensity.
  18353. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18354. */
  18355. set intensityMode(value: number);
  18356. private _radius;
  18357. /**
  18358. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18359. */
  18360. get radius(): number;
  18361. /**
  18362. * sets the light radius used by PBR Materials to simulate soft area lights.
  18363. */
  18364. set radius(value: number);
  18365. private _renderPriority;
  18366. /**
  18367. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18368. * exceeding the number allowed of the materials.
  18369. */
  18370. renderPriority: number;
  18371. private _shadowEnabled;
  18372. /**
  18373. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18374. * the current shadow generator.
  18375. */
  18376. get shadowEnabled(): boolean;
  18377. /**
  18378. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18379. * the current shadow generator.
  18380. */
  18381. set shadowEnabled(value: boolean);
  18382. private _includedOnlyMeshes;
  18383. /**
  18384. * Gets the only meshes impacted by this light.
  18385. */
  18386. get includedOnlyMeshes(): AbstractMesh[];
  18387. /**
  18388. * Sets the only meshes impacted by this light.
  18389. */
  18390. set includedOnlyMeshes(value: AbstractMesh[]);
  18391. private _excludedMeshes;
  18392. /**
  18393. * Gets the meshes not impacted by this light.
  18394. */
  18395. get excludedMeshes(): AbstractMesh[];
  18396. /**
  18397. * Sets the meshes not impacted by this light.
  18398. */
  18399. set excludedMeshes(value: AbstractMesh[]);
  18400. private _excludeWithLayerMask;
  18401. /**
  18402. * Gets the layer id use to find what meshes are not impacted by the light.
  18403. * Inactive if 0
  18404. */
  18405. get excludeWithLayerMask(): number;
  18406. /**
  18407. * Sets the layer id use to find what meshes are not impacted by the light.
  18408. * Inactive if 0
  18409. */
  18410. set excludeWithLayerMask(value: number);
  18411. private _includeOnlyWithLayerMask;
  18412. /**
  18413. * Gets the layer id use to find what meshes are impacted by the light.
  18414. * Inactive if 0
  18415. */
  18416. get includeOnlyWithLayerMask(): number;
  18417. /**
  18418. * Sets the layer id use to find what meshes are impacted by the light.
  18419. * Inactive if 0
  18420. */
  18421. set includeOnlyWithLayerMask(value: number);
  18422. private _lightmapMode;
  18423. /**
  18424. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18425. */
  18426. get lightmapMode(): number;
  18427. /**
  18428. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18429. */
  18430. set lightmapMode(value: number);
  18431. /**
  18432. * Shadow generator associted to the light.
  18433. * @hidden Internal use only.
  18434. */
  18435. _shadowGenerator: Nullable<IShadowGenerator>;
  18436. /**
  18437. * @hidden Internal use only.
  18438. */
  18439. _excludedMeshesIds: string[];
  18440. /**
  18441. * @hidden Internal use only.
  18442. */
  18443. _includedOnlyMeshesIds: string[];
  18444. /**
  18445. * The current light unifom buffer.
  18446. * @hidden Internal use only.
  18447. */
  18448. _uniformBuffer: UniformBuffer;
  18449. /** @hidden */
  18450. _renderId: number;
  18451. /**
  18452. * Creates a Light object in the scene.
  18453. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18454. * @param name The firendly name of the light
  18455. * @param scene The scene the light belongs too
  18456. */
  18457. constructor(name: string, scene: Scene);
  18458. protected abstract _buildUniformLayout(): void;
  18459. /**
  18460. * Sets the passed Effect "effect" with the Light information.
  18461. * @param effect The effect to update
  18462. * @param lightIndex The index of the light in the effect to update
  18463. * @returns The light
  18464. */
  18465. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18466. /**
  18467. * Sets the passed Effect "effect" with the Light textures.
  18468. * @param effect The effect to update
  18469. * @param lightIndex The index of the light in the effect to update
  18470. * @returns The light
  18471. */
  18472. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18473. /**
  18474. * Binds the lights information from the scene to the effect for the given mesh.
  18475. * @param lightIndex Light index
  18476. * @param scene The scene where the light belongs to
  18477. * @param effect The effect we are binding the data to
  18478. * @param useSpecular Defines if specular is supported
  18479. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18480. */
  18481. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18482. /**
  18483. * Sets the passed Effect "effect" with the Light information.
  18484. * @param effect The effect to update
  18485. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18486. * @returns The light
  18487. */
  18488. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18489. /**
  18490. * Returns the string "Light".
  18491. * @returns the class name
  18492. */
  18493. getClassName(): string;
  18494. /** @hidden */
  18495. readonly _isLight: boolean;
  18496. /**
  18497. * Converts the light information to a readable string for debug purpose.
  18498. * @param fullDetails Supports for multiple levels of logging within scene loading
  18499. * @returns the human readable light info
  18500. */
  18501. toString(fullDetails?: boolean): string;
  18502. /** @hidden */
  18503. protected _syncParentEnabledState(): void;
  18504. /**
  18505. * Set the enabled state of this node.
  18506. * @param value - the new enabled state
  18507. */
  18508. setEnabled(value: boolean): void;
  18509. /**
  18510. * Returns the Light associated shadow generator if any.
  18511. * @return the associated shadow generator.
  18512. */
  18513. getShadowGenerator(): Nullable<IShadowGenerator>;
  18514. /**
  18515. * Returns a Vector3, the absolute light position in the World.
  18516. * @returns the world space position of the light
  18517. */
  18518. getAbsolutePosition(): Vector3;
  18519. /**
  18520. * Specifies if the light will affect the passed mesh.
  18521. * @param mesh The mesh to test against the light
  18522. * @return true the mesh is affected otherwise, false.
  18523. */
  18524. canAffectMesh(mesh: AbstractMesh): boolean;
  18525. /**
  18526. * Sort function to order lights for rendering.
  18527. * @param a First Light object to compare to second.
  18528. * @param b Second Light object to compare first.
  18529. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18530. */
  18531. static CompareLightsPriority(a: Light, b: Light): number;
  18532. /**
  18533. * Releases resources associated with this node.
  18534. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18535. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18536. */
  18537. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18538. /**
  18539. * Returns the light type ID (integer).
  18540. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18541. */
  18542. getTypeID(): number;
  18543. /**
  18544. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18545. * @returns the scaled intensity in intensity mode unit
  18546. */
  18547. getScaledIntensity(): number;
  18548. /**
  18549. * Returns a new Light object, named "name", from the current one.
  18550. * @param name The name of the cloned light
  18551. * @param newParent The parent of this light, if it has one
  18552. * @returns the new created light
  18553. */
  18554. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18555. /**
  18556. * Serializes the current light into a Serialization object.
  18557. * @returns the serialized object.
  18558. */
  18559. serialize(): any;
  18560. /**
  18561. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18562. * This new light is named "name" and added to the passed scene.
  18563. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18564. * @param name The friendly name of the light
  18565. * @param scene The scene the new light will belong to
  18566. * @returns the constructor function
  18567. */
  18568. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18569. /**
  18570. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18571. * @param parsedLight The JSON representation of the light
  18572. * @param scene The scene to create the parsed light in
  18573. * @returns the created light after parsing
  18574. */
  18575. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18576. private _hookArrayForExcluded;
  18577. private _hookArrayForIncludedOnly;
  18578. private _resyncMeshes;
  18579. /**
  18580. * Forces the meshes to update their light related information in their rendering used effects
  18581. * @hidden Internal Use Only
  18582. */
  18583. _markMeshesAsLightDirty(): void;
  18584. /**
  18585. * Recomputes the cached photometric scale if needed.
  18586. */
  18587. private _computePhotometricScale;
  18588. /**
  18589. * Returns the Photometric Scale according to the light type and intensity mode.
  18590. */
  18591. private _getPhotometricScale;
  18592. /**
  18593. * Reorder the light in the scene according to their defined priority.
  18594. * @hidden Internal Use Only
  18595. */
  18596. _reorderLightsInScene(): void;
  18597. /**
  18598. * Prepares the list of defines specific to the light type.
  18599. * @param defines the list of defines
  18600. * @param lightIndex defines the index of the light for the effect
  18601. */
  18602. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18603. }
  18604. }
  18605. declare module "babylonjs/Cameras/targetCamera" {
  18606. import { Nullable } from "babylonjs/types";
  18607. import { Camera } from "babylonjs/Cameras/camera";
  18608. import { Scene } from "babylonjs/scene";
  18609. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18610. /**
  18611. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18612. * This is the base of the follow, arc rotate cameras and Free camera
  18613. * @see http://doc.babylonjs.com/features/cameras
  18614. */
  18615. export class TargetCamera extends Camera {
  18616. private static _RigCamTransformMatrix;
  18617. private static _TargetTransformMatrix;
  18618. private static _TargetFocalPoint;
  18619. /**
  18620. * Define the current direction the camera is moving to
  18621. */
  18622. cameraDirection: Vector3;
  18623. /**
  18624. * Define the current rotation the camera is rotating to
  18625. */
  18626. cameraRotation: Vector2;
  18627. /**
  18628. * When set, the up vector of the camera will be updated by the rotation of the camera
  18629. */
  18630. updateUpVectorFromRotation: boolean;
  18631. private _tmpQuaternion;
  18632. /**
  18633. * Define the current rotation of the camera
  18634. */
  18635. rotation: Vector3;
  18636. /**
  18637. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18638. */
  18639. rotationQuaternion: Quaternion;
  18640. /**
  18641. * Define the current speed of the camera
  18642. */
  18643. speed: number;
  18644. /**
  18645. * Add constraint to the camera to prevent it to move freely in all directions and
  18646. * around all axis.
  18647. */
  18648. noRotationConstraint: boolean;
  18649. /**
  18650. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18651. * panning
  18652. */
  18653. invertRotation: boolean;
  18654. /**
  18655. * Speed multiplier for inverse camera panning
  18656. */
  18657. inverseRotationSpeed: number;
  18658. /**
  18659. * Define the current target of the camera as an object or a position.
  18660. */
  18661. lockedTarget: any;
  18662. /** @hidden */
  18663. _currentTarget: Vector3;
  18664. /** @hidden */
  18665. _initialFocalDistance: number;
  18666. /** @hidden */
  18667. _viewMatrix: Matrix;
  18668. /** @hidden */
  18669. _camMatrix: Matrix;
  18670. /** @hidden */
  18671. _cameraTransformMatrix: Matrix;
  18672. /** @hidden */
  18673. _cameraRotationMatrix: Matrix;
  18674. /** @hidden */
  18675. _referencePoint: Vector3;
  18676. /** @hidden */
  18677. _transformedReferencePoint: Vector3;
  18678. protected _globalCurrentTarget: Vector3;
  18679. protected _globalCurrentUpVector: Vector3;
  18680. /** @hidden */
  18681. _reset: () => void;
  18682. private _defaultUp;
  18683. /**
  18684. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18685. * This is the base of the follow, arc rotate cameras and Free camera
  18686. * @see http://doc.babylonjs.com/features/cameras
  18687. * @param name Defines the name of the camera in the scene
  18688. * @param position Defines the start position of the camera in the scene
  18689. * @param scene Defines the scene the camera belongs to
  18690. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18691. */
  18692. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18693. /**
  18694. * Gets the position in front of the camera at a given distance.
  18695. * @param distance The distance from the camera we want the position to be
  18696. * @returns the position
  18697. */
  18698. getFrontPosition(distance: number): Vector3;
  18699. /** @hidden */
  18700. _getLockedTargetPosition(): Nullable<Vector3>;
  18701. private _storedPosition;
  18702. private _storedRotation;
  18703. private _storedRotationQuaternion;
  18704. /**
  18705. * Store current camera state of the camera (fov, position, rotation, etc..)
  18706. * @returns the camera
  18707. */
  18708. storeState(): Camera;
  18709. /**
  18710. * Restored camera state. You must call storeState() first
  18711. * @returns whether it was successful or not
  18712. * @hidden
  18713. */
  18714. _restoreStateValues(): boolean;
  18715. /** @hidden */
  18716. _initCache(): void;
  18717. /** @hidden */
  18718. _updateCache(ignoreParentClass?: boolean): void;
  18719. /** @hidden */
  18720. _isSynchronizedViewMatrix(): boolean;
  18721. /** @hidden */
  18722. _computeLocalCameraSpeed(): number;
  18723. /**
  18724. * Defines the target the camera should look at.
  18725. * @param target Defines the new target as a Vector or a mesh
  18726. */
  18727. setTarget(target: Vector3): void;
  18728. /**
  18729. * Return the current target position of the camera. This value is expressed in local space.
  18730. * @returns the target position
  18731. */
  18732. getTarget(): Vector3;
  18733. /** @hidden */
  18734. _decideIfNeedsToMove(): boolean;
  18735. /** @hidden */
  18736. _updatePosition(): void;
  18737. /** @hidden */
  18738. _checkInputs(): void;
  18739. protected _updateCameraRotationMatrix(): void;
  18740. /**
  18741. * 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)
  18742. * @returns the current camera
  18743. */
  18744. private _rotateUpVectorWithCameraRotationMatrix;
  18745. private _cachedRotationZ;
  18746. private _cachedQuaternionRotationZ;
  18747. /** @hidden */
  18748. _getViewMatrix(): Matrix;
  18749. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18750. /**
  18751. * @hidden
  18752. */
  18753. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18754. /**
  18755. * @hidden
  18756. */
  18757. _updateRigCameras(): void;
  18758. private _getRigCamPositionAndTarget;
  18759. /**
  18760. * Gets the current object class name.
  18761. * @return the class name
  18762. */
  18763. getClassName(): string;
  18764. }
  18765. }
  18766. declare module "babylonjs/Events/keyboardEvents" {
  18767. /**
  18768. * Gather the list of keyboard event types as constants.
  18769. */
  18770. export class KeyboardEventTypes {
  18771. /**
  18772. * The keydown event is fired when a key becomes active (pressed).
  18773. */
  18774. static readonly KEYDOWN: number;
  18775. /**
  18776. * The keyup event is fired when a key has been released.
  18777. */
  18778. static readonly KEYUP: number;
  18779. }
  18780. /**
  18781. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18782. */
  18783. export class KeyboardInfo {
  18784. /**
  18785. * Defines the type of event (KeyboardEventTypes)
  18786. */
  18787. type: number;
  18788. /**
  18789. * Defines the related dom event
  18790. */
  18791. event: KeyboardEvent;
  18792. /**
  18793. * Instantiates a new keyboard info.
  18794. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18795. * @param type Defines the type of event (KeyboardEventTypes)
  18796. * @param event Defines the related dom event
  18797. */
  18798. constructor(
  18799. /**
  18800. * Defines the type of event (KeyboardEventTypes)
  18801. */
  18802. type: number,
  18803. /**
  18804. * Defines the related dom event
  18805. */
  18806. event: KeyboardEvent);
  18807. }
  18808. /**
  18809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18810. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18811. */
  18812. export class KeyboardInfoPre extends KeyboardInfo {
  18813. /**
  18814. * Defines the type of event (KeyboardEventTypes)
  18815. */
  18816. type: number;
  18817. /**
  18818. * Defines the related dom event
  18819. */
  18820. event: KeyboardEvent;
  18821. /**
  18822. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18823. */
  18824. skipOnPointerObservable: boolean;
  18825. /**
  18826. * Instantiates a new keyboard pre info.
  18827. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18828. * @param type Defines the type of event (KeyboardEventTypes)
  18829. * @param event Defines the related dom event
  18830. */
  18831. constructor(
  18832. /**
  18833. * Defines the type of event (KeyboardEventTypes)
  18834. */
  18835. type: number,
  18836. /**
  18837. * Defines the related dom event
  18838. */
  18839. event: KeyboardEvent);
  18840. }
  18841. }
  18842. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18843. import { Nullable } from "babylonjs/types";
  18844. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18845. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18846. /**
  18847. * Manage the keyboard inputs to control the movement of a free camera.
  18848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18849. */
  18850. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18851. /**
  18852. * Defines the camera the input is attached to.
  18853. */
  18854. camera: FreeCamera;
  18855. /**
  18856. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18857. */
  18858. keysUp: number[];
  18859. /**
  18860. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18861. */
  18862. keysUpward: number[];
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18865. */
  18866. keysDown: number[];
  18867. /**
  18868. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18869. */
  18870. keysDownward: number[];
  18871. /**
  18872. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18873. */
  18874. keysLeft: number[];
  18875. /**
  18876. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18877. */
  18878. keysRight: number[];
  18879. private _keys;
  18880. private _onCanvasBlurObserver;
  18881. private _onKeyboardObserver;
  18882. private _engine;
  18883. private _scene;
  18884. /**
  18885. * Attach the input controls to a specific dom element to get the input from.
  18886. * @param element Defines the element the controls should be listened from
  18887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18888. */
  18889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18890. /**
  18891. * Detach the current controls from the specified dom element.
  18892. * @param element Defines the element to stop listening the inputs from
  18893. */
  18894. detachControl(element: Nullable<HTMLElement>): void;
  18895. /**
  18896. * Update the current camera state depending on the inputs that have been used this frame.
  18897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18898. */
  18899. checkInputs(): void;
  18900. /**
  18901. * Gets the class name of the current intput.
  18902. * @returns the class name
  18903. */
  18904. getClassName(): string;
  18905. /** @hidden */
  18906. _onLostFocus(): void;
  18907. /**
  18908. * Get the friendly name associated with the input class.
  18909. * @returns the input friendly name
  18910. */
  18911. getSimpleName(): string;
  18912. }
  18913. }
  18914. declare module "babylonjs/Events/pointerEvents" {
  18915. import { Nullable } from "babylonjs/types";
  18916. import { Vector2 } from "babylonjs/Maths/math.vector";
  18917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18918. import { Ray } from "babylonjs/Culling/ray";
  18919. /**
  18920. * Gather the list of pointer event types as constants.
  18921. */
  18922. export class PointerEventTypes {
  18923. /**
  18924. * 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.
  18925. */
  18926. static readonly POINTERDOWN: number;
  18927. /**
  18928. * The pointerup event is fired when a pointer is no longer active.
  18929. */
  18930. static readonly POINTERUP: number;
  18931. /**
  18932. * The pointermove event is fired when a pointer changes coordinates.
  18933. */
  18934. static readonly POINTERMOVE: number;
  18935. /**
  18936. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18937. */
  18938. static readonly POINTERWHEEL: number;
  18939. /**
  18940. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18941. */
  18942. static readonly POINTERPICK: number;
  18943. /**
  18944. * The pointertap event is fired when a the object has been touched and released without drag.
  18945. */
  18946. static readonly POINTERTAP: number;
  18947. /**
  18948. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18949. */
  18950. static readonly POINTERDOUBLETAP: number;
  18951. }
  18952. /**
  18953. * Base class of pointer info types.
  18954. */
  18955. export class PointerInfoBase {
  18956. /**
  18957. * Defines the type of event (PointerEventTypes)
  18958. */
  18959. type: number;
  18960. /**
  18961. * Defines the related dom event
  18962. */
  18963. event: PointerEvent | MouseWheelEvent;
  18964. /**
  18965. * Instantiates the base class of pointers info.
  18966. * @param type Defines the type of event (PointerEventTypes)
  18967. * @param event Defines the related dom event
  18968. */
  18969. constructor(
  18970. /**
  18971. * Defines the type of event (PointerEventTypes)
  18972. */
  18973. type: number,
  18974. /**
  18975. * Defines the related dom event
  18976. */
  18977. event: PointerEvent | MouseWheelEvent);
  18978. }
  18979. /**
  18980. * This class is used to store pointer related info for the onPrePointerObservable event.
  18981. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18982. */
  18983. export class PointerInfoPre extends PointerInfoBase {
  18984. /**
  18985. * Ray from a pointer if availible (eg. 6dof controller)
  18986. */
  18987. ray: Nullable<Ray>;
  18988. /**
  18989. * Defines the local position of the pointer on the canvas.
  18990. */
  18991. localPosition: Vector2;
  18992. /**
  18993. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18994. */
  18995. skipOnPointerObservable: boolean;
  18996. /**
  18997. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18998. * @param type Defines the type of event (PointerEventTypes)
  18999. * @param event Defines the related dom event
  19000. * @param localX Defines the local x coordinates of the pointer when the event occured
  19001. * @param localY Defines the local y coordinates of the pointer when the event occured
  19002. */
  19003. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19004. }
  19005. /**
  19006. * This type contains all the data related to a pointer event in Babylon.js.
  19007. * 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.
  19008. */
  19009. export class PointerInfo extends PointerInfoBase {
  19010. /**
  19011. * Defines the picking info associated to the info (if any)\
  19012. */
  19013. pickInfo: Nullable<PickingInfo>;
  19014. /**
  19015. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19016. * @param type Defines the type of event (PointerEventTypes)
  19017. * @param event Defines the related dom event
  19018. * @param pickInfo Defines the picking info associated to the info (if any)\
  19019. */
  19020. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19021. /**
  19022. * Defines the picking info associated to the info (if any)\
  19023. */
  19024. pickInfo: Nullable<PickingInfo>);
  19025. }
  19026. /**
  19027. * Data relating to a touch event on the screen.
  19028. */
  19029. export interface PointerTouch {
  19030. /**
  19031. * X coordinate of touch.
  19032. */
  19033. x: number;
  19034. /**
  19035. * Y coordinate of touch.
  19036. */
  19037. y: number;
  19038. /**
  19039. * Id of touch. Unique for each finger.
  19040. */
  19041. pointerId: number;
  19042. /**
  19043. * Event type passed from DOM.
  19044. */
  19045. type: any;
  19046. }
  19047. }
  19048. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19049. import { Observable } from "babylonjs/Misc/observable";
  19050. import { Nullable } from "babylonjs/types";
  19051. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19052. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19053. /**
  19054. * Manage the mouse inputs to control the movement of a free camera.
  19055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19056. */
  19057. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19058. /**
  19059. * Define if touch is enabled in the mouse input
  19060. */
  19061. touchEnabled: boolean;
  19062. /**
  19063. * Defines the camera the input is attached to.
  19064. */
  19065. camera: FreeCamera;
  19066. /**
  19067. * Defines the buttons associated with the input to handle camera move.
  19068. */
  19069. buttons: number[];
  19070. /**
  19071. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19072. */
  19073. angularSensibility: number;
  19074. private _pointerInput;
  19075. private _onMouseMove;
  19076. private _observer;
  19077. private previousPosition;
  19078. /**
  19079. * Observable for when a pointer move event occurs containing the move offset
  19080. */
  19081. onPointerMovedObservable: Observable<{
  19082. offsetX: number;
  19083. offsetY: number;
  19084. }>;
  19085. /**
  19086. * @hidden
  19087. * If the camera should be rotated automatically based on pointer movement
  19088. */
  19089. _allowCameraRotation: boolean;
  19090. /**
  19091. * Manage the mouse inputs to control the movement of a free camera.
  19092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19093. * @param touchEnabled Defines if touch is enabled or not
  19094. */
  19095. constructor(
  19096. /**
  19097. * Define if touch is enabled in the mouse input
  19098. */
  19099. touchEnabled?: boolean);
  19100. /**
  19101. * Attach the input controls to a specific dom element to get the input from.
  19102. * @param element Defines the element the controls should be listened from
  19103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19104. */
  19105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19106. /**
  19107. * Called on JS contextmenu event.
  19108. * Override this method to provide functionality.
  19109. */
  19110. protected onContextMenu(evt: PointerEvent): void;
  19111. /**
  19112. * Detach the current controls from the specified dom element.
  19113. * @param element Defines the element to stop listening the inputs from
  19114. */
  19115. detachControl(element: Nullable<HTMLElement>): void;
  19116. /**
  19117. * Gets the class name of the current intput.
  19118. * @returns the class name
  19119. */
  19120. getClassName(): string;
  19121. /**
  19122. * Get the friendly name associated with the input class.
  19123. * @returns the input friendly name
  19124. */
  19125. getSimpleName(): string;
  19126. }
  19127. }
  19128. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19129. import { Nullable } from "babylonjs/types";
  19130. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19131. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19132. /**
  19133. * Manage the touch inputs to control the movement of a free camera.
  19134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19135. */
  19136. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19137. /**
  19138. * Defines the camera the input is attached to.
  19139. */
  19140. camera: FreeCamera;
  19141. /**
  19142. * Defines the touch sensibility for rotation.
  19143. * The higher the faster.
  19144. */
  19145. touchAngularSensibility: number;
  19146. /**
  19147. * Defines the touch sensibility for move.
  19148. * The higher the faster.
  19149. */
  19150. touchMoveSensibility: number;
  19151. private _offsetX;
  19152. private _offsetY;
  19153. private _pointerPressed;
  19154. private _pointerInput;
  19155. private _observer;
  19156. private _onLostFocus;
  19157. /**
  19158. * Attach the input controls to a specific dom element to get the input from.
  19159. * @param element Defines the element the controls should be listened from
  19160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19161. */
  19162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19163. /**
  19164. * Detach the current controls from the specified dom element.
  19165. * @param element Defines the element to stop listening the inputs from
  19166. */
  19167. detachControl(element: Nullable<HTMLElement>): void;
  19168. /**
  19169. * Update the current camera state depending on the inputs that have been used this frame.
  19170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19171. */
  19172. checkInputs(): void;
  19173. /**
  19174. * Gets the class name of the current intput.
  19175. * @returns the class name
  19176. */
  19177. getClassName(): string;
  19178. /**
  19179. * Get the friendly name associated with the input class.
  19180. * @returns the input friendly name
  19181. */
  19182. getSimpleName(): string;
  19183. }
  19184. }
  19185. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19186. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19187. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19188. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19189. import { Nullable } from "babylonjs/types";
  19190. /**
  19191. * Default Inputs manager for the FreeCamera.
  19192. * It groups all the default supported inputs for ease of use.
  19193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19194. */
  19195. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19196. /**
  19197. * @hidden
  19198. */
  19199. _mouseInput: Nullable<FreeCameraMouseInput>;
  19200. /**
  19201. * Instantiates a new FreeCameraInputsManager.
  19202. * @param camera Defines the camera the inputs belong to
  19203. */
  19204. constructor(camera: FreeCamera);
  19205. /**
  19206. * Add keyboard input support to the input manager.
  19207. * @returns the current input manager
  19208. */
  19209. addKeyboard(): FreeCameraInputsManager;
  19210. /**
  19211. * Add mouse input support to the input manager.
  19212. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19213. * @returns the current input manager
  19214. */
  19215. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19216. /**
  19217. * Removes the mouse input support from the manager
  19218. * @returns the current input manager
  19219. */
  19220. removeMouse(): FreeCameraInputsManager;
  19221. /**
  19222. * Add touch input support to the input manager.
  19223. * @returns the current input manager
  19224. */
  19225. addTouch(): FreeCameraInputsManager;
  19226. /**
  19227. * Remove all attached input methods from a camera
  19228. */
  19229. clear(): void;
  19230. }
  19231. }
  19232. declare module "babylonjs/Cameras/freeCamera" {
  19233. import { Vector3 } from "babylonjs/Maths/math.vector";
  19234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19235. import { Scene } from "babylonjs/scene";
  19236. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19237. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19238. /**
  19239. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19240. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19241. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19242. */
  19243. export class FreeCamera extends TargetCamera {
  19244. /**
  19245. * Define the collision ellipsoid of the camera.
  19246. * This is helpful to simulate a camera body like the player body around the camera
  19247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19248. */
  19249. ellipsoid: Vector3;
  19250. /**
  19251. * Define an offset for the position of the ellipsoid around the camera.
  19252. * This can be helpful to determine the center of the body near the gravity center of the body
  19253. * instead of its head.
  19254. */
  19255. ellipsoidOffset: Vector3;
  19256. /**
  19257. * Enable or disable collisions of the camera with the rest of the scene objects.
  19258. */
  19259. checkCollisions: boolean;
  19260. /**
  19261. * Enable or disable gravity on the camera.
  19262. */
  19263. applyGravity: boolean;
  19264. /**
  19265. * Define the input manager associated to the camera.
  19266. */
  19267. inputs: FreeCameraInputsManager;
  19268. /**
  19269. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19270. * Higher values reduce sensitivity.
  19271. */
  19272. get angularSensibility(): number;
  19273. /**
  19274. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19275. * Higher values reduce sensitivity.
  19276. */
  19277. set angularSensibility(value: number);
  19278. /**
  19279. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19280. */
  19281. get keysUp(): number[];
  19282. set keysUp(value: number[]);
  19283. /**
  19284. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19285. */
  19286. get keysUpward(): number[];
  19287. set keysUpward(value: number[]);
  19288. /**
  19289. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19290. */
  19291. get keysDown(): number[];
  19292. set keysDown(value: number[]);
  19293. /**
  19294. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19295. */
  19296. get keysDownward(): number[];
  19297. set keysDownward(value: number[]);
  19298. /**
  19299. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19300. */
  19301. get keysLeft(): number[];
  19302. set keysLeft(value: number[]);
  19303. /**
  19304. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19305. */
  19306. get keysRight(): number[];
  19307. set keysRight(value: number[]);
  19308. /**
  19309. * Event raised when the camera collide with a mesh in the scene.
  19310. */
  19311. onCollide: (collidedMesh: AbstractMesh) => void;
  19312. private _collider;
  19313. private _needMoveForGravity;
  19314. private _oldPosition;
  19315. private _diffPosition;
  19316. private _newPosition;
  19317. /** @hidden */
  19318. _localDirection: Vector3;
  19319. /** @hidden */
  19320. _transformedDirection: Vector3;
  19321. /**
  19322. * Instantiates a Free Camera.
  19323. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19324. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19326. * @param name Define the name of the camera in the scene
  19327. * @param position Define the start position of the camera in the scene
  19328. * @param scene Define the scene the camera belongs to
  19329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19330. */
  19331. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19332. /**
  19333. * Attached controls to the current camera.
  19334. * @param element Defines the element the controls should be listened from
  19335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19336. */
  19337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19338. /**
  19339. * Detach the current controls from the camera.
  19340. * The camera will stop reacting to inputs.
  19341. * @param element Defines the element to stop listening the inputs from
  19342. */
  19343. detachControl(element: HTMLElement): void;
  19344. private _collisionMask;
  19345. /**
  19346. * Define a collision mask to limit the list of object the camera can collide with
  19347. */
  19348. get collisionMask(): number;
  19349. set collisionMask(mask: number);
  19350. /** @hidden */
  19351. _collideWithWorld(displacement: Vector3): void;
  19352. private _onCollisionPositionChange;
  19353. /** @hidden */
  19354. _checkInputs(): void;
  19355. /** @hidden */
  19356. _decideIfNeedsToMove(): boolean;
  19357. /** @hidden */
  19358. _updatePosition(): void;
  19359. /**
  19360. * Destroy the camera and release the current resources hold by it.
  19361. */
  19362. dispose(): void;
  19363. /**
  19364. * Gets the current object class name.
  19365. * @return the class name
  19366. */
  19367. getClassName(): string;
  19368. }
  19369. }
  19370. declare module "babylonjs/Gamepads/gamepad" {
  19371. import { Observable } from "babylonjs/Misc/observable";
  19372. /**
  19373. * Represents a gamepad control stick position
  19374. */
  19375. export class StickValues {
  19376. /**
  19377. * The x component of the control stick
  19378. */
  19379. x: number;
  19380. /**
  19381. * The y component of the control stick
  19382. */
  19383. y: number;
  19384. /**
  19385. * Initializes the gamepad x and y control stick values
  19386. * @param x The x component of the gamepad control stick value
  19387. * @param y The y component of the gamepad control stick value
  19388. */
  19389. constructor(
  19390. /**
  19391. * The x component of the control stick
  19392. */
  19393. x: number,
  19394. /**
  19395. * The y component of the control stick
  19396. */
  19397. y: number);
  19398. }
  19399. /**
  19400. * An interface which manages callbacks for gamepad button changes
  19401. */
  19402. export interface GamepadButtonChanges {
  19403. /**
  19404. * Called when a gamepad has been changed
  19405. */
  19406. changed: boolean;
  19407. /**
  19408. * Called when a gamepad press event has been triggered
  19409. */
  19410. pressChanged: boolean;
  19411. /**
  19412. * Called when a touch event has been triggered
  19413. */
  19414. touchChanged: boolean;
  19415. /**
  19416. * Called when a value has changed
  19417. */
  19418. valueChanged: boolean;
  19419. }
  19420. /**
  19421. * Represents a gamepad
  19422. */
  19423. export class Gamepad {
  19424. /**
  19425. * The id of the gamepad
  19426. */
  19427. id: string;
  19428. /**
  19429. * The index of the gamepad
  19430. */
  19431. index: number;
  19432. /**
  19433. * The browser gamepad
  19434. */
  19435. browserGamepad: any;
  19436. /**
  19437. * Specifies what type of gamepad this represents
  19438. */
  19439. type: number;
  19440. private _leftStick;
  19441. private _rightStick;
  19442. /** @hidden */
  19443. _isConnected: boolean;
  19444. private _leftStickAxisX;
  19445. private _leftStickAxisY;
  19446. private _rightStickAxisX;
  19447. private _rightStickAxisY;
  19448. /**
  19449. * Triggered when the left control stick has been changed
  19450. */
  19451. private _onleftstickchanged;
  19452. /**
  19453. * Triggered when the right control stick has been changed
  19454. */
  19455. private _onrightstickchanged;
  19456. /**
  19457. * Represents a gamepad controller
  19458. */
  19459. static GAMEPAD: number;
  19460. /**
  19461. * Represents a generic controller
  19462. */
  19463. static GENERIC: number;
  19464. /**
  19465. * Represents an XBox controller
  19466. */
  19467. static XBOX: number;
  19468. /**
  19469. * Represents a pose-enabled controller
  19470. */
  19471. static POSE_ENABLED: number;
  19472. /**
  19473. * Represents an Dual Shock controller
  19474. */
  19475. static DUALSHOCK: number;
  19476. /**
  19477. * Specifies whether the left control stick should be Y-inverted
  19478. */
  19479. protected _invertLeftStickY: boolean;
  19480. /**
  19481. * Specifies if the gamepad has been connected
  19482. */
  19483. get isConnected(): boolean;
  19484. /**
  19485. * Initializes the gamepad
  19486. * @param id The id of the gamepad
  19487. * @param index The index of the gamepad
  19488. * @param browserGamepad The browser gamepad
  19489. * @param leftStickX The x component of the left joystick
  19490. * @param leftStickY The y component of the left joystick
  19491. * @param rightStickX The x component of the right joystick
  19492. * @param rightStickY The y component of the right joystick
  19493. */
  19494. constructor(
  19495. /**
  19496. * The id of the gamepad
  19497. */
  19498. id: string,
  19499. /**
  19500. * The index of the gamepad
  19501. */
  19502. index: number,
  19503. /**
  19504. * The browser gamepad
  19505. */
  19506. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19507. /**
  19508. * Callback triggered when the left joystick has changed
  19509. * @param callback
  19510. */
  19511. onleftstickchanged(callback: (values: StickValues) => void): void;
  19512. /**
  19513. * Callback triggered when the right joystick has changed
  19514. * @param callback
  19515. */
  19516. onrightstickchanged(callback: (values: StickValues) => void): void;
  19517. /**
  19518. * Gets the left joystick
  19519. */
  19520. get leftStick(): StickValues;
  19521. /**
  19522. * Sets the left joystick values
  19523. */
  19524. set leftStick(newValues: StickValues);
  19525. /**
  19526. * Gets the right joystick
  19527. */
  19528. get rightStick(): StickValues;
  19529. /**
  19530. * Sets the right joystick value
  19531. */
  19532. set rightStick(newValues: StickValues);
  19533. /**
  19534. * Updates the gamepad joystick positions
  19535. */
  19536. update(): void;
  19537. /**
  19538. * Disposes the gamepad
  19539. */
  19540. dispose(): void;
  19541. }
  19542. /**
  19543. * Represents a generic gamepad
  19544. */
  19545. export class GenericPad extends Gamepad {
  19546. private _buttons;
  19547. private _onbuttondown;
  19548. private _onbuttonup;
  19549. /**
  19550. * Observable triggered when a button has been pressed
  19551. */
  19552. onButtonDownObservable: Observable<number>;
  19553. /**
  19554. * Observable triggered when a button has been released
  19555. */
  19556. onButtonUpObservable: Observable<number>;
  19557. /**
  19558. * Callback triggered when a button has been pressed
  19559. * @param callback Called when a button has been pressed
  19560. */
  19561. onbuttondown(callback: (buttonPressed: number) => void): void;
  19562. /**
  19563. * Callback triggered when a button has been released
  19564. * @param callback Called when a button has been released
  19565. */
  19566. onbuttonup(callback: (buttonReleased: number) => void): void;
  19567. /**
  19568. * Initializes the generic gamepad
  19569. * @param id The id of the generic gamepad
  19570. * @param index The index of the generic gamepad
  19571. * @param browserGamepad The browser gamepad
  19572. */
  19573. constructor(id: string, index: number, browserGamepad: any);
  19574. private _setButtonValue;
  19575. /**
  19576. * Updates the generic gamepad
  19577. */
  19578. update(): void;
  19579. /**
  19580. * Disposes the generic gamepad
  19581. */
  19582. dispose(): void;
  19583. }
  19584. }
  19585. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19586. import { Observable } from "babylonjs/Misc/observable";
  19587. import { Nullable } from "babylonjs/types";
  19588. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19591. import { Ray } from "babylonjs/Culling/ray";
  19592. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19593. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19594. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19595. /**
  19596. * Defines the types of pose enabled controllers that are supported
  19597. */
  19598. export enum PoseEnabledControllerType {
  19599. /**
  19600. * HTC Vive
  19601. */
  19602. VIVE = 0,
  19603. /**
  19604. * Oculus Rift
  19605. */
  19606. OCULUS = 1,
  19607. /**
  19608. * Windows mixed reality
  19609. */
  19610. WINDOWS = 2,
  19611. /**
  19612. * Samsung gear VR
  19613. */
  19614. GEAR_VR = 3,
  19615. /**
  19616. * Google Daydream
  19617. */
  19618. DAYDREAM = 4,
  19619. /**
  19620. * Generic
  19621. */
  19622. GENERIC = 5
  19623. }
  19624. /**
  19625. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19626. */
  19627. export interface MutableGamepadButton {
  19628. /**
  19629. * Value of the button/trigger
  19630. */
  19631. value: number;
  19632. /**
  19633. * If the button/trigger is currently touched
  19634. */
  19635. touched: boolean;
  19636. /**
  19637. * If the button/trigger is currently pressed
  19638. */
  19639. pressed: boolean;
  19640. }
  19641. /**
  19642. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19643. * @hidden
  19644. */
  19645. export interface ExtendedGamepadButton extends GamepadButton {
  19646. /**
  19647. * If the button/trigger is currently pressed
  19648. */
  19649. readonly pressed: boolean;
  19650. /**
  19651. * If the button/trigger is currently touched
  19652. */
  19653. readonly touched: boolean;
  19654. /**
  19655. * Value of the button/trigger
  19656. */
  19657. readonly value: number;
  19658. }
  19659. /** @hidden */
  19660. export interface _GamePadFactory {
  19661. /**
  19662. * Returns whether or not the current gamepad can be created for this type of controller.
  19663. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19664. * @returns true if it can be created, otherwise false
  19665. */
  19666. canCreate(gamepadInfo: any): boolean;
  19667. /**
  19668. * Creates a new instance of the Gamepad.
  19669. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19670. * @returns the new gamepad instance
  19671. */
  19672. create(gamepadInfo: any): Gamepad;
  19673. }
  19674. /**
  19675. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19676. */
  19677. export class PoseEnabledControllerHelper {
  19678. /** @hidden */
  19679. static _ControllerFactories: _GamePadFactory[];
  19680. /** @hidden */
  19681. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19682. /**
  19683. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19684. * @param vrGamepad the gamepad to initialized
  19685. * @returns a vr controller of the type the gamepad identified as
  19686. */
  19687. static InitiateController(vrGamepad: any): Gamepad;
  19688. }
  19689. /**
  19690. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19691. */
  19692. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19693. /**
  19694. * If the controller is used in a webXR session
  19695. */
  19696. isXR: boolean;
  19697. private _deviceRoomPosition;
  19698. private _deviceRoomRotationQuaternion;
  19699. /**
  19700. * The device position in babylon space
  19701. */
  19702. devicePosition: Vector3;
  19703. /**
  19704. * The device rotation in babylon space
  19705. */
  19706. deviceRotationQuaternion: Quaternion;
  19707. /**
  19708. * The scale factor of the device in babylon space
  19709. */
  19710. deviceScaleFactor: number;
  19711. /**
  19712. * (Likely devicePosition should be used instead) The device position in its room space
  19713. */
  19714. position: Vector3;
  19715. /**
  19716. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19717. */
  19718. rotationQuaternion: Quaternion;
  19719. /**
  19720. * The type of controller (Eg. Windows mixed reality)
  19721. */
  19722. controllerType: PoseEnabledControllerType;
  19723. protected _calculatedPosition: Vector3;
  19724. private _calculatedRotation;
  19725. /**
  19726. * The raw pose from the device
  19727. */
  19728. rawPose: DevicePose;
  19729. private _trackPosition;
  19730. private _maxRotationDistFromHeadset;
  19731. private _draggedRoomRotation;
  19732. /**
  19733. * @hidden
  19734. */
  19735. _disableTrackPosition(fixedPosition: Vector3): void;
  19736. /**
  19737. * Internal, the mesh attached to the controller
  19738. * @hidden
  19739. */
  19740. _mesh: Nullable<AbstractMesh>;
  19741. private _poseControlledCamera;
  19742. private _leftHandSystemQuaternion;
  19743. /**
  19744. * Internal, matrix used to convert room space to babylon space
  19745. * @hidden
  19746. */
  19747. _deviceToWorld: Matrix;
  19748. /**
  19749. * Node to be used when casting a ray from the controller
  19750. * @hidden
  19751. */
  19752. _pointingPoseNode: Nullable<TransformNode>;
  19753. /**
  19754. * Name of the child mesh that can be used to cast a ray from the controller
  19755. */
  19756. static readonly POINTING_POSE: string;
  19757. /**
  19758. * Creates a new PoseEnabledController from a gamepad
  19759. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19760. */
  19761. constructor(browserGamepad: any);
  19762. private _workingMatrix;
  19763. /**
  19764. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19765. */
  19766. update(): void;
  19767. /**
  19768. * Updates only the pose device and mesh without doing any button event checking
  19769. */
  19770. protected _updatePoseAndMesh(): void;
  19771. /**
  19772. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19773. * @param poseData raw pose fromthe device
  19774. */
  19775. updateFromDevice(poseData: DevicePose): void;
  19776. /**
  19777. * @hidden
  19778. */
  19779. _meshAttachedObservable: Observable<AbstractMesh>;
  19780. /**
  19781. * Attaches a mesh to the controller
  19782. * @param mesh the mesh to be attached
  19783. */
  19784. attachToMesh(mesh: AbstractMesh): void;
  19785. /**
  19786. * Attaches the controllers mesh to a camera
  19787. * @param camera the camera the mesh should be attached to
  19788. */
  19789. attachToPoseControlledCamera(camera: TargetCamera): void;
  19790. /**
  19791. * Disposes of the controller
  19792. */
  19793. dispose(): void;
  19794. /**
  19795. * The mesh that is attached to the controller
  19796. */
  19797. get mesh(): Nullable<AbstractMesh>;
  19798. /**
  19799. * Gets the ray of the controller in the direction the controller is pointing
  19800. * @param length the length the resulting ray should be
  19801. * @returns a ray in the direction the controller is pointing
  19802. */
  19803. getForwardRay(length?: number): Ray;
  19804. }
  19805. }
  19806. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19807. import { Observable } from "babylonjs/Misc/observable";
  19808. import { Scene } from "babylonjs/scene";
  19809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19810. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19811. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19812. import { Nullable } from "babylonjs/types";
  19813. /**
  19814. * Defines the WebVRController object that represents controllers tracked in 3D space
  19815. */
  19816. export abstract class WebVRController extends PoseEnabledController {
  19817. /**
  19818. * Internal, the default controller model for the controller
  19819. */
  19820. protected _defaultModel: Nullable<AbstractMesh>;
  19821. /**
  19822. * Fired when the trigger state has changed
  19823. */
  19824. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19825. /**
  19826. * Fired when the main button state has changed
  19827. */
  19828. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19829. /**
  19830. * Fired when the secondary button state has changed
  19831. */
  19832. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19833. /**
  19834. * Fired when the pad state has changed
  19835. */
  19836. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19837. /**
  19838. * Fired when controllers stick values have changed
  19839. */
  19840. onPadValuesChangedObservable: Observable<StickValues>;
  19841. /**
  19842. * Array of button availible on the controller
  19843. */
  19844. protected _buttons: Array<MutableGamepadButton>;
  19845. private _onButtonStateChange;
  19846. /**
  19847. * Fired when a controller button's state has changed
  19848. * @param callback the callback containing the button that was modified
  19849. */
  19850. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19851. /**
  19852. * X and Y axis corresponding to the controllers joystick
  19853. */
  19854. pad: StickValues;
  19855. /**
  19856. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19857. */
  19858. hand: string;
  19859. /**
  19860. * The default controller model for the controller
  19861. */
  19862. get defaultModel(): Nullable<AbstractMesh>;
  19863. /**
  19864. * Creates a new WebVRController from a gamepad
  19865. * @param vrGamepad the gamepad that the WebVRController should be created from
  19866. */
  19867. constructor(vrGamepad: any);
  19868. /**
  19869. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19870. */
  19871. update(): void;
  19872. /**
  19873. * Function to be called when a button is modified
  19874. */
  19875. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19876. /**
  19877. * Loads a mesh and attaches it to the controller
  19878. * @param scene the scene the mesh should be added to
  19879. * @param meshLoaded callback for when the mesh has been loaded
  19880. */
  19881. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19882. private _setButtonValue;
  19883. private _changes;
  19884. private _checkChanges;
  19885. /**
  19886. * Disposes of th webVRCOntroller
  19887. */
  19888. dispose(): void;
  19889. }
  19890. }
  19891. declare module "babylonjs/Lights/hemisphericLight" {
  19892. import { Nullable } from "babylonjs/types";
  19893. import { Scene } from "babylonjs/scene";
  19894. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19895. import { Color3 } from "babylonjs/Maths/math.color";
  19896. import { Effect } from "babylonjs/Materials/effect";
  19897. import { Light } from "babylonjs/Lights/light";
  19898. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19899. /**
  19900. * The HemisphericLight simulates the ambient environment light,
  19901. * so the passed direction is the light reflection direction, not the incoming direction.
  19902. */
  19903. export class HemisphericLight extends Light {
  19904. /**
  19905. * The groundColor is the light in the opposite direction to the one specified during creation.
  19906. * 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.
  19907. */
  19908. groundColor: Color3;
  19909. /**
  19910. * The light reflection direction, not the incoming direction.
  19911. */
  19912. direction: Vector3;
  19913. /**
  19914. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19915. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19916. * The HemisphericLight can't cast shadows.
  19917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19918. * @param name The friendly name of the light
  19919. * @param direction The direction of the light reflection
  19920. * @param scene The scene the light belongs to
  19921. */
  19922. constructor(name: string, direction: Vector3, scene: Scene);
  19923. protected _buildUniformLayout(): void;
  19924. /**
  19925. * Returns the string "HemisphericLight".
  19926. * @return The class name
  19927. */
  19928. getClassName(): string;
  19929. /**
  19930. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19931. * Returns the updated direction.
  19932. * @param target The target the direction should point to
  19933. * @return The computed direction
  19934. */
  19935. setDirectionToTarget(target: Vector3): Vector3;
  19936. /**
  19937. * Returns the shadow generator associated to the light.
  19938. * @returns Always null for hemispheric lights because it does not support shadows.
  19939. */
  19940. getShadowGenerator(): Nullable<IShadowGenerator>;
  19941. /**
  19942. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19943. * @param effect The effect to update
  19944. * @param lightIndex The index of the light in the effect to update
  19945. * @returns The hemispheric light
  19946. */
  19947. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19948. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19949. /**
  19950. * Computes the world matrix of the node
  19951. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19952. * @param useWasUpdatedFlag defines a reserved property
  19953. * @returns the world matrix
  19954. */
  19955. computeWorldMatrix(): Matrix;
  19956. /**
  19957. * Returns the integer 3.
  19958. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19959. */
  19960. getTypeID(): number;
  19961. /**
  19962. * Prepares the list of defines specific to the light type.
  19963. * @param defines the list of defines
  19964. * @param lightIndex defines the index of the light for the effect
  19965. */
  19966. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19967. }
  19968. }
  19969. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19970. /** @hidden */
  19971. export var vrMultiviewToSingleviewPixelShader: {
  19972. name: string;
  19973. shader: string;
  19974. };
  19975. }
  19976. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19977. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19978. import { Scene } from "babylonjs/scene";
  19979. /**
  19980. * Renders to multiple views with a single draw call
  19981. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19982. */
  19983. export class MultiviewRenderTarget extends RenderTargetTexture {
  19984. /**
  19985. * Creates a multiview render target
  19986. * @param scene scene used with the render target
  19987. * @param size the size of the render target (used for each view)
  19988. */
  19989. constructor(scene: Scene, size?: number | {
  19990. width: number;
  19991. height: number;
  19992. } | {
  19993. ratio: number;
  19994. });
  19995. /**
  19996. * @hidden
  19997. * @param faceIndex the face index, if its a cube texture
  19998. */
  19999. _bindFrameBuffer(faceIndex?: number): void;
  20000. /**
  20001. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20002. * @returns the view count
  20003. */
  20004. getViewCount(): number;
  20005. }
  20006. }
  20007. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20008. import { Camera } from "babylonjs/Cameras/camera";
  20009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20010. import { Nullable } from "babylonjs/types";
  20011. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20012. import { Matrix } from "babylonjs/Maths/math.vector";
  20013. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20014. module "babylonjs/Engines/engine" {
  20015. interface Engine {
  20016. /**
  20017. * Creates a new multiview render target
  20018. * @param width defines the width of the texture
  20019. * @param height defines the height of the texture
  20020. * @returns the created multiview texture
  20021. */
  20022. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20023. /**
  20024. * Binds a multiview framebuffer to be drawn to
  20025. * @param multiviewTexture texture to bind
  20026. */
  20027. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20028. }
  20029. }
  20030. module "babylonjs/Cameras/camera" {
  20031. interface Camera {
  20032. /**
  20033. * @hidden
  20034. * 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)
  20035. */
  20036. _useMultiviewToSingleView: boolean;
  20037. /**
  20038. * @hidden
  20039. * 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)
  20040. */
  20041. _multiviewTexture: Nullable<RenderTargetTexture>;
  20042. /**
  20043. * @hidden
  20044. * ensures the multiview texture of the camera exists and has the specified width/height
  20045. * @param width height to set on the multiview texture
  20046. * @param height width to set on the multiview texture
  20047. */
  20048. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20049. }
  20050. }
  20051. module "babylonjs/scene" {
  20052. interface Scene {
  20053. /** @hidden */
  20054. _transformMatrixR: Matrix;
  20055. /** @hidden */
  20056. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20057. /** @hidden */
  20058. _createMultiviewUbo(): void;
  20059. /** @hidden */
  20060. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20061. /** @hidden */
  20062. _renderMultiviewToSingleView(camera: Camera): void;
  20063. }
  20064. }
  20065. }
  20066. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20067. import { Camera } from "babylonjs/Cameras/camera";
  20068. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20069. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20070. import "babylonjs/Engines/Extensions/engine.multiview";
  20071. /**
  20072. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20073. * This will not be used for webXR as it supports displaying texture arrays directly
  20074. */
  20075. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20076. /**
  20077. * Initializes a VRMultiviewToSingleview
  20078. * @param name name of the post process
  20079. * @param camera camera to be applied to
  20080. * @param scaleFactor scaling factor to the size of the output texture
  20081. */
  20082. constructor(name: string, camera: Camera, scaleFactor: number);
  20083. }
  20084. }
  20085. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20086. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20087. import { Nullable } from "babylonjs/types";
  20088. import { Size } from "babylonjs/Maths/math.size";
  20089. import { Observable } from "babylonjs/Misc/observable";
  20090. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20091. /**
  20092. * Interface used to define additional presentation attributes
  20093. */
  20094. export interface IVRPresentationAttributes {
  20095. /**
  20096. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20097. */
  20098. highRefreshRate: boolean;
  20099. /**
  20100. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20101. */
  20102. foveationLevel: number;
  20103. }
  20104. module "babylonjs/Engines/engine" {
  20105. interface Engine {
  20106. /** @hidden */
  20107. _vrDisplay: any;
  20108. /** @hidden */
  20109. _vrSupported: boolean;
  20110. /** @hidden */
  20111. _oldSize: Size;
  20112. /** @hidden */
  20113. _oldHardwareScaleFactor: number;
  20114. /** @hidden */
  20115. _vrExclusivePointerMode: boolean;
  20116. /** @hidden */
  20117. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20118. /** @hidden */
  20119. _onVRDisplayPointerRestricted: () => void;
  20120. /** @hidden */
  20121. _onVRDisplayPointerUnrestricted: () => void;
  20122. /** @hidden */
  20123. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20124. /** @hidden */
  20125. _onVrDisplayDisconnect: Nullable<() => void>;
  20126. /** @hidden */
  20127. _onVrDisplayPresentChange: Nullable<() => void>;
  20128. /**
  20129. * Observable signaled when VR display mode changes
  20130. */
  20131. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20132. /**
  20133. * Observable signaled when VR request present is complete
  20134. */
  20135. onVRRequestPresentComplete: Observable<boolean>;
  20136. /**
  20137. * Observable signaled when VR request present starts
  20138. */
  20139. onVRRequestPresentStart: Observable<Engine>;
  20140. /**
  20141. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20142. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20143. */
  20144. isInVRExclusivePointerMode: boolean;
  20145. /**
  20146. * Gets a boolean indicating if a webVR device was detected
  20147. * @returns true if a webVR device was detected
  20148. */
  20149. isVRDevicePresent(): boolean;
  20150. /**
  20151. * Gets the current webVR device
  20152. * @returns the current webVR device (or null)
  20153. */
  20154. getVRDevice(): any;
  20155. /**
  20156. * Initializes a webVR display and starts listening to display change events
  20157. * The onVRDisplayChangedObservable will be notified upon these changes
  20158. * @returns A promise containing a VRDisplay and if vr is supported
  20159. */
  20160. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20161. /** @hidden */
  20162. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20163. /**
  20164. * Gets or sets the presentation attributes used to configure VR rendering
  20165. */
  20166. vrPresentationAttributes?: IVRPresentationAttributes;
  20167. /**
  20168. * Call this function to switch to webVR mode
  20169. * Will do nothing if webVR is not supported or if there is no webVR device
  20170. * @param options the webvr options provided to the camera. mainly used for multiview
  20171. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20172. */
  20173. enableVR(options: WebVROptions): void;
  20174. /** @hidden */
  20175. _onVRFullScreenTriggered(): void;
  20176. }
  20177. }
  20178. }
  20179. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20180. import { Nullable } from "babylonjs/types";
  20181. import { Observable } from "babylonjs/Misc/observable";
  20182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20183. import { Scene } from "babylonjs/scene";
  20184. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20185. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20186. import { Node } from "babylonjs/node";
  20187. import { Ray } from "babylonjs/Culling/ray";
  20188. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20189. import "babylonjs/Engines/Extensions/engine.webVR";
  20190. /**
  20191. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20192. * IMPORTANT!! The data is right-hand data.
  20193. * @export
  20194. * @interface DevicePose
  20195. */
  20196. export interface DevicePose {
  20197. /**
  20198. * The position of the device, values in array are [x,y,z].
  20199. */
  20200. readonly position: Nullable<Float32Array>;
  20201. /**
  20202. * The linearVelocity of the device, values in array are [x,y,z].
  20203. */
  20204. readonly linearVelocity: Nullable<Float32Array>;
  20205. /**
  20206. * The linearAcceleration of the device, values in array are [x,y,z].
  20207. */
  20208. readonly linearAcceleration: Nullable<Float32Array>;
  20209. /**
  20210. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20211. */
  20212. readonly orientation: Nullable<Float32Array>;
  20213. /**
  20214. * The angularVelocity of the device, values in array are [x,y,z].
  20215. */
  20216. readonly angularVelocity: Nullable<Float32Array>;
  20217. /**
  20218. * The angularAcceleration of the device, values in array are [x,y,z].
  20219. */
  20220. readonly angularAcceleration: Nullable<Float32Array>;
  20221. }
  20222. /**
  20223. * Interface representing a pose controlled object in Babylon.
  20224. * A pose controlled object has both regular pose values as well as pose values
  20225. * from an external device such as a VR head mounted display
  20226. */
  20227. export interface PoseControlled {
  20228. /**
  20229. * The position of the object in babylon space.
  20230. */
  20231. position: Vector3;
  20232. /**
  20233. * The rotation quaternion of the object in babylon space.
  20234. */
  20235. rotationQuaternion: Quaternion;
  20236. /**
  20237. * The position of the device in babylon space.
  20238. */
  20239. devicePosition?: Vector3;
  20240. /**
  20241. * The rotation quaternion of the device in babylon space.
  20242. */
  20243. deviceRotationQuaternion: Quaternion;
  20244. /**
  20245. * The raw pose coming from the device.
  20246. */
  20247. rawPose: Nullable<DevicePose>;
  20248. /**
  20249. * The scale of the device to be used when translating from device space to babylon space.
  20250. */
  20251. deviceScaleFactor: number;
  20252. /**
  20253. * Updates the poseControlled values based on the input device pose.
  20254. * @param poseData the pose data to update the object with
  20255. */
  20256. updateFromDevice(poseData: DevicePose): void;
  20257. }
  20258. /**
  20259. * Set of options to customize the webVRCamera
  20260. */
  20261. export interface WebVROptions {
  20262. /**
  20263. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20264. */
  20265. trackPosition?: boolean;
  20266. /**
  20267. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20268. */
  20269. positionScale?: number;
  20270. /**
  20271. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20272. */
  20273. displayName?: string;
  20274. /**
  20275. * Should the native controller meshes be initialized. (default: true)
  20276. */
  20277. controllerMeshes?: boolean;
  20278. /**
  20279. * Creating a default HemiLight only on controllers. (default: true)
  20280. */
  20281. defaultLightingOnControllers?: boolean;
  20282. /**
  20283. * If you don't want to use the default VR button of the helper. (default: false)
  20284. */
  20285. useCustomVRButton?: boolean;
  20286. /**
  20287. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20288. */
  20289. customVRButton?: HTMLButtonElement;
  20290. /**
  20291. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20292. */
  20293. rayLength?: number;
  20294. /**
  20295. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20296. */
  20297. defaultHeight?: number;
  20298. /**
  20299. * If multiview should be used if availible (default: false)
  20300. */
  20301. useMultiview?: boolean;
  20302. }
  20303. /**
  20304. * This represents a WebVR camera.
  20305. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20306. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20307. */
  20308. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20309. private webVROptions;
  20310. /**
  20311. * @hidden
  20312. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20313. */
  20314. _vrDevice: any;
  20315. /**
  20316. * The rawPose of the vrDevice.
  20317. */
  20318. rawPose: Nullable<DevicePose>;
  20319. private _onVREnabled;
  20320. private _specsVersion;
  20321. private _attached;
  20322. private _frameData;
  20323. protected _descendants: Array<Node>;
  20324. private _deviceRoomPosition;
  20325. /** @hidden */
  20326. _deviceRoomRotationQuaternion: Quaternion;
  20327. private _standingMatrix;
  20328. /**
  20329. * Represents device position in babylon space.
  20330. */
  20331. devicePosition: Vector3;
  20332. /**
  20333. * Represents device rotation in babylon space.
  20334. */
  20335. deviceRotationQuaternion: Quaternion;
  20336. /**
  20337. * The scale of the device to be used when translating from device space to babylon space.
  20338. */
  20339. deviceScaleFactor: number;
  20340. private _deviceToWorld;
  20341. private _worldToDevice;
  20342. /**
  20343. * References to the webVR controllers for the vrDevice.
  20344. */
  20345. controllers: Array<WebVRController>;
  20346. /**
  20347. * Emits an event when a controller is attached.
  20348. */
  20349. onControllersAttachedObservable: Observable<WebVRController[]>;
  20350. /**
  20351. * Emits an event when a controller's mesh has been loaded;
  20352. */
  20353. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20354. /**
  20355. * Emits an event when the HMD's pose has been updated.
  20356. */
  20357. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20358. private _poseSet;
  20359. /**
  20360. * If the rig cameras be used as parent instead of this camera.
  20361. */
  20362. rigParenting: boolean;
  20363. private _lightOnControllers;
  20364. private _defaultHeight?;
  20365. /**
  20366. * Instantiates a WebVRFreeCamera.
  20367. * @param name The name of the WebVRFreeCamera
  20368. * @param position The starting anchor position for the camera
  20369. * @param scene The scene the camera belongs to
  20370. * @param webVROptions a set of customizable options for the webVRCamera
  20371. */
  20372. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20373. /**
  20374. * Gets the device distance from the ground in meters.
  20375. * @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.
  20376. */
  20377. deviceDistanceToRoomGround(): number;
  20378. /**
  20379. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20380. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20381. */
  20382. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20383. /**
  20384. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20385. * @returns A promise with a boolean set to if the standing matrix is supported.
  20386. */
  20387. useStandingMatrixAsync(): Promise<boolean>;
  20388. /**
  20389. * Disposes the camera
  20390. */
  20391. dispose(): void;
  20392. /**
  20393. * Gets a vrController by name.
  20394. * @param name The name of the controller to retreive
  20395. * @returns the controller matching the name specified or null if not found
  20396. */
  20397. getControllerByName(name: string): Nullable<WebVRController>;
  20398. private _leftController;
  20399. /**
  20400. * The controller corresponding to the users left hand.
  20401. */
  20402. get leftController(): Nullable<WebVRController>;
  20403. private _rightController;
  20404. /**
  20405. * The controller corresponding to the users right hand.
  20406. */
  20407. get rightController(): Nullable<WebVRController>;
  20408. /**
  20409. * Casts a ray forward from the vrCamera's gaze.
  20410. * @param length Length of the ray (default: 100)
  20411. * @returns the ray corresponding to the gaze
  20412. */
  20413. getForwardRay(length?: number): Ray;
  20414. /**
  20415. * @hidden
  20416. * Updates the camera based on device's frame data
  20417. */
  20418. _checkInputs(): void;
  20419. /**
  20420. * Updates the poseControlled values based on the input device pose.
  20421. * @param poseData Pose coming from the device
  20422. */
  20423. updateFromDevice(poseData: DevicePose): void;
  20424. private _htmlElementAttached;
  20425. private _detachIfAttached;
  20426. /**
  20427. * WebVR's attach control will start broadcasting frames to the device.
  20428. * Note that in certain browsers (chrome for example) this function must be called
  20429. * within a user-interaction callback. Example:
  20430. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20431. *
  20432. * @param element html element to attach the vrDevice to
  20433. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20434. */
  20435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20436. /**
  20437. * Detaches the camera from the html element and disables VR
  20438. *
  20439. * @param element html element to detach from
  20440. */
  20441. detachControl(element: HTMLElement): void;
  20442. /**
  20443. * @returns the name of this class
  20444. */
  20445. getClassName(): string;
  20446. /**
  20447. * Calls resetPose on the vrDisplay
  20448. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20449. */
  20450. resetToCurrentRotation(): void;
  20451. /**
  20452. * @hidden
  20453. * Updates the rig cameras (left and right eye)
  20454. */
  20455. _updateRigCameras(): void;
  20456. private _workingVector;
  20457. private _oneVector;
  20458. private _workingMatrix;
  20459. private updateCacheCalled;
  20460. private _correctPositionIfNotTrackPosition;
  20461. /**
  20462. * @hidden
  20463. * Updates the cached values of the camera
  20464. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20465. */
  20466. _updateCache(ignoreParentClass?: boolean): void;
  20467. /**
  20468. * @hidden
  20469. * Get current device position in babylon world
  20470. */
  20471. _computeDevicePosition(): void;
  20472. /**
  20473. * Updates the current device position and rotation in the babylon world
  20474. */
  20475. update(): void;
  20476. /**
  20477. * @hidden
  20478. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20479. * @returns an identity matrix
  20480. */
  20481. _getViewMatrix(): Matrix;
  20482. private _tmpMatrix;
  20483. /**
  20484. * This function is called by the two RIG cameras.
  20485. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20486. * @hidden
  20487. */
  20488. _getWebVRViewMatrix(): Matrix;
  20489. /** @hidden */
  20490. _getWebVRProjectionMatrix(): Matrix;
  20491. private _onGamepadConnectedObserver;
  20492. private _onGamepadDisconnectedObserver;
  20493. private _updateCacheWhenTrackingDisabledObserver;
  20494. /**
  20495. * Initializes the controllers and their meshes
  20496. */
  20497. initControllers(): void;
  20498. }
  20499. }
  20500. declare module "babylonjs/Materials/materialHelper" {
  20501. import { Nullable } from "babylonjs/types";
  20502. import { Scene } from "babylonjs/scene";
  20503. import { Engine } from "babylonjs/Engines/engine";
  20504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20505. import { Light } from "babylonjs/Lights/light";
  20506. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20507. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20509. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20510. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20511. /**
  20512. * "Static Class" containing the most commonly used helper while dealing with material for
  20513. * rendering purpose.
  20514. *
  20515. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20516. *
  20517. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20518. */
  20519. export class MaterialHelper {
  20520. /**
  20521. * Bind the current view position to an effect.
  20522. * @param effect The effect to be bound
  20523. * @param scene The scene the eyes position is used from
  20524. * @param variableName name of the shader variable that will hold the eye position
  20525. */
  20526. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20527. /**
  20528. * Helps preparing the defines values about the UVs in used in the effect.
  20529. * UVs are shared as much as we can accross channels in the shaders.
  20530. * @param texture The texture we are preparing the UVs for
  20531. * @param defines The defines to update
  20532. * @param key The channel key "diffuse", "specular"... used in the shader
  20533. */
  20534. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20535. /**
  20536. * Binds a texture matrix value to its corrsponding uniform
  20537. * @param texture The texture to bind the matrix for
  20538. * @param uniformBuffer The uniform buffer receivin the data
  20539. * @param key The channel key "diffuse", "specular"... used in the shader
  20540. */
  20541. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20542. /**
  20543. * Gets the current status of the fog (should it be enabled?)
  20544. * @param mesh defines the mesh to evaluate for fog support
  20545. * @param scene defines the hosting scene
  20546. * @returns true if fog must be enabled
  20547. */
  20548. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20549. /**
  20550. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20551. * @param mesh defines the current mesh
  20552. * @param scene defines the current scene
  20553. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20554. * @param pointsCloud defines if point cloud rendering has to be turned on
  20555. * @param fogEnabled defines if fog has to be turned on
  20556. * @param alphaTest defines if alpha testing has to be turned on
  20557. * @param defines defines the current list of defines
  20558. */
  20559. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20560. /**
  20561. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20562. * @param scene defines the current scene
  20563. * @param engine defines the current engine
  20564. * @param defines specifies the list of active defines
  20565. * @param useInstances defines if instances have to be turned on
  20566. * @param useClipPlane defines if clip plane have to be turned on
  20567. */
  20568. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  20569. /**
  20570. * Prepares the defines for bones
  20571. * @param mesh The mesh containing the geometry data we will draw
  20572. * @param defines The defines to update
  20573. */
  20574. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20575. /**
  20576. * Prepares the defines for morph targets
  20577. * @param mesh The mesh containing the geometry data we will draw
  20578. * @param defines The defines to update
  20579. */
  20580. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20581. /**
  20582. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20583. * @param mesh The mesh containing the geometry data we will draw
  20584. * @param defines The defines to update
  20585. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20586. * @param useBones Precise whether bones should be used or not (override mesh info)
  20587. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20588. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20589. * @returns false if defines are considered not dirty and have not been checked
  20590. */
  20591. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20592. /**
  20593. * Prepares the defines related to multiview
  20594. * @param scene The scene we are intending to draw
  20595. * @param defines The defines to update
  20596. */
  20597. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20598. /**
  20599. * Prepares the defines related to the light information passed in parameter
  20600. * @param scene The scene we are intending to draw
  20601. * @param mesh The mesh the effect is compiling for
  20602. * @param light The light the effect is compiling for
  20603. * @param lightIndex The index of the light
  20604. * @param defines The defines to update
  20605. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20606. * @param state Defines the current state regarding what is needed (normals, etc...)
  20607. */
  20608. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20609. needNormals: boolean;
  20610. needRebuild: boolean;
  20611. shadowEnabled: boolean;
  20612. specularEnabled: boolean;
  20613. lightmapMode: boolean;
  20614. }): void;
  20615. /**
  20616. * Prepares the defines related to the light information passed in parameter
  20617. * @param scene The scene we are intending to draw
  20618. * @param mesh The mesh the effect is compiling for
  20619. * @param defines The defines to update
  20620. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20621. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20622. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20623. * @returns true if normals will be required for the rest of the effect
  20624. */
  20625. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20626. /**
  20627. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20628. * @param lightIndex defines the light index
  20629. * @param uniformsList The uniform list
  20630. * @param samplersList The sampler list
  20631. * @param projectedLightTexture defines if projected texture must be used
  20632. * @param uniformBuffersList defines an optional list of uniform buffers
  20633. */
  20634. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20635. /**
  20636. * Prepares the uniforms and samplers list to be used in the effect
  20637. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20638. * @param samplersList The sampler list
  20639. * @param defines The defines helping in the list generation
  20640. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20641. */
  20642. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20643. /**
  20644. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20645. * @param defines The defines to update while falling back
  20646. * @param fallbacks The authorized effect fallbacks
  20647. * @param maxSimultaneousLights The maximum number of lights allowed
  20648. * @param rank the current rank of the Effect
  20649. * @returns The newly affected rank
  20650. */
  20651. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20652. private static _TmpMorphInfluencers;
  20653. /**
  20654. * Prepares the list of attributes required for morph targets according to the effect defines.
  20655. * @param attribs The current list of supported attribs
  20656. * @param mesh The mesh to prepare the morph targets attributes for
  20657. * @param influencers The number of influencers
  20658. */
  20659. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20660. /**
  20661. * Prepares the list of attributes required for morph targets according to the effect defines.
  20662. * @param attribs The current list of supported attribs
  20663. * @param mesh The mesh to prepare the morph targets attributes for
  20664. * @param defines The current Defines of the effect
  20665. */
  20666. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20667. /**
  20668. * Prepares the list of attributes required for bones according to the effect defines.
  20669. * @param attribs The current list of supported attribs
  20670. * @param mesh The mesh to prepare the bones attributes for
  20671. * @param defines The current Defines of the effect
  20672. * @param fallbacks The current efffect fallback strategy
  20673. */
  20674. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20675. /**
  20676. * Check and prepare the list of attributes required for instances according to the effect defines.
  20677. * @param attribs The current list of supported attribs
  20678. * @param defines The current MaterialDefines of the effect
  20679. */
  20680. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20681. /**
  20682. * Add the list of attributes required for instances to the attribs array.
  20683. * @param attribs The current list of supported attribs
  20684. */
  20685. static PushAttributesForInstances(attribs: string[]): void;
  20686. /**
  20687. * Binds the light information to the effect.
  20688. * @param light The light containing the generator
  20689. * @param effect The effect we are binding the data to
  20690. * @param lightIndex The light index in the effect used to render
  20691. */
  20692. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20693. /**
  20694. * Binds the lights information from the scene to the effect for the given mesh.
  20695. * @param light Light to bind
  20696. * @param lightIndex Light index
  20697. * @param scene The scene where the light belongs to
  20698. * @param effect The effect we are binding the data to
  20699. * @param useSpecular Defines if specular is supported
  20700. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20701. */
  20702. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20703. /**
  20704. * Binds the lights information from the scene to the effect for the given mesh.
  20705. * @param scene The scene the lights belongs to
  20706. * @param mesh The mesh we are binding the information to render
  20707. * @param effect The effect we are binding the data to
  20708. * @param defines The generated defines for the effect
  20709. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20710. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20711. */
  20712. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20713. private static _tempFogColor;
  20714. /**
  20715. * Binds the fog information from the scene to the effect for the given mesh.
  20716. * @param scene The scene the lights belongs to
  20717. * @param mesh The mesh we are binding the information to render
  20718. * @param effect The effect we are binding the data to
  20719. * @param linearSpace Defines if the fog effect is applied in linear space
  20720. */
  20721. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20722. /**
  20723. * Binds the bones information from the mesh to the effect.
  20724. * @param mesh The mesh we are binding the information to render
  20725. * @param effect The effect we are binding the data to
  20726. */
  20727. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20728. /**
  20729. * Binds the morph targets information from the mesh to the effect.
  20730. * @param abstractMesh The mesh we are binding the information to render
  20731. * @param effect The effect we are binding the data to
  20732. */
  20733. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20734. /**
  20735. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20736. * @param defines The generated defines used in the effect
  20737. * @param effect The effect we are binding the data to
  20738. * @param scene The scene we are willing to render with logarithmic scale for
  20739. */
  20740. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20741. /**
  20742. * Binds the clip plane information from the scene to the effect.
  20743. * @param scene The scene the clip plane information are extracted from
  20744. * @param effect The effect we are binding the data to
  20745. */
  20746. static BindClipPlane(effect: Effect, scene: Scene): void;
  20747. }
  20748. }
  20749. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20751. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20752. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20753. import { Nullable } from "babylonjs/types";
  20754. import { Effect } from "babylonjs/Materials/effect";
  20755. import { Matrix } from "babylonjs/Maths/math.vector";
  20756. import { Scene } from "babylonjs/scene";
  20757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20759. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20760. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20761. import { Observable } from "babylonjs/Misc/observable";
  20762. /**
  20763. * Block used to expose an input value
  20764. */
  20765. export class InputBlock extends NodeMaterialBlock {
  20766. private _mode;
  20767. private _associatedVariableName;
  20768. private _storedValue;
  20769. private _valueCallback;
  20770. private _type;
  20771. private _animationType;
  20772. /** Gets or set a value used to limit the range of float values */
  20773. min: number;
  20774. /** Gets or set a value used to limit the range of float values */
  20775. max: number;
  20776. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20777. isBoolean: boolean;
  20778. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20779. matrixMode: number;
  20780. /** @hidden */
  20781. _systemValue: Nullable<NodeMaterialSystemValues>;
  20782. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20783. visibleInInspector: boolean;
  20784. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20785. isConstant: boolean;
  20786. /** Gets or sets the group to use to display this block in the Inspector */
  20787. groupInInspector: string;
  20788. /** Gets an observable raised when the value is changed */
  20789. onValueChangedObservable: Observable<InputBlock>;
  20790. /**
  20791. * Gets or sets the connection point type (default is float)
  20792. */
  20793. get type(): NodeMaterialBlockConnectionPointTypes;
  20794. /**
  20795. * Creates a new InputBlock
  20796. * @param name defines the block name
  20797. * @param target defines the target of that block (Vertex by default)
  20798. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20799. */
  20800. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20801. /**
  20802. * Gets the output component
  20803. */
  20804. get output(): NodeMaterialConnectionPoint;
  20805. /**
  20806. * Set the source of this connection point to a vertex attribute
  20807. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20808. * @returns the current connection point
  20809. */
  20810. setAsAttribute(attributeName?: string): InputBlock;
  20811. /**
  20812. * Set the source of this connection point to a system value
  20813. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20814. * @returns the current connection point
  20815. */
  20816. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20817. /**
  20818. * Gets or sets the value of that point.
  20819. * Please note that this value will be ignored if valueCallback is defined
  20820. */
  20821. get value(): any;
  20822. set value(value: any);
  20823. /**
  20824. * Gets or sets a callback used to get the value of that point.
  20825. * Please note that setting this value will force the connection point to ignore the value property
  20826. */
  20827. get valueCallback(): () => any;
  20828. set valueCallback(value: () => any);
  20829. /**
  20830. * Gets or sets the associated variable name in the shader
  20831. */
  20832. get associatedVariableName(): string;
  20833. set associatedVariableName(value: string);
  20834. /** Gets or sets the type of animation applied to the input */
  20835. get animationType(): AnimatedInputBlockTypes;
  20836. set animationType(value: AnimatedInputBlockTypes);
  20837. /**
  20838. * Gets a boolean indicating that this connection point not defined yet
  20839. */
  20840. get isUndefined(): boolean;
  20841. /**
  20842. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20843. * In this case the connection point name must be the name of the uniform to use.
  20844. * Can only be set on inputs
  20845. */
  20846. get isUniform(): boolean;
  20847. set isUniform(value: boolean);
  20848. /**
  20849. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20850. * In this case the connection point name must be the name of the attribute to use
  20851. * Can only be set on inputs
  20852. */
  20853. get isAttribute(): boolean;
  20854. set isAttribute(value: boolean);
  20855. /**
  20856. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20857. * Can only be set on exit points
  20858. */
  20859. get isVarying(): boolean;
  20860. set isVarying(value: boolean);
  20861. /**
  20862. * Gets a boolean indicating that the current connection point is a system value
  20863. */
  20864. get isSystemValue(): boolean;
  20865. /**
  20866. * Gets or sets the current well known value or null if not defined as a system value
  20867. */
  20868. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20869. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20870. /**
  20871. * Gets the current class name
  20872. * @returns the class name
  20873. */
  20874. getClassName(): string;
  20875. /**
  20876. * Animate the input if animationType !== None
  20877. * @param scene defines the rendering scene
  20878. */
  20879. animate(scene: Scene): void;
  20880. private _emitDefine;
  20881. initialize(state: NodeMaterialBuildState): void;
  20882. /**
  20883. * Set the input block to its default value (based on its type)
  20884. */
  20885. setDefaultValue(): void;
  20886. private _emitConstant;
  20887. /** @hidden */
  20888. get _noContextSwitch(): boolean;
  20889. private _emit;
  20890. /** @hidden */
  20891. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20892. /** @hidden */
  20893. _transmit(effect: Effect, scene: Scene): void;
  20894. protected _buildBlock(state: NodeMaterialBuildState): void;
  20895. protected _dumpPropertiesCode(): string;
  20896. dispose(): void;
  20897. serialize(): any;
  20898. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20899. }
  20900. }
  20901. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20902. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20903. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20904. import { Nullable } from "babylonjs/types";
  20905. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20906. import { Observable } from "babylonjs/Misc/observable";
  20907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20908. /**
  20909. * Enum used to define the compatibility state between two connection points
  20910. */
  20911. export enum NodeMaterialConnectionPointCompatibilityStates {
  20912. /** Points are compatibles */
  20913. Compatible = 0,
  20914. /** Points are incompatible because of their types */
  20915. TypeIncompatible = 1,
  20916. /** Points are incompatible because of their targets (vertex vs fragment) */
  20917. TargetIncompatible = 2
  20918. }
  20919. /**
  20920. * Defines the direction of a connection point
  20921. */
  20922. export enum NodeMaterialConnectionPointDirection {
  20923. /** Input */
  20924. Input = 0,
  20925. /** Output */
  20926. Output = 1
  20927. }
  20928. /**
  20929. * Defines a connection point for a block
  20930. */
  20931. export class NodeMaterialConnectionPoint {
  20932. /** @hidden */
  20933. _ownerBlock: NodeMaterialBlock;
  20934. /** @hidden */
  20935. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20936. private _endpoints;
  20937. private _associatedVariableName;
  20938. private _direction;
  20939. /** @hidden */
  20940. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20941. /** @hidden */
  20942. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20943. private _type;
  20944. /** @hidden */
  20945. _enforceAssociatedVariableName: boolean;
  20946. /** Gets the direction of the point */
  20947. get direction(): NodeMaterialConnectionPointDirection;
  20948. /** Indicates that this connection point needs dual validation before being connected to another point */
  20949. needDualDirectionValidation: boolean;
  20950. /**
  20951. * Gets or sets the additional types supported by this connection point
  20952. */
  20953. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20954. /**
  20955. * Gets or sets the additional types excluded by this connection point
  20956. */
  20957. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20958. /**
  20959. * Observable triggered when this point is connected
  20960. */
  20961. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20962. /**
  20963. * Gets or sets the associated variable name in the shader
  20964. */
  20965. get associatedVariableName(): string;
  20966. set associatedVariableName(value: string);
  20967. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20968. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20969. /**
  20970. * Gets or sets the connection point type (default is float)
  20971. */
  20972. get type(): NodeMaterialBlockConnectionPointTypes;
  20973. set type(value: NodeMaterialBlockConnectionPointTypes);
  20974. /**
  20975. * Gets or sets the connection point name
  20976. */
  20977. name: string;
  20978. /**
  20979. * Gets or sets the connection point name
  20980. */
  20981. displayName: string;
  20982. /**
  20983. * Gets or sets a boolean indicating that this connection point can be omitted
  20984. */
  20985. isOptional: boolean;
  20986. /**
  20987. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20988. */
  20989. define: string;
  20990. /** @hidden */
  20991. _prioritizeVertex: boolean;
  20992. private _target;
  20993. /** Gets or sets the target of that connection point */
  20994. get target(): NodeMaterialBlockTargets;
  20995. set target(value: NodeMaterialBlockTargets);
  20996. /**
  20997. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20998. */
  20999. get isConnected(): boolean;
  21000. /**
  21001. * Gets a boolean indicating that the current point is connected to an input block
  21002. */
  21003. get isConnectedToInputBlock(): boolean;
  21004. /**
  21005. * Gets a the connected input block (if any)
  21006. */
  21007. get connectInputBlock(): Nullable<InputBlock>;
  21008. /** Get the other side of the connection (if any) */
  21009. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21010. /** Get the block that owns this connection point */
  21011. get ownerBlock(): NodeMaterialBlock;
  21012. /** Get the block connected on the other side of this connection (if any) */
  21013. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21014. /** Get the block connected on the endpoints of this connection (if any) */
  21015. get connectedBlocks(): Array<NodeMaterialBlock>;
  21016. /** Gets the list of connected endpoints */
  21017. get endpoints(): NodeMaterialConnectionPoint[];
  21018. /** Gets a boolean indicating if that output point is connected to at least one input */
  21019. get hasEndpoints(): boolean;
  21020. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21021. get isConnectedInVertexShader(): boolean;
  21022. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21023. get isConnectedInFragmentShader(): boolean;
  21024. /**
  21025. * Creates a block suitable to be used as an input for this input point.
  21026. * If null is returned, a block based on the point type will be created.
  21027. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21028. */
  21029. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21030. /**
  21031. * Creates a new connection point
  21032. * @param name defines the connection point name
  21033. * @param ownerBlock defines the block hosting this connection point
  21034. * @param direction defines the direction of the connection point
  21035. */
  21036. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21037. /**
  21038. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21039. * @returns the class name
  21040. */
  21041. getClassName(): string;
  21042. /**
  21043. * Gets a boolean indicating if the current point can be connected to another point
  21044. * @param connectionPoint defines the other connection point
  21045. * @returns a boolean
  21046. */
  21047. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21048. /**
  21049. * Gets a number indicating if the current point can be connected to another point
  21050. * @param connectionPoint defines the other connection point
  21051. * @returns a number defining the compatibility state
  21052. */
  21053. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21054. /**
  21055. * Connect this point to another connection point
  21056. * @param connectionPoint defines the other connection point
  21057. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21058. * @returns the current connection point
  21059. */
  21060. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21061. /**
  21062. * Disconnect this point from one of his endpoint
  21063. * @param endpoint defines the other connection point
  21064. * @returns the current connection point
  21065. */
  21066. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21067. /**
  21068. * Serializes this point in a JSON representation
  21069. * @param isInput defines if the connection point is an input (default is true)
  21070. * @returns the serialized point object
  21071. */
  21072. serialize(isInput?: boolean): any;
  21073. /**
  21074. * Release resources
  21075. */
  21076. dispose(): void;
  21077. }
  21078. }
  21079. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21080. /**
  21081. * Enum used to define the material modes
  21082. */
  21083. export enum NodeMaterialModes {
  21084. /** Regular material */
  21085. Material = 0,
  21086. /** For post process */
  21087. PostProcess = 1,
  21088. /** For particle system */
  21089. Particle = 2
  21090. }
  21091. }
  21092. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21095. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21098. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21099. import { Effect } from "babylonjs/Materials/effect";
  21100. import { Mesh } from "babylonjs/Meshes/mesh";
  21101. import { Nullable } from "babylonjs/types";
  21102. import { Texture } from "babylonjs/Materials/Textures/texture";
  21103. import { Scene } from "babylonjs/scene";
  21104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21105. /**
  21106. * Block used to read a texture from a sampler
  21107. */
  21108. export class TextureBlock extends NodeMaterialBlock {
  21109. private _defineName;
  21110. private _linearDefineName;
  21111. private _gammaDefineName;
  21112. private _tempTextureRead;
  21113. private _samplerName;
  21114. private _transformedUVName;
  21115. private _textureTransformName;
  21116. private _textureInfoName;
  21117. private _mainUVName;
  21118. private _mainUVDefineName;
  21119. private _fragmentOnly;
  21120. /**
  21121. * Gets or sets the texture associated with the node
  21122. */
  21123. texture: Nullable<Texture>;
  21124. /**
  21125. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21126. */
  21127. convertToGammaSpace: boolean;
  21128. /**
  21129. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21130. */
  21131. convertToLinearSpace: boolean;
  21132. /**
  21133. * Create a new TextureBlock
  21134. * @param name defines the block name
  21135. */
  21136. constructor(name: string, fragmentOnly?: boolean);
  21137. /**
  21138. * Gets the current class name
  21139. * @returns the class name
  21140. */
  21141. getClassName(): string;
  21142. /**
  21143. * Gets the uv input component
  21144. */
  21145. get uv(): NodeMaterialConnectionPoint;
  21146. /**
  21147. * Gets the rgba output component
  21148. */
  21149. get rgba(): NodeMaterialConnectionPoint;
  21150. /**
  21151. * Gets the rgb output component
  21152. */
  21153. get rgb(): NodeMaterialConnectionPoint;
  21154. /**
  21155. * Gets the r output component
  21156. */
  21157. get r(): NodeMaterialConnectionPoint;
  21158. /**
  21159. * Gets the g output component
  21160. */
  21161. get g(): NodeMaterialConnectionPoint;
  21162. /**
  21163. * Gets the b output component
  21164. */
  21165. get b(): NodeMaterialConnectionPoint;
  21166. /**
  21167. * Gets the a output component
  21168. */
  21169. get a(): NodeMaterialConnectionPoint;
  21170. get target(): NodeMaterialBlockTargets;
  21171. autoConfigure(material: NodeMaterial): void;
  21172. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21174. isReady(): boolean;
  21175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21176. private get _isMixed();
  21177. private _injectVertexCode;
  21178. private _writeTextureRead;
  21179. private _writeOutput;
  21180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21181. protected _dumpPropertiesCode(): string;
  21182. serialize(): any;
  21183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21184. }
  21185. }
  21186. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21187. /** @hidden */
  21188. export var reflectionFunction: {
  21189. name: string;
  21190. shader: string;
  21191. };
  21192. }
  21193. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21199. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21200. import { Effect } from "babylonjs/Materials/effect";
  21201. import { Mesh } from "babylonjs/Meshes/mesh";
  21202. import { Nullable } from "babylonjs/types";
  21203. import { Scene } from "babylonjs/scene";
  21204. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21205. /**
  21206. * Base block used to read a reflection texture from a sampler
  21207. */
  21208. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21209. /** @hidden */
  21210. _define3DName: string;
  21211. /** @hidden */
  21212. _defineCubicName: string;
  21213. /** @hidden */
  21214. _defineExplicitName: string;
  21215. /** @hidden */
  21216. _defineProjectionName: string;
  21217. /** @hidden */
  21218. _defineLocalCubicName: string;
  21219. /** @hidden */
  21220. _defineSphericalName: string;
  21221. /** @hidden */
  21222. _definePlanarName: string;
  21223. /** @hidden */
  21224. _defineEquirectangularName: string;
  21225. /** @hidden */
  21226. _defineMirroredEquirectangularFixedName: string;
  21227. /** @hidden */
  21228. _defineEquirectangularFixedName: string;
  21229. /** @hidden */
  21230. _defineSkyboxName: string;
  21231. /** @hidden */
  21232. _defineOppositeZ: string;
  21233. /** @hidden */
  21234. _cubeSamplerName: string;
  21235. /** @hidden */
  21236. _2DSamplerName: string;
  21237. protected _positionUVWName: string;
  21238. protected _directionWName: string;
  21239. protected _reflectionVectorName: string;
  21240. /** @hidden */
  21241. _reflectionCoordsName: string;
  21242. /** @hidden */
  21243. _reflectionMatrixName: string;
  21244. protected _reflectionColorName: string;
  21245. /**
  21246. * Gets or sets the texture associated with the node
  21247. */
  21248. texture: Nullable<BaseTexture>;
  21249. /**
  21250. * Create a new ReflectionTextureBaseBlock
  21251. * @param name defines the block name
  21252. */
  21253. constructor(name: string);
  21254. /**
  21255. * Gets the current class name
  21256. * @returns the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Gets the world position input component
  21261. */
  21262. abstract get position(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the world position input component
  21265. */
  21266. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the world normal input component
  21269. */
  21270. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the world input component
  21273. */
  21274. abstract get world(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the camera (or eye) position component
  21277. */
  21278. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Gets the view input component
  21281. */
  21282. abstract get view(): NodeMaterialConnectionPoint;
  21283. protected _getTexture(): Nullable<BaseTexture>;
  21284. autoConfigure(material: NodeMaterial): void;
  21285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21286. isReady(): boolean;
  21287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21288. /**
  21289. * Gets the code to inject in the vertex shader
  21290. * @param state current state of the node material building
  21291. * @returns the shader code
  21292. */
  21293. handleVertexSide(state: NodeMaterialBuildState): string;
  21294. /**
  21295. * Handles the inits for the fragment code path
  21296. * @param state node material build state
  21297. */
  21298. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21299. /**
  21300. * Generates the reflection coords code for the fragment code path
  21301. * @param worldNormalVarName name of the world normal variable
  21302. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21303. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21304. * @returns the shader code
  21305. */
  21306. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21307. /**
  21308. * Generates the reflection color code for the fragment code path
  21309. * @param lodVarName name of the lod variable
  21310. * @param swizzleLookupTexture swizzle to use for the final color variable
  21311. * @returns the shader code
  21312. */
  21313. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21314. /**
  21315. * Generates the code corresponding to the connected output points
  21316. * @param state node material build state
  21317. * @param varName name of the variable to output
  21318. * @returns the shader code
  21319. */
  21320. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21321. protected _buildBlock(state: NodeMaterialBuildState): this;
  21322. protected _dumpPropertiesCode(): string;
  21323. serialize(): any;
  21324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21325. }
  21326. }
  21327. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21329. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21330. import { Nullable } from "babylonjs/types";
  21331. /**
  21332. * Defines a connection point to be used for points with a custom object type
  21333. */
  21334. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21335. private _blockType;
  21336. private _blockName;
  21337. private _nameForCheking?;
  21338. /**
  21339. * Creates a new connection point
  21340. * @param name defines the connection point name
  21341. * @param ownerBlock defines the block hosting this connection point
  21342. * @param direction defines the direction of the connection point
  21343. */
  21344. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21345. /**
  21346. * Gets a number indicating if the current point can be connected to another point
  21347. * @param connectionPoint defines the other connection point
  21348. * @returns a number defining the compatibility state
  21349. */
  21350. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21351. /**
  21352. * Creates a block suitable to be used as an input for this input point.
  21353. * If null is returned, a block based on the point type will be created.
  21354. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21355. */
  21356. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21357. }
  21358. }
  21359. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21360. /**
  21361. * Enum defining the type of properties that can be edited in the property pages in the NME
  21362. */
  21363. export enum PropertyTypeForEdition {
  21364. /** property is a boolean */
  21365. Boolean = 0,
  21366. /** property is a float */
  21367. Float = 1,
  21368. /** property is a Vector2 */
  21369. Vector2 = 2,
  21370. /** property is a list of values */
  21371. List = 3
  21372. }
  21373. /**
  21374. * Interface that defines an option in a variable of type list
  21375. */
  21376. export interface IEditablePropertyListOption {
  21377. /** label of the option */
  21378. "label": string;
  21379. /** value of the option */
  21380. "value": number;
  21381. }
  21382. /**
  21383. * Interface that defines the options available for an editable property
  21384. */
  21385. export interface IEditablePropertyOption {
  21386. /** min value */
  21387. "min"?: number;
  21388. /** max value */
  21389. "max"?: number;
  21390. /** notifiers: indicates which actions to take when the property is changed */
  21391. "notifiers"?: {
  21392. /** the material should be rebuilt */
  21393. "rebuild"?: boolean;
  21394. /** the preview should be updated */
  21395. "update"?: boolean;
  21396. };
  21397. /** list of the options for a variable of type list */
  21398. "options"?: IEditablePropertyListOption[];
  21399. }
  21400. /**
  21401. * Interface that describes an editable property
  21402. */
  21403. export interface IPropertyDescriptionForEdition {
  21404. /** name of the property */
  21405. "propertyName": string;
  21406. /** display name of the property */
  21407. "displayName": string;
  21408. /** type of the property */
  21409. "type": PropertyTypeForEdition;
  21410. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21411. "groupName": string;
  21412. /** options for the property */
  21413. "options": IEditablePropertyOption;
  21414. }
  21415. /**
  21416. * Decorator that flags a property in a node material block as being editable
  21417. */
  21418. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21419. }
  21420. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21423. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21425. import { Nullable } from "babylonjs/types";
  21426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21427. import { Mesh } from "babylonjs/Meshes/mesh";
  21428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21429. import { Effect } from "babylonjs/Materials/effect";
  21430. import { Scene } from "babylonjs/scene";
  21431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21432. /**
  21433. * Block used to implement the refraction part of the sub surface module of the PBR material
  21434. */
  21435. export class RefractionBlock extends NodeMaterialBlock {
  21436. /** @hidden */
  21437. _define3DName: string;
  21438. /** @hidden */
  21439. _refractionMatrixName: string;
  21440. /** @hidden */
  21441. _defineLODRefractionAlpha: string;
  21442. /** @hidden */
  21443. _defineLinearSpecularRefraction: string;
  21444. /** @hidden */
  21445. _defineOppositeZ: string;
  21446. /** @hidden */
  21447. _cubeSamplerName: string;
  21448. /** @hidden */
  21449. _2DSamplerName: string;
  21450. /** @hidden */
  21451. _vRefractionMicrosurfaceInfosName: string;
  21452. /** @hidden */
  21453. _vRefractionInfosName: string;
  21454. private _scene;
  21455. /**
  21456. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21457. * Materials half opaque for instance using refraction could benefit from this control.
  21458. */
  21459. linkRefractionWithTransparency: boolean;
  21460. /**
  21461. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21462. */
  21463. invertRefractionY: boolean;
  21464. /**
  21465. * Gets or sets the texture associated with the node
  21466. */
  21467. texture: Nullable<BaseTexture>;
  21468. /**
  21469. * Create a new RefractionBlock
  21470. * @param name defines the block name
  21471. */
  21472. constructor(name: string);
  21473. /**
  21474. * Gets the current class name
  21475. * @returns the class name
  21476. */
  21477. getClassName(): string;
  21478. /**
  21479. * Gets the intensity input component
  21480. */
  21481. get intensity(): NodeMaterialConnectionPoint;
  21482. /**
  21483. * Gets the index of refraction input component
  21484. */
  21485. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21486. /**
  21487. * Gets the tint at distance input component
  21488. */
  21489. get tintAtDistance(): NodeMaterialConnectionPoint;
  21490. /**
  21491. * Gets the view input component
  21492. */
  21493. get view(): NodeMaterialConnectionPoint;
  21494. /**
  21495. * Gets the refraction object output component
  21496. */
  21497. get refraction(): NodeMaterialConnectionPoint;
  21498. /**
  21499. * Returns true if the block has a texture
  21500. */
  21501. get hasTexture(): boolean;
  21502. protected _getTexture(): Nullable<BaseTexture>;
  21503. autoConfigure(material: NodeMaterial): void;
  21504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21505. isReady(): boolean;
  21506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21507. /**
  21508. * Gets the main code of the block (fragment side)
  21509. * @param state current state of the node material building
  21510. * @returns the shader code
  21511. */
  21512. getCode(state: NodeMaterialBuildState): string;
  21513. protected _buildBlock(state: NodeMaterialBuildState): this;
  21514. protected _dumpPropertiesCode(): string;
  21515. serialize(): any;
  21516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21517. }
  21518. }
  21519. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21522. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21525. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21527. import { Nullable } from "babylonjs/types";
  21528. import { Scene } from "babylonjs/scene";
  21529. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21530. /**
  21531. * Base block used as input for post process
  21532. */
  21533. export class CurrentScreenBlock extends NodeMaterialBlock {
  21534. private _samplerName;
  21535. private _linearDefineName;
  21536. private _gammaDefineName;
  21537. private _mainUVName;
  21538. private _tempTextureRead;
  21539. /**
  21540. * Gets or sets the texture associated with the node
  21541. */
  21542. texture: Nullable<BaseTexture>;
  21543. /**
  21544. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21545. */
  21546. convertToGammaSpace: boolean;
  21547. /**
  21548. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21549. */
  21550. convertToLinearSpace: boolean;
  21551. /**
  21552. * Create a new CurrentScreenBlock
  21553. * @param name defines the block name
  21554. */
  21555. constructor(name: string);
  21556. /**
  21557. * Gets the current class name
  21558. * @returns the class name
  21559. */
  21560. getClassName(): string;
  21561. /**
  21562. * Gets the uv input component
  21563. */
  21564. get uv(): NodeMaterialConnectionPoint;
  21565. /**
  21566. * Gets the rgba output component
  21567. */
  21568. get rgba(): NodeMaterialConnectionPoint;
  21569. /**
  21570. * Gets the rgb output component
  21571. */
  21572. get rgb(): NodeMaterialConnectionPoint;
  21573. /**
  21574. * Gets the r output component
  21575. */
  21576. get r(): NodeMaterialConnectionPoint;
  21577. /**
  21578. * Gets the g output component
  21579. */
  21580. get g(): NodeMaterialConnectionPoint;
  21581. /**
  21582. * Gets the b output component
  21583. */
  21584. get b(): NodeMaterialConnectionPoint;
  21585. /**
  21586. * Gets the a output component
  21587. */
  21588. get a(): NodeMaterialConnectionPoint;
  21589. /**
  21590. * Initialize the block and prepare the context for build
  21591. * @param state defines the state that will be used for the build
  21592. */
  21593. initialize(state: NodeMaterialBuildState): void;
  21594. get target(): NodeMaterialBlockTargets;
  21595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21596. isReady(): boolean;
  21597. private _injectVertexCode;
  21598. private _writeTextureRead;
  21599. private _writeOutput;
  21600. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21601. serialize(): any;
  21602. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21603. }
  21604. }
  21605. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21610. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21612. import { Nullable } from "babylonjs/types";
  21613. import { Scene } from "babylonjs/scene";
  21614. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21615. /**
  21616. * Base block used for the particle texture
  21617. */
  21618. export class ParticleTextureBlock extends NodeMaterialBlock {
  21619. private _samplerName;
  21620. private _linearDefineName;
  21621. private _gammaDefineName;
  21622. private _tempTextureRead;
  21623. /**
  21624. * Gets or sets the texture associated with the node
  21625. */
  21626. texture: Nullable<BaseTexture>;
  21627. /**
  21628. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21629. */
  21630. convertToGammaSpace: boolean;
  21631. /**
  21632. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21633. */
  21634. convertToLinearSpace: boolean;
  21635. /**
  21636. * Create a new ParticleTextureBlock
  21637. * @param name defines the block name
  21638. */
  21639. constructor(name: string);
  21640. /**
  21641. * Gets the current class name
  21642. * @returns the class name
  21643. */
  21644. getClassName(): string;
  21645. /**
  21646. * Gets the uv input component
  21647. */
  21648. get uv(): NodeMaterialConnectionPoint;
  21649. /**
  21650. * Gets the rgba output component
  21651. */
  21652. get rgba(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the rgb output component
  21655. */
  21656. get rgb(): NodeMaterialConnectionPoint;
  21657. /**
  21658. * Gets the r output component
  21659. */
  21660. get r(): NodeMaterialConnectionPoint;
  21661. /**
  21662. * Gets the g output component
  21663. */
  21664. get g(): NodeMaterialConnectionPoint;
  21665. /**
  21666. * Gets the b output component
  21667. */
  21668. get b(): NodeMaterialConnectionPoint;
  21669. /**
  21670. * Gets the a output component
  21671. */
  21672. get a(): NodeMaterialConnectionPoint;
  21673. /**
  21674. * Initialize the block and prepare the context for build
  21675. * @param state defines the state that will be used for the build
  21676. */
  21677. initialize(state: NodeMaterialBuildState): void;
  21678. autoConfigure(material: NodeMaterial): void;
  21679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21680. isReady(): boolean;
  21681. private _writeOutput;
  21682. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21683. serialize(): any;
  21684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21685. }
  21686. }
  21687. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21690. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21691. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21692. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21693. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21694. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21695. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21696. import { Scene } from "babylonjs/scene";
  21697. /**
  21698. * Class used to store shared data between 2 NodeMaterialBuildState
  21699. */
  21700. export class NodeMaterialBuildStateSharedData {
  21701. /**
  21702. * Gets the list of emitted varyings
  21703. */
  21704. temps: string[];
  21705. /**
  21706. * Gets the list of emitted varyings
  21707. */
  21708. varyings: string[];
  21709. /**
  21710. * Gets the varying declaration string
  21711. */
  21712. varyingDeclaration: string;
  21713. /**
  21714. * Input blocks
  21715. */
  21716. inputBlocks: InputBlock[];
  21717. /**
  21718. * Input blocks
  21719. */
  21720. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21721. /**
  21722. * Bindable blocks (Blocks that need to set data to the effect)
  21723. */
  21724. bindableBlocks: NodeMaterialBlock[];
  21725. /**
  21726. * List of blocks that can provide a compilation fallback
  21727. */
  21728. blocksWithFallbacks: NodeMaterialBlock[];
  21729. /**
  21730. * List of blocks that can provide a define update
  21731. */
  21732. blocksWithDefines: NodeMaterialBlock[];
  21733. /**
  21734. * List of blocks that can provide a repeatable content
  21735. */
  21736. repeatableContentBlocks: NodeMaterialBlock[];
  21737. /**
  21738. * List of blocks that can provide a dynamic list of uniforms
  21739. */
  21740. dynamicUniformBlocks: NodeMaterialBlock[];
  21741. /**
  21742. * List of blocks that can block the isReady function for the material
  21743. */
  21744. blockingBlocks: NodeMaterialBlock[];
  21745. /**
  21746. * Gets the list of animated inputs
  21747. */
  21748. animatedInputs: InputBlock[];
  21749. /**
  21750. * Build Id used to avoid multiple recompilations
  21751. */
  21752. buildId: number;
  21753. /** List of emitted variables */
  21754. variableNames: {
  21755. [key: string]: number;
  21756. };
  21757. /** List of emitted defines */
  21758. defineNames: {
  21759. [key: string]: number;
  21760. };
  21761. /** Should emit comments? */
  21762. emitComments: boolean;
  21763. /** Emit build activity */
  21764. verbose: boolean;
  21765. /** Gets or sets the hosting scene */
  21766. scene: Scene;
  21767. /**
  21768. * Gets the compilation hints emitted at compilation time
  21769. */
  21770. hints: {
  21771. needWorldViewMatrix: boolean;
  21772. needWorldViewProjectionMatrix: boolean;
  21773. needAlphaBlending: boolean;
  21774. needAlphaTesting: boolean;
  21775. };
  21776. /**
  21777. * List of compilation checks
  21778. */
  21779. checks: {
  21780. emitVertex: boolean;
  21781. emitFragment: boolean;
  21782. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21783. };
  21784. /**
  21785. * Is vertex program allowed to be empty?
  21786. */
  21787. allowEmptyVertexProgram: boolean;
  21788. /** Creates a new shared data */
  21789. constructor();
  21790. /**
  21791. * Emits console errors and exceptions if there is a failing check
  21792. */
  21793. emitErrors(): void;
  21794. }
  21795. }
  21796. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21797. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21798. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21799. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21800. /**
  21801. * Class used to store node based material build state
  21802. */
  21803. export class NodeMaterialBuildState {
  21804. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21805. supportUniformBuffers: boolean;
  21806. /**
  21807. * Gets the list of emitted attributes
  21808. */
  21809. attributes: string[];
  21810. /**
  21811. * Gets the list of emitted uniforms
  21812. */
  21813. uniforms: string[];
  21814. /**
  21815. * Gets the list of emitted constants
  21816. */
  21817. constants: string[];
  21818. /**
  21819. * Gets the list of emitted samplers
  21820. */
  21821. samplers: string[];
  21822. /**
  21823. * Gets the list of emitted functions
  21824. */
  21825. functions: {
  21826. [key: string]: string;
  21827. };
  21828. /**
  21829. * Gets the list of emitted extensions
  21830. */
  21831. extensions: {
  21832. [key: string]: string;
  21833. };
  21834. /**
  21835. * Gets the target of the compilation state
  21836. */
  21837. target: NodeMaterialBlockTargets;
  21838. /**
  21839. * Gets the list of emitted counters
  21840. */
  21841. counters: {
  21842. [key: string]: number;
  21843. };
  21844. /**
  21845. * Shared data between multiple NodeMaterialBuildState instances
  21846. */
  21847. sharedData: NodeMaterialBuildStateSharedData;
  21848. /** @hidden */
  21849. _vertexState: NodeMaterialBuildState;
  21850. /** @hidden */
  21851. _attributeDeclaration: string;
  21852. /** @hidden */
  21853. _uniformDeclaration: string;
  21854. /** @hidden */
  21855. _constantDeclaration: string;
  21856. /** @hidden */
  21857. _samplerDeclaration: string;
  21858. /** @hidden */
  21859. _varyingTransfer: string;
  21860. /** @hidden */
  21861. _injectAtEnd: string;
  21862. private _repeatableContentAnchorIndex;
  21863. /** @hidden */
  21864. _builtCompilationString: string;
  21865. /**
  21866. * Gets the emitted compilation strings
  21867. */
  21868. compilationString: string;
  21869. /**
  21870. * Finalize the compilation strings
  21871. * @param state defines the current compilation state
  21872. */
  21873. finalize(state: NodeMaterialBuildState): void;
  21874. /** @hidden */
  21875. get _repeatableContentAnchor(): string;
  21876. /** @hidden */
  21877. _getFreeVariableName(prefix: string): string;
  21878. /** @hidden */
  21879. _getFreeDefineName(prefix: string): string;
  21880. /** @hidden */
  21881. _excludeVariableName(name: string): void;
  21882. /** @hidden */
  21883. _emit2DSampler(name: string): void;
  21884. /** @hidden */
  21885. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21886. /** @hidden */
  21887. _emitExtension(name: string, extension: string, define?: string): void;
  21888. /** @hidden */
  21889. _emitFunction(name: string, code: string, comments: string): void;
  21890. /** @hidden */
  21891. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21892. replaceStrings?: {
  21893. search: RegExp;
  21894. replace: string;
  21895. }[];
  21896. repeatKey?: string;
  21897. }): string;
  21898. /** @hidden */
  21899. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21900. repeatKey?: string;
  21901. removeAttributes?: boolean;
  21902. removeUniforms?: boolean;
  21903. removeVaryings?: boolean;
  21904. removeIfDef?: boolean;
  21905. replaceStrings?: {
  21906. search: RegExp;
  21907. replace: string;
  21908. }[];
  21909. }, storeKey?: string): void;
  21910. /** @hidden */
  21911. _registerTempVariable(name: string): boolean;
  21912. /** @hidden */
  21913. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21914. /** @hidden */
  21915. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21916. /** @hidden */
  21917. _emitFloat(value: number): string;
  21918. }
  21919. }
  21920. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21921. /**
  21922. * Helper class used to generate session unique ID
  21923. */
  21924. export class UniqueIdGenerator {
  21925. private static _UniqueIdCounter;
  21926. /**
  21927. * Gets an unique (relatively to the current scene) Id
  21928. */
  21929. static get UniqueId(): number;
  21930. }
  21931. }
  21932. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21933. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21935. import { Nullable } from "babylonjs/types";
  21936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21937. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21938. import { Effect } from "babylonjs/Materials/effect";
  21939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21940. import { Mesh } from "babylonjs/Meshes/mesh";
  21941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21942. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21943. import { Scene } from "babylonjs/scene";
  21944. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21945. /**
  21946. * Defines a block that can be used inside a node based material
  21947. */
  21948. export class NodeMaterialBlock {
  21949. private _buildId;
  21950. private _buildTarget;
  21951. private _target;
  21952. private _isFinalMerger;
  21953. private _isInput;
  21954. protected _isUnique: boolean;
  21955. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21956. inputsAreExclusive: boolean;
  21957. /** @hidden */
  21958. _codeVariableName: string;
  21959. /** @hidden */
  21960. _inputs: NodeMaterialConnectionPoint[];
  21961. /** @hidden */
  21962. _outputs: NodeMaterialConnectionPoint[];
  21963. /** @hidden */
  21964. _preparationId: number;
  21965. /**
  21966. * Gets or sets the name of the block
  21967. */
  21968. name: string;
  21969. /**
  21970. * Gets or sets the unique id of the node
  21971. */
  21972. uniqueId: number;
  21973. /**
  21974. * Gets or sets the comments associated with this block
  21975. */
  21976. comments: string;
  21977. /**
  21978. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21979. */
  21980. get isUnique(): boolean;
  21981. /**
  21982. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21983. */
  21984. get isFinalMerger(): boolean;
  21985. /**
  21986. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21987. */
  21988. get isInput(): boolean;
  21989. /**
  21990. * Gets or sets the build Id
  21991. */
  21992. get buildId(): number;
  21993. set buildId(value: number);
  21994. /**
  21995. * Gets or sets the target of the block
  21996. */
  21997. get target(): NodeMaterialBlockTargets;
  21998. set target(value: NodeMaterialBlockTargets);
  21999. /**
  22000. * Gets the list of input points
  22001. */
  22002. get inputs(): NodeMaterialConnectionPoint[];
  22003. /** Gets the list of output points */
  22004. get outputs(): NodeMaterialConnectionPoint[];
  22005. /**
  22006. * Find an input by its name
  22007. * @param name defines the name of the input to look for
  22008. * @returns the input or null if not found
  22009. */
  22010. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22011. /**
  22012. * Find an output by its name
  22013. * @param name defines the name of the outputto look for
  22014. * @returns the output or null if not found
  22015. */
  22016. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22017. /**
  22018. * Creates a new NodeMaterialBlock
  22019. * @param name defines the block name
  22020. * @param target defines the target of that block (Vertex by default)
  22021. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22022. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22023. */
  22024. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22025. /**
  22026. * Initialize the block and prepare the context for build
  22027. * @param state defines the state that will be used for the build
  22028. */
  22029. initialize(state: NodeMaterialBuildState): void;
  22030. /**
  22031. * Bind data to effect. Will only be called for blocks with isBindable === true
  22032. * @param effect defines the effect to bind data to
  22033. * @param nodeMaterial defines the hosting NodeMaterial
  22034. * @param mesh defines the mesh that will be rendered
  22035. * @param subMesh defines the submesh that will be rendered
  22036. */
  22037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22038. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22039. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22040. protected _writeFloat(value: number): string;
  22041. /**
  22042. * Gets the current class name e.g. "NodeMaterialBlock"
  22043. * @returns the class name
  22044. */
  22045. getClassName(): string;
  22046. /**
  22047. * Register a new input. Must be called inside a block constructor
  22048. * @param name defines the connection point name
  22049. * @param type defines the connection point type
  22050. * @param isOptional defines a boolean indicating that this input can be omitted
  22051. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22052. * @param point an already created connection point. If not provided, create a new one
  22053. * @returns the current block
  22054. */
  22055. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22056. /**
  22057. * Register a new output. Must be called inside a block constructor
  22058. * @param name defines the connection point name
  22059. * @param type defines the connection point type
  22060. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22061. * @param point an already created connection point. If not provided, create a new one
  22062. * @returns the current block
  22063. */
  22064. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22065. /**
  22066. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22067. * @param forOutput defines an optional connection point to check compatibility with
  22068. * @returns the first available input or null
  22069. */
  22070. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22071. /**
  22072. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22073. * @param forBlock defines an optional block to check compatibility with
  22074. * @returns the first available input or null
  22075. */
  22076. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22077. /**
  22078. * Gets the sibling of the given output
  22079. * @param current defines the current output
  22080. * @returns the next output in the list or null
  22081. */
  22082. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22083. /**
  22084. * Connect current block with another block
  22085. * @param other defines the block to connect with
  22086. * @param options define the various options to help pick the right connections
  22087. * @returns the current block
  22088. */
  22089. connectTo(other: NodeMaterialBlock, options?: {
  22090. input?: string;
  22091. output?: string;
  22092. outputSwizzle?: string;
  22093. }): this | undefined;
  22094. protected _buildBlock(state: NodeMaterialBuildState): void;
  22095. /**
  22096. * Add uniforms, samplers and uniform buffers at compilation time
  22097. * @param state defines the state to update
  22098. * @param nodeMaterial defines the node material requesting the update
  22099. * @param defines defines the material defines to update
  22100. * @param uniformBuffers defines the list of uniform buffer names
  22101. */
  22102. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22103. /**
  22104. * Add potential fallbacks if shader compilation fails
  22105. * @param mesh defines the mesh to be rendered
  22106. * @param fallbacks defines the current prioritized list of fallbacks
  22107. */
  22108. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22109. /**
  22110. * Initialize defines for shader compilation
  22111. * @param mesh defines the mesh to be rendered
  22112. * @param nodeMaterial defines the node material requesting the update
  22113. * @param defines defines the material defines to update
  22114. * @param useInstances specifies that instances should be used
  22115. */
  22116. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22117. /**
  22118. * Update defines for shader compilation
  22119. * @param mesh defines the mesh to be rendered
  22120. * @param nodeMaterial defines the node material requesting the update
  22121. * @param defines defines the material defines to update
  22122. * @param useInstances specifies that instances should be used
  22123. */
  22124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22125. /**
  22126. * Lets the block try to connect some inputs automatically
  22127. * @param material defines the hosting NodeMaterial
  22128. */
  22129. autoConfigure(material: NodeMaterial): void;
  22130. /**
  22131. * Function called when a block is declared as repeatable content generator
  22132. * @param vertexShaderState defines the current compilation state for the vertex shader
  22133. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22134. * @param mesh defines the mesh to be rendered
  22135. * @param defines defines the material defines to update
  22136. */
  22137. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22138. /**
  22139. * Checks if the block is ready
  22140. * @param mesh defines the mesh to be rendered
  22141. * @param nodeMaterial defines the node material requesting the update
  22142. * @param defines defines the material defines to update
  22143. * @param useInstances specifies that instances should be used
  22144. * @returns true if the block is ready
  22145. */
  22146. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22147. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22148. private _processBuild;
  22149. /**
  22150. * Compile the current node and generate the shader code
  22151. * @param state defines the current compilation state (uniforms, samplers, current string)
  22152. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22153. * @returns true if already built
  22154. */
  22155. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22156. protected _inputRename(name: string): string;
  22157. protected _outputRename(name: string): string;
  22158. protected _dumpPropertiesCode(): string;
  22159. /** @hidden */
  22160. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22161. /** @hidden */
  22162. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22163. /**
  22164. * Clone the current block to a new identical block
  22165. * @param scene defines the hosting scene
  22166. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22167. * @returns a copy of the current block
  22168. */
  22169. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22170. /**
  22171. * Serializes this block in a JSON representation
  22172. * @returns the serialized block object
  22173. */
  22174. serialize(): any;
  22175. /** @hidden */
  22176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22177. private _deserializePortDisplayNames;
  22178. /**
  22179. * Release resources
  22180. */
  22181. dispose(): void;
  22182. }
  22183. }
  22184. declare module "babylonjs/Materials/pushMaterial" {
  22185. import { Nullable } from "babylonjs/types";
  22186. import { Scene } from "babylonjs/scene";
  22187. import { Matrix } from "babylonjs/Maths/math.vector";
  22188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22189. import { Mesh } from "babylonjs/Meshes/mesh";
  22190. import { Material } from "babylonjs/Materials/material";
  22191. import { Effect } from "babylonjs/Materials/effect";
  22192. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22193. /**
  22194. * Base class of materials working in push mode in babylon JS
  22195. * @hidden
  22196. */
  22197. export class PushMaterial extends Material {
  22198. protected _activeEffect: Effect;
  22199. protected _normalMatrix: Matrix;
  22200. /**
  22201. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22202. * This means that the material can keep using a previous shader while a new one is being compiled.
  22203. * This is mostly used when shader parallel compilation is supported (true by default)
  22204. */
  22205. allowShaderHotSwapping: boolean;
  22206. constructor(name: string, scene: Scene);
  22207. getEffect(): Effect;
  22208. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22209. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22210. /**
  22211. * Binds the given world matrix to the active effect
  22212. *
  22213. * @param world the matrix to bind
  22214. */
  22215. bindOnlyWorldMatrix(world: Matrix): void;
  22216. /**
  22217. * Binds the given normal matrix to the active effect
  22218. *
  22219. * @param normalMatrix the matrix to bind
  22220. */
  22221. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22222. bind(world: Matrix, mesh?: Mesh): void;
  22223. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22224. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22225. }
  22226. }
  22227. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22229. /**
  22230. * Root class for all node material optimizers
  22231. */
  22232. export class NodeMaterialOptimizer {
  22233. /**
  22234. * Function used to optimize a NodeMaterial graph
  22235. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22236. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22237. */
  22238. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22239. }
  22240. }
  22241. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22245. import { Scene } from "babylonjs/scene";
  22246. /**
  22247. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22248. */
  22249. export class TransformBlock extends NodeMaterialBlock {
  22250. /**
  22251. * Defines the value to use to complement W value to transform it to a Vector4
  22252. */
  22253. complementW: number;
  22254. /**
  22255. * Defines the value to use to complement z value to transform it to a Vector4
  22256. */
  22257. complementZ: number;
  22258. /**
  22259. * Creates a new TransformBlock
  22260. * @param name defines the block name
  22261. */
  22262. constructor(name: string);
  22263. /**
  22264. * Gets the current class name
  22265. * @returns the class name
  22266. */
  22267. getClassName(): string;
  22268. /**
  22269. * Gets the vector input
  22270. */
  22271. get vector(): NodeMaterialConnectionPoint;
  22272. /**
  22273. * Gets the output component
  22274. */
  22275. get output(): NodeMaterialConnectionPoint;
  22276. /**
  22277. * Gets the xyz output component
  22278. */
  22279. get xyz(): NodeMaterialConnectionPoint;
  22280. /**
  22281. * Gets the matrix transform input
  22282. */
  22283. get transform(): NodeMaterialConnectionPoint;
  22284. protected _buildBlock(state: NodeMaterialBuildState): this;
  22285. serialize(): any;
  22286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22287. protected _dumpPropertiesCode(): string;
  22288. }
  22289. }
  22290. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22294. /**
  22295. * Block used to output the vertex position
  22296. */
  22297. export class VertexOutputBlock extends NodeMaterialBlock {
  22298. /**
  22299. * Creates a new VertexOutputBlock
  22300. * @param name defines the block name
  22301. */
  22302. constructor(name: string);
  22303. /**
  22304. * Gets the current class name
  22305. * @returns the class name
  22306. */
  22307. getClassName(): string;
  22308. /**
  22309. * Gets the vector input component
  22310. */
  22311. get vector(): NodeMaterialConnectionPoint;
  22312. protected _buildBlock(state: NodeMaterialBuildState): this;
  22313. }
  22314. }
  22315. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22319. /**
  22320. * Block used to output the final color
  22321. */
  22322. export class FragmentOutputBlock extends NodeMaterialBlock {
  22323. /**
  22324. * Create a new FragmentOutputBlock
  22325. * @param name defines the block name
  22326. */
  22327. constructor(name: string);
  22328. /**
  22329. * Gets the current class name
  22330. * @returns the class name
  22331. */
  22332. getClassName(): string;
  22333. /**
  22334. * Gets the rgba input component
  22335. */
  22336. get rgba(): NodeMaterialConnectionPoint;
  22337. /**
  22338. * Gets the rgb input component
  22339. */
  22340. get rgb(): NodeMaterialConnectionPoint;
  22341. /**
  22342. * Gets the a input component
  22343. */
  22344. get a(): NodeMaterialConnectionPoint;
  22345. protected _buildBlock(state: NodeMaterialBuildState): this;
  22346. }
  22347. }
  22348. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22352. /**
  22353. * Block used for the particle ramp gradient section
  22354. */
  22355. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22356. /**
  22357. * Create a new ParticleRampGradientBlock
  22358. * @param name defines the block name
  22359. */
  22360. constructor(name: string);
  22361. /**
  22362. * Gets the current class name
  22363. * @returns the class name
  22364. */
  22365. getClassName(): string;
  22366. /**
  22367. * Gets the color input component
  22368. */
  22369. get color(): NodeMaterialConnectionPoint;
  22370. /**
  22371. * Gets the rampColor output component
  22372. */
  22373. get rampColor(): NodeMaterialConnectionPoint;
  22374. /**
  22375. * Initialize the block and prepare the context for build
  22376. * @param state defines the state that will be used for the build
  22377. */
  22378. initialize(state: NodeMaterialBuildState): void;
  22379. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22380. }
  22381. }
  22382. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22386. /**
  22387. * Block used for the particle blend multiply section
  22388. */
  22389. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22390. /**
  22391. * Create a new ParticleBlendMultiplyBlock
  22392. * @param name defines the block name
  22393. */
  22394. constructor(name: string);
  22395. /**
  22396. * Gets the current class name
  22397. * @returns the class name
  22398. */
  22399. getClassName(): string;
  22400. /**
  22401. * Gets the color input component
  22402. */
  22403. get color(): NodeMaterialConnectionPoint;
  22404. /**
  22405. * Gets the alphaTexture input component
  22406. */
  22407. get alphaTexture(): NodeMaterialConnectionPoint;
  22408. /**
  22409. * Gets the alphaColor input component
  22410. */
  22411. get alphaColor(): NodeMaterialConnectionPoint;
  22412. /**
  22413. * Gets the blendColor output component
  22414. */
  22415. get blendColor(): NodeMaterialConnectionPoint;
  22416. /**
  22417. * Initialize the block and prepare the context for build
  22418. * @param state defines the state that will be used for the build
  22419. */
  22420. initialize(state: NodeMaterialBuildState): void;
  22421. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22422. }
  22423. }
  22424. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22428. /**
  22429. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22430. */
  22431. export class VectorMergerBlock extends NodeMaterialBlock {
  22432. /**
  22433. * Create a new VectorMergerBlock
  22434. * @param name defines the block name
  22435. */
  22436. constructor(name: string);
  22437. /**
  22438. * Gets the current class name
  22439. * @returns the class name
  22440. */
  22441. getClassName(): string;
  22442. /**
  22443. * Gets the xyz component (input)
  22444. */
  22445. get xyzIn(): NodeMaterialConnectionPoint;
  22446. /**
  22447. * Gets the xy component (input)
  22448. */
  22449. get xyIn(): NodeMaterialConnectionPoint;
  22450. /**
  22451. * Gets the x component (input)
  22452. */
  22453. get x(): NodeMaterialConnectionPoint;
  22454. /**
  22455. * Gets the y component (input)
  22456. */
  22457. get y(): NodeMaterialConnectionPoint;
  22458. /**
  22459. * Gets the z component (input)
  22460. */
  22461. get z(): NodeMaterialConnectionPoint;
  22462. /**
  22463. * Gets the w component (input)
  22464. */
  22465. get w(): NodeMaterialConnectionPoint;
  22466. /**
  22467. * Gets the xyzw component (output)
  22468. */
  22469. get xyzw(): NodeMaterialConnectionPoint;
  22470. /**
  22471. * Gets the xyz component (output)
  22472. */
  22473. get xyzOut(): NodeMaterialConnectionPoint;
  22474. /**
  22475. * Gets the xy component (output)
  22476. */
  22477. get xyOut(): NodeMaterialConnectionPoint;
  22478. /**
  22479. * Gets the xy component (output)
  22480. * @deprecated Please use xyOut instead.
  22481. */
  22482. get xy(): NodeMaterialConnectionPoint;
  22483. /**
  22484. * Gets the xyz component (output)
  22485. * @deprecated Please use xyzOut instead.
  22486. */
  22487. get xyz(): NodeMaterialConnectionPoint;
  22488. protected _buildBlock(state: NodeMaterialBuildState): this;
  22489. }
  22490. }
  22491. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22495. import { Vector2 } from "babylonjs/Maths/math.vector";
  22496. import { Scene } from "babylonjs/scene";
  22497. /**
  22498. * Block used to remap a float from a range to a new one
  22499. */
  22500. export class RemapBlock extends NodeMaterialBlock {
  22501. /**
  22502. * Gets or sets the source range
  22503. */
  22504. sourceRange: Vector2;
  22505. /**
  22506. * Gets or sets the target range
  22507. */
  22508. targetRange: Vector2;
  22509. /**
  22510. * Creates a new RemapBlock
  22511. * @param name defines the block name
  22512. */
  22513. constructor(name: string);
  22514. /**
  22515. * Gets the current class name
  22516. * @returns the class name
  22517. */
  22518. getClassName(): string;
  22519. /**
  22520. * Gets the input component
  22521. */
  22522. get input(): NodeMaterialConnectionPoint;
  22523. /**
  22524. * Gets the source min input component
  22525. */
  22526. get sourceMin(): NodeMaterialConnectionPoint;
  22527. /**
  22528. * Gets the source max input component
  22529. */
  22530. get sourceMax(): NodeMaterialConnectionPoint;
  22531. /**
  22532. * Gets the target min input component
  22533. */
  22534. get targetMin(): NodeMaterialConnectionPoint;
  22535. /**
  22536. * Gets the target max input component
  22537. */
  22538. get targetMax(): NodeMaterialConnectionPoint;
  22539. /**
  22540. * Gets the output component
  22541. */
  22542. get output(): NodeMaterialConnectionPoint;
  22543. protected _buildBlock(state: NodeMaterialBuildState): this;
  22544. protected _dumpPropertiesCode(): string;
  22545. serialize(): any;
  22546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22547. }
  22548. }
  22549. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22553. /**
  22554. * Block used to multiply 2 values
  22555. */
  22556. export class MultiplyBlock extends NodeMaterialBlock {
  22557. /**
  22558. * Creates a new MultiplyBlock
  22559. * @param name defines the block name
  22560. */
  22561. constructor(name: string);
  22562. /**
  22563. * Gets the current class name
  22564. * @returns the class name
  22565. */
  22566. getClassName(): string;
  22567. /**
  22568. * Gets the left operand input component
  22569. */
  22570. get left(): NodeMaterialConnectionPoint;
  22571. /**
  22572. * Gets the right operand input component
  22573. */
  22574. get right(): NodeMaterialConnectionPoint;
  22575. /**
  22576. * Gets the output component
  22577. */
  22578. get output(): NodeMaterialConnectionPoint;
  22579. protected _buildBlock(state: NodeMaterialBuildState): this;
  22580. }
  22581. }
  22582. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22586. /**
  22587. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22588. */
  22589. export class ColorSplitterBlock extends NodeMaterialBlock {
  22590. /**
  22591. * Create a new ColorSplitterBlock
  22592. * @param name defines the block name
  22593. */
  22594. constructor(name: string);
  22595. /**
  22596. * Gets the current class name
  22597. * @returns the class name
  22598. */
  22599. getClassName(): string;
  22600. /**
  22601. * Gets the rgba component (input)
  22602. */
  22603. get rgba(): NodeMaterialConnectionPoint;
  22604. /**
  22605. * Gets the rgb component (input)
  22606. */
  22607. get rgbIn(): NodeMaterialConnectionPoint;
  22608. /**
  22609. * Gets the rgb component (output)
  22610. */
  22611. get rgbOut(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the r component (output)
  22614. */
  22615. get r(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the g component (output)
  22618. */
  22619. get g(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the b component (output)
  22622. */
  22623. get b(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the a component (output)
  22626. */
  22627. get a(): NodeMaterialConnectionPoint;
  22628. protected _inputRename(name: string): string;
  22629. protected _outputRename(name: string): string;
  22630. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22631. }
  22632. }
  22633. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22635. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22636. import { Scene } from "babylonjs/scene";
  22637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22638. import { Matrix } from "babylonjs/Maths/math.vector";
  22639. import { Mesh } from "babylonjs/Meshes/mesh";
  22640. import { Engine } from "babylonjs/Engines/engine";
  22641. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22642. import { Observable } from "babylonjs/Misc/observable";
  22643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22644. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22645. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22646. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22647. import { Nullable } from "babylonjs/types";
  22648. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22649. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22650. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22651. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22652. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22653. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22654. import { Effect } from "babylonjs/Materials/effect";
  22655. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22656. import { Camera } from "babylonjs/Cameras/camera";
  22657. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22658. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22659. /**
  22660. * Interface used to configure the node material editor
  22661. */
  22662. export interface INodeMaterialEditorOptions {
  22663. /** Define the URl to load node editor script */
  22664. editorURL?: string;
  22665. }
  22666. /** @hidden */
  22667. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22668. NORMAL: boolean;
  22669. TANGENT: boolean;
  22670. UV1: boolean;
  22671. /** BONES */
  22672. NUM_BONE_INFLUENCERS: number;
  22673. BonesPerMesh: number;
  22674. BONETEXTURE: boolean;
  22675. /** MORPH TARGETS */
  22676. MORPHTARGETS: boolean;
  22677. MORPHTARGETS_NORMAL: boolean;
  22678. MORPHTARGETS_TANGENT: boolean;
  22679. MORPHTARGETS_UV: boolean;
  22680. NUM_MORPH_INFLUENCERS: number;
  22681. /** IMAGE PROCESSING */
  22682. IMAGEPROCESSING: boolean;
  22683. VIGNETTE: boolean;
  22684. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22685. VIGNETTEBLENDMODEOPAQUE: boolean;
  22686. TONEMAPPING: boolean;
  22687. TONEMAPPING_ACES: boolean;
  22688. CONTRAST: boolean;
  22689. EXPOSURE: boolean;
  22690. COLORCURVES: boolean;
  22691. COLORGRADING: boolean;
  22692. COLORGRADING3D: boolean;
  22693. SAMPLER3DGREENDEPTH: boolean;
  22694. SAMPLER3DBGRMAP: boolean;
  22695. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22696. /** MISC. */
  22697. BUMPDIRECTUV: number;
  22698. constructor();
  22699. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22700. }
  22701. /**
  22702. * Class used to configure NodeMaterial
  22703. */
  22704. export interface INodeMaterialOptions {
  22705. /**
  22706. * Defines if blocks should emit comments
  22707. */
  22708. emitComments: boolean;
  22709. }
  22710. /**
  22711. * Class used to create a node based material built by assembling shader blocks
  22712. */
  22713. export class NodeMaterial extends PushMaterial {
  22714. private static _BuildIdGenerator;
  22715. private _options;
  22716. private _vertexCompilationState;
  22717. private _fragmentCompilationState;
  22718. private _sharedData;
  22719. private _buildId;
  22720. private _buildWasSuccessful;
  22721. private _cachedWorldViewMatrix;
  22722. private _cachedWorldViewProjectionMatrix;
  22723. private _optimizers;
  22724. private _animationFrame;
  22725. /** Define the Url to load node editor script */
  22726. static EditorURL: string;
  22727. /** Define the Url to load snippets */
  22728. static SnippetUrl: string;
  22729. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22730. static IgnoreTexturesAtLoadTime: boolean;
  22731. private BJSNODEMATERIALEDITOR;
  22732. /** Get the inspector from bundle or global */
  22733. private _getGlobalNodeMaterialEditor;
  22734. /**
  22735. * Snippet ID if the material was created from the snippet server
  22736. */
  22737. snippetId: string;
  22738. /**
  22739. * Gets or sets data used by visual editor
  22740. * @see https://nme.babylonjs.com
  22741. */
  22742. editorData: any;
  22743. /**
  22744. * 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)
  22745. */
  22746. ignoreAlpha: boolean;
  22747. /**
  22748. * Defines the maximum number of lights that can be used in the material
  22749. */
  22750. maxSimultaneousLights: number;
  22751. /**
  22752. * Observable raised when the material is built
  22753. */
  22754. onBuildObservable: Observable<NodeMaterial>;
  22755. /**
  22756. * Gets or sets the root nodes of the material vertex shader
  22757. */
  22758. _vertexOutputNodes: NodeMaterialBlock[];
  22759. /**
  22760. * Gets or sets the root nodes of the material fragment (pixel) shader
  22761. */
  22762. _fragmentOutputNodes: NodeMaterialBlock[];
  22763. /** Gets or sets options to control the node material overall behavior */
  22764. get options(): INodeMaterialOptions;
  22765. set options(options: INodeMaterialOptions);
  22766. /**
  22767. * Default configuration related to image processing available in the standard Material.
  22768. */
  22769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22770. /**
  22771. * Gets the image processing configuration used either in this material.
  22772. */
  22773. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22774. /**
  22775. * Sets the Default image processing configuration used either in the this material.
  22776. *
  22777. * If sets to null, the scene one is in use.
  22778. */
  22779. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22780. /**
  22781. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22782. */
  22783. attachedBlocks: NodeMaterialBlock[];
  22784. /**
  22785. * Specifies the mode of the node material
  22786. * @hidden
  22787. */
  22788. _mode: NodeMaterialModes;
  22789. /**
  22790. * Gets the mode property
  22791. */
  22792. get mode(): NodeMaterialModes;
  22793. /**
  22794. * Create a new node based material
  22795. * @param name defines the material name
  22796. * @param scene defines the hosting scene
  22797. * @param options defines creation option
  22798. */
  22799. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22800. /**
  22801. * Gets the current class name of the material e.g. "NodeMaterial"
  22802. * @returns the class name
  22803. */
  22804. getClassName(): string;
  22805. /**
  22806. * Keep track of the image processing observer to allow dispose and replace.
  22807. */
  22808. private _imageProcessingObserver;
  22809. /**
  22810. * Attaches a new image processing configuration to the Standard Material.
  22811. * @param configuration
  22812. */
  22813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22814. /**
  22815. * Get a block by its name
  22816. * @param name defines the name of the block to retrieve
  22817. * @returns the required block or null if not found
  22818. */
  22819. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22820. /**
  22821. * Get a block by its name
  22822. * @param predicate defines the predicate used to find the good candidate
  22823. * @returns the required block or null if not found
  22824. */
  22825. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22826. /**
  22827. * Get an input block by its name
  22828. * @param predicate defines the predicate used to find the good candidate
  22829. * @returns the required input block or null if not found
  22830. */
  22831. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22832. /**
  22833. * Gets the list of input blocks attached to this material
  22834. * @returns an array of InputBlocks
  22835. */
  22836. getInputBlocks(): InputBlock[];
  22837. /**
  22838. * Adds a new optimizer to the list of optimizers
  22839. * @param optimizer defines the optimizers to add
  22840. * @returns the current material
  22841. */
  22842. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22843. /**
  22844. * Remove an optimizer from the list of optimizers
  22845. * @param optimizer defines the optimizers to remove
  22846. * @returns the current material
  22847. */
  22848. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22849. /**
  22850. * Add a new block to the list of output nodes
  22851. * @param node defines the node to add
  22852. * @returns the current material
  22853. */
  22854. addOutputNode(node: NodeMaterialBlock): this;
  22855. /**
  22856. * Remove a block from the list of root nodes
  22857. * @param node defines the node to remove
  22858. * @returns the current material
  22859. */
  22860. removeOutputNode(node: NodeMaterialBlock): this;
  22861. private _addVertexOutputNode;
  22862. private _removeVertexOutputNode;
  22863. private _addFragmentOutputNode;
  22864. private _removeFragmentOutputNode;
  22865. /**
  22866. * Specifies if the material will require alpha blending
  22867. * @returns a boolean specifying if alpha blending is needed
  22868. */
  22869. needAlphaBlending(): boolean;
  22870. /**
  22871. * Specifies if this material should be rendered in alpha test mode
  22872. * @returns a boolean specifying if an alpha test is needed.
  22873. */
  22874. needAlphaTesting(): boolean;
  22875. private _initializeBlock;
  22876. private _resetDualBlocks;
  22877. /**
  22878. * Remove a block from the current node material
  22879. * @param block defines the block to remove
  22880. */
  22881. removeBlock(block: NodeMaterialBlock): void;
  22882. /**
  22883. * Build the material and generates the inner effect
  22884. * @param verbose defines if the build should log activity
  22885. */
  22886. build(verbose?: boolean): void;
  22887. /**
  22888. * Runs an otpimization phase to try to improve the shader code
  22889. */
  22890. optimize(): void;
  22891. private _prepareDefinesForAttributes;
  22892. /**
  22893. * Create a post process from the material
  22894. * @param camera The camera to apply the render pass to.
  22895. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22897. * @param engine The engine which the post process will be applied. (default: current engine)
  22898. * @param reusable If the post process can be reused on the same frame. (default: false)
  22899. * @param textureType Type of textures used when performing the post process. (default: 0)
  22900. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22901. * @returns the post process created
  22902. */
  22903. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22904. private _createEffectForParticles;
  22905. /**
  22906. * Create the effect to be used as the custom effect for a particle system
  22907. * @param particleSystem Particle system to create the effect for
  22908. * @param onCompiled defines a function to call when the effect creation is successful
  22909. * @param onError defines a function to call when the effect creation has failed
  22910. */
  22911. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22912. private _processDefines;
  22913. /**
  22914. * Get if the submesh is ready to be used and all its information available.
  22915. * Child classes can use it to update shaders
  22916. * @param mesh defines the mesh to check
  22917. * @param subMesh defines which submesh to check
  22918. * @param useInstances specifies that instances should be used
  22919. * @returns a boolean indicating that the submesh is ready or not
  22920. */
  22921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22922. /**
  22923. * Get a string representing the shaders built by the current node graph
  22924. */
  22925. get compiledShaders(): string;
  22926. /**
  22927. * Binds the world matrix to the material
  22928. * @param world defines the world transformation matrix
  22929. */
  22930. bindOnlyWorldMatrix(world: Matrix): void;
  22931. /**
  22932. * Binds the submesh to this material by preparing the effect and shader to draw
  22933. * @param world defines the world transformation matrix
  22934. * @param mesh defines the mesh containing the submesh
  22935. * @param subMesh defines the submesh to bind the material to
  22936. */
  22937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22938. /**
  22939. * Gets the active textures from the material
  22940. * @returns an array of textures
  22941. */
  22942. getActiveTextures(): BaseTexture[];
  22943. /**
  22944. * Gets the list of texture blocks
  22945. * @returns an array of texture blocks
  22946. */
  22947. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22948. /**
  22949. * Specifies if the material uses a texture
  22950. * @param texture defines the texture to check against the material
  22951. * @returns a boolean specifying if the material uses the texture
  22952. */
  22953. hasTexture(texture: BaseTexture): boolean;
  22954. /**
  22955. * Disposes the material
  22956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22959. */
  22960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22961. /** Creates the node editor window. */
  22962. private _createNodeEditor;
  22963. /**
  22964. * Launch the node material editor
  22965. * @param config Define the configuration of the editor
  22966. * @return a promise fulfilled when the node editor is visible
  22967. */
  22968. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22969. /**
  22970. * Clear the current material
  22971. */
  22972. clear(): void;
  22973. /**
  22974. * Clear the current material and set it to a default state
  22975. */
  22976. setToDefault(): void;
  22977. /**
  22978. * Clear the current material and set it to a default state for post process
  22979. */
  22980. setToDefaultPostProcess(): void;
  22981. /**
  22982. * Clear the current material and set it to a default state for particle
  22983. */
  22984. setToDefaultParticle(): void;
  22985. /**
  22986. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22987. * @param url defines the url to load from
  22988. * @returns a promise that will fullfil when the material is fully loaded
  22989. */
  22990. loadAsync(url: string): Promise<void>;
  22991. private _gatherBlocks;
  22992. /**
  22993. * Generate a string containing the code declaration required to create an equivalent of this material
  22994. * @returns a string
  22995. */
  22996. generateCode(): string;
  22997. /**
  22998. * Serializes this material in a JSON representation
  22999. * @returns the serialized material object
  23000. */
  23001. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23002. private _restoreConnections;
  23003. /**
  23004. * Clear the current graph and load a new one from a serialization object
  23005. * @param source defines the JSON representation of the material
  23006. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23007. */
  23008. loadFromSerialization(source: any, rootUrl?: string): void;
  23009. /**
  23010. * Makes a duplicate of the current material.
  23011. * @param name - name to use for the new material.
  23012. */
  23013. clone(name: string): NodeMaterial;
  23014. /**
  23015. * Creates a node material from parsed material data
  23016. * @param source defines the JSON representation of the material
  23017. * @param scene defines the hosting scene
  23018. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23019. * @returns a new node material
  23020. */
  23021. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23022. /**
  23023. * Creates a node material from a snippet saved in a remote file
  23024. * @param name defines the name of the material to create
  23025. * @param url defines the url to load from
  23026. * @param scene defines the hosting scene
  23027. * @returns a promise that will resolve to the new node material
  23028. */
  23029. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23030. /**
  23031. * Creates a node material from a snippet saved by the node material editor
  23032. * @param snippetId defines the snippet to load
  23033. * @param scene defines the hosting scene
  23034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23035. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23036. * @returns a promise that will resolve to the new node material
  23037. */
  23038. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23039. /**
  23040. * Creates a new node material set to default basic configuration
  23041. * @param name defines the name of the material
  23042. * @param scene defines the hosting scene
  23043. * @returns a new NodeMaterial
  23044. */
  23045. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23046. }
  23047. }
  23048. declare module "babylonjs/PostProcesses/postProcess" {
  23049. import { Nullable } from "babylonjs/types";
  23050. import { SmartArray } from "babylonjs/Misc/smartArray";
  23051. import { Observable } from "babylonjs/Misc/observable";
  23052. import { Vector2 } from "babylonjs/Maths/math.vector";
  23053. import { Camera } from "babylonjs/Cameras/camera";
  23054. import { Effect } from "babylonjs/Materials/effect";
  23055. import "babylonjs/Shaders/postprocess.vertex";
  23056. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23057. import { Engine } from "babylonjs/Engines/engine";
  23058. import { Color4 } from "babylonjs/Maths/math.color";
  23059. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23060. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23061. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23062. /**
  23063. * Size options for a post process
  23064. */
  23065. export type PostProcessOptions = {
  23066. width: number;
  23067. height: number;
  23068. };
  23069. /**
  23070. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23071. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23072. */
  23073. export class PostProcess {
  23074. /** Name of the PostProcess. */
  23075. name: string;
  23076. /**
  23077. * Gets or sets the unique id of the post process
  23078. */
  23079. uniqueId: number;
  23080. /**
  23081. * Width of the texture to apply the post process on
  23082. */
  23083. width: number;
  23084. /**
  23085. * Height of the texture to apply the post process on
  23086. */
  23087. height: number;
  23088. /**
  23089. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23090. */
  23091. nodeMaterialSource: Nullable<NodeMaterial>;
  23092. /**
  23093. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23094. * @hidden
  23095. */
  23096. _outputTexture: Nullable<InternalTexture>;
  23097. /**
  23098. * Sampling mode used by the shader
  23099. * See https://doc.babylonjs.com/classes/3.1/texture
  23100. */
  23101. renderTargetSamplingMode: number;
  23102. /**
  23103. * Clear color to use when screen clearing
  23104. */
  23105. clearColor: Color4;
  23106. /**
  23107. * If the buffer needs to be cleared before applying the post process. (default: true)
  23108. * Should be set to false if shader will overwrite all previous pixels.
  23109. */
  23110. autoClear: boolean;
  23111. /**
  23112. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23113. */
  23114. alphaMode: number;
  23115. /**
  23116. * Sets the setAlphaBlendConstants of the babylon engine
  23117. */
  23118. alphaConstants: Color4;
  23119. /**
  23120. * Animations to be used for the post processing
  23121. */
  23122. animations: import("babylonjs/Animations/animation").Animation[];
  23123. /**
  23124. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23125. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23126. */
  23127. enablePixelPerfectMode: boolean;
  23128. /**
  23129. * Force the postprocess to be applied without taking in account viewport
  23130. */
  23131. forceFullscreenViewport: boolean;
  23132. /**
  23133. * List of inspectable custom properties (used by the Inspector)
  23134. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23135. */
  23136. inspectableCustomProperties: IInspectable[];
  23137. /**
  23138. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23139. *
  23140. * | Value | Type | Description |
  23141. * | ----- | ----------------------------------- | ----------- |
  23142. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23143. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23144. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23145. *
  23146. */
  23147. scaleMode: number;
  23148. /**
  23149. * Force textures to be a power of two (default: false)
  23150. */
  23151. alwaysForcePOT: boolean;
  23152. private _samples;
  23153. /**
  23154. * Number of sample textures (default: 1)
  23155. */
  23156. get samples(): number;
  23157. set samples(n: number);
  23158. /**
  23159. * Modify the scale of the post process to be the same as the viewport (default: false)
  23160. */
  23161. adaptScaleToCurrentViewport: boolean;
  23162. private _camera;
  23163. private _scene;
  23164. private _engine;
  23165. private _options;
  23166. private _reusable;
  23167. private _textureType;
  23168. private _textureFormat;
  23169. /**
  23170. * Smart array of input and output textures for the post process.
  23171. * @hidden
  23172. */
  23173. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23174. /**
  23175. * The index in _textures that corresponds to the output texture.
  23176. * @hidden
  23177. */
  23178. _currentRenderTextureInd: number;
  23179. private _effect;
  23180. private _samplers;
  23181. private _fragmentUrl;
  23182. private _vertexUrl;
  23183. private _parameters;
  23184. private _scaleRatio;
  23185. protected _indexParameters: any;
  23186. private _shareOutputWithPostProcess;
  23187. private _texelSize;
  23188. private _forcedOutputTexture;
  23189. /**
  23190. * Returns the fragment url or shader name used in the post process.
  23191. * @returns the fragment url or name in the shader store.
  23192. */
  23193. getEffectName(): string;
  23194. /**
  23195. * An event triggered when the postprocess is activated.
  23196. */
  23197. onActivateObservable: Observable<Camera>;
  23198. private _onActivateObserver;
  23199. /**
  23200. * A function that is added to the onActivateObservable
  23201. */
  23202. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23203. /**
  23204. * An event triggered when the postprocess changes its size.
  23205. */
  23206. onSizeChangedObservable: Observable<PostProcess>;
  23207. private _onSizeChangedObserver;
  23208. /**
  23209. * A function that is added to the onSizeChangedObservable
  23210. */
  23211. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23212. /**
  23213. * An event triggered when the postprocess applies its effect.
  23214. */
  23215. onApplyObservable: Observable<Effect>;
  23216. private _onApplyObserver;
  23217. /**
  23218. * A function that is added to the onApplyObservable
  23219. */
  23220. set onApply(callback: (effect: Effect) => void);
  23221. /**
  23222. * An event triggered before rendering the postprocess
  23223. */
  23224. onBeforeRenderObservable: Observable<Effect>;
  23225. private _onBeforeRenderObserver;
  23226. /**
  23227. * A function that is added to the onBeforeRenderObservable
  23228. */
  23229. set onBeforeRender(callback: (effect: Effect) => void);
  23230. /**
  23231. * An event triggered after rendering the postprocess
  23232. */
  23233. onAfterRenderObservable: Observable<Effect>;
  23234. private _onAfterRenderObserver;
  23235. /**
  23236. * A function that is added to the onAfterRenderObservable
  23237. */
  23238. set onAfterRender(callback: (efect: Effect) => void);
  23239. /**
  23240. * 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
  23241. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23242. */
  23243. get inputTexture(): InternalTexture;
  23244. set inputTexture(value: InternalTexture);
  23245. /**
  23246. * Gets the camera which post process is applied to.
  23247. * @returns The camera the post process is applied to.
  23248. */
  23249. getCamera(): Camera;
  23250. /**
  23251. * Gets the texel size of the postprocess.
  23252. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23253. */
  23254. get texelSize(): Vector2;
  23255. /**
  23256. * Creates a new instance PostProcess
  23257. * @param name The name of the PostProcess.
  23258. * @param fragmentUrl The url of the fragment shader to be used.
  23259. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23260. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23261. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23262. * @param camera The camera to apply the render pass to.
  23263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23264. * @param engine The engine which the post process will be applied. (default: current engine)
  23265. * @param reusable If the post process can be reused on the same frame. (default: false)
  23266. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23267. * @param textureType Type of textures used when performing the post process. (default: 0)
  23268. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23269. * @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
  23270. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23271. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23272. */
  23273. constructor(
  23274. /** Name of the PostProcess. */
  23275. 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);
  23276. /**
  23277. * Gets a string idenfifying the name of the class
  23278. * @returns "PostProcess" string
  23279. */
  23280. getClassName(): string;
  23281. /**
  23282. * Gets the engine which this post process belongs to.
  23283. * @returns The engine the post process was enabled with.
  23284. */
  23285. getEngine(): Engine;
  23286. /**
  23287. * The effect that is created when initializing the post process.
  23288. * @returns The created effect corresponding the the postprocess.
  23289. */
  23290. getEffect(): Effect;
  23291. /**
  23292. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23293. * @param postProcess The post process to share the output with.
  23294. * @returns This post process.
  23295. */
  23296. shareOutputWith(postProcess: PostProcess): PostProcess;
  23297. /**
  23298. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23299. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23300. */
  23301. useOwnOutput(): void;
  23302. /**
  23303. * Updates the effect with the current post process compile time values and recompiles the shader.
  23304. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23305. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23306. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23307. * @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
  23308. * @param onCompiled Called when the shader has been compiled.
  23309. * @param onError Called if there is an error when compiling a shader.
  23310. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23311. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23312. */
  23313. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  23314. /**
  23315. * The post process is reusable if it can be used multiple times within one frame.
  23316. * @returns If the post process is reusable
  23317. */
  23318. isReusable(): boolean;
  23319. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23320. markTextureDirty(): void;
  23321. /**
  23322. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23323. * 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.
  23324. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23325. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23326. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23327. * @returns The target texture that was bound to be written to.
  23328. */
  23329. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23330. /**
  23331. * If the post process is supported.
  23332. */
  23333. get isSupported(): boolean;
  23334. /**
  23335. * The aspect ratio of the output texture.
  23336. */
  23337. get aspectRatio(): number;
  23338. /**
  23339. * Get a value indicating if the post-process is ready to be used
  23340. * @returns true if the post-process is ready (shader is compiled)
  23341. */
  23342. isReady(): boolean;
  23343. /**
  23344. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23345. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23346. */
  23347. apply(): Nullable<Effect>;
  23348. private _disposeTextures;
  23349. /**
  23350. * Disposes the post process.
  23351. * @param camera The camera to dispose the post process on.
  23352. */
  23353. dispose(camera?: Camera): void;
  23354. }
  23355. }
  23356. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23357. /** @hidden */
  23358. export var kernelBlurVaryingDeclaration: {
  23359. name: string;
  23360. shader: string;
  23361. };
  23362. }
  23363. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23364. /** @hidden */
  23365. export var kernelBlurFragment: {
  23366. name: string;
  23367. shader: string;
  23368. };
  23369. }
  23370. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23371. /** @hidden */
  23372. export var kernelBlurFragment2: {
  23373. name: string;
  23374. shader: string;
  23375. };
  23376. }
  23377. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23378. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23379. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23380. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23381. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23382. /** @hidden */
  23383. export var kernelBlurPixelShader: {
  23384. name: string;
  23385. shader: string;
  23386. };
  23387. }
  23388. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23389. /** @hidden */
  23390. export var kernelBlurVertex: {
  23391. name: string;
  23392. shader: string;
  23393. };
  23394. }
  23395. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23396. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23397. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23398. /** @hidden */
  23399. export var kernelBlurVertexShader: {
  23400. name: string;
  23401. shader: string;
  23402. };
  23403. }
  23404. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23405. import { Vector2 } from "babylonjs/Maths/math.vector";
  23406. import { Nullable } from "babylonjs/types";
  23407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23408. import { Camera } from "babylonjs/Cameras/camera";
  23409. import { Effect } from "babylonjs/Materials/effect";
  23410. import { Engine } from "babylonjs/Engines/engine";
  23411. import "babylonjs/Shaders/kernelBlur.fragment";
  23412. import "babylonjs/Shaders/kernelBlur.vertex";
  23413. /**
  23414. * The Blur Post Process which blurs an image based on a kernel and direction.
  23415. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23416. */
  23417. export class BlurPostProcess extends PostProcess {
  23418. /** The direction in which to blur the image. */
  23419. direction: Vector2;
  23420. private blockCompilation;
  23421. protected _kernel: number;
  23422. protected _idealKernel: number;
  23423. protected _packedFloat: boolean;
  23424. private _staticDefines;
  23425. /**
  23426. * Sets the length in pixels of the blur sample region
  23427. */
  23428. set kernel(v: number);
  23429. /**
  23430. * Gets the length in pixels of the blur sample region
  23431. */
  23432. get kernel(): number;
  23433. /**
  23434. * Sets wether or not the blur needs to unpack/repack floats
  23435. */
  23436. set packedFloat(v: boolean);
  23437. /**
  23438. * Gets wether or not the blur is unpacking/repacking floats
  23439. */
  23440. get packedFloat(): boolean;
  23441. /**
  23442. * Creates a new instance BlurPostProcess
  23443. * @param name The name of the effect.
  23444. * @param direction The direction in which to blur the image.
  23445. * @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.
  23446. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23447. * @param camera The camera to apply the render pass to.
  23448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23449. * @param engine The engine which the post process will be applied. (default: current engine)
  23450. * @param reusable If the post process can be reused on the same frame. (default: false)
  23451. * @param textureType Type of textures used when performing the post process. (default: 0)
  23452. * @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)
  23453. */
  23454. constructor(name: string,
  23455. /** The direction in which to blur the image. */
  23456. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23457. /**
  23458. * Updates the effect with the current post process compile time values and recompiles the shader.
  23459. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23460. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23461. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23462. * @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
  23463. * @param onCompiled Called when the shader has been compiled.
  23464. * @param onError Called if there is an error when compiling a shader.
  23465. */
  23466. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23467. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23468. /**
  23469. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23470. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23471. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23472. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23473. * The gaps between physical kernels are compensated for in the weighting of the samples
  23474. * @param idealKernel Ideal blur kernel.
  23475. * @return Nearest best kernel.
  23476. */
  23477. protected _nearestBestKernel(idealKernel: number): number;
  23478. /**
  23479. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23480. * @param x The point on the Gaussian distribution to sample.
  23481. * @return the value of the Gaussian function at x.
  23482. */
  23483. protected _gaussianWeight(x: number): number;
  23484. /**
  23485. * Generates a string that can be used as a floating point number in GLSL.
  23486. * @param x Value to print.
  23487. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23488. * @return GLSL float string.
  23489. */
  23490. protected _glslFloat(x: number, decimalFigures?: number): string;
  23491. }
  23492. }
  23493. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23494. import { Scene } from "babylonjs/scene";
  23495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23496. import { Plane } from "babylonjs/Maths/math.plane";
  23497. /**
  23498. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23499. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23500. * You can then easily use it as a reflectionTexture on a flat surface.
  23501. * In case the surface is not a plane, please consider relying on reflection probes.
  23502. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23503. */
  23504. export class MirrorTexture extends RenderTargetTexture {
  23505. private scene;
  23506. /**
  23507. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23508. * 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.
  23509. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23510. */
  23511. mirrorPlane: Plane;
  23512. /**
  23513. * Define the blur ratio used to blur the reflection if needed.
  23514. */
  23515. set blurRatio(value: number);
  23516. get blurRatio(): number;
  23517. /**
  23518. * Define the adaptive blur kernel used to blur the reflection if needed.
  23519. * This will autocompute the closest best match for the `blurKernel`
  23520. */
  23521. set adaptiveBlurKernel(value: number);
  23522. /**
  23523. * Define the blur kernel used to blur the reflection if needed.
  23524. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23525. */
  23526. set blurKernel(value: number);
  23527. /**
  23528. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23529. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23530. */
  23531. set blurKernelX(value: number);
  23532. get blurKernelX(): number;
  23533. /**
  23534. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23535. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23536. */
  23537. set blurKernelY(value: number);
  23538. get blurKernelY(): number;
  23539. private _autoComputeBlurKernel;
  23540. protected _onRatioRescale(): void;
  23541. private _updateGammaSpace;
  23542. private _imageProcessingConfigChangeObserver;
  23543. private _transformMatrix;
  23544. private _mirrorMatrix;
  23545. private _savedViewMatrix;
  23546. private _blurX;
  23547. private _blurY;
  23548. private _adaptiveBlurKernel;
  23549. private _blurKernelX;
  23550. private _blurKernelY;
  23551. private _blurRatio;
  23552. /**
  23553. * Instantiates a Mirror Texture.
  23554. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23555. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23556. * You can then easily use it as a reflectionTexture on a flat surface.
  23557. * In case the surface is not a plane, please consider relying on reflection probes.
  23558. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23559. * @param name
  23560. * @param size
  23561. * @param scene
  23562. * @param generateMipMaps
  23563. * @param type
  23564. * @param samplingMode
  23565. * @param generateDepthBuffer
  23566. */
  23567. constructor(name: string, size: number | {
  23568. width: number;
  23569. height: number;
  23570. } | {
  23571. ratio: number;
  23572. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23573. private _preparePostProcesses;
  23574. /**
  23575. * Clone the mirror texture.
  23576. * @returns the cloned texture
  23577. */
  23578. clone(): MirrorTexture;
  23579. /**
  23580. * Serialize the texture to a JSON representation you could use in Parse later on
  23581. * @returns the serialized JSON representation
  23582. */
  23583. serialize(): any;
  23584. /**
  23585. * Dispose the texture and release its associated resources.
  23586. */
  23587. dispose(): void;
  23588. }
  23589. }
  23590. declare module "babylonjs/Materials/Textures/texture" {
  23591. import { Observable } from "babylonjs/Misc/observable";
  23592. import { Nullable } from "babylonjs/types";
  23593. import { Matrix } from "babylonjs/Maths/math.vector";
  23594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23595. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23596. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23597. import { Scene } from "babylonjs/scene";
  23598. /**
  23599. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23600. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23601. */
  23602. export class Texture extends BaseTexture {
  23603. /**
  23604. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23605. */
  23606. static SerializeBuffers: boolean;
  23607. /** @hidden */
  23608. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23609. /** @hidden */
  23610. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23611. /** @hidden */
  23612. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23613. /** nearest is mag = nearest and min = nearest and mip = linear */
  23614. static readonly NEAREST_SAMPLINGMODE: number;
  23615. /** nearest is mag = nearest and min = nearest and mip = linear */
  23616. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23617. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23618. static readonly BILINEAR_SAMPLINGMODE: number;
  23619. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23620. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23621. /** Trilinear is mag = linear and min = linear and mip = linear */
  23622. static readonly TRILINEAR_SAMPLINGMODE: number;
  23623. /** Trilinear is mag = linear and min = linear and mip = linear */
  23624. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23625. /** mag = nearest and min = nearest and mip = nearest */
  23626. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23627. /** mag = nearest and min = linear and mip = nearest */
  23628. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23629. /** mag = nearest and min = linear and mip = linear */
  23630. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23631. /** mag = nearest and min = linear and mip = none */
  23632. static readonly NEAREST_LINEAR: number;
  23633. /** mag = nearest and min = nearest and mip = none */
  23634. static readonly NEAREST_NEAREST: number;
  23635. /** mag = linear and min = nearest and mip = nearest */
  23636. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23637. /** mag = linear and min = nearest and mip = linear */
  23638. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23639. /** mag = linear and min = linear and mip = none */
  23640. static readonly LINEAR_LINEAR: number;
  23641. /** mag = linear and min = nearest and mip = none */
  23642. static readonly LINEAR_NEAREST: number;
  23643. /** Explicit coordinates mode */
  23644. static readonly EXPLICIT_MODE: number;
  23645. /** Spherical coordinates mode */
  23646. static readonly SPHERICAL_MODE: number;
  23647. /** Planar coordinates mode */
  23648. static readonly PLANAR_MODE: number;
  23649. /** Cubic coordinates mode */
  23650. static readonly CUBIC_MODE: number;
  23651. /** Projection coordinates mode */
  23652. static readonly PROJECTION_MODE: number;
  23653. /** Inverse Cubic coordinates mode */
  23654. static readonly SKYBOX_MODE: number;
  23655. /** Inverse Cubic coordinates mode */
  23656. static readonly INVCUBIC_MODE: number;
  23657. /** Equirectangular coordinates mode */
  23658. static readonly EQUIRECTANGULAR_MODE: number;
  23659. /** Equirectangular Fixed coordinates mode */
  23660. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23661. /** Equirectangular Fixed Mirrored coordinates mode */
  23662. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23663. /** Texture is not repeating outside of 0..1 UVs */
  23664. static readonly CLAMP_ADDRESSMODE: number;
  23665. /** Texture is repeating outside of 0..1 UVs */
  23666. static readonly WRAP_ADDRESSMODE: number;
  23667. /** Texture is repeating and mirrored */
  23668. static readonly MIRROR_ADDRESSMODE: number;
  23669. /**
  23670. * 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
  23671. */
  23672. static UseSerializedUrlIfAny: boolean;
  23673. /**
  23674. * Define the url of the texture.
  23675. */
  23676. url: Nullable<string>;
  23677. /**
  23678. * Define an offset on the texture to offset the u coordinates of the UVs
  23679. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23680. */
  23681. uOffset: number;
  23682. /**
  23683. * Define an offset on the texture to offset the v coordinates of the UVs
  23684. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23685. */
  23686. vOffset: number;
  23687. /**
  23688. * Define an offset on the texture to scale the u coordinates of the UVs
  23689. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23690. */
  23691. uScale: number;
  23692. /**
  23693. * Define an offset on the texture to scale the v coordinates of the UVs
  23694. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23695. */
  23696. vScale: number;
  23697. /**
  23698. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23699. * @see http://doc.babylonjs.com/how_to/more_materials
  23700. */
  23701. uAng: number;
  23702. /**
  23703. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23704. * @see http://doc.babylonjs.com/how_to/more_materials
  23705. */
  23706. vAng: number;
  23707. /**
  23708. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23709. * @see http://doc.babylonjs.com/how_to/more_materials
  23710. */
  23711. wAng: number;
  23712. /**
  23713. * Defines the center of rotation (U)
  23714. */
  23715. uRotationCenter: number;
  23716. /**
  23717. * Defines the center of rotation (V)
  23718. */
  23719. vRotationCenter: number;
  23720. /**
  23721. * Defines the center of rotation (W)
  23722. */
  23723. wRotationCenter: number;
  23724. /**
  23725. * Are mip maps generated for this texture or not.
  23726. */
  23727. get noMipmap(): boolean;
  23728. /**
  23729. * List of inspectable custom properties (used by the Inspector)
  23730. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23731. */
  23732. inspectableCustomProperties: Nullable<IInspectable[]>;
  23733. private _noMipmap;
  23734. /** @hidden */
  23735. _invertY: boolean;
  23736. private _rowGenerationMatrix;
  23737. private _cachedTextureMatrix;
  23738. private _projectionModeMatrix;
  23739. private _t0;
  23740. private _t1;
  23741. private _t2;
  23742. private _cachedUOffset;
  23743. private _cachedVOffset;
  23744. private _cachedUScale;
  23745. private _cachedVScale;
  23746. private _cachedUAng;
  23747. private _cachedVAng;
  23748. private _cachedWAng;
  23749. private _cachedProjectionMatrixId;
  23750. private _cachedCoordinatesMode;
  23751. /** @hidden */
  23752. protected _initialSamplingMode: number;
  23753. /** @hidden */
  23754. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23755. private _deleteBuffer;
  23756. protected _format: Nullable<number>;
  23757. private _delayedOnLoad;
  23758. private _delayedOnError;
  23759. private _mimeType?;
  23760. /**
  23761. * Observable triggered once the texture has been loaded.
  23762. */
  23763. onLoadObservable: Observable<Texture>;
  23764. protected _isBlocking: boolean;
  23765. /**
  23766. * Is the texture preventing material to render while loading.
  23767. * If false, a default texture will be used instead of the loading one during the preparation step.
  23768. */
  23769. set isBlocking(value: boolean);
  23770. get isBlocking(): boolean;
  23771. /**
  23772. * Get the current sampling mode associated with the texture.
  23773. */
  23774. get samplingMode(): number;
  23775. /**
  23776. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23777. */
  23778. get invertY(): boolean;
  23779. /**
  23780. * Instantiates a new texture.
  23781. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23782. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23783. * @param url defines the url of the picture to load as a texture
  23784. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23785. * @param noMipmap defines if the texture will require mip maps or not
  23786. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23787. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23788. * @param onLoad defines a callback triggered when the texture has been loaded
  23789. * @param onError defines a callback triggered when an error occurred during the loading session
  23790. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23791. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23792. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23793. * @param mimeType defines an optional mime type information
  23794. */
  23795. 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);
  23796. /**
  23797. * Update the url (and optional buffer) of this texture if url was null during construction.
  23798. * @param url the url of the texture
  23799. * @param buffer the buffer of the texture (defaults to null)
  23800. * @param onLoad callback called when the texture is loaded (defaults to null)
  23801. */
  23802. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23803. /**
  23804. * Finish the loading sequence of a texture flagged as delayed load.
  23805. * @hidden
  23806. */
  23807. delayLoad(): void;
  23808. private _prepareRowForTextureGeneration;
  23809. /**
  23810. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23811. * @returns the transform matrix of the texture.
  23812. */
  23813. getTextureMatrix(uBase?: number): Matrix;
  23814. /**
  23815. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23816. * @returns The reflection texture transform
  23817. */
  23818. getReflectionTextureMatrix(): Matrix;
  23819. /**
  23820. * Clones the texture.
  23821. * @returns the cloned texture
  23822. */
  23823. clone(): Texture;
  23824. /**
  23825. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23826. * @returns The JSON representation of the texture
  23827. */
  23828. serialize(): any;
  23829. /**
  23830. * Get the current class name of the texture useful for serialization or dynamic coding.
  23831. * @returns "Texture"
  23832. */
  23833. getClassName(): string;
  23834. /**
  23835. * Dispose the texture and release its associated resources.
  23836. */
  23837. dispose(): void;
  23838. /**
  23839. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23840. * @param parsedTexture Define the JSON representation of the texture
  23841. * @param scene Define the scene the parsed texture should be instantiated in
  23842. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23843. * @returns The parsed texture if successful
  23844. */
  23845. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23846. /**
  23847. * Creates a texture from its base 64 representation.
  23848. * @param data Define the base64 payload without the data: prefix
  23849. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23850. * @param scene Define the scene the texture should belong to
  23851. * @param noMipmap Forces the texture to not create mip map information if true
  23852. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23853. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23854. * @param onLoad define a callback triggered when the texture has been loaded
  23855. * @param onError define a callback triggered when an error occurred during the loading session
  23856. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23857. * @returns the created texture
  23858. */
  23859. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23860. /**
  23861. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23862. * @param data Define the base64 payload without the data: prefix
  23863. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23864. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23865. * @param scene Define the scene the texture should belong to
  23866. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23867. * @param noMipmap Forces the texture to not create mip map information if true
  23868. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23869. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23870. * @param onLoad define a callback triggered when the texture has been loaded
  23871. * @param onError define a callback triggered when an error occurred during the loading session
  23872. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23873. * @returns the created texture
  23874. */
  23875. 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;
  23876. }
  23877. }
  23878. declare module "babylonjs/PostProcesses/postProcessManager" {
  23879. import { Nullable } from "babylonjs/types";
  23880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23881. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23882. import { Scene } from "babylonjs/scene";
  23883. /**
  23884. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23885. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23886. */
  23887. export class PostProcessManager {
  23888. private _scene;
  23889. private _indexBuffer;
  23890. private _vertexBuffers;
  23891. /**
  23892. * Creates a new instance PostProcess
  23893. * @param scene The scene that the post process is associated with.
  23894. */
  23895. constructor(scene: Scene);
  23896. private _prepareBuffers;
  23897. private _buildIndexBuffer;
  23898. /**
  23899. * Rebuilds the vertex buffers of the manager.
  23900. * @hidden
  23901. */
  23902. _rebuild(): void;
  23903. /**
  23904. * Prepares a frame to be run through a post process.
  23905. * @param sourceTexture The input texture to the post procesess. (default: null)
  23906. * @param postProcesses An array of post processes to be run. (default: null)
  23907. * @returns True if the post processes were able to be run.
  23908. * @hidden
  23909. */
  23910. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23911. /**
  23912. * Manually render a set of post processes to a texture.
  23913. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23914. * @param postProcesses An array of post processes to be run.
  23915. * @param targetTexture The target texture to render to.
  23916. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23917. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23918. * @param lodLevel defines which lod of the texture to render to
  23919. */
  23920. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23921. /**
  23922. * Finalize the result of the output of the postprocesses.
  23923. * @param doNotPresent If true the result will not be displayed to the screen.
  23924. * @param targetTexture The target texture to render to.
  23925. * @param faceIndex The index of the face to bind the target texture to.
  23926. * @param postProcesses The array of post processes to render.
  23927. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23928. * @hidden
  23929. */
  23930. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23931. /**
  23932. * Disposes of the post process manager.
  23933. */
  23934. dispose(): void;
  23935. }
  23936. }
  23937. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23938. import { Observable } from "babylonjs/Misc/observable";
  23939. import { SmartArray } from "babylonjs/Misc/smartArray";
  23940. import { Nullable, Immutable } from "babylonjs/types";
  23941. import { Camera } from "babylonjs/Cameras/camera";
  23942. import { Scene } from "babylonjs/scene";
  23943. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23944. import { Color4 } from "babylonjs/Maths/math.color";
  23945. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23947. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23949. import { Texture } from "babylonjs/Materials/Textures/texture";
  23950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23951. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23952. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23953. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23954. import { Engine } from "babylonjs/Engines/engine";
  23955. /**
  23956. * This Helps creating a texture that will be created from a camera in your scene.
  23957. * It is basically a dynamic texture that could be used to create special effects for instance.
  23958. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23959. */
  23960. export class RenderTargetTexture extends Texture {
  23961. isCube: boolean;
  23962. /**
  23963. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23964. */
  23965. static readonly REFRESHRATE_RENDER_ONCE: number;
  23966. /**
  23967. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23968. */
  23969. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23970. /**
  23971. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23972. * the central point of your effect and can save a lot of performances.
  23973. */
  23974. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23975. /**
  23976. * Use this predicate to dynamically define the list of mesh you want to render.
  23977. * If set, the renderList property will be overwritten.
  23978. */
  23979. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23980. private _renderList;
  23981. /**
  23982. * Use this list to define the list of mesh you want to render.
  23983. */
  23984. get renderList(): Nullable<Array<AbstractMesh>>;
  23985. set renderList(value: Nullable<Array<AbstractMesh>>);
  23986. /**
  23987. * Use this function to overload the renderList array at rendering time.
  23988. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23989. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23990. * the cube (if the RTT is a cube, else layerOrFace=0).
  23991. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23992. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23993. * hold dummy elements!
  23994. */
  23995. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23996. private _hookArray;
  23997. /**
  23998. * Define if particles should be rendered in your texture.
  23999. */
  24000. renderParticles: boolean;
  24001. /**
  24002. * Define if sprites should be rendered in your texture.
  24003. */
  24004. renderSprites: boolean;
  24005. /**
  24006. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24007. */
  24008. coordinatesMode: number;
  24009. /**
  24010. * Define the camera used to render the texture.
  24011. */
  24012. activeCamera: Nullable<Camera>;
  24013. /**
  24014. * Override the mesh isReady function with your own one.
  24015. */
  24016. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24017. /**
  24018. * Override the render function of the texture with your own one.
  24019. */
  24020. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24021. /**
  24022. * Define if camera post processes should be use while rendering the texture.
  24023. */
  24024. useCameraPostProcesses: boolean;
  24025. /**
  24026. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24027. */
  24028. ignoreCameraViewport: boolean;
  24029. private _postProcessManager;
  24030. private _postProcesses;
  24031. private _resizeObserver;
  24032. /**
  24033. * An event triggered when the texture is unbind.
  24034. */
  24035. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24036. /**
  24037. * An event triggered when the texture is unbind.
  24038. */
  24039. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24040. private _onAfterUnbindObserver;
  24041. /**
  24042. * Set a after unbind callback in the texture.
  24043. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24044. */
  24045. set onAfterUnbind(callback: () => void);
  24046. /**
  24047. * An event triggered before rendering the texture
  24048. */
  24049. onBeforeRenderObservable: Observable<number>;
  24050. private _onBeforeRenderObserver;
  24051. /**
  24052. * Set a before render callback in the texture.
  24053. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24054. */
  24055. set onBeforeRender(callback: (faceIndex: number) => void);
  24056. /**
  24057. * An event triggered after rendering the texture
  24058. */
  24059. onAfterRenderObservable: Observable<number>;
  24060. private _onAfterRenderObserver;
  24061. /**
  24062. * Set a after render callback in the texture.
  24063. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24064. */
  24065. set onAfterRender(callback: (faceIndex: number) => void);
  24066. /**
  24067. * An event triggered after the texture clear
  24068. */
  24069. onClearObservable: Observable<Engine>;
  24070. private _onClearObserver;
  24071. /**
  24072. * Set a clear callback in the texture.
  24073. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24074. */
  24075. set onClear(callback: (Engine: Engine) => void);
  24076. /**
  24077. * An event triggered when the texture is resized.
  24078. */
  24079. onResizeObservable: Observable<RenderTargetTexture>;
  24080. /**
  24081. * Define the clear color of the Render Target if it should be different from the scene.
  24082. */
  24083. clearColor: Color4;
  24084. protected _size: number | {
  24085. width: number;
  24086. height: number;
  24087. layers?: number;
  24088. };
  24089. protected _initialSizeParameter: number | {
  24090. width: number;
  24091. height: number;
  24092. } | {
  24093. ratio: number;
  24094. };
  24095. protected _sizeRatio: Nullable<number>;
  24096. /** @hidden */
  24097. _generateMipMaps: boolean;
  24098. protected _renderingManager: RenderingManager;
  24099. /** @hidden */
  24100. _waitingRenderList: string[];
  24101. protected _doNotChangeAspectRatio: boolean;
  24102. protected _currentRefreshId: number;
  24103. protected _refreshRate: number;
  24104. protected _textureMatrix: Matrix;
  24105. protected _samples: number;
  24106. protected _renderTargetOptions: RenderTargetCreationOptions;
  24107. /**
  24108. * Gets render target creation options that were used.
  24109. */
  24110. get renderTargetOptions(): RenderTargetCreationOptions;
  24111. protected _onRatioRescale(): void;
  24112. /**
  24113. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24114. * It must define where the camera used to render the texture is set
  24115. */
  24116. boundingBoxPosition: Vector3;
  24117. private _boundingBoxSize;
  24118. /**
  24119. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24120. * When defined, the cubemap will switch to local mode
  24121. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24122. * @example https://www.babylonjs-playground.com/#RNASML
  24123. */
  24124. set boundingBoxSize(value: Vector3);
  24125. get boundingBoxSize(): Vector3;
  24126. /**
  24127. * In case the RTT has been created with a depth texture, get the associated
  24128. * depth texture.
  24129. * Otherwise, return null.
  24130. */
  24131. get depthStencilTexture(): Nullable<InternalTexture>;
  24132. /**
  24133. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24134. * or used a shadow, depth texture...
  24135. * @param name The friendly name of the texture
  24136. * @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)
  24137. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24138. * @param generateMipMaps True if mip maps need to be generated after render.
  24139. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24140. * @param type The type of the buffer in the RTT (int, half float, float...)
  24141. * @param isCube True if a cube texture needs to be created
  24142. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24143. * @param generateDepthBuffer True to generate a depth buffer
  24144. * @param generateStencilBuffer True to generate a stencil buffer
  24145. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24146. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24147. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24148. */
  24149. constructor(name: string, size: number | {
  24150. width: number;
  24151. height: number;
  24152. layers?: number;
  24153. } | {
  24154. ratio: number;
  24155. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24156. /**
  24157. * Creates a depth stencil texture.
  24158. * This is only available in WebGL 2 or with the depth texture extension available.
  24159. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24160. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24161. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24162. */
  24163. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24164. private _processSizeParameter;
  24165. /**
  24166. * Define the number of samples to use in case of MSAA.
  24167. * It defaults to one meaning no MSAA has been enabled.
  24168. */
  24169. get samples(): number;
  24170. set samples(value: number);
  24171. /**
  24172. * Resets the refresh counter of the texture and start bak from scratch.
  24173. * Could be useful to regenerate the texture if it is setup to render only once.
  24174. */
  24175. resetRefreshCounter(): void;
  24176. /**
  24177. * Define the refresh rate of the texture or the rendering frequency.
  24178. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24179. */
  24180. get refreshRate(): number;
  24181. set refreshRate(value: number);
  24182. /**
  24183. * Adds a post process to the render target rendering passes.
  24184. * @param postProcess define the post process to add
  24185. */
  24186. addPostProcess(postProcess: PostProcess): void;
  24187. /**
  24188. * Clear all the post processes attached to the render target
  24189. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24190. */
  24191. clearPostProcesses(dispose?: boolean): void;
  24192. /**
  24193. * Remove one of the post process from the list of attached post processes to the texture
  24194. * @param postProcess define the post process to remove from the list
  24195. */
  24196. removePostProcess(postProcess: PostProcess): void;
  24197. /** @hidden */
  24198. _shouldRender(): boolean;
  24199. /**
  24200. * Gets the actual render size of the texture.
  24201. * @returns the width of the render size
  24202. */
  24203. getRenderSize(): number;
  24204. /**
  24205. * Gets the actual render width of the texture.
  24206. * @returns the width of the render size
  24207. */
  24208. getRenderWidth(): number;
  24209. /**
  24210. * Gets the actual render height of the texture.
  24211. * @returns the height of the render size
  24212. */
  24213. getRenderHeight(): number;
  24214. /**
  24215. * Gets the actual number of layers of the texture.
  24216. * @returns the number of layers
  24217. */
  24218. getRenderLayers(): number;
  24219. /**
  24220. * Get if the texture can be rescaled or not.
  24221. */
  24222. get canRescale(): boolean;
  24223. /**
  24224. * Resize the texture using a ratio.
  24225. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24226. */
  24227. scale(ratio: number): void;
  24228. /**
  24229. * Get the texture reflection matrix used to rotate/transform the reflection.
  24230. * @returns the reflection matrix
  24231. */
  24232. getReflectionTextureMatrix(): Matrix;
  24233. /**
  24234. * Resize the texture to a new desired size.
  24235. * Be carrefull as it will recreate all the data in the new texture.
  24236. * @param size Define the new size. It can be:
  24237. * - a number for squared texture,
  24238. * - an object containing { width: number, height: number }
  24239. * - or an object containing a ratio { ratio: number }
  24240. */
  24241. resize(size: number | {
  24242. width: number;
  24243. height: number;
  24244. } | {
  24245. ratio: number;
  24246. }): void;
  24247. private _defaultRenderListPrepared;
  24248. /**
  24249. * Renders all the objects from the render list into the texture.
  24250. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24251. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24252. */
  24253. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24254. private _bestReflectionRenderTargetDimension;
  24255. private _prepareRenderingManager;
  24256. /**
  24257. * @hidden
  24258. * @param faceIndex face index to bind to if this is a cubetexture
  24259. * @param layer defines the index of the texture to bind in the array
  24260. */
  24261. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24262. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24263. private renderToTarget;
  24264. /**
  24265. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24266. * This allowed control for front to back rendering or reversly depending of the special needs.
  24267. *
  24268. * @param renderingGroupId The rendering group id corresponding to its index
  24269. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24270. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24271. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24272. */
  24273. 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;
  24274. /**
  24275. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24276. *
  24277. * @param renderingGroupId The rendering group id corresponding to its index
  24278. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24279. */
  24280. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24281. /**
  24282. * Clones the texture.
  24283. * @returns the cloned texture
  24284. */
  24285. clone(): RenderTargetTexture;
  24286. /**
  24287. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24288. * @returns The JSON representation of the texture
  24289. */
  24290. serialize(): any;
  24291. /**
  24292. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24293. */
  24294. disposeFramebufferObjects(): void;
  24295. /**
  24296. * Dispose the texture and release its associated resources.
  24297. */
  24298. dispose(): void;
  24299. /** @hidden */
  24300. _rebuild(): void;
  24301. /**
  24302. * Clear the info related to rendering groups preventing retention point in material dispose.
  24303. */
  24304. freeRenderingGroups(): void;
  24305. /**
  24306. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24307. * @returns the view count
  24308. */
  24309. getViewCount(): number;
  24310. }
  24311. }
  24312. declare module "babylonjs/Misc/guid" {
  24313. /**
  24314. * Class used to manipulate GUIDs
  24315. */
  24316. export class GUID {
  24317. /**
  24318. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24319. * Be aware Math.random() could cause collisions, but:
  24320. * "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"
  24321. * @returns a pseudo random id
  24322. */
  24323. static RandomId(): string;
  24324. }
  24325. }
  24326. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24327. import { Nullable } from "babylonjs/types";
  24328. import { Scene } from "babylonjs/scene";
  24329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24330. import { Material } from "babylonjs/Materials/material";
  24331. import { Effect } from "babylonjs/Materials/effect";
  24332. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24333. /**
  24334. * Options to be used when creating a shadow depth material
  24335. */
  24336. export interface IIOptionShadowDepthMaterial {
  24337. /** Variables in the vertex shader code that need to have their names remapped.
  24338. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24339. * "var_name" should be either: worldPos or vNormalW
  24340. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24341. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24342. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24343. */
  24344. remappedVariables?: string[];
  24345. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24346. standalone?: boolean;
  24347. }
  24348. /**
  24349. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24350. */
  24351. export class ShadowDepthWrapper {
  24352. private _scene;
  24353. private _options?;
  24354. private _baseMaterial;
  24355. private _onEffectCreatedObserver;
  24356. private _subMeshToEffect;
  24357. private _subMeshToDepthEffect;
  24358. private _meshes;
  24359. /** @hidden */
  24360. _matriceNames: any;
  24361. /** Gets the standalone status of the wrapper */
  24362. get standalone(): boolean;
  24363. /** Gets the base material the wrapper is built upon */
  24364. get baseMaterial(): Material;
  24365. /**
  24366. * Instantiate a new shadow depth wrapper.
  24367. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24368. * generate the shadow depth map. For more information, please refer to the documentation:
  24369. * https://doc.babylonjs.com/babylon101/shadows
  24370. * @param baseMaterial Material to wrap
  24371. * @param scene Define the scene the material belongs to
  24372. * @param options Options used to create the wrapper
  24373. */
  24374. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24375. /**
  24376. * Gets the effect to use to generate the depth map
  24377. * @param subMesh subMesh to get the effect for
  24378. * @param shadowGenerator shadow generator to get the effect for
  24379. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24380. */
  24381. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24382. /**
  24383. * Specifies that the submesh is ready to be used for depth rendering
  24384. * @param subMesh submesh to check
  24385. * @param defines the list of defines to take into account when checking the effect
  24386. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24387. * @param useInstances specifies that instances should be used
  24388. * @returns a boolean indicating that the submesh is ready or not
  24389. */
  24390. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24391. /**
  24392. * Disposes the resources
  24393. */
  24394. dispose(): void;
  24395. private _makeEffect;
  24396. }
  24397. }
  24398. declare module "babylonjs/Materials/material" {
  24399. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24400. import { SmartArray } from "babylonjs/Misc/smartArray";
  24401. import { Observable } from "babylonjs/Misc/observable";
  24402. import { Nullable } from "babylonjs/types";
  24403. import { Scene } from "babylonjs/scene";
  24404. import { Matrix } from "babylonjs/Maths/math.vector";
  24405. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  24406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24407. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24408. import { Effect } from "babylonjs/Materials/effect";
  24409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24411. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24412. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24413. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24414. import { Mesh } from "babylonjs/Meshes/mesh";
  24415. import { Animation } from "babylonjs/Animations/animation";
  24416. /**
  24417. * Options for compiling materials.
  24418. */
  24419. export interface IMaterialCompilationOptions {
  24420. /**
  24421. * Defines whether clip planes are enabled.
  24422. */
  24423. clipPlane: boolean;
  24424. /**
  24425. * Defines whether instances are enabled.
  24426. */
  24427. useInstances: boolean;
  24428. }
  24429. /**
  24430. * Base class for the main features of a material in Babylon.js
  24431. */
  24432. export class Material implements IAnimatable {
  24433. /**
  24434. * Returns the triangle fill mode
  24435. */
  24436. static readonly TriangleFillMode: number;
  24437. /**
  24438. * Returns the wireframe mode
  24439. */
  24440. static readonly WireFrameFillMode: number;
  24441. /**
  24442. * Returns the point fill mode
  24443. */
  24444. static readonly PointFillMode: number;
  24445. /**
  24446. * Returns the point list draw mode
  24447. */
  24448. static readonly PointListDrawMode: number;
  24449. /**
  24450. * Returns the line list draw mode
  24451. */
  24452. static readonly LineListDrawMode: number;
  24453. /**
  24454. * Returns the line loop draw mode
  24455. */
  24456. static readonly LineLoopDrawMode: number;
  24457. /**
  24458. * Returns the line strip draw mode
  24459. */
  24460. static readonly LineStripDrawMode: number;
  24461. /**
  24462. * Returns the triangle strip draw mode
  24463. */
  24464. static readonly TriangleStripDrawMode: number;
  24465. /**
  24466. * Returns the triangle fan draw mode
  24467. */
  24468. static readonly TriangleFanDrawMode: number;
  24469. /**
  24470. * Stores the clock-wise side orientation
  24471. */
  24472. static readonly ClockWiseSideOrientation: number;
  24473. /**
  24474. * Stores the counter clock-wise side orientation
  24475. */
  24476. static readonly CounterClockWiseSideOrientation: number;
  24477. /**
  24478. * The dirty texture flag value
  24479. */
  24480. static readonly TextureDirtyFlag: number;
  24481. /**
  24482. * The dirty light flag value
  24483. */
  24484. static readonly LightDirtyFlag: number;
  24485. /**
  24486. * The dirty fresnel flag value
  24487. */
  24488. static readonly FresnelDirtyFlag: number;
  24489. /**
  24490. * The dirty attribute flag value
  24491. */
  24492. static readonly AttributesDirtyFlag: number;
  24493. /**
  24494. * The dirty misc flag value
  24495. */
  24496. static readonly MiscDirtyFlag: number;
  24497. /**
  24498. * The all dirty flag value
  24499. */
  24500. static readonly AllDirtyFlag: number;
  24501. /**
  24502. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24503. */
  24504. static readonly MATERIAL_OPAQUE: number;
  24505. /**
  24506. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24507. */
  24508. static readonly MATERIAL_ALPHATEST: number;
  24509. /**
  24510. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24511. */
  24512. static readonly MATERIAL_ALPHABLEND: number;
  24513. /**
  24514. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24515. * They are also discarded below the alpha cutoff threshold to improve performances.
  24516. */
  24517. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24518. /**
  24519. * Custom callback helping to override the default shader used in the material.
  24520. */
  24521. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  24522. /**
  24523. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24524. */
  24525. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24526. /**
  24527. * The ID of the material
  24528. */
  24529. id: string;
  24530. /**
  24531. * Gets or sets the unique id of the material
  24532. */
  24533. uniqueId: number;
  24534. /**
  24535. * The name of the material
  24536. */
  24537. name: string;
  24538. /**
  24539. * Gets or sets user defined metadata
  24540. */
  24541. metadata: any;
  24542. /**
  24543. * For internal use only. Please do not use.
  24544. */
  24545. reservedDataStore: any;
  24546. /**
  24547. * Specifies if the ready state should be checked on each call
  24548. */
  24549. checkReadyOnEveryCall: boolean;
  24550. /**
  24551. * Specifies if the ready state should be checked once
  24552. */
  24553. checkReadyOnlyOnce: boolean;
  24554. /**
  24555. * The state of the material
  24556. */
  24557. state: string;
  24558. /**
  24559. * The alpha value of the material
  24560. */
  24561. protected _alpha: number;
  24562. /**
  24563. * List of inspectable custom properties (used by the Inspector)
  24564. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24565. */
  24566. inspectableCustomProperties: IInspectable[];
  24567. /**
  24568. * Sets the alpha value of the material
  24569. */
  24570. set alpha(value: number);
  24571. /**
  24572. * Gets the alpha value of the material
  24573. */
  24574. get alpha(): number;
  24575. /**
  24576. * Specifies if back face culling is enabled
  24577. */
  24578. protected _backFaceCulling: boolean;
  24579. /**
  24580. * Sets the back-face culling state
  24581. */
  24582. set backFaceCulling(value: boolean);
  24583. /**
  24584. * Gets the back-face culling state
  24585. */
  24586. get backFaceCulling(): boolean;
  24587. /**
  24588. * Stores the value for side orientation
  24589. */
  24590. sideOrientation: number;
  24591. /**
  24592. * Callback triggered when the material is compiled
  24593. */
  24594. onCompiled: Nullable<(effect: Effect) => void>;
  24595. /**
  24596. * Callback triggered when an error occurs
  24597. */
  24598. onError: Nullable<(effect: Effect, errors: string) => void>;
  24599. /**
  24600. * Callback triggered to get the render target textures
  24601. */
  24602. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24603. /**
  24604. * Gets a boolean indicating that current material needs to register RTT
  24605. */
  24606. get hasRenderTargetTextures(): boolean;
  24607. /**
  24608. * Specifies if the material should be serialized
  24609. */
  24610. doNotSerialize: boolean;
  24611. /**
  24612. * @hidden
  24613. */
  24614. _storeEffectOnSubMeshes: boolean;
  24615. /**
  24616. * Stores the animations for the material
  24617. */
  24618. animations: Nullable<Array<Animation>>;
  24619. /**
  24620. * An event triggered when the material is disposed
  24621. */
  24622. onDisposeObservable: Observable<Material>;
  24623. /**
  24624. * An observer which watches for dispose events
  24625. */
  24626. private _onDisposeObserver;
  24627. private _onUnBindObservable;
  24628. /**
  24629. * Called during a dispose event
  24630. */
  24631. set onDispose(callback: () => void);
  24632. private _onBindObservable;
  24633. /**
  24634. * An event triggered when the material is bound
  24635. */
  24636. get onBindObservable(): Observable<AbstractMesh>;
  24637. /**
  24638. * An observer which watches for bind events
  24639. */
  24640. private _onBindObserver;
  24641. /**
  24642. * Called during a bind event
  24643. */
  24644. set onBind(callback: (Mesh: AbstractMesh) => void);
  24645. /**
  24646. * An event triggered when the material is unbound
  24647. */
  24648. get onUnBindObservable(): Observable<Material>;
  24649. protected _onEffectCreatedObservable: Nullable<Observable<{
  24650. effect: Effect;
  24651. subMesh: Nullable<SubMesh>;
  24652. }>>;
  24653. /**
  24654. * An event triggered when the effect is (re)created
  24655. */
  24656. get onEffectCreatedObservable(): Observable<{
  24657. effect: Effect;
  24658. subMesh: Nullable<SubMesh>;
  24659. }>;
  24660. /**
  24661. * Stores the value of the alpha mode
  24662. */
  24663. private _alphaMode;
  24664. /**
  24665. * Sets the value of the alpha mode.
  24666. *
  24667. * | Value | Type | Description |
  24668. * | --- | --- | --- |
  24669. * | 0 | ALPHA_DISABLE | |
  24670. * | 1 | ALPHA_ADD | |
  24671. * | 2 | ALPHA_COMBINE | |
  24672. * | 3 | ALPHA_SUBTRACT | |
  24673. * | 4 | ALPHA_MULTIPLY | |
  24674. * | 5 | ALPHA_MAXIMIZED | |
  24675. * | 6 | ALPHA_ONEONE | |
  24676. * | 7 | ALPHA_PREMULTIPLIED | |
  24677. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24678. * | 9 | ALPHA_INTERPOLATE | |
  24679. * | 10 | ALPHA_SCREENMODE | |
  24680. *
  24681. */
  24682. set alphaMode(value: number);
  24683. /**
  24684. * Gets the value of the alpha mode
  24685. */
  24686. get alphaMode(): number;
  24687. /**
  24688. * Stores the state of the need depth pre-pass value
  24689. */
  24690. private _needDepthPrePass;
  24691. /**
  24692. * Sets the need depth pre-pass value
  24693. */
  24694. set needDepthPrePass(value: boolean);
  24695. /**
  24696. * Gets the depth pre-pass value
  24697. */
  24698. get needDepthPrePass(): boolean;
  24699. /**
  24700. * Specifies if depth writing should be disabled
  24701. */
  24702. disableDepthWrite: boolean;
  24703. /**
  24704. * Specifies if color writing should be disabled
  24705. */
  24706. disableColorWrite: boolean;
  24707. /**
  24708. * Specifies if depth writing should be forced
  24709. */
  24710. forceDepthWrite: boolean;
  24711. /**
  24712. * Specifies the depth function that should be used. 0 means the default engine function
  24713. */
  24714. depthFunction: number;
  24715. /**
  24716. * Specifies if there should be a separate pass for culling
  24717. */
  24718. separateCullingPass: boolean;
  24719. /**
  24720. * Stores the state specifing if fog should be enabled
  24721. */
  24722. private _fogEnabled;
  24723. /**
  24724. * Sets the state for enabling fog
  24725. */
  24726. set fogEnabled(value: boolean);
  24727. /**
  24728. * Gets the value of the fog enabled state
  24729. */
  24730. get fogEnabled(): boolean;
  24731. /**
  24732. * Stores the size of points
  24733. */
  24734. pointSize: number;
  24735. /**
  24736. * Stores the z offset value
  24737. */
  24738. zOffset: number;
  24739. get wireframe(): boolean;
  24740. /**
  24741. * Sets the state of wireframe mode
  24742. */
  24743. set wireframe(value: boolean);
  24744. /**
  24745. * Gets the value specifying if point clouds are enabled
  24746. */
  24747. get pointsCloud(): boolean;
  24748. /**
  24749. * Sets the state of point cloud mode
  24750. */
  24751. set pointsCloud(value: boolean);
  24752. /**
  24753. * Gets the material fill mode
  24754. */
  24755. get fillMode(): number;
  24756. /**
  24757. * Sets the material fill mode
  24758. */
  24759. set fillMode(value: number);
  24760. /**
  24761. * @hidden
  24762. * Stores the effects for the material
  24763. */
  24764. _effect: Nullable<Effect>;
  24765. /**
  24766. * Specifies if uniform buffers should be used
  24767. */
  24768. private _useUBO;
  24769. /**
  24770. * Stores a reference to the scene
  24771. */
  24772. private _scene;
  24773. /**
  24774. * Stores the fill mode state
  24775. */
  24776. private _fillMode;
  24777. /**
  24778. * Specifies if the depth write state should be cached
  24779. */
  24780. private _cachedDepthWriteState;
  24781. /**
  24782. * Specifies if the color write state should be cached
  24783. */
  24784. private _cachedColorWriteState;
  24785. /**
  24786. * Specifies if the depth function state should be cached
  24787. */
  24788. private _cachedDepthFunctionState;
  24789. /**
  24790. * Stores the uniform buffer
  24791. */
  24792. protected _uniformBuffer: UniformBuffer;
  24793. /** @hidden */
  24794. _indexInSceneMaterialArray: number;
  24795. /** @hidden */
  24796. meshMap: Nullable<{
  24797. [id: string]: AbstractMesh | undefined;
  24798. }>;
  24799. /**
  24800. * Creates a material instance
  24801. * @param name defines the name of the material
  24802. * @param scene defines the scene to reference
  24803. * @param doNotAdd specifies if the material should be added to the scene
  24804. */
  24805. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24806. /**
  24807. * Returns a string representation of the current material
  24808. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24809. * @returns a string with material information
  24810. */
  24811. toString(fullDetails?: boolean): string;
  24812. /**
  24813. * Gets the class name of the material
  24814. * @returns a string with the class name of the material
  24815. */
  24816. getClassName(): string;
  24817. /**
  24818. * Specifies if updates for the material been locked
  24819. */
  24820. get isFrozen(): boolean;
  24821. /**
  24822. * Locks updates for the material
  24823. */
  24824. freeze(): void;
  24825. /**
  24826. * Unlocks updates for the material
  24827. */
  24828. unfreeze(): void;
  24829. /**
  24830. * Specifies if the material is ready to be used
  24831. * @param mesh defines the mesh to check
  24832. * @param useInstances specifies if instances should be used
  24833. * @returns a boolean indicating if the material is ready to be used
  24834. */
  24835. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24836. /**
  24837. * Specifies that the submesh is ready to be used
  24838. * @param mesh defines the mesh to check
  24839. * @param subMesh defines which submesh to check
  24840. * @param useInstances specifies that instances should be used
  24841. * @returns a boolean indicating that the submesh is ready or not
  24842. */
  24843. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24844. /**
  24845. * Returns the material effect
  24846. * @returns the effect associated with the material
  24847. */
  24848. getEffect(): Nullable<Effect>;
  24849. /**
  24850. * Returns the current scene
  24851. * @returns a Scene
  24852. */
  24853. getScene(): Scene;
  24854. /**
  24855. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24856. */
  24857. protected _forceAlphaTest: boolean;
  24858. /**
  24859. * The transparency mode of the material.
  24860. */
  24861. protected _transparencyMode: Nullable<number>;
  24862. /**
  24863. * Gets the current transparency mode.
  24864. */
  24865. get transparencyMode(): Nullable<number>;
  24866. /**
  24867. * Sets the transparency mode of the material.
  24868. *
  24869. * | Value | Type | Description |
  24870. * | ----- | ----------------------------------- | ----------- |
  24871. * | 0 | OPAQUE | |
  24872. * | 1 | ALPHATEST | |
  24873. * | 2 | ALPHABLEND | |
  24874. * | 3 | ALPHATESTANDBLEND | |
  24875. *
  24876. */
  24877. set transparencyMode(value: Nullable<number>);
  24878. /**
  24879. * Returns true if alpha blending should be disabled.
  24880. */
  24881. protected get _disableAlphaBlending(): boolean;
  24882. /**
  24883. * Specifies whether or not this material should be rendered in alpha blend mode.
  24884. * @returns a boolean specifying if alpha blending is needed
  24885. */
  24886. needAlphaBlending(): boolean;
  24887. /**
  24888. * Specifies if the mesh will require alpha blending
  24889. * @param mesh defines the mesh to check
  24890. * @returns a boolean specifying if alpha blending is needed for the mesh
  24891. */
  24892. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24893. /**
  24894. * Specifies whether or not this material should be rendered in alpha test mode.
  24895. * @returns a boolean specifying if an alpha test is needed.
  24896. */
  24897. needAlphaTesting(): boolean;
  24898. /**
  24899. * Specifies if material alpha testing should be turned on for the mesh
  24900. * @param mesh defines the mesh to check
  24901. */
  24902. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24903. /**
  24904. * Gets the texture used for the alpha test
  24905. * @returns the texture to use for alpha testing
  24906. */
  24907. getAlphaTestTexture(): Nullable<BaseTexture>;
  24908. /**
  24909. * Marks the material to indicate that it needs to be re-calculated
  24910. */
  24911. markDirty(): void;
  24912. /** @hidden */
  24913. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24914. /**
  24915. * Binds the material to the mesh
  24916. * @param world defines the world transformation matrix
  24917. * @param mesh defines the mesh to bind the material to
  24918. */
  24919. bind(world: Matrix, mesh?: Mesh): void;
  24920. /**
  24921. * Binds the submesh to the material
  24922. * @param world defines the world transformation matrix
  24923. * @param mesh defines the mesh containing the submesh
  24924. * @param subMesh defines the submesh to bind the material to
  24925. */
  24926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24927. /**
  24928. * Binds the world matrix to the material
  24929. * @param world defines the world transformation matrix
  24930. */
  24931. bindOnlyWorldMatrix(world: Matrix): void;
  24932. /**
  24933. * Binds the scene's uniform buffer to the effect.
  24934. * @param effect defines the effect to bind to the scene uniform buffer
  24935. * @param sceneUbo defines the uniform buffer storing scene data
  24936. */
  24937. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24938. /**
  24939. * Binds the view matrix to the effect
  24940. * @param effect defines the effect to bind the view matrix to
  24941. */
  24942. bindView(effect: Effect): void;
  24943. /**
  24944. * Binds the view projection matrix to the effect
  24945. * @param effect defines the effect to bind the view projection matrix to
  24946. */
  24947. bindViewProjection(effect: Effect): void;
  24948. /**
  24949. * Processes to execute after binding the material to a mesh
  24950. * @param mesh defines the rendered mesh
  24951. */
  24952. protected _afterBind(mesh?: Mesh): void;
  24953. /**
  24954. * Unbinds the material from the mesh
  24955. */
  24956. unbind(): void;
  24957. /**
  24958. * Gets the active textures from the material
  24959. * @returns an array of textures
  24960. */
  24961. getActiveTextures(): BaseTexture[];
  24962. /**
  24963. * Specifies if the material uses a texture
  24964. * @param texture defines the texture to check against the material
  24965. * @returns a boolean specifying if the material uses the texture
  24966. */
  24967. hasTexture(texture: BaseTexture): boolean;
  24968. /**
  24969. * Makes a duplicate of the material, and gives it a new name
  24970. * @param name defines the new name for the duplicated material
  24971. * @returns the cloned material
  24972. */
  24973. clone(name: string): Nullable<Material>;
  24974. /**
  24975. * Gets the meshes bound to the material
  24976. * @returns an array of meshes bound to the material
  24977. */
  24978. getBindedMeshes(): AbstractMesh[];
  24979. /**
  24980. * Force shader compilation
  24981. * @param mesh defines the mesh associated with this material
  24982. * @param onCompiled defines a function to execute once the material is compiled
  24983. * @param options defines the options to configure the compilation
  24984. * @param onError defines a function to execute if the material fails compiling
  24985. */
  24986. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24987. /**
  24988. * Force shader compilation
  24989. * @param mesh defines the mesh that will use this material
  24990. * @param options defines additional options for compiling the shaders
  24991. * @returns a promise that resolves when the compilation completes
  24992. */
  24993. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24994. private static readonly _AllDirtyCallBack;
  24995. private static readonly _ImageProcessingDirtyCallBack;
  24996. private static readonly _TextureDirtyCallBack;
  24997. private static readonly _FresnelDirtyCallBack;
  24998. private static readonly _MiscDirtyCallBack;
  24999. private static readonly _LightsDirtyCallBack;
  25000. private static readonly _AttributeDirtyCallBack;
  25001. private static _FresnelAndMiscDirtyCallBack;
  25002. private static _TextureAndMiscDirtyCallBack;
  25003. private static readonly _DirtyCallbackArray;
  25004. private static readonly _RunDirtyCallBacks;
  25005. /**
  25006. * Marks a define in the material to indicate that it needs to be re-computed
  25007. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25008. */
  25009. markAsDirty(flag: number): void;
  25010. /**
  25011. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25012. * @param func defines a function which checks material defines against the submeshes
  25013. */
  25014. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25015. /**
  25016. * Indicates that we need to re-calculated for all submeshes
  25017. */
  25018. protected _markAllSubMeshesAsAllDirty(): void;
  25019. /**
  25020. * Indicates that image processing needs to be re-calculated for all submeshes
  25021. */
  25022. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25023. /**
  25024. * Indicates that textures need to be re-calculated for all submeshes
  25025. */
  25026. protected _markAllSubMeshesAsTexturesDirty(): void;
  25027. /**
  25028. * Indicates that fresnel needs to be re-calculated for all submeshes
  25029. */
  25030. protected _markAllSubMeshesAsFresnelDirty(): void;
  25031. /**
  25032. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25033. */
  25034. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25035. /**
  25036. * Indicates that lights need to be re-calculated for all submeshes
  25037. */
  25038. protected _markAllSubMeshesAsLightsDirty(): void;
  25039. /**
  25040. * Indicates that attributes need to be re-calculated for all submeshes
  25041. */
  25042. protected _markAllSubMeshesAsAttributesDirty(): void;
  25043. /**
  25044. * Indicates that misc needs to be re-calculated for all submeshes
  25045. */
  25046. protected _markAllSubMeshesAsMiscDirty(): void;
  25047. /**
  25048. * Indicates that textures and misc need to be re-calculated for all submeshes
  25049. */
  25050. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25051. /**
  25052. * Disposes the material
  25053. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25054. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25055. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25056. */
  25057. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25058. /** @hidden */
  25059. private releaseVertexArrayObject;
  25060. /**
  25061. * Serializes this material
  25062. * @returns the serialized material object
  25063. */
  25064. serialize(): any;
  25065. /**
  25066. * Creates a material from parsed material data
  25067. * @param parsedMaterial defines parsed material data
  25068. * @param scene defines the hosting scene
  25069. * @param rootUrl defines the root URL to use to load textures
  25070. * @returns a new material
  25071. */
  25072. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25073. }
  25074. }
  25075. declare module "babylonjs/Materials/multiMaterial" {
  25076. import { Nullable } from "babylonjs/types";
  25077. import { Scene } from "babylonjs/scene";
  25078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25079. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  25080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25081. import { Material } from "babylonjs/Materials/material";
  25082. /**
  25083. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25084. * separate meshes. This can be use to improve performances.
  25085. * @see http://doc.babylonjs.com/how_to/multi_materials
  25086. */
  25087. export class MultiMaterial extends Material {
  25088. private _subMaterials;
  25089. /**
  25090. * Gets or Sets the list of Materials used within the multi material.
  25091. * They need to be ordered according to the submeshes order in the associated mesh
  25092. */
  25093. get subMaterials(): Nullable<Material>[];
  25094. set subMaterials(value: Nullable<Material>[]);
  25095. /**
  25096. * Function used to align with Node.getChildren()
  25097. * @returns the list of Materials used within the multi material
  25098. */
  25099. getChildren(): Nullable<Material>[];
  25100. /**
  25101. * Instantiates a new Multi Material
  25102. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25103. * separate meshes. This can be use to improve performances.
  25104. * @see http://doc.babylonjs.com/how_to/multi_materials
  25105. * @param name Define the name in the scene
  25106. * @param scene Define the scene the material belongs to
  25107. */
  25108. constructor(name: string, scene: Scene);
  25109. private _hookArray;
  25110. /**
  25111. * Get one of the submaterial by its index in the submaterials array
  25112. * @param index The index to look the sub material at
  25113. * @returns The Material if the index has been defined
  25114. */
  25115. getSubMaterial(index: number): Nullable<Material>;
  25116. /**
  25117. * Get the list of active textures for the whole sub materials list.
  25118. * @returns All the textures that will be used during the rendering
  25119. */
  25120. getActiveTextures(): BaseTexture[];
  25121. /**
  25122. * Gets the current class name of the material e.g. "MultiMaterial"
  25123. * Mainly use in serialization.
  25124. * @returns the class name
  25125. */
  25126. getClassName(): string;
  25127. /**
  25128. * Checks if the material is ready to render the requested sub mesh
  25129. * @param mesh Define the mesh the submesh belongs to
  25130. * @param subMesh Define the sub mesh to look readyness for
  25131. * @param useInstances Define whether or not the material is used with instances
  25132. * @returns true if ready, otherwise false
  25133. */
  25134. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  25135. /**
  25136. * Clones the current material and its related sub materials
  25137. * @param name Define the name of the newly cloned material
  25138. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25139. * @returns the cloned material
  25140. */
  25141. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25142. /**
  25143. * Serializes the materials into a JSON representation.
  25144. * @returns the JSON representation
  25145. */
  25146. serialize(): any;
  25147. /**
  25148. * Dispose the material and release its associated resources
  25149. * @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)
  25150. * @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)
  25151. * @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)
  25152. */
  25153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25154. /**
  25155. * Creates a MultiMaterial from parsed MultiMaterial data.
  25156. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25157. * @param scene defines the hosting scene
  25158. * @returns a new MultiMaterial
  25159. */
  25160. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25161. }
  25162. }
  25163. declare module "babylonjs/Meshes/subMesh" {
  25164. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25165. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25166. import { Engine } from "babylonjs/Engines/engine";
  25167. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25168. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25169. import { Effect } from "babylonjs/Materials/effect";
  25170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25171. import { Plane } from "babylonjs/Maths/math.plane";
  25172. import { Collider } from "babylonjs/Collisions/collider";
  25173. import { Material } from "babylonjs/Materials/material";
  25174. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25176. import { Mesh } from "babylonjs/Meshes/mesh";
  25177. import { Ray } from "babylonjs/Culling/ray";
  25178. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25179. /**
  25180. * Base class for submeshes
  25181. */
  25182. export class BaseSubMesh {
  25183. /** @hidden */
  25184. _materialDefines: Nullable<MaterialDefines>;
  25185. /** @hidden */
  25186. _materialEffect: Nullable<Effect>;
  25187. /** @hidden */
  25188. _effectOverride: Nullable<Effect>;
  25189. /**
  25190. * Gets material defines used by the effect associated to the sub mesh
  25191. */
  25192. get materialDefines(): Nullable<MaterialDefines>;
  25193. /**
  25194. * Sets material defines used by the effect associated to the sub mesh
  25195. */
  25196. set materialDefines(defines: Nullable<MaterialDefines>);
  25197. /**
  25198. * Gets associated effect
  25199. */
  25200. get effect(): Nullable<Effect>;
  25201. /**
  25202. * Sets associated effect (effect used to render this submesh)
  25203. * @param effect defines the effect to associate with
  25204. * @param defines defines the set of defines used to compile this effect
  25205. */
  25206. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25207. }
  25208. /**
  25209. * Defines a subdivision inside a mesh
  25210. */
  25211. export class SubMesh extends BaseSubMesh implements ICullable {
  25212. /** the material index to use */
  25213. materialIndex: number;
  25214. /** vertex index start */
  25215. verticesStart: number;
  25216. /** vertices count */
  25217. verticesCount: number;
  25218. /** index start */
  25219. indexStart: number;
  25220. /** indices count */
  25221. indexCount: number;
  25222. /** @hidden */
  25223. _linesIndexCount: number;
  25224. private _mesh;
  25225. private _renderingMesh;
  25226. private _boundingInfo;
  25227. private _linesIndexBuffer;
  25228. /** @hidden */
  25229. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25230. /** @hidden */
  25231. _trianglePlanes: Plane[];
  25232. /** @hidden */
  25233. _lastColliderTransformMatrix: Nullable<Matrix>;
  25234. /** @hidden */
  25235. _renderId: number;
  25236. /** @hidden */
  25237. _alphaIndex: number;
  25238. /** @hidden */
  25239. _distanceToCamera: number;
  25240. /** @hidden */
  25241. _id: number;
  25242. private _currentMaterial;
  25243. /**
  25244. * Add a new submesh to a mesh
  25245. * @param materialIndex defines the material index to use
  25246. * @param verticesStart defines vertex index start
  25247. * @param verticesCount defines vertices count
  25248. * @param indexStart defines index start
  25249. * @param indexCount defines indices count
  25250. * @param mesh defines the parent mesh
  25251. * @param renderingMesh defines an optional rendering mesh
  25252. * @param createBoundingBox defines if bounding box should be created for this submesh
  25253. * @returns the new submesh
  25254. */
  25255. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25256. /**
  25257. * Creates a new submesh
  25258. * @param materialIndex defines the material index to use
  25259. * @param verticesStart defines vertex index start
  25260. * @param verticesCount defines vertices count
  25261. * @param indexStart defines index start
  25262. * @param indexCount defines indices count
  25263. * @param mesh defines the parent mesh
  25264. * @param renderingMesh defines an optional rendering mesh
  25265. * @param createBoundingBox defines if bounding box should be created for this submesh
  25266. */
  25267. constructor(
  25268. /** the material index to use */
  25269. materialIndex: number,
  25270. /** vertex index start */
  25271. verticesStart: number,
  25272. /** vertices count */
  25273. verticesCount: number,
  25274. /** index start */
  25275. indexStart: number,
  25276. /** indices count */
  25277. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25278. /**
  25279. * Returns true if this submesh covers the entire parent mesh
  25280. * @ignorenaming
  25281. */
  25282. get IsGlobal(): boolean;
  25283. /**
  25284. * Returns the submesh BoudingInfo object
  25285. * @returns current bounding info (or mesh's one if the submesh is global)
  25286. */
  25287. getBoundingInfo(): BoundingInfo;
  25288. /**
  25289. * Sets the submesh BoundingInfo
  25290. * @param boundingInfo defines the new bounding info to use
  25291. * @returns the SubMesh
  25292. */
  25293. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25294. /**
  25295. * Returns the mesh of the current submesh
  25296. * @return the parent mesh
  25297. */
  25298. getMesh(): AbstractMesh;
  25299. /**
  25300. * Returns the rendering mesh of the submesh
  25301. * @returns the rendering mesh (could be different from parent mesh)
  25302. */
  25303. getRenderingMesh(): Mesh;
  25304. /**
  25305. * Returns the submesh material
  25306. * @returns null or the current material
  25307. */
  25308. getMaterial(): Nullable<Material>;
  25309. /**
  25310. * Sets a new updated BoundingInfo object to the submesh
  25311. * @param data defines an optional position array to use to determine the bounding info
  25312. * @returns the SubMesh
  25313. */
  25314. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25315. /** @hidden */
  25316. _checkCollision(collider: Collider): boolean;
  25317. /**
  25318. * Updates the submesh BoundingInfo
  25319. * @param world defines the world matrix to use to update the bounding info
  25320. * @returns the submesh
  25321. */
  25322. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25323. /**
  25324. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25325. * @param frustumPlanes defines the frustum planes
  25326. * @returns true if the submesh is intersecting with the frustum
  25327. */
  25328. isInFrustum(frustumPlanes: Plane[]): boolean;
  25329. /**
  25330. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25331. * @param frustumPlanes defines the frustum planes
  25332. * @returns true if the submesh is inside the frustum
  25333. */
  25334. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25335. /**
  25336. * Renders the submesh
  25337. * @param enableAlphaMode defines if alpha needs to be used
  25338. * @returns the submesh
  25339. */
  25340. render(enableAlphaMode: boolean): SubMesh;
  25341. /**
  25342. * @hidden
  25343. */
  25344. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25345. /**
  25346. * Checks if the submesh intersects with a ray
  25347. * @param ray defines the ray to test
  25348. * @returns true is the passed ray intersects the submesh bounding box
  25349. */
  25350. canIntersects(ray: Ray): boolean;
  25351. /**
  25352. * Intersects current submesh with a ray
  25353. * @param ray defines the ray to test
  25354. * @param positions defines mesh's positions array
  25355. * @param indices defines mesh's indices array
  25356. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25358. * @returns intersection info or null if no intersection
  25359. */
  25360. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25361. /** @hidden */
  25362. private _intersectLines;
  25363. /** @hidden */
  25364. private _intersectUnIndexedLines;
  25365. /** @hidden */
  25366. private _intersectTriangles;
  25367. /** @hidden */
  25368. private _intersectUnIndexedTriangles;
  25369. /** @hidden */
  25370. _rebuild(): void;
  25371. /**
  25372. * Creates a new submesh from the passed mesh
  25373. * @param newMesh defines the new hosting mesh
  25374. * @param newRenderingMesh defines an optional rendering mesh
  25375. * @returns the new submesh
  25376. */
  25377. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25378. /**
  25379. * Release associated resources
  25380. */
  25381. dispose(): void;
  25382. /**
  25383. * Gets the class name
  25384. * @returns the string "SubMesh".
  25385. */
  25386. getClassName(): string;
  25387. /**
  25388. * Creates a new submesh from indices data
  25389. * @param materialIndex the index of the main mesh material
  25390. * @param startIndex the index where to start the copy in the mesh indices array
  25391. * @param indexCount the number of indices to copy then from the startIndex
  25392. * @param mesh the main mesh to create the submesh from
  25393. * @param renderingMesh the optional rendering mesh
  25394. * @returns a new submesh
  25395. */
  25396. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25397. }
  25398. }
  25399. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25400. /**
  25401. * Class used to represent data loading progression
  25402. */
  25403. export class SceneLoaderFlags {
  25404. private static _ForceFullSceneLoadingForIncremental;
  25405. private static _ShowLoadingScreen;
  25406. private static _CleanBoneMatrixWeights;
  25407. private static _loggingLevel;
  25408. /**
  25409. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25410. */
  25411. static get ForceFullSceneLoadingForIncremental(): boolean;
  25412. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25413. /**
  25414. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25415. */
  25416. static get ShowLoadingScreen(): boolean;
  25417. static set ShowLoadingScreen(value: boolean);
  25418. /**
  25419. * Defines the current logging level (while loading the scene)
  25420. * @ignorenaming
  25421. */
  25422. static get loggingLevel(): number;
  25423. static set loggingLevel(value: number);
  25424. /**
  25425. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25426. */
  25427. static get CleanBoneMatrixWeights(): boolean;
  25428. static set CleanBoneMatrixWeights(value: boolean);
  25429. }
  25430. }
  25431. declare module "babylonjs/Meshes/geometry" {
  25432. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25433. import { Scene } from "babylonjs/scene";
  25434. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25435. import { Engine } from "babylonjs/Engines/engine";
  25436. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25437. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25438. import { Effect } from "babylonjs/Materials/effect";
  25439. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25440. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25441. import { Mesh } from "babylonjs/Meshes/mesh";
  25442. /**
  25443. * Class used to store geometry data (vertex buffers + index buffer)
  25444. */
  25445. export class Geometry implements IGetSetVerticesData {
  25446. /**
  25447. * Gets or sets the ID of the geometry
  25448. */
  25449. id: string;
  25450. /**
  25451. * Gets or sets the unique ID of the geometry
  25452. */
  25453. uniqueId: number;
  25454. /**
  25455. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25456. */
  25457. delayLoadState: number;
  25458. /**
  25459. * Gets the file containing the data to load when running in delay load state
  25460. */
  25461. delayLoadingFile: Nullable<string>;
  25462. /**
  25463. * Callback called when the geometry is updated
  25464. */
  25465. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25466. private _scene;
  25467. private _engine;
  25468. private _meshes;
  25469. private _totalVertices;
  25470. /** @hidden */
  25471. _indices: IndicesArray;
  25472. /** @hidden */
  25473. _vertexBuffers: {
  25474. [key: string]: VertexBuffer;
  25475. };
  25476. private _isDisposed;
  25477. private _extend;
  25478. private _boundingBias;
  25479. /** @hidden */
  25480. _delayInfo: Array<string>;
  25481. private _indexBuffer;
  25482. private _indexBufferIsUpdatable;
  25483. /** @hidden */
  25484. _boundingInfo: Nullable<BoundingInfo>;
  25485. /** @hidden */
  25486. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25487. /** @hidden */
  25488. _softwareSkinningFrameId: number;
  25489. private _vertexArrayObjects;
  25490. private _updatable;
  25491. /** @hidden */
  25492. _positions: Nullable<Vector3[]>;
  25493. /**
  25494. * 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
  25495. */
  25496. get boundingBias(): Vector2;
  25497. /**
  25498. * 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
  25499. */
  25500. set boundingBias(value: Vector2);
  25501. /**
  25502. * Static function used to attach a new empty geometry to a mesh
  25503. * @param mesh defines the mesh to attach the geometry to
  25504. * @returns the new Geometry
  25505. */
  25506. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25507. /** Get the list of meshes using this geometry */
  25508. get meshes(): Mesh[];
  25509. /**
  25510. * Creates a new geometry
  25511. * @param id defines the unique ID
  25512. * @param scene defines the hosting scene
  25513. * @param vertexData defines the VertexData used to get geometry data
  25514. * @param updatable defines if geometry must be updatable (false by default)
  25515. * @param mesh defines the mesh that will be associated with the geometry
  25516. */
  25517. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25518. /**
  25519. * Gets the current extend of the geometry
  25520. */
  25521. get extend(): {
  25522. minimum: Vector3;
  25523. maximum: Vector3;
  25524. };
  25525. /**
  25526. * Gets the hosting scene
  25527. * @returns the hosting Scene
  25528. */
  25529. getScene(): Scene;
  25530. /**
  25531. * Gets the hosting engine
  25532. * @returns the hosting Engine
  25533. */
  25534. getEngine(): Engine;
  25535. /**
  25536. * Defines if the geometry is ready to use
  25537. * @returns true if the geometry is ready to be used
  25538. */
  25539. isReady(): boolean;
  25540. /**
  25541. * Gets a value indicating that the geometry should not be serialized
  25542. */
  25543. get doNotSerialize(): boolean;
  25544. /** @hidden */
  25545. _rebuild(): void;
  25546. /**
  25547. * Affects all geometry data in one call
  25548. * @param vertexData defines the geometry data
  25549. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25550. */
  25551. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25552. /**
  25553. * Set specific vertex data
  25554. * @param kind defines the data kind (Position, normal, etc...)
  25555. * @param data defines the vertex data to use
  25556. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25557. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25558. */
  25559. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25560. /**
  25561. * Removes a specific vertex data
  25562. * @param kind defines the data kind (Position, normal, etc...)
  25563. */
  25564. removeVerticesData(kind: string): void;
  25565. /**
  25566. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25567. * @param buffer defines the vertex buffer to use
  25568. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25569. */
  25570. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25571. /**
  25572. * Update a specific vertex buffer
  25573. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25574. * It will do nothing if the buffer is not updatable
  25575. * @param kind defines the data kind (Position, normal, etc...)
  25576. * @param data defines the data to use
  25577. * @param offset defines the offset in the target buffer where to store the data
  25578. * @param useBytes set to true if the offset is in bytes
  25579. */
  25580. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25581. /**
  25582. * Update a specific vertex buffer
  25583. * This function will create a new buffer if the current one is not updatable
  25584. * @param kind defines the data kind (Position, normal, etc...)
  25585. * @param data defines the data to use
  25586. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25587. */
  25588. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25589. private _updateBoundingInfo;
  25590. /** @hidden */
  25591. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25592. /**
  25593. * Gets total number of vertices
  25594. * @returns the total number of vertices
  25595. */
  25596. getTotalVertices(): number;
  25597. /**
  25598. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25599. * @param kind defines the data kind (Position, normal, etc...)
  25600. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25601. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25602. * @returns a float array containing vertex data
  25603. */
  25604. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25605. /**
  25606. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25607. * @param kind defines the data kind (Position, normal, etc...)
  25608. * @returns true if the vertex buffer with the specified kind is updatable
  25609. */
  25610. isVertexBufferUpdatable(kind: string): boolean;
  25611. /**
  25612. * Gets a specific vertex buffer
  25613. * @param kind defines the data kind (Position, normal, etc...)
  25614. * @returns a VertexBuffer
  25615. */
  25616. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25617. /**
  25618. * Returns all vertex buffers
  25619. * @return an object holding all vertex buffers indexed by kind
  25620. */
  25621. getVertexBuffers(): Nullable<{
  25622. [key: string]: VertexBuffer;
  25623. }>;
  25624. /**
  25625. * Gets a boolean indicating if specific vertex buffer is present
  25626. * @param kind defines the data kind (Position, normal, etc...)
  25627. * @returns true if data is present
  25628. */
  25629. isVerticesDataPresent(kind: string): boolean;
  25630. /**
  25631. * Gets a list of all attached data kinds (Position, normal, etc...)
  25632. * @returns a list of string containing all kinds
  25633. */
  25634. getVerticesDataKinds(): string[];
  25635. /**
  25636. * Update index buffer
  25637. * @param indices defines the indices to store in the index buffer
  25638. * @param offset defines the offset in the target buffer where to store the data
  25639. * @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)
  25640. */
  25641. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25642. /**
  25643. * Creates a new index buffer
  25644. * @param indices defines the indices to store in the index buffer
  25645. * @param totalVertices defines the total number of vertices (could be null)
  25646. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25647. */
  25648. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25649. /**
  25650. * Return the total number of indices
  25651. * @returns the total number of indices
  25652. */
  25653. getTotalIndices(): number;
  25654. /**
  25655. * Gets the index buffer array
  25656. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25657. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25658. * @returns the index buffer array
  25659. */
  25660. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25661. /**
  25662. * Gets the index buffer
  25663. * @return the index buffer
  25664. */
  25665. getIndexBuffer(): Nullable<DataBuffer>;
  25666. /** @hidden */
  25667. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25668. /**
  25669. * Release the associated resources for a specific mesh
  25670. * @param mesh defines the source mesh
  25671. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25672. */
  25673. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25674. /**
  25675. * Apply current geometry to a given mesh
  25676. * @param mesh defines the mesh to apply geometry to
  25677. */
  25678. applyToMesh(mesh: Mesh): void;
  25679. private _updateExtend;
  25680. private _applyToMesh;
  25681. private notifyUpdate;
  25682. /**
  25683. * Load the geometry if it was flagged as delay loaded
  25684. * @param scene defines the hosting scene
  25685. * @param onLoaded defines a callback called when the geometry is loaded
  25686. */
  25687. load(scene: Scene, onLoaded?: () => void): void;
  25688. private _queueLoad;
  25689. /**
  25690. * Invert the geometry to move from a right handed system to a left handed one.
  25691. */
  25692. toLeftHanded(): void;
  25693. /** @hidden */
  25694. _resetPointsArrayCache(): void;
  25695. /** @hidden */
  25696. _generatePointsArray(): boolean;
  25697. /**
  25698. * Gets a value indicating if the geometry is disposed
  25699. * @returns true if the geometry was disposed
  25700. */
  25701. isDisposed(): boolean;
  25702. private _disposeVertexArrayObjects;
  25703. /**
  25704. * Free all associated resources
  25705. */
  25706. dispose(): void;
  25707. /**
  25708. * Clone the current geometry into a new geometry
  25709. * @param id defines the unique ID of the new geometry
  25710. * @returns a new geometry object
  25711. */
  25712. copy(id: string): Geometry;
  25713. /**
  25714. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25715. * @return a JSON representation of the current geometry data (without the vertices data)
  25716. */
  25717. serialize(): any;
  25718. private toNumberArray;
  25719. /**
  25720. * Serialize all vertices data into a JSON oject
  25721. * @returns a JSON representation of the current geometry data
  25722. */
  25723. serializeVerticeData(): any;
  25724. /**
  25725. * Extracts a clone of a mesh geometry
  25726. * @param mesh defines the source mesh
  25727. * @param id defines the unique ID of the new geometry object
  25728. * @returns the new geometry object
  25729. */
  25730. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25731. /**
  25732. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25733. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25734. * Be aware Math.random() could cause collisions, but:
  25735. * "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"
  25736. * @returns a string containing a new GUID
  25737. */
  25738. static RandomId(): string;
  25739. /** @hidden */
  25740. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25741. private static _CleanMatricesWeights;
  25742. /**
  25743. * Create a new geometry from persisted data (Using .babylon file format)
  25744. * @param parsedVertexData defines the persisted data
  25745. * @param scene defines the hosting scene
  25746. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25747. * @returns the new geometry object
  25748. */
  25749. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25750. }
  25751. }
  25752. declare module "babylonjs/Meshes/mesh.vertexData" {
  25753. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25754. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25755. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25756. import { Geometry } from "babylonjs/Meshes/geometry";
  25757. import { Mesh } from "babylonjs/Meshes/mesh";
  25758. /**
  25759. * Define an interface for all classes that will get and set the data on vertices
  25760. */
  25761. export interface IGetSetVerticesData {
  25762. /**
  25763. * Gets a boolean indicating if specific vertex data is present
  25764. * @param kind defines the vertex data kind to use
  25765. * @returns true is data kind is present
  25766. */
  25767. isVerticesDataPresent(kind: string): boolean;
  25768. /**
  25769. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25770. * @param kind defines the data kind (Position, normal, etc...)
  25771. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25772. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25773. * @returns a float array containing vertex data
  25774. */
  25775. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25776. /**
  25777. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25778. * @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.
  25779. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25780. * @returns the indices array or an empty array if the mesh has no geometry
  25781. */
  25782. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25783. /**
  25784. * Set specific vertex data
  25785. * @param kind defines the data kind (Position, normal, etc...)
  25786. * @param data defines the vertex data to use
  25787. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25788. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25789. */
  25790. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25791. /**
  25792. * Update a specific associated vertex buffer
  25793. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25794. * - VertexBuffer.PositionKind
  25795. * - VertexBuffer.UVKind
  25796. * - VertexBuffer.UV2Kind
  25797. * - VertexBuffer.UV3Kind
  25798. * - VertexBuffer.UV4Kind
  25799. * - VertexBuffer.UV5Kind
  25800. * - VertexBuffer.UV6Kind
  25801. * - VertexBuffer.ColorKind
  25802. * - VertexBuffer.MatricesIndicesKind
  25803. * - VertexBuffer.MatricesIndicesExtraKind
  25804. * - VertexBuffer.MatricesWeightsKind
  25805. * - VertexBuffer.MatricesWeightsExtraKind
  25806. * @param data defines the data source
  25807. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25808. * @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)
  25809. */
  25810. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25811. /**
  25812. * Creates a new index buffer
  25813. * @param indices defines the indices to store in the index buffer
  25814. * @param totalVertices defines the total number of vertices (could be null)
  25815. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25816. */
  25817. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25818. }
  25819. /**
  25820. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25821. */
  25822. export class VertexData {
  25823. /**
  25824. * Mesh side orientation : usually the external or front surface
  25825. */
  25826. static readonly FRONTSIDE: number;
  25827. /**
  25828. * Mesh side orientation : usually the internal or back surface
  25829. */
  25830. static readonly BACKSIDE: number;
  25831. /**
  25832. * Mesh side orientation : both internal and external or front and back surfaces
  25833. */
  25834. static readonly DOUBLESIDE: number;
  25835. /**
  25836. * Mesh side orientation : by default, `FRONTSIDE`
  25837. */
  25838. static readonly DEFAULTSIDE: number;
  25839. /**
  25840. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25841. */
  25842. positions: Nullable<FloatArray>;
  25843. /**
  25844. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25845. */
  25846. normals: Nullable<FloatArray>;
  25847. /**
  25848. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25849. */
  25850. tangents: Nullable<FloatArray>;
  25851. /**
  25852. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25853. */
  25854. uvs: Nullable<FloatArray>;
  25855. /**
  25856. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25857. */
  25858. uvs2: Nullable<FloatArray>;
  25859. /**
  25860. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25861. */
  25862. uvs3: Nullable<FloatArray>;
  25863. /**
  25864. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25865. */
  25866. uvs4: Nullable<FloatArray>;
  25867. /**
  25868. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25869. */
  25870. uvs5: Nullable<FloatArray>;
  25871. /**
  25872. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25873. */
  25874. uvs6: Nullable<FloatArray>;
  25875. /**
  25876. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25877. */
  25878. colors: Nullable<FloatArray>;
  25879. /**
  25880. * 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).
  25881. */
  25882. matricesIndices: Nullable<FloatArray>;
  25883. /**
  25884. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25885. */
  25886. matricesWeights: Nullable<FloatArray>;
  25887. /**
  25888. * An array extending the number of possible indices
  25889. */
  25890. matricesIndicesExtra: Nullable<FloatArray>;
  25891. /**
  25892. * An array extending the number of possible weights when the number of indices is extended
  25893. */
  25894. matricesWeightsExtra: Nullable<FloatArray>;
  25895. /**
  25896. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25897. */
  25898. indices: Nullable<IndicesArray>;
  25899. /**
  25900. * Uses the passed data array to set the set the values for the specified kind of data
  25901. * @param data a linear array of floating numbers
  25902. * @param kind the type of data that is being set, eg positions, colors etc
  25903. */
  25904. set(data: FloatArray, kind: string): void;
  25905. /**
  25906. * Associates the vertexData to the passed Mesh.
  25907. * Sets it as updatable or not (default `false`)
  25908. * @param mesh the mesh the vertexData is applied to
  25909. * @param updatable when used and having the value true allows new data to update the vertexData
  25910. * @returns the VertexData
  25911. */
  25912. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25913. /**
  25914. * Associates the vertexData to the passed Geometry.
  25915. * Sets it as updatable or not (default `false`)
  25916. * @param geometry the geometry the vertexData is applied to
  25917. * @param updatable when used and having the value true allows new data to update the vertexData
  25918. * @returns VertexData
  25919. */
  25920. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25921. /**
  25922. * Updates the associated mesh
  25923. * @param mesh the mesh to be updated
  25924. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25925. * @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
  25926. * @returns VertexData
  25927. */
  25928. updateMesh(mesh: Mesh): VertexData;
  25929. /**
  25930. * Updates the associated geometry
  25931. * @param geometry the geometry to be updated
  25932. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25933. * @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
  25934. * @returns VertexData.
  25935. */
  25936. updateGeometry(geometry: Geometry): VertexData;
  25937. private _applyTo;
  25938. private _update;
  25939. /**
  25940. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25941. * @param matrix the transforming matrix
  25942. * @returns the VertexData
  25943. */
  25944. transform(matrix: Matrix): VertexData;
  25945. /**
  25946. * Merges the passed VertexData into the current one
  25947. * @param other the VertexData to be merged into the current one
  25948. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25949. * @returns the modified VertexData
  25950. */
  25951. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25952. private _mergeElement;
  25953. private _validate;
  25954. /**
  25955. * Serializes the VertexData
  25956. * @returns a serialized object
  25957. */
  25958. serialize(): any;
  25959. /**
  25960. * Extracts the vertexData from a mesh
  25961. * @param mesh the mesh from which to extract the VertexData
  25962. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25963. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25964. * @returns the object VertexData associated to the passed mesh
  25965. */
  25966. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25967. /**
  25968. * Extracts the vertexData from the geometry
  25969. * @param geometry the geometry from which to extract the VertexData
  25970. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25971. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25972. * @returns the object VertexData associated to the passed mesh
  25973. */
  25974. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25975. private static _ExtractFrom;
  25976. /**
  25977. * Creates the VertexData for a Ribbon
  25978. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25979. * * pathArray array of paths, each of which an array of successive Vector3
  25980. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25981. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25982. * * 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
  25983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25984. * * 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)
  25985. * * 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)
  25986. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25987. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25988. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25989. * @returns the VertexData of the ribbon
  25990. */
  25991. static CreateRibbon(options: {
  25992. pathArray: Vector3[][];
  25993. closeArray?: boolean;
  25994. closePath?: boolean;
  25995. offset?: number;
  25996. sideOrientation?: number;
  25997. frontUVs?: Vector4;
  25998. backUVs?: Vector4;
  25999. invertUV?: boolean;
  26000. uvs?: Vector2[];
  26001. colors?: Color4[];
  26002. }): VertexData;
  26003. /**
  26004. * Creates the VertexData for a box
  26005. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26006. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26007. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26008. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26009. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26010. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26011. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26013. * * 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)
  26014. * * 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)
  26015. * @returns the VertexData of the box
  26016. */
  26017. static CreateBox(options: {
  26018. size?: number;
  26019. width?: number;
  26020. height?: number;
  26021. depth?: number;
  26022. faceUV?: Vector4[];
  26023. faceColors?: Color4[];
  26024. sideOrientation?: number;
  26025. frontUVs?: Vector4;
  26026. backUVs?: Vector4;
  26027. }): VertexData;
  26028. /**
  26029. * Creates the VertexData for a tiled box
  26030. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26031. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26032. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26033. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26034. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26035. * @returns the VertexData of the box
  26036. */
  26037. static CreateTiledBox(options: {
  26038. pattern?: number;
  26039. width?: number;
  26040. height?: number;
  26041. depth?: number;
  26042. tileSize?: number;
  26043. tileWidth?: number;
  26044. tileHeight?: number;
  26045. alignHorizontal?: number;
  26046. alignVertical?: number;
  26047. faceUV?: Vector4[];
  26048. faceColors?: Color4[];
  26049. sideOrientation?: number;
  26050. }): VertexData;
  26051. /**
  26052. * Creates the VertexData for a tiled plane
  26053. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26054. * * pattern a limited pattern arrangement depending on the number
  26055. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26056. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26057. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26059. * * 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)
  26060. * * 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)
  26061. * @returns the VertexData of the tiled plane
  26062. */
  26063. static CreateTiledPlane(options: {
  26064. pattern?: number;
  26065. tileSize?: number;
  26066. tileWidth?: number;
  26067. tileHeight?: number;
  26068. size?: number;
  26069. width?: number;
  26070. height?: number;
  26071. alignHorizontal?: number;
  26072. alignVertical?: number;
  26073. sideOrientation?: number;
  26074. frontUVs?: Vector4;
  26075. backUVs?: Vector4;
  26076. }): VertexData;
  26077. /**
  26078. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26079. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26080. * * segments sets the number of horizontal strips optional, default 32
  26081. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26082. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26083. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26084. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26085. * * 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
  26086. * * 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
  26087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26088. * * 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)
  26089. * * 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)
  26090. * @returns the VertexData of the ellipsoid
  26091. */
  26092. static CreateSphere(options: {
  26093. segments?: number;
  26094. diameter?: number;
  26095. diameterX?: number;
  26096. diameterY?: number;
  26097. diameterZ?: number;
  26098. arc?: number;
  26099. slice?: number;
  26100. sideOrientation?: number;
  26101. frontUVs?: Vector4;
  26102. backUVs?: Vector4;
  26103. }): VertexData;
  26104. /**
  26105. * Creates the VertexData for a cylinder, cone or prism
  26106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26107. * * height sets the height (y direction) of the cylinder, optional, default 2
  26108. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26109. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26110. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26111. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26112. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26113. * * 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
  26114. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26115. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26116. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26117. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26119. * * 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)
  26120. * * 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)
  26121. * @returns the VertexData of the cylinder, cone or prism
  26122. */
  26123. static CreateCylinder(options: {
  26124. height?: number;
  26125. diameterTop?: number;
  26126. diameterBottom?: number;
  26127. diameter?: number;
  26128. tessellation?: number;
  26129. subdivisions?: number;
  26130. arc?: number;
  26131. faceColors?: Color4[];
  26132. faceUV?: Vector4[];
  26133. hasRings?: boolean;
  26134. enclose?: boolean;
  26135. sideOrientation?: number;
  26136. frontUVs?: Vector4;
  26137. backUVs?: Vector4;
  26138. }): VertexData;
  26139. /**
  26140. * Creates the VertexData for a torus
  26141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26142. * * diameter the diameter of the torus, optional default 1
  26143. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26144. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26146. * * 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)
  26147. * * 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)
  26148. * @returns the VertexData of the torus
  26149. */
  26150. static CreateTorus(options: {
  26151. diameter?: number;
  26152. thickness?: number;
  26153. tessellation?: number;
  26154. sideOrientation?: number;
  26155. frontUVs?: Vector4;
  26156. backUVs?: Vector4;
  26157. }): VertexData;
  26158. /**
  26159. * Creates the VertexData of the LineSystem
  26160. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26161. * - lines an array of lines, each line being an array of successive Vector3
  26162. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26163. * @returns the VertexData of the LineSystem
  26164. */
  26165. static CreateLineSystem(options: {
  26166. lines: Vector3[][];
  26167. colors?: Nullable<Color4[][]>;
  26168. }): VertexData;
  26169. /**
  26170. * Create the VertexData for a DashedLines
  26171. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26172. * - points an array successive Vector3
  26173. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26174. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26175. * - dashNb the intended total number of dashes, optional, default 200
  26176. * @returns the VertexData for the DashedLines
  26177. */
  26178. static CreateDashedLines(options: {
  26179. points: Vector3[];
  26180. dashSize?: number;
  26181. gapSize?: number;
  26182. dashNb?: number;
  26183. }): VertexData;
  26184. /**
  26185. * Creates the VertexData for a Ground
  26186. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26187. * - width the width (x direction) of the ground, optional, default 1
  26188. * - height the height (z direction) of the ground, optional, default 1
  26189. * - subdivisions the number of subdivisions per side, optional, default 1
  26190. * @returns the VertexData of the Ground
  26191. */
  26192. static CreateGround(options: {
  26193. width?: number;
  26194. height?: number;
  26195. subdivisions?: number;
  26196. subdivisionsX?: number;
  26197. subdivisionsY?: number;
  26198. }): VertexData;
  26199. /**
  26200. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26201. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26202. * * xmin the ground minimum X coordinate, optional, default -1
  26203. * * zmin the ground minimum Z coordinate, optional, default -1
  26204. * * xmax the ground maximum X coordinate, optional, default 1
  26205. * * zmax the ground maximum Z coordinate, optional, default 1
  26206. * * 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}
  26207. * * 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}
  26208. * @returns the VertexData of the TiledGround
  26209. */
  26210. static CreateTiledGround(options: {
  26211. xmin: number;
  26212. zmin: number;
  26213. xmax: number;
  26214. zmax: number;
  26215. subdivisions?: {
  26216. w: number;
  26217. h: number;
  26218. };
  26219. precision?: {
  26220. w: number;
  26221. h: number;
  26222. };
  26223. }): VertexData;
  26224. /**
  26225. * Creates the VertexData of the Ground designed from a heightmap
  26226. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26227. * * width the width (x direction) of the ground
  26228. * * height the height (z direction) of the ground
  26229. * * subdivisions the number of subdivisions per side
  26230. * * minHeight the minimum altitude on the ground, optional, default 0
  26231. * * maxHeight the maximum altitude on the ground, optional default 1
  26232. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26233. * * buffer the array holding the image color data
  26234. * * bufferWidth the width of image
  26235. * * bufferHeight the height of image
  26236. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26237. * @returns the VertexData of the Ground designed from a heightmap
  26238. */
  26239. static CreateGroundFromHeightMap(options: {
  26240. width: number;
  26241. height: number;
  26242. subdivisions: number;
  26243. minHeight: number;
  26244. maxHeight: number;
  26245. colorFilter: Color3;
  26246. buffer: Uint8Array;
  26247. bufferWidth: number;
  26248. bufferHeight: number;
  26249. alphaFilter: number;
  26250. }): VertexData;
  26251. /**
  26252. * Creates the VertexData for a Plane
  26253. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26254. * * size sets the width and height of the plane to the value of size, optional default 1
  26255. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26256. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26258. * * 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)
  26259. * * 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)
  26260. * @returns the VertexData of the box
  26261. */
  26262. static CreatePlane(options: {
  26263. size?: number;
  26264. width?: number;
  26265. height?: number;
  26266. sideOrientation?: number;
  26267. frontUVs?: Vector4;
  26268. backUVs?: Vector4;
  26269. }): VertexData;
  26270. /**
  26271. * Creates the VertexData of the Disc or regular Polygon
  26272. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26273. * * radius the radius of the disc, optional default 0.5
  26274. * * tessellation the number of polygon sides, optional, default 64
  26275. * * 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
  26276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26277. * * 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)
  26278. * * 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)
  26279. * @returns the VertexData of the box
  26280. */
  26281. static CreateDisc(options: {
  26282. radius?: number;
  26283. tessellation?: number;
  26284. arc?: number;
  26285. sideOrientation?: number;
  26286. frontUVs?: Vector4;
  26287. backUVs?: Vector4;
  26288. }): VertexData;
  26289. /**
  26290. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26291. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26292. * @param polygon a mesh built from polygonTriangulation.build()
  26293. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26294. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26295. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26296. * @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)
  26297. * @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)
  26298. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26299. * @returns the VertexData of the Polygon
  26300. */
  26301. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26302. /**
  26303. * Creates the VertexData of the IcoSphere
  26304. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26305. * * radius the radius of the IcoSphere, optional default 1
  26306. * * radiusX allows stretching in the x direction, optional, default radius
  26307. * * radiusY allows stretching in the y direction, optional, default radius
  26308. * * radiusZ allows stretching in the z direction, optional, default radius
  26309. * * flat when true creates a flat shaded mesh, optional, default true
  26310. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26311. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26312. * * 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)
  26313. * * 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)
  26314. * @returns the VertexData of the IcoSphere
  26315. */
  26316. static CreateIcoSphere(options: {
  26317. radius?: number;
  26318. radiusX?: number;
  26319. radiusY?: number;
  26320. radiusZ?: number;
  26321. flat?: boolean;
  26322. subdivisions?: number;
  26323. sideOrientation?: number;
  26324. frontUVs?: Vector4;
  26325. backUVs?: Vector4;
  26326. }): VertexData;
  26327. /**
  26328. * Creates the VertexData for a Polyhedron
  26329. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26330. * * type provided types are:
  26331. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26332. * * 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)
  26333. * * size the size of the IcoSphere, optional default 1
  26334. * * sizeX allows stretching in the x direction, optional, default size
  26335. * * sizeY allows stretching in the y direction, optional, default size
  26336. * * sizeZ allows stretching in the z direction, optional, default size
  26337. * * 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
  26338. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26339. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26340. * * flat when true creates a flat shaded mesh, optional, default true
  26341. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26342. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26343. * * 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)
  26344. * * 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)
  26345. * @returns the VertexData of the Polyhedron
  26346. */
  26347. static CreatePolyhedron(options: {
  26348. type?: number;
  26349. size?: number;
  26350. sizeX?: number;
  26351. sizeY?: number;
  26352. sizeZ?: number;
  26353. custom?: any;
  26354. faceUV?: Vector4[];
  26355. faceColors?: Color4[];
  26356. flat?: boolean;
  26357. sideOrientation?: number;
  26358. frontUVs?: Vector4;
  26359. backUVs?: Vector4;
  26360. }): VertexData;
  26361. /**
  26362. * Creates the VertexData for a TorusKnot
  26363. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26364. * * radius the radius of the torus knot, optional, default 2
  26365. * * tube the thickness of the tube, optional, default 0.5
  26366. * * radialSegments the number of sides on each tube segments, optional, default 32
  26367. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26368. * * p the number of windings around the z axis, optional, default 2
  26369. * * q the number of windings around the x axis, optional, default 3
  26370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26371. * * 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)
  26372. * * 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)
  26373. * @returns the VertexData of the Torus Knot
  26374. */
  26375. static CreateTorusKnot(options: {
  26376. radius?: number;
  26377. tube?: number;
  26378. radialSegments?: number;
  26379. tubularSegments?: number;
  26380. p?: number;
  26381. q?: number;
  26382. sideOrientation?: number;
  26383. frontUVs?: Vector4;
  26384. backUVs?: Vector4;
  26385. }): VertexData;
  26386. /**
  26387. * Compute normals for given positions and indices
  26388. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26389. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26390. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26391. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26392. * * facetNormals : optional array of facet normals (vector3)
  26393. * * facetPositions : optional array of facet positions (vector3)
  26394. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26395. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26396. * * bInfo : optional bounding info, required for facetPartitioning computation
  26397. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26398. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26399. * * useRightHandedSystem: optional boolean to for right handed system computation
  26400. * * depthSort : optional boolean to enable the facet depth sort computation
  26401. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26402. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26403. */
  26404. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26405. facetNormals?: any;
  26406. facetPositions?: any;
  26407. facetPartitioning?: any;
  26408. ratio?: number;
  26409. bInfo?: any;
  26410. bbSize?: Vector3;
  26411. subDiv?: any;
  26412. useRightHandedSystem?: boolean;
  26413. depthSort?: boolean;
  26414. distanceTo?: Vector3;
  26415. depthSortedFacets?: any;
  26416. }): void;
  26417. /** @hidden */
  26418. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26419. /**
  26420. * Applies VertexData created from the imported parameters to the geometry
  26421. * @param parsedVertexData the parsed data from an imported file
  26422. * @param geometry the geometry to apply the VertexData to
  26423. */
  26424. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26425. }
  26426. }
  26427. declare module "babylonjs/Morph/morphTarget" {
  26428. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26429. import { Observable } from "babylonjs/Misc/observable";
  26430. import { Nullable, FloatArray } from "babylonjs/types";
  26431. import { Scene } from "babylonjs/scene";
  26432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26433. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26434. /**
  26435. * Defines a target to use with MorphTargetManager
  26436. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26437. */
  26438. export class MorphTarget implements IAnimatable {
  26439. /** defines the name of the target */
  26440. name: string;
  26441. /**
  26442. * Gets or sets the list of animations
  26443. */
  26444. animations: import("babylonjs/Animations/animation").Animation[];
  26445. private _scene;
  26446. private _positions;
  26447. private _normals;
  26448. private _tangents;
  26449. private _uvs;
  26450. private _influence;
  26451. private _uniqueId;
  26452. /**
  26453. * Observable raised when the influence changes
  26454. */
  26455. onInfluenceChanged: Observable<boolean>;
  26456. /** @hidden */
  26457. _onDataLayoutChanged: Observable<void>;
  26458. /**
  26459. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26460. */
  26461. get influence(): number;
  26462. set influence(influence: number);
  26463. /**
  26464. * Gets or sets the id of the morph Target
  26465. */
  26466. id: string;
  26467. private _animationPropertiesOverride;
  26468. /**
  26469. * Gets or sets the animation properties override
  26470. */
  26471. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26472. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26473. /**
  26474. * Creates a new MorphTarget
  26475. * @param name defines the name of the target
  26476. * @param influence defines the influence to use
  26477. * @param scene defines the scene the morphtarget belongs to
  26478. */
  26479. constructor(
  26480. /** defines the name of the target */
  26481. name: string, influence?: number, scene?: Nullable<Scene>);
  26482. /**
  26483. * Gets the unique ID of this manager
  26484. */
  26485. get uniqueId(): number;
  26486. /**
  26487. * Gets a boolean defining if the target contains position data
  26488. */
  26489. get hasPositions(): boolean;
  26490. /**
  26491. * Gets a boolean defining if the target contains normal data
  26492. */
  26493. get hasNormals(): boolean;
  26494. /**
  26495. * Gets a boolean defining if the target contains tangent data
  26496. */
  26497. get hasTangents(): boolean;
  26498. /**
  26499. * Gets a boolean defining if the target contains texture coordinates data
  26500. */
  26501. get hasUVs(): boolean;
  26502. /**
  26503. * Affects position data to this target
  26504. * @param data defines the position data to use
  26505. */
  26506. setPositions(data: Nullable<FloatArray>): void;
  26507. /**
  26508. * Gets the position data stored in this target
  26509. * @returns a FloatArray containing the position data (or null if not present)
  26510. */
  26511. getPositions(): Nullable<FloatArray>;
  26512. /**
  26513. * Affects normal data to this target
  26514. * @param data defines the normal data to use
  26515. */
  26516. setNormals(data: Nullable<FloatArray>): void;
  26517. /**
  26518. * Gets the normal data stored in this target
  26519. * @returns a FloatArray containing the normal data (or null if not present)
  26520. */
  26521. getNormals(): Nullable<FloatArray>;
  26522. /**
  26523. * Affects tangent data to this target
  26524. * @param data defines the tangent data to use
  26525. */
  26526. setTangents(data: Nullable<FloatArray>): void;
  26527. /**
  26528. * Gets the tangent data stored in this target
  26529. * @returns a FloatArray containing the tangent data (or null if not present)
  26530. */
  26531. getTangents(): Nullable<FloatArray>;
  26532. /**
  26533. * Affects texture coordinates data to this target
  26534. * @param data defines the texture coordinates data to use
  26535. */
  26536. setUVs(data: Nullable<FloatArray>): void;
  26537. /**
  26538. * Gets the texture coordinates data stored in this target
  26539. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26540. */
  26541. getUVs(): Nullable<FloatArray>;
  26542. /**
  26543. * Clone the current target
  26544. * @returns a new MorphTarget
  26545. */
  26546. clone(): MorphTarget;
  26547. /**
  26548. * Serializes the current target into a Serialization object
  26549. * @returns the serialized object
  26550. */
  26551. serialize(): any;
  26552. /**
  26553. * Returns the string "MorphTarget"
  26554. * @returns "MorphTarget"
  26555. */
  26556. getClassName(): string;
  26557. /**
  26558. * Creates a new target from serialized data
  26559. * @param serializationObject defines the serialized data to use
  26560. * @returns a new MorphTarget
  26561. */
  26562. static Parse(serializationObject: any): MorphTarget;
  26563. /**
  26564. * Creates a MorphTarget from mesh data
  26565. * @param mesh defines the source mesh
  26566. * @param name defines the name to use for the new target
  26567. * @param influence defines the influence to attach to the target
  26568. * @returns a new MorphTarget
  26569. */
  26570. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26571. }
  26572. }
  26573. declare module "babylonjs/Morph/morphTargetManager" {
  26574. import { Nullable } from "babylonjs/types";
  26575. import { Scene } from "babylonjs/scene";
  26576. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26577. /**
  26578. * This class is used to deform meshes using morphing between different targets
  26579. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26580. */
  26581. export class MorphTargetManager {
  26582. private _targets;
  26583. private _targetInfluenceChangedObservers;
  26584. private _targetDataLayoutChangedObservers;
  26585. private _activeTargets;
  26586. private _scene;
  26587. private _influences;
  26588. private _supportsNormals;
  26589. private _supportsTangents;
  26590. private _supportsUVs;
  26591. private _vertexCount;
  26592. private _uniqueId;
  26593. private _tempInfluences;
  26594. /**
  26595. * Gets or sets a boolean indicating if normals must be morphed
  26596. */
  26597. enableNormalMorphing: boolean;
  26598. /**
  26599. * Gets or sets a boolean indicating if tangents must be morphed
  26600. */
  26601. enableTangentMorphing: boolean;
  26602. /**
  26603. * Gets or sets a boolean indicating if UV must be morphed
  26604. */
  26605. enableUVMorphing: boolean;
  26606. /**
  26607. * Creates a new MorphTargetManager
  26608. * @param scene defines the current scene
  26609. */
  26610. constructor(scene?: Nullable<Scene>);
  26611. /**
  26612. * Gets the unique ID of this manager
  26613. */
  26614. get uniqueId(): number;
  26615. /**
  26616. * Gets the number of vertices handled by this manager
  26617. */
  26618. get vertexCount(): number;
  26619. /**
  26620. * Gets a boolean indicating if this manager supports morphing of normals
  26621. */
  26622. get supportsNormals(): boolean;
  26623. /**
  26624. * Gets a boolean indicating if this manager supports morphing of tangents
  26625. */
  26626. get supportsTangents(): boolean;
  26627. /**
  26628. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26629. */
  26630. get supportsUVs(): boolean;
  26631. /**
  26632. * Gets the number of targets stored in this manager
  26633. */
  26634. get numTargets(): number;
  26635. /**
  26636. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26637. */
  26638. get numInfluencers(): number;
  26639. /**
  26640. * Gets the list of influences (one per target)
  26641. */
  26642. get influences(): Float32Array;
  26643. /**
  26644. * Gets the active target at specified index. An active target is a target with an influence > 0
  26645. * @param index defines the index to check
  26646. * @returns the requested target
  26647. */
  26648. getActiveTarget(index: number): MorphTarget;
  26649. /**
  26650. * Gets the target at specified index
  26651. * @param index defines the index to check
  26652. * @returns the requested target
  26653. */
  26654. getTarget(index: number): MorphTarget;
  26655. /**
  26656. * Add a new target to this manager
  26657. * @param target defines the target to add
  26658. */
  26659. addTarget(target: MorphTarget): void;
  26660. /**
  26661. * Removes a target from the manager
  26662. * @param target defines the target to remove
  26663. */
  26664. removeTarget(target: MorphTarget): void;
  26665. /**
  26666. * Clone the current manager
  26667. * @returns a new MorphTargetManager
  26668. */
  26669. clone(): MorphTargetManager;
  26670. /**
  26671. * Serializes the current manager into a Serialization object
  26672. * @returns the serialized object
  26673. */
  26674. serialize(): any;
  26675. private _syncActiveTargets;
  26676. /**
  26677. * Syncrhonize the targets with all the meshes using this morph target manager
  26678. */
  26679. synchronize(): void;
  26680. /**
  26681. * Creates a new MorphTargetManager from serialized data
  26682. * @param serializationObject defines the serialized data
  26683. * @param scene defines the hosting scene
  26684. * @returns the new MorphTargetManager
  26685. */
  26686. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26687. }
  26688. }
  26689. declare module "babylonjs/Meshes/meshLODLevel" {
  26690. import { Mesh } from "babylonjs/Meshes/mesh";
  26691. import { Nullable } from "babylonjs/types";
  26692. /**
  26693. * Class used to represent a specific level of detail of a mesh
  26694. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26695. */
  26696. export class MeshLODLevel {
  26697. /** Defines the distance where this level should start being displayed */
  26698. distance: number;
  26699. /** Defines the mesh to use to render this level */
  26700. mesh: Nullable<Mesh>;
  26701. /**
  26702. * Creates a new LOD level
  26703. * @param distance defines the distance where this level should star being displayed
  26704. * @param mesh defines the mesh to use to render this level
  26705. */
  26706. constructor(
  26707. /** Defines the distance where this level should start being displayed */
  26708. distance: number,
  26709. /** Defines the mesh to use to render this level */
  26710. mesh: Nullable<Mesh>);
  26711. }
  26712. }
  26713. declare module "babylonjs/Meshes/groundMesh" {
  26714. import { Scene } from "babylonjs/scene";
  26715. import { Vector3 } from "babylonjs/Maths/math.vector";
  26716. import { Mesh } from "babylonjs/Meshes/mesh";
  26717. /**
  26718. * Mesh representing the gorund
  26719. */
  26720. export class GroundMesh extends Mesh {
  26721. /** If octree should be generated */
  26722. generateOctree: boolean;
  26723. private _heightQuads;
  26724. /** @hidden */
  26725. _subdivisionsX: number;
  26726. /** @hidden */
  26727. _subdivisionsY: number;
  26728. /** @hidden */
  26729. _width: number;
  26730. /** @hidden */
  26731. _height: number;
  26732. /** @hidden */
  26733. _minX: number;
  26734. /** @hidden */
  26735. _maxX: number;
  26736. /** @hidden */
  26737. _minZ: number;
  26738. /** @hidden */
  26739. _maxZ: number;
  26740. constructor(name: string, scene: Scene);
  26741. /**
  26742. * "GroundMesh"
  26743. * @returns "GroundMesh"
  26744. */
  26745. getClassName(): string;
  26746. /**
  26747. * The minimum of x and y subdivisions
  26748. */
  26749. get subdivisions(): number;
  26750. /**
  26751. * X subdivisions
  26752. */
  26753. get subdivisionsX(): number;
  26754. /**
  26755. * Y subdivisions
  26756. */
  26757. get subdivisionsY(): number;
  26758. /**
  26759. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26760. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26761. * @param chunksCount the number of subdivisions for x and y
  26762. * @param octreeBlocksSize (Default: 32)
  26763. */
  26764. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26765. /**
  26766. * Returns a height (y) value in the Worl system :
  26767. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26768. * @param x x coordinate
  26769. * @param z z coordinate
  26770. * @returns the ground y position if (x, z) are outside the ground surface.
  26771. */
  26772. getHeightAtCoordinates(x: number, z: number): number;
  26773. /**
  26774. * Returns a normalized vector (Vector3) orthogonal to the ground
  26775. * at the ground coordinates (x, z) expressed in the World system.
  26776. * @param x x coordinate
  26777. * @param z z coordinate
  26778. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26779. */
  26780. getNormalAtCoordinates(x: number, z: number): Vector3;
  26781. /**
  26782. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26783. * at the ground coordinates (x, z) expressed in the World system.
  26784. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26785. * @param x x coordinate
  26786. * @param z z coordinate
  26787. * @param ref vector to store the result
  26788. * @returns the GroundMesh.
  26789. */
  26790. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26791. /**
  26792. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26793. * if the ground has been updated.
  26794. * This can be used in the render loop.
  26795. * @returns the GroundMesh.
  26796. */
  26797. updateCoordinateHeights(): GroundMesh;
  26798. private _getFacetAt;
  26799. private _initHeightQuads;
  26800. private _computeHeightQuads;
  26801. /**
  26802. * Serializes this ground mesh
  26803. * @param serializationObject object to write serialization to
  26804. */
  26805. serialize(serializationObject: any): void;
  26806. /**
  26807. * Parses a serialized ground mesh
  26808. * @param parsedMesh the serialized mesh
  26809. * @param scene the scene to create the ground mesh in
  26810. * @returns the created ground mesh
  26811. */
  26812. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26813. }
  26814. }
  26815. declare module "babylonjs/Physics/physicsJoint" {
  26816. import { Vector3 } from "babylonjs/Maths/math.vector";
  26817. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26818. /**
  26819. * Interface for Physics-Joint data
  26820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26821. */
  26822. export interface PhysicsJointData {
  26823. /**
  26824. * The main pivot of the joint
  26825. */
  26826. mainPivot?: Vector3;
  26827. /**
  26828. * The connected pivot of the joint
  26829. */
  26830. connectedPivot?: Vector3;
  26831. /**
  26832. * The main axis of the joint
  26833. */
  26834. mainAxis?: Vector3;
  26835. /**
  26836. * The connected axis of the joint
  26837. */
  26838. connectedAxis?: Vector3;
  26839. /**
  26840. * The collision of the joint
  26841. */
  26842. collision?: boolean;
  26843. /**
  26844. * Native Oimo/Cannon/Energy data
  26845. */
  26846. nativeParams?: any;
  26847. }
  26848. /**
  26849. * This is a holder class for the physics joint created by the physics plugin
  26850. * It holds a set of functions to control the underlying joint
  26851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26852. */
  26853. export class PhysicsJoint {
  26854. /**
  26855. * The type of the physics joint
  26856. */
  26857. type: number;
  26858. /**
  26859. * The data for the physics joint
  26860. */
  26861. jointData: PhysicsJointData;
  26862. private _physicsJoint;
  26863. protected _physicsPlugin: IPhysicsEnginePlugin;
  26864. /**
  26865. * Initializes the physics joint
  26866. * @param type The type of the physics joint
  26867. * @param jointData The data for the physics joint
  26868. */
  26869. constructor(
  26870. /**
  26871. * The type of the physics joint
  26872. */
  26873. type: number,
  26874. /**
  26875. * The data for the physics joint
  26876. */
  26877. jointData: PhysicsJointData);
  26878. /**
  26879. * Gets the physics joint
  26880. */
  26881. get physicsJoint(): any;
  26882. /**
  26883. * Sets the physics joint
  26884. */
  26885. set physicsJoint(newJoint: any);
  26886. /**
  26887. * Sets the physics plugin
  26888. */
  26889. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26890. /**
  26891. * Execute a function that is physics-plugin specific.
  26892. * @param {Function} func the function that will be executed.
  26893. * It accepts two parameters: the physics world and the physics joint
  26894. */
  26895. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26896. /**
  26897. * Distance-Joint type
  26898. */
  26899. static DistanceJoint: number;
  26900. /**
  26901. * Hinge-Joint type
  26902. */
  26903. static HingeJoint: number;
  26904. /**
  26905. * Ball-and-Socket joint type
  26906. */
  26907. static BallAndSocketJoint: number;
  26908. /**
  26909. * Wheel-Joint type
  26910. */
  26911. static WheelJoint: number;
  26912. /**
  26913. * Slider-Joint type
  26914. */
  26915. static SliderJoint: number;
  26916. /**
  26917. * Prismatic-Joint type
  26918. */
  26919. static PrismaticJoint: number;
  26920. /**
  26921. * Universal-Joint type
  26922. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26923. */
  26924. static UniversalJoint: number;
  26925. /**
  26926. * Hinge-Joint 2 type
  26927. */
  26928. static Hinge2Joint: number;
  26929. /**
  26930. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26931. */
  26932. static PointToPointJoint: number;
  26933. /**
  26934. * Spring-Joint type
  26935. */
  26936. static SpringJoint: number;
  26937. /**
  26938. * Lock-Joint type
  26939. */
  26940. static LockJoint: number;
  26941. }
  26942. /**
  26943. * A class representing a physics distance joint
  26944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26945. */
  26946. export class DistanceJoint extends PhysicsJoint {
  26947. /**
  26948. *
  26949. * @param jointData The data for the Distance-Joint
  26950. */
  26951. constructor(jointData: DistanceJointData);
  26952. /**
  26953. * Update the predefined distance.
  26954. * @param maxDistance The maximum preferred distance
  26955. * @param minDistance The minimum preferred distance
  26956. */
  26957. updateDistance(maxDistance: number, minDistance?: number): void;
  26958. }
  26959. /**
  26960. * Represents a Motor-Enabled Joint
  26961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26962. */
  26963. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26964. /**
  26965. * Initializes the Motor-Enabled Joint
  26966. * @param type The type of the joint
  26967. * @param jointData The physica joint data for the joint
  26968. */
  26969. constructor(type: number, jointData: PhysicsJointData);
  26970. /**
  26971. * Set the motor values.
  26972. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26973. * @param force the force to apply
  26974. * @param maxForce max force for this motor.
  26975. */
  26976. setMotor(force?: number, maxForce?: number): void;
  26977. /**
  26978. * Set the motor's limits.
  26979. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26980. * @param upperLimit The upper limit of the motor
  26981. * @param lowerLimit The lower limit of the motor
  26982. */
  26983. setLimit(upperLimit: number, lowerLimit?: number): void;
  26984. }
  26985. /**
  26986. * This class represents a single physics Hinge-Joint
  26987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26988. */
  26989. export class HingeJoint extends MotorEnabledJoint {
  26990. /**
  26991. * Initializes the Hinge-Joint
  26992. * @param jointData The joint data for the Hinge-Joint
  26993. */
  26994. constructor(jointData: PhysicsJointData);
  26995. /**
  26996. * Set the motor values.
  26997. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26998. * @param {number} force the force to apply
  26999. * @param {number} maxForce max force for this motor.
  27000. */
  27001. setMotor(force?: number, maxForce?: number): void;
  27002. /**
  27003. * Set the motor's limits.
  27004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27005. * @param upperLimit The upper limit of the motor
  27006. * @param lowerLimit The lower limit of the motor
  27007. */
  27008. setLimit(upperLimit: number, lowerLimit?: number): void;
  27009. }
  27010. /**
  27011. * This class represents a dual hinge physics joint (same as wheel joint)
  27012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27013. */
  27014. export class Hinge2Joint extends MotorEnabledJoint {
  27015. /**
  27016. * Initializes the Hinge2-Joint
  27017. * @param jointData The joint data for the Hinge2-Joint
  27018. */
  27019. constructor(jointData: PhysicsJointData);
  27020. /**
  27021. * Set the motor values.
  27022. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27023. * @param {number} targetSpeed the speed the motor is to reach
  27024. * @param {number} maxForce max force for this motor.
  27025. * @param {motorIndex} the motor's index, 0 or 1.
  27026. */
  27027. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27028. /**
  27029. * Set the motor limits.
  27030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27031. * @param {number} upperLimit the upper limit
  27032. * @param {number} lowerLimit lower limit
  27033. * @param {motorIndex} the motor's index, 0 or 1.
  27034. */
  27035. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27036. }
  27037. /**
  27038. * Interface for a motor enabled joint
  27039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27040. */
  27041. export interface IMotorEnabledJoint {
  27042. /**
  27043. * Physics joint
  27044. */
  27045. physicsJoint: any;
  27046. /**
  27047. * Sets the motor of the motor-enabled joint
  27048. * @param force The force of the motor
  27049. * @param maxForce The maximum force of the motor
  27050. * @param motorIndex The index of the motor
  27051. */
  27052. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27053. /**
  27054. * Sets the limit of the motor
  27055. * @param upperLimit The upper limit of the motor
  27056. * @param lowerLimit The lower limit of the motor
  27057. * @param motorIndex The index of the motor
  27058. */
  27059. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27060. }
  27061. /**
  27062. * Joint data for a Distance-Joint
  27063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27064. */
  27065. export interface DistanceJointData extends PhysicsJointData {
  27066. /**
  27067. * Max distance the 2 joint objects can be apart
  27068. */
  27069. maxDistance: number;
  27070. }
  27071. /**
  27072. * Joint data from a spring joint
  27073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27074. */
  27075. export interface SpringJointData extends PhysicsJointData {
  27076. /**
  27077. * Length of the spring
  27078. */
  27079. length: number;
  27080. /**
  27081. * Stiffness of the spring
  27082. */
  27083. stiffness: number;
  27084. /**
  27085. * Damping of the spring
  27086. */
  27087. damping: number;
  27088. /** this callback will be called when applying the force to the impostors. */
  27089. forceApplicationCallback: () => void;
  27090. }
  27091. }
  27092. declare module "babylonjs/Physics/physicsRaycastResult" {
  27093. import { Vector3 } from "babylonjs/Maths/math.vector";
  27094. /**
  27095. * Holds the data for the raycast result
  27096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27097. */
  27098. export class PhysicsRaycastResult {
  27099. private _hasHit;
  27100. private _hitDistance;
  27101. private _hitNormalWorld;
  27102. private _hitPointWorld;
  27103. private _rayFromWorld;
  27104. private _rayToWorld;
  27105. /**
  27106. * Gets if there was a hit
  27107. */
  27108. get hasHit(): boolean;
  27109. /**
  27110. * Gets the distance from the hit
  27111. */
  27112. get hitDistance(): number;
  27113. /**
  27114. * Gets the hit normal/direction in the world
  27115. */
  27116. get hitNormalWorld(): Vector3;
  27117. /**
  27118. * Gets the hit point in the world
  27119. */
  27120. get hitPointWorld(): Vector3;
  27121. /**
  27122. * Gets the ray "start point" of the ray in the world
  27123. */
  27124. get rayFromWorld(): Vector3;
  27125. /**
  27126. * Gets the ray "end point" of the ray in the world
  27127. */
  27128. get rayToWorld(): Vector3;
  27129. /**
  27130. * Sets the hit data (normal & point in world space)
  27131. * @param hitNormalWorld defines the normal in world space
  27132. * @param hitPointWorld defines the point in world space
  27133. */
  27134. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27135. /**
  27136. * Sets the distance from the start point to the hit point
  27137. * @param distance
  27138. */
  27139. setHitDistance(distance: number): void;
  27140. /**
  27141. * Calculates the distance manually
  27142. */
  27143. calculateHitDistance(): void;
  27144. /**
  27145. * Resets all the values to default
  27146. * @param from The from point on world space
  27147. * @param to The to point on world space
  27148. */
  27149. reset(from?: Vector3, to?: Vector3): void;
  27150. }
  27151. /**
  27152. * Interface for the size containing width and height
  27153. */
  27154. interface IXYZ {
  27155. /**
  27156. * X
  27157. */
  27158. x: number;
  27159. /**
  27160. * Y
  27161. */
  27162. y: number;
  27163. /**
  27164. * Z
  27165. */
  27166. z: number;
  27167. }
  27168. }
  27169. declare module "babylonjs/Physics/IPhysicsEngine" {
  27170. import { Nullable } from "babylonjs/types";
  27171. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27173. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27174. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27175. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27176. /**
  27177. * Interface used to describe a physics joint
  27178. */
  27179. export interface PhysicsImpostorJoint {
  27180. /** Defines the main impostor to which the joint is linked */
  27181. mainImpostor: PhysicsImpostor;
  27182. /** Defines the impostor that is connected to the main impostor using this joint */
  27183. connectedImpostor: PhysicsImpostor;
  27184. /** Defines the joint itself */
  27185. joint: PhysicsJoint;
  27186. }
  27187. /** @hidden */
  27188. export interface IPhysicsEnginePlugin {
  27189. world: any;
  27190. name: string;
  27191. setGravity(gravity: Vector3): void;
  27192. setTimeStep(timeStep: number): void;
  27193. getTimeStep(): number;
  27194. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27195. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27196. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27197. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27198. removePhysicsBody(impostor: PhysicsImpostor): void;
  27199. generateJoint(joint: PhysicsImpostorJoint): void;
  27200. removeJoint(joint: PhysicsImpostorJoint): void;
  27201. isSupported(): boolean;
  27202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27203. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27204. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27205. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27206. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27207. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27208. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27209. getBodyMass(impostor: PhysicsImpostor): number;
  27210. getBodyFriction(impostor: PhysicsImpostor): number;
  27211. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27212. getBodyRestitution(impostor: PhysicsImpostor): number;
  27213. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27214. getBodyPressure?(impostor: PhysicsImpostor): number;
  27215. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27216. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27217. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27218. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27219. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27220. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27221. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27222. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27223. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27224. sleepBody(impostor: PhysicsImpostor): void;
  27225. wakeUpBody(impostor: PhysicsImpostor): void;
  27226. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27227. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27228. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27229. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27230. getRadius(impostor: PhysicsImpostor): number;
  27231. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27232. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27233. dispose(): void;
  27234. }
  27235. /**
  27236. * Interface used to define a physics engine
  27237. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27238. */
  27239. export interface IPhysicsEngine {
  27240. /**
  27241. * Gets the gravity vector used by the simulation
  27242. */
  27243. gravity: Vector3;
  27244. /**
  27245. * Sets the gravity vector used by the simulation
  27246. * @param gravity defines the gravity vector to use
  27247. */
  27248. setGravity(gravity: Vector3): void;
  27249. /**
  27250. * Set the time step of the physics engine.
  27251. * Default is 1/60.
  27252. * To slow it down, enter 1/600 for example.
  27253. * To speed it up, 1/30
  27254. * @param newTimeStep the new timestep to apply to this world.
  27255. */
  27256. setTimeStep(newTimeStep: number): void;
  27257. /**
  27258. * Get the time step of the physics engine.
  27259. * @returns the current time step
  27260. */
  27261. getTimeStep(): number;
  27262. /**
  27263. * Set the sub time step of the physics engine.
  27264. * Default is 0 meaning there is no sub steps
  27265. * To increase physics resolution precision, set a small value (like 1 ms)
  27266. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27267. */
  27268. setSubTimeStep(subTimeStep: number): void;
  27269. /**
  27270. * Get the sub time step of the physics engine.
  27271. * @returns the current sub time step
  27272. */
  27273. getSubTimeStep(): number;
  27274. /**
  27275. * Release all resources
  27276. */
  27277. dispose(): void;
  27278. /**
  27279. * Gets the name of the current physics plugin
  27280. * @returns the name of the plugin
  27281. */
  27282. getPhysicsPluginName(): string;
  27283. /**
  27284. * Adding a new impostor for the impostor tracking.
  27285. * This will be done by the impostor itself.
  27286. * @param impostor the impostor to add
  27287. */
  27288. addImpostor(impostor: PhysicsImpostor): void;
  27289. /**
  27290. * Remove an impostor from the engine.
  27291. * This impostor and its mesh will not longer be updated by the physics engine.
  27292. * @param impostor the impostor to remove
  27293. */
  27294. removeImpostor(impostor: PhysicsImpostor): void;
  27295. /**
  27296. * Add a joint to the physics engine
  27297. * @param mainImpostor defines the main impostor to which the joint is added.
  27298. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27299. * @param joint defines the joint that will connect both impostors.
  27300. */
  27301. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27302. /**
  27303. * Removes a joint from the simulation
  27304. * @param mainImpostor defines the impostor used with the joint
  27305. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27306. * @param joint defines the joint to remove
  27307. */
  27308. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27309. /**
  27310. * Gets the current plugin used to run the simulation
  27311. * @returns current plugin
  27312. */
  27313. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27314. /**
  27315. * Gets the list of physic impostors
  27316. * @returns an array of PhysicsImpostor
  27317. */
  27318. getImpostors(): Array<PhysicsImpostor>;
  27319. /**
  27320. * Gets the impostor for a physics enabled object
  27321. * @param object defines the object impersonated by the impostor
  27322. * @returns the PhysicsImpostor or null if not found
  27323. */
  27324. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27325. /**
  27326. * Gets the impostor for a physics body object
  27327. * @param body defines physics body used by the impostor
  27328. * @returns the PhysicsImpostor or null if not found
  27329. */
  27330. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27331. /**
  27332. * Does a raycast in the physics world
  27333. * @param from when should the ray start?
  27334. * @param to when should the ray end?
  27335. * @returns PhysicsRaycastResult
  27336. */
  27337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27338. /**
  27339. * Called by the scene. No need to call it.
  27340. * @param delta defines the timespam between frames
  27341. */
  27342. _step(delta: number): void;
  27343. }
  27344. }
  27345. declare module "babylonjs/Physics/physicsImpostor" {
  27346. import { Nullable, IndicesArray } from "babylonjs/types";
  27347. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27350. import { Scene } from "babylonjs/scene";
  27351. import { Bone } from "babylonjs/Bones/bone";
  27352. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27353. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27354. import { Space } from "babylonjs/Maths/math.axis";
  27355. /**
  27356. * The interface for the physics imposter parameters
  27357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27358. */
  27359. export interface PhysicsImpostorParameters {
  27360. /**
  27361. * The mass of the physics imposter
  27362. */
  27363. mass: number;
  27364. /**
  27365. * The friction of the physics imposter
  27366. */
  27367. friction?: number;
  27368. /**
  27369. * The coefficient of restitution of the physics imposter
  27370. */
  27371. restitution?: number;
  27372. /**
  27373. * The native options of the physics imposter
  27374. */
  27375. nativeOptions?: any;
  27376. /**
  27377. * Specifies if the parent should be ignored
  27378. */
  27379. ignoreParent?: boolean;
  27380. /**
  27381. * Specifies if bi-directional transformations should be disabled
  27382. */
  27383. disableBidirectionalTransformation?: boolean;
  27384. /**
  27385. * The pressure inside the physics imposter, soft object only
  27386. */
  27387. pressure?: number;
  27388. /**
  27389. * The stiffness the physics imposter, soft object only
  27390. */
  27391. stiffness?: number;
  27392. /**
  27393. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27394. */
  27395. velocityIterations?: number;
  27396. /**
  27397. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27398. */
  27399. positionIterations?: number;
  27400. /**
  27401. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27402. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27403. * Add to fix multiple points
  27404. */
  27405. fixedPoints?: number;
  27406. /**
  27407. * The collision margin around a soft object
  27408. */
  27409. margin?: number;
  27410. /**
  27411. * The collision margin around a soft object
  27412. */
  27413. damping?: number;
  27414. /**
  27415. * The path for a rope based on an extrusion
  27416. */
  27417. path?: any;
  27418. /**
  27419. * The shape of an extrusion used for a rope based on an extrusion
  27420. */
  27421. shape?: any;
  27422. }
  27423. /**
  27424. * Interface for a physics-enabled object
  27425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27426. */
  27427. export interface IPhysicsEnabledObject {
  27428. /**
  27429. * The position of the physics-enabled object
  27430. */
  27431. position: Vector3;
  27432. /**
  27433. * The rotation of the physics-enabled object
  27434. */
  27435. rotationQuaternion: Nullable<Quaternion>;
  27436. /**
  27437. * The scale of the physics-enabled object
  27438. */
  27439. scaling: Vector3;
  27440. /**
  27441. * The rotation of the physics-enabled object
  27442. */
  27443. rotation?: Vector3;
  27444. /**
  27445. * The parent of the physics-enabled object
  27446. */
  27447. parent?: any;
  27448. /**
  27449. * The bounding info of the physics-enabled object
  27450. * @returns The bounding info of the physics-enabled object
  27451. */
  27452. getBoundingInfo(): BoundingInfo;
  27453. /**
  27454. * Computes the world matrix
  27455. * @param force Specifies if the world matrix should be computed by force
  27456. * @returns A world matrix
  27457. */
  27458. computeWorldMatrix(force: boolean): Matrix;
  27459. /**
  27460. * Gets the world matrix
  27461. * @returns A world matrix
  27462. */
  27463. getWorldMatrix?(): Matrix;
  27464. /**
  27465. * Gets the child meshes
  27466. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27467. * @returns An array of abstract meshes
  27468. */
  27469. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27470. /**
  27471. * Gets the vertex data
  27472. * @param kind The type of vertex data
  27473. * @returns A nullable array of numbers, or a float32 array
  27474. */
  27475. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27476. /**
  27477. * Gets the indices from the mesh
  27478. * @returns A nullable array of index arrays
  27479. */
  27480. getIndices?(): Nullable<IndicesArray>;
  27481. /**
  27482. * Gets the scene from the mesh
  27483. * @returns the indices array or null
  27484. */
  27485. getScene?(): Scene;
  27486. /**
  27487. * Gets the absolute position from the mesh
  27488. * @returns the absolute position
  27489. */
  27490. getAbsolutePosition(): Vector3;
  27491. /**
  27492. * Gets the absolute pivot point from the mesh
  27493. * @returns the absolute pivot point
  27494. */
  27495. getAbsolutePivotPoint(): Vector3;
  27496. /**
  27497. * Rotates the mesh
  27498. * @param axis The axis of rotation
  27499. * @param amount The amount of rotation
  27500. * @param space The space of the rotation
  27501. * @returns The rotation transform node
  27502. */
  27503. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27504. /**
  27505. * Translates the mesh
  27506. * @param axis The axis of translation
  27507. * @param distance The distance of translation
  27508. * @param space The space of the translation
  27509. * @returns The transform node
  27510. */
  27511. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27512. /**
  27513. * Sets the absolute position of the mesh
  27514. * @param absolutePosition The absolute position of the mesh
  27515. * @returns The transform node
  27516. */
  27517. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27518. /**
  27519. * Gets the class name of the mesh
  27520. * @returns The class name
  27521. */
  27522. getClassName(): string;
  27523. }
  27524. /**
  27525. * Represents a physics imposter
  27526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27527. */
  27528. export class PhysicsImpostor {
  27529. /**
  27530. * The physics-enabled object used as the physics imposter
  27531. */
  27532. object: IPhysicsEnabledObject;
  27533. /**
  27534. * The type of the physics imposter
  27535. */
  27536. type: number;
  27537. private _options;
  27538. private _scene?;
  27539. /**
  27540. * The default object size of the imposter
  27541. */
  27542. static DEFAULT_OBJECT_SIZE: Vector3;
  27543. /**
  27544. * The identity quaternion of the imposter
  27545. */
  27546. static IDENTITY_QUATERNION: Quaternion;
  27547. /** @hidden */
  27548. _pluginData: any;
  27549. private _physicsEngine;
  27550. private _physicsBody;
  27551. private _bodyUpdateRequired;
  27552. private _onBeforePhysicsStepCallbacks;
  27553. private _onAfterPhysicsStepCallbacks;
  27554. /** @hidden */
  27555. _onPhysicsCollideCallbacks: Array<{
  27556. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27557. otherImpostors: Array<PhysicsImpostor>;
  27558. }>;
  27559. private _deltaPosition;
  27560. private _deltaRotation;
  27561. private _deltaRotationConjugated;
  27562. /** @hidden */
  27563. _isFromLine: boolean;
  27564. private _parent;
  27565. private _isDisposed;
  27566. private static _tmpVecs;
  27567. private static _tmpQuat;
  27568. /**
  27569. * Specifies if the physics imposter is disposed
  27570. */
  27571. get isDisposed(): boolean;
  27572. /**
  27573. * Gets the mass of the physics imposter
  27574. */
  27575. get mass(): number;
  27576. set mass(value: number);
  27577. /**
  27578. * Gets the coefficient of friction
  27579. */
  27580. get friction(): number;
  27581. /**
  27582. * Sets the coefficient of friction
  27583. */
  27584. set friction(value: number);
  27585. /**
  27586. * Gets the coefficient of restitution
  27587. */
  27588. get restitution(): number;
  27589. /**
  27590. * Sets the coefficient of restitution
  27591. */
  27592. set restitution(value: number);
  27593. /**
  27594. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27595. */
  27596. get pressure(): number;
  27597. /**
  27598. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27599. */
  27600. set pressure(value: number);
  27601. /**
  27602. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27603. */
  27604. get stiffness(): number;
  27605. /**
  27606. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27607. */
  27608. set stiffness(value: number);
  27609. /**
  27610. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27611. */
  27612. get velocityIterations(): number;
  27613. /**
  27614. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27615. */
  27616. set velocityIterations(value: number);
  27617. /**
  27618. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27619. */
  27620. get positionIterations(): number;
  27621. /**
  27622. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27623. */
  27624. set positionIterations(value: number);
  27625. /**
  27626. * The unique id of the physics imposter
  27627. * set by the physics engine when adding this impostor to the array
  27628. */
  27629. uniqueId: number;
  27630. /**
  27631. * @hidden
  27632. */
  27633. soft: boolean;
  27634. /**
  27635. * @hidden
  27636. */
  27637. segments: number;
  27638. private _joints;
  27639. /**
  27640. * Initializes the physics imposter
  27641. * @param object The physics-enabled object used as the physics imposter
  27642. * @param type The type of the physics imposter
  27643. * @param _options The options for the physics imposter
  27644. * @param _scene The Babylon scene
  27645. */
  27646. constructor(
  27647. /**
  27648. * The physics-enabled object used as the physics imposter
  27649. */
  27650. object: IPhysicsEnabledObject,
  27651. /**
  27652. * The type of the physics imposter
  27653. */
  27654. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27655. /**
  27656. * This function will completly initialize this impostor.
  27657. * It will create a new body - but only if this mesh has no parent.
  27658. * If it has, this impostor will not be used other than to define the impostor
  27659. * of the child mesh.
  27660. * @hidden
  27661. */
  27662. _init(): void;
  27663. private _getPhysicsParent;
  27664. /**
  27665. * Should a new body be generated.
  27666. * @returns boolean specifying if body initialization is required
  27667. */
  27668. isBodyInitRequired(): boolean;
  27669. /**
  27670. * Sets the updated scaling
  27671. * @param updated Specifies if the scaling is updated
  27672. */
  27673. setScalingUpdated(): void;
  27674. /**
  27675. * Force a regeneration of this or the parent's impostor's body.
  27676. * Use under cautious - This will remove all joints already implemented.
  27677. */
  27678. forceUpdate(): void;
  27679. /**
  27680. * Gets the body that holds this impostor. Either its own, or its parent.
  27681. */
  27682. get physicsBody(): any;
  27683. /**
  27684. * Get the parent of the physics imposter
  27685. * @returns Physics imposter or null
  27686. */
  27687. get parent(): Nullable<PhysicsImpostor>;
  27688. /**
  27689. * Sets the parent of the physics imposter
  27690. */
  27691. set parent(value: Nullable<PhysicsImpostor>);
  27692. /**
  27693. * Set the physics body. Used mainly by the physics engine/plugin
  27694. */
  27695. set physicsBody(physicsBody: any);
  27696. /**
  27697. * Resets the update flags
  27698. */
  27699. resetUpdateFlags(): void;
  27700. /**
  27701. * Gets the object extend size
  27702. * @returns the object extend size
  27703. */
  27704. getObjectExtendSize(): Vector3;
  27705. /**
  27706. * Gets the object center
  27707. * @returns The object center
  27708. */
  27709. getObjectCenter(): Vector3;
  27710. /**
  27711. * Get a specific parameter from the options parameters
  27712. * @param paramName The object parameter name
  27713. * @returns The object parameter
  27714. */
  27715. getParam(paramName: string): any;
  27716. /**
  27717. * Sets a specific parameter in the options given to the physics plugin
  27718. * @param paramName The parameter name
  27719. * @param value The value of the parameter
  27720. */
  27721. setParam(paramName: string, value: number): void;
  27722. /**
  27723. * Specifically change the body's mass option. Won't recreate the physics body object
  27724. * @param mass The mass of the physics imposter
  27725. */
  27726. setMass(mass: number): void;
  27727. /**
  27728. * Gets the linear velocity
  27729. * @returns linear velocity or null
  27730. */
  27731. getLinearVelocity(): Nullable<Vector3>;
  27732. /**
  27733. * Sets the linear velocity
  27734. * @param velocity linear velocity or null
  27735. */
  27736. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27737. /**
  27738. * Gets the angular velocity
  27739. * @returns angular velocity or null
  27740. */
  27741. getAngularVelocity(): Nullable<Vector3>;
  27742. /**
  27743. * Sets the angular velocity
  27744. * @param velocity The velocity or null
  27745. */
  27746. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27747. /**
  27748. * Execute a function with the physics plugin native code
  27749. * Provide a function the will have two variables - the world object and the physics body object
  27750. * @param func The function to execute with the physics plugin native code
  27751. */
  27752. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27753. /**
  27754. * Register a function that will be executed before the physics world is stepping forward
  27755. * @param func The function to execute before the physics world is stepped forward
  27756. */
  27757. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27758. /**
  27759. * Unregister a function that will be executed before the physics world is stepping forward
  27760. * @param func The function to execute before the physics world is stepped forward
  27761. */
  27762. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27763. /**
  27764. * Register a function that will be executed after the physics step
  27765. * @param func The function to execute after physics step
  27766. */
  27767. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27768. /**
  27769. * Unregisters a function that will be executed after the physics step
  27770. * @param func The function to execute after physics step
  27771. */
  27772. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27773. /**
  27774. * register a function that will be executed when this impostor collides against a different body
  27775. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27776. * @param func Callback that is executed on collision
  27777. */
  27778. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27779. /**
  27780. * Unregisters the physics imposter on contact
  27781. * @param collideAgainst The physics object to collide against
  27782. * @param func Callback to execute on collision
  27783. */
  27784. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27785. private _tmpQuat;
  27786. private _tmpQuat2;
  27787. /**
  27788. * Get the parent rotation
  27789. * @returns The parent rotation
  27790. */
  27791. getParentsRotation(): Quaternion;
  27792. /**
  27793. * this function is executed by the physics engine.
  27794. */
  27795. beforeStep: () => void;
  27796. /**
  27797. * this function is executed by the physics engine
  27798. */
  27799. afterStep: () => void;
  27800. /**
  27801. * Legacy collision detection event support
  27802. */
  27803. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27804. /**
  27805. * event and body object due to cannon's event-based architecture.
  27806. */
  27807. onCollide: (e: {
  27808. body: any;
  27809. }) => void;
  27810. /**
  27811. * Apply a force
  27812. * @param force The force to apply
  27813. * @param contactPoint The contact point for the force
  27814. * @returns The physics imposter
  27815. */
  27816. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27817. /**
  27818. * Apply an impulse
  27819. * @param force The impulse force
  27820. * @param contactPoint The contact point for the impulse force
  27821. * @returns The physics imposter
  27822. */
  27823. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27824. /**
  27825. * A help function to create a joint
  27826. * @param otherImpostor A physics imposter used to create a joint
  27827. * @param jointType The type of joint
  27828. * @param jointData The data for the joint
  27829. * @returns The physics imposter
  27830. */
  27831. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27832. /**
  27833. * Add a joint to this impostor with a different impostor
  27834. * @param otherImpostor A physics imposter used to add a joint
  27835. * @param joint The joint to add
  27836. * @returns The physics imposter
  27837. */
  27838. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27839. /**
  27840. * Add an anchor to a cloth impostor
  27841. * @param otherImpostor rigid impostor to anchor to
  27842. * @param width ratio across width from 0 to 1
  27843. * @param height ratio up height from 0 to 1
  27844. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27845. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27846. * @returns impostor the soft imposter
  27847. */
  27848. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27849. /**
  27850. * Add a hook to a rope impostor
  27851. * @param otherImpostor rigid impostor to anchor to
  27852. * @param length ratio across rope from 0 to 1
  27853. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27854. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27855. * @returns impostor the rope imposter
  27856. */
  27857. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27858. /**
  27859. * Will keep this body still, in a sleep mode.
  27860. * @returns the physics imposter
  27861. */
  27862. sleep(): PhysicsImpostor;
  27863. /**
  27864. * Wake the body up.
  27865. * @returns The physics imposter
  27866. */
  27867. wakeUp(): PhysicsImpostor;
  27868. /**
  27869. * Clones the physics imposter
  27870. * @param newObject The physics imposter clones to this physics-enabled object
  27871. * @returns A nullable physics imposter
  27872. */
  27873. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27874. /**
  27875. * Disposes the physics imposter
  27876. */
  27877. dispose(): void;
  27878. /**
  27879. * Sets the delta position
  27880. * @param position The delta position amount
  27881. */
  27882. setDeltaPosition(position: Vector3): void;
  27883. /**
  27884. * Sets the delta rotation
  27885. * @param rotation The delta rotation amount
  27886. */
  27887. setDeltaRotation(rotation: Quaternion): void;
  27888. /**
  27889. * Gets the box size of the physics imposter and stores the result in the input parameter
  27890. * @param result Stores the box size
  27891. * @returns The physics imposter
  27892. */
  27893. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27894. /**
  27895. * Gets the radius of the physics imposter
  27896. * @returns Radius of the physics imposter
  27897. */
  27898. getRadius(): number;
  27899. /**
  27900. * Sync a bone with this impostor
  27901. * @param bone The bone to sync to the impostor.
  27902. * @param boneMesh The mesh that the bone is influencing.
  27903. * @param jointPivot The pivot of the joint / bone in local space.
  27904. * @param distToJoint Optional distance from the impostor to the joint.
  27905. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27906. */
  27907. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27908. /**
  27909. * Sync impostor to a bone
  27910. * @param bone The bone that the impostor will be synced to.
  27911. * @param boneMesh The mesh that the bone is influencing.
  27912. * @param jointPivot The pivot of the joint / bone in local space.
  27913. * @param distToJoint Optional distance from the impostor to the joint.
  27914. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27915. * @param boneAxis Optional vector3 axis the bone is aligned with
  27916. */
  27917. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27918. /**
  27919. * No-Imposter type
  27920. */
  27921. static NoImpostor: number;
  27922. /**
  27923. * Sphere-Imposter type
  27924. */
  27925. static SphereImpostor: number;
  27926. /**
  27927. * Box-Imposter type
  27928. */
  27929. static BoxImpostor: number;
  27930. /**
  27931. * Plane-Imposter type
  27932. */
  27933. static PlaneImpostor: number;
  27934. /**
  27935. * Mesh-imposter type
  27936. */
  27937. static MeshImpostor: number;
  27938. /**
  27939. * Capsule-Impostor type (Ammo.js plugin only)
  27940. */
  27941. static CapsuleImpostor: number;
  27942. /**
  27943. * Cylinder-Imposter type
  27944. */
  27945. static CylinderImpostor: number;
  27946. /**
  27947. * Particle-Imposter type
  27948. */
  27949. static ParticleImpostor: number;
  27950. /**
  27951. * Heightmap-Imposter type
  27952. */
  27953. static HeightmapImpostor: number;
  27954. /**
  27955. * ConvexHull-Impostor type (Ammo.js plugin only)
  27956. */
  27957. static ConvexHullImpostor: number;
  27958. /**
  27959. * Custom-Imposter type (Ammo.js plugin only)
  27960. */
  27961. static CustomImpostor: number;
  27962. /**
  27963. * Rope-Imposter type
  27964. */
  27965. static RopeImpostor: number;
  27966. /**
  27967. * Cloth-Imposter type
  27968. */
  27969. static ClothImpostor: number;
  27970. /**
  27971. * Softbody-Imposter type
  27972. */
  27973. static SoftbodyImpostor: number;
  27974. }
  27975. }
  27976. declare module "babylonjs/Meshes/mesh" {
  27977. import { Observable } from "babylonjs/Misc/observable";
  27978. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27979. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  27980. import { Camera } from "babylonjs/Cameras/camera";
  27981. import { Scene } from "babylonjs/scene";
  27982. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  27983. import { Color4 } from "babylonjs/Maths/math.color";
  27984. import { Engine } from "babylonjs/Engines/engine";
  27985. import { Node } from "babylonjs/node";
  27986. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27987. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  27988. import { Buffer } from "babylonjs/Meshes/buffer";
  27989. import { Geometry } from "babylonjs/Meshes/geometry";
  27990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27991. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27992. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  27993. import { Effect } from "babylonjs/Materials/effect";
  27994. import { Material } from "babylonjs/Materials/material";
  27995. import { Skeleton } from "babylonjs/Bones/skeleton";
  27996. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  27997. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  27998. import { Path3D } from "babylonjs/Maths/math.path";
  27999. import { Plane } from "babylonjs/Maths/math.plane";
  28000. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28001. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28002. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28003. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28004. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28005. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28006. /**
  28007. * @hidden
  28008. **/
  28009. export class _CreationDataStorage {
  28010. closePath?: boolean;
  28011. closeArray?: boolean;
  28012. idx: number[];
  28013. dashSize: number;
  28014. gapSize: number;
  28015. path3D: Path3D;
  28016. pathArray: Vector3[][];
  28017. arc: number;
  28018. radius: number;
  28019. cap: number;
  28020. tessellation: number;
  28021. }
  28022. /**
  28023. * @hidden
  28024. **/
  28025. class _InstanceDataStorage {
  28026. visibleInstances: any;
  28027. batchCache: _InstancesBatch;
  28028. instancesBufferSize: number;
  28029. instancesBuffer: Nullable<Buffer>;
  28030. instancesData: Float32Array;
  28031. overridenInstanceCount: number;
  28032. isFrozen: boolean;
  28033. previousBatch: Nullable<_InstancesBatch>;
  28034. hardwareInstancedRendering: boolean;
  28035. sideOrientation: number;
  28036. manualUpdate: boolean;
  28037. }
  28038. /**
  28039. * @hidden
  28040. **/
  28041. export class _InstancesBatch {
  28042. mustReturn: boolean;
  28043. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28044. renderSelf: boolean[];
  28045. hardwareInstancedRendering: boolean[];
  28046. }
  28047. /**
  28048. * Class used to represent renderable models
  28049. */
  28050. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28051. /**
  28052. * Mesh side orientation : usually the external or front surface
  28053. */
  28054. static readonly FRONTSIDE: number;
  28055. /**
  28056. * Mesh side orientation : usually the internal or back surface
  28057. */
  28058. static readonly BACKSIDE: number;
  28059. /**
  28060. * Mesh side orientation : both internal and external or front and back surfaces
  28061. */
  28062. static readonly DOUBLESIDE: number;
  28063. /**
  28064. * Mesh side orientation : by default, `FRONTSIDE`
  28065. */
  28066. static readonly DEFAULTSIDE: number;
  28067. /**
  28068. * Mesh cap setting : no cap
  28069. */
  28070. static readonly NO_CAP: number;
  28071. /**
  28072. * Mesh cap setting : one cap at the beginning of the mesh
  28073. */
  28074. static readonly CAP_START: number;
  28075. /**
  28076. * Mesh cap setting : one cap at the end of the mesh
  28077. */
  28078. static readonly CAP_END: number;
  28079. /**
  28080. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28081. */
  28082. static readonly CAP_ALL: number;
  28083. /**
  28084. * Mesh pattern setting : no flip or rotate
  28085. */
  28086. static readonly NO_FLIP: number;
  28087. /**
  28088. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28089. */
  28090. static readonly FLIP_TILE: number;
  28091. /**
  28092. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28093. */
  28094. static readonly ROTATE_TILE: number;
  28095. /**
  28096. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28097. */
  28098. static readonly FLIP_ROW: number;
  28099. /**
  28100. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28101. */
  28102. static readonly ROTATE_ROW: number;
  28103. /**
  28104. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28105. */
  28106. static readonly FLIP_N_ROTATE_TILE: number;
  28107. /**
  28108. * Mesh pattern setting : rotate pattern and rotate
  28109. */
  28110. static readonly FLIP_N_ROTATE_ROW: number;
  28111. /**
  28112. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28113. */
  28114. static readonly CENTER: number;
  28115. /**
  28116. * Mesh tile positioning : part tiles on left
  28117. */
  28118. static readonly LEFT: number;
  28119. /**
  28120. * Mesh tile positioning : part tiles on right
  28121. */
  28122. static readonly RIGHT: number;
  28123. /**
  28124. * Mesh tile positioning : part tiles on top
  28125. */
  28126. static readonly TOP: number;
  28127. /**
  28128. * Mesh tile positioning : part tiles on bottom
  28129. */
  28130. static readonly BOTTOM: number;
  28131. /**
  28132. * Gets the default side orientation.
  28133. * @param orientation the orientation to value to attempt to get
  28134. * @returns the default orientation
  28135. * @hidden
  28136. */
  28137. static _GetDefaultSideOrientation(orientation?: number): number;
  28138. private _internalMeshDataInfo;
  28139. /**
  28140. * An event triggered before rendering the mesh
  28141. */
  28142. get onBeforeRenderObservable(): Observable<Mesh>;
  28143. /**
  28144. * An event triggered before binding the mesh
  28145. */
  28146. get onBeforeBindObservable(): Observable<Mesh>;
  28147. /**
  28148. * An event triggered after rendering the mesh
  28149. */
  28150. get onAfterRenderObservable(): Observable<Mesh>;
  28151. /**
  28152. * An event triggered before drawing the mesh
  28153. */
  28154. get onBeforeDrawObservable(): Observable<Mesh>;
  28155. private _onBeforeDrawObserver;
  28156. /**
  28157. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28158. */
  28159. set onBeforeDraw(callback: () => void);
  28160. get hasInstances(): boolean;
  28161. /**
  28162. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28163. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28164. */
  28165. delayLoadState: number;
  28166. /**
  28167. * Gets the list of instances created from this mesh
  28168. * it is not supposed to be modified manually.
  28169. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28170. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28171. */
  28172. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28173. /**
  28174. * Gets the file containing delay loading data for this mesh
  28175. */
  28176. delayLoadingFile: string;
  28177. /** @hidden */
  28178. _binaryInfo: any;
  28179. /**
  28180. * User defined function used to change how LOD level selection is done
  28181. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28182. */
  28183. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28184. /**
  28185. * Gets or sets the morph target manager
  28186. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28187. */
  28188. get morphTargetManager(): Nullable<MorphTargetManager>;
  28189. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28190. /** @hidden */
  28191. _creationDataStorage: Nullable<_CreationDataStorage>;
  28192. /** @hidden */
  28193. _geometry: Nullable<Geometry>;
  28194. /** @hidden */
  28195. _delayInfo: Array<string>;
  28196. /** @hidden */
  28197. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28198. /** @hidden */
  28199. _instanceDataStorage: _InstanceDataStorage;
  28200. private _effectiveMaterial;
  28201. /** @hidden */
  28202. _shouldGenerateFlatShading: boolean;
  28203. /** @hidden */
  28204. _originalBuilderSideOrientation: number;
  28205. /**
  28206. * Use this property to change the original side orientation defined at construction time
  28207. */
  28208. overrideMaterialSideOrientation: Nullable<number>;
  28209. /**
  28210. * Gets the source mesh (the one used to clone this one from)
  28211. */
  28212. get source(): Nullable<Mesh>;
  28213. /**
  28214. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28215. */
  28216. get isUnIndexed(): boolean;
  28217. set isUnIndexed(value: boolean);
  28218. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28219. get worldMatrixInstancedBuffer(): Float32Array;
  28220. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28221. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28222. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28223. /**
  28224. * @constructor
  28225. * @param name The value used by scene.getMeshByName() to do a lookup.
  28226. * @param scene The scene to add this mesh to.
  28227. * @param parent The parent of this mesh, if it has one
  28228. * @param source An optional Mesh from which geometry is shared, cloned.
  28229. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28230. * When false, achieved by calling a clone(), also passing False.
  28231. * This will make creation of children, recursive.
  28232. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28233. */
  28234. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28235. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28236. doNotInstantiate: boolean;
  28237. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28238. /**
  28239. * Gets the class name
  28240. * @returns the string "Mesh".
  28241. */
  28242. getClassName(): string;
  28243. /** @hidden */
  28244. get _isMesh(): boolean;
  28245. /**
  28246. * Returns a description of this mesh
  28247. * @param fullDetails define if full details about this mesh must be used
  28248. * @returns a descriptive string representing this mesh
  28249. */
  28250. toString(fullDetails?: boolean): string;
  28251. /** @hidden */
  28252. _unBindEffect(): void;
  28253. /**
  28254. * Gets a boolean indicating if this mesh has LOD
  28255. */
  28256. get hasLODLevels(): boolean;
  28257. /**
  28258. * Gets the list of MeshLODLevel associated with the current mesh
  28259. * @returns an array of MeshLODLevel
  28260. */
  28261. getLODLevels(): MeshLODLevel[];
  28262. private _sortLODLevels;
  28263. /**
  28264. * Add a mesh as LOD level triggered at the given distance.
  28265. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28266. * @param distance The distance from the center of the object to show this level
  28267. * @param mesh The mesh to be added as LOD level (can be null)
  28268. * @return This mesh (for chaining)
  28269. */
  28270. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28271. /**
  28272. * Returns the LOD level mesh at the passed distance or null if not found.
  28273. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28274. * @param distance The distance from the center of the object to show this level
  28275. * @returns a Mesh or `null`
  28276. */
  28277. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28278. /**
  28279. * Remove a mesh from the LOD array
  28280. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28281. * @param mesh defines the mesh to be removed
  28282. * @return This mesh (for chaining)
  28283. */
  28284. removeLODLevel(mesh: Mesh): Mesh;
  28285. /**
  28286. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28287. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28288. * @param camera defines the camera to use to compute distance
  28289. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28290. * @return This mesh (for chaining)
  28291. */
  28292. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28293. /**
  28294. * Gets the mesh internal Geometry object
  28295. */
  28296. get geometry(): Nullable<Geometry>;
  28297. /**
  28298. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28299. * @returns the total number of vertices
  28300. */
  28301. getTotalVertices(): number;
  28302. /**
  28303. * Returns the content of an associated vertex buffer
  28304. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28305. * - VertexBuffer.PositionKind
  28306. * - VertexBuffer.UVKind
  28307. * - VertexBuffer.UV2Kind
  28308. * - VertexBuffer.UV3Kind
  28309. * - VertexBuffer.UV4Kind
  28310. * - VertexBuffer.UV5Kind
  28311. * - VertexBuffer.UV6Kind
  28312. * - VertexBuffer.ColorKind
  28313. * - VertexBuffer.MatricesIndicesKind
  28314. * - VertexBuffer.MatricesIndicesExtraKind
  28315. * - VertexBuffer.MatricesWeightsKind
  28316. * - VertexBuffer.MatricesWeightsExtraKind
  28317. * @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
  28318. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28319. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28320. */
  28321. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28322. /**
  28323. * Returns the mesh VertexBuffer object from the requested `kind`
  28324. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28325. * - VertexBuffer.PositionKind
  28326. * - VertexBuffer.NormalKind
  28327. * - VertexBuffer.UVKind
  28328. * - VertexBuffer.UV2Kind
  28329. * - VertexBuffer.UV3Kind
  28330. * - VertexBuffer.UV4Kind
  28331. * - VertexBuffer.UV5Kind
  28332. * - VertexBuffer.UV6Kind
  28333. * - VertexBuffer.ColorKind
  28334. * - VertexBuffer.MatricesIndicesKind
  28335. * - VertexBuffer.MatricesIndicesExtraKind
  28336. * - VertexBuffer.MatricesWeightsKind
  28337. * - VertexBuffer.MatricesWeightsExtraKind
  28338. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28339. */
  28340. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28341. /**
  28342. * Tests if a specific vertex buffer is associated with this mesh
  28343. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28344. * - VertexBuffer.PositionKind
  28345. * - VertexBuffer.NormalKind
  28346. * - VertexBuffer.UVKind
  28347. * - VertexBuffer.UV2Kind
  28348. * - VertexBuffer.UV3Kind
  28349. * - VertexBuffer.UV4Kind
  28350. * - VertexBuffer.UV5Kind
  28351. * - VertexBuffer.UV6Kind
  28352. * - VertexBuffer.ColorKind
  28353. * - VertexBuffer.MatricesIndicesKind
  28354. * - VertexBuffer.MatricesIndicesExtraKind
  28355. * - VertexBuffer.MatricesWeightsKind
  28356. * - VertexBuffer.MatricesWeightsExtraKind
  28357. * @returns a boolean
  28358. */
  28359. isVerticesDataPresent(kind: string): boolean;
  28360. /**
  28361. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28362. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28363. * - VertexBuffer.PositionKind
  28364. * - VertexBuffer.UVKind
  28365. * - VertexBuffer.UV2Kind
  28366. * - VertexBuffer.UV3Kind
  28367. * - VertexBuffer.UV4Kind
  28368. * - VertexBuffer.UV5Kind
  28369. * - VertexBuffer.UV6Kind
  28370. * - VertexBuffer.ColorKind
  28371. * - VertexBuffer.MatricesIndicesKind
  28372. * - VertexBuffer.MatricesIndicesExtraKind
  28373. * - VertexBuffer.MatricesWeightsKind
  28374. * - VertexBuffer.MatricesWeightsExtraKind
  28375. * @returns a boolean
  28376. */
  28377. isVertexBufferUpdatable(kind: string): boolean;
  28378. /**
  28379. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28380. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28381. * - VertexBuffer.PositionKind
  28382. * - VertexBuffer.NormalKind
  28383. * - VertexBuffer.UVKind
  28384. * - VertexBuffer.UV2Kind
  28385. * - VertexBuffer.UV3Kind
  28386. * - VertexBuffer.UV4Kind
  28387. * - VertexBuffer.UV5Kind
  28388. * - VertexBuffer.UV6Kind
  28389. * - VertexBuffer.ColorKind
  28390. * - VertexBuffer.MatricesIndicesKind
  28391. * - VertexBuffer.MatricesIndicesExtraKind
  28392. * - VertexBuffer.MatricesWeightsKind
  28393. * - VertexBuffer.MatricesWeightsExtraKind
  28394. * @returns an array of strings
  28395. */
  28396. getVerticesDataKinds(): string[];
  28397. /**
  28398. * Returns a positive integer : the total number of indices in this mesh geometry.
  28399. * @returns the numner of indices or zero if the mesh has no geometry.
  28400. */
  28401. getTotalIndices(): number;
  28402. /**
  28403. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28404. * @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.
  28405. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28406. * @returns the indices array or an empty array if the mesh has no geometry
  28407. */
  28408. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28409. get isBlocked(): boolean;
  28410. /**
  28411. * Determine if the current mesh is ready to be rendered
  28412. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28413. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28414. * @returns true if all associated assets are ready (material, textures, shaders)
  28415. */
  28416. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28417. /**
  28418. * 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.
  28419. */
  28420. get areNormalsFrozen(): boolean;
  28421. /**
  28422. * 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.
  28423. * @returns the current mesh
  28424. */
  28425. freezeNormals(): Mesh;
  28426. /**
  28427. * 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
  28428. * @returns the current mesh
  28429. */
  28430. unfreezeNormals(): Mesh;
  28431. /**
  28432. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28433. */
  28434. set overridenInstanceCount(count: number);
  28435. /** @hidden */
  28436. _preActivate(): Mesh;
  28437. /** @hidden */
  28438. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28439. /** @hidden */
  28440. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28441. /**
  28442. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28443. * This means the mesh underlying bounding box and sphere are recomputed.
  28444. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28445. * @returns the current mesh
  28446. */
  28447. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28448. /** @hidden */
  28449. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28450. /**
  28451. * This function will subdivide the mesh into multiple submeshes
  28452. * @param count defines the expected number of submeshes
  28453. */
  28454. subdivide(count: number): void;
  28455. /**
  28456. * Copy a FloatArray into a specific associated vertex buffer
  28457. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28458. * - VertexBuffer.PositionKind
  28459. * - VertexBuffer.UVKind
  28460. * - VertexBuffer.UV2Kind
  28461. * - VertexBuffer.UV3Kind
  28462. * - VertexBuffer.UV4Kind
  28463. * - VertexBuffer.UV5Kind
  28464. * - VertexBuffer.UV6Kind
  28465. * - VertexBuffer.ColorKind
  28466. * - VertexBuffer.MatricesIndicesKind
  28467. * - VertexBuffer.MatricesIndicesExtraKind
  28468. * - VertexBuffer.MatricesWeightsKind
  28469. * - VertexBuffer.MatricesWeightsExtraKind
  28470. * @param data defines the data source
  28471. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28472. * @param stride defines the data stride size (can be null)
  28473. * @returns the current mesh
  28474. */
  28475. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28476. /**
  28477. * Delete a vertex buffer associated with this mesh
  28478. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28479. * - VertexBuffer.PositionKind
  28480. * - VertexBuffer.UVKind
  28481. * - VertexBuffer.UV2Kind
  28482. * - VertexBuffer.UV3Kind
  28483. * - VertexBuffer.UV4Kind
  28484. * - VertexBuffer.UV5Kind
  28485. * - VertexBuffer.UV6Kind
  28486. * - VertexBuffer.ColorKind
  28487. * - VertexBuffer.MatricesIndicesKind
  28488. * - VertexBuffer.MatricesIndicesExtraKind
  28489. * - VertexBuffer.MatricesWeightsKind
  28490. * - VertexBuffer.MatricesWeightsExtraKind
  28491. */
  28492. removeVerticesData(kind: string): void;
  28493. /**
  28494. * Flags an associated vertex buffer as updatable
  28495. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28496. * - VertexBuffer.PositionKind
  28497. * - VertexBuffer.UVKind
  28498. * - VertexBuffer.UV2Kind
  28499. * - VertexBuffer.UV3Kind
  28500. * - VertexBuffer.UV4Kind
  28501. * - VertexBuffer.UV5Kind
  28502. * - VertexBuffer.UV6Kind
  28503. * - VertexBuffer.ColorKind
  28504. * - VertexBuffer.MatricesIndicesKind
  28505. * - VertexBuffer.MatricesIndicesExtraKind
  28506. * - VertexBuffer.MatricesWeightsKind
  28507. * - VertexBuffer.MatricesWeightsExtraKind
  28508. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28509. */
  28510. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28511. /**
  28512. * Sets the mesh global Vertex Buffer
  28513. * @param buffer defines the buffer to use
  28514. * @returns the current mesh
  28515. */
  28516. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28517. /**
  28518. * Update a specific associated vertex buffer
  28519. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28520. * - VertexBuffer.PositionKind
  28521. * - VertexBuffer.UVKind
  28522. * - VertexBuffer.UV2Kind
  28523. * - VertexBuffer.UV3Kind
  28524. * - VertexBuffer.UV4Kind
  28525. * - VertexBuffer.UV5Kind
  28526. * - VertexBuffer.UV6Kind
  28527. * - VertexBuffer.ColorKind
  28528. * - VertexBuffer.MatricesIndicesKind
  28529. * - VertexBuffer.MatricesIndicesExtraKind
  28530. * - VertexBuffer.MatricesWeightsKind
  28531. * - VertexBuffer.MatricesWeightsExtraKind
  28532. * @param data defines the data source
  28533. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28534. * @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)
  28535. * @returns the current mesh
  28536. */
  28537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28538. /**
  28539. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28540. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28541. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28542. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28543. * @returns the current mesh
  28544. */
  28545. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28546. /**
  28547. * Creates a un-shared specific occurence of the geometry for the mesh.
  28548. * @returns the current mesh
  28549. */
  28550. makeGeometryUnique(): Mesh;
  28551. /**
  28552. * Set the index buffer of this mesh
  28553. * @param indices defines the source data
  28554. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28555. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28556. * @returns the current mesh
  28557. */
  28558. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28559. /**
  28560. * Update the current index buffer
  28561. * @param indices defines the source data
  28562. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28563. * @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)
  28564. * @returns the current mesh
  28565. */
  28566. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28567. /**
  28568. * Invert the geometry to move from a right handed system to a left handed one.
  28569. * @returns the current mesh
  28570. */
  28571. toLeftHanded(): Mesh;
  28572. /** @hidden */
  28573. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28574. /** @hidden */
  28575. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28576. /**
  28577. * Registers for this mesh a javascript function called just before the rendering process
  28578. * @param func defines the function to call before rendering this mesh
  28579. * @returns the current mesh
  28580. */
  28581. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28582. /**
  28583. * Disposes a previously registered javascript function called before the rendering
  28584. * @param func defines the function to remove
  28585. * @returns the current mesh
  28586. */
  28587. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28588. /**
  28589. * Registers for this mesh a javascript function called just after the rendering is complete
  28590. * @param func defines the function to call after rendering this mesh
  28591. * @returns the current mesh
  28592. */
  28593. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28594. /**
  28595. * Disposes a previously registered javascript function called after the rendering.
  28596. * @param func defines the function to remove
  28597. * @returns the current mesh
  28598. */
  28599. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28600. /** @hidden */
  28601. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28602. /** @hidden */
  28603. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28604. /** @hidden */
  28605. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28606. /** @hidden */
  28607. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28608. /** @hidden */
  28609. _rebuild(): void;
  28610. /** @hidden */
  28611. _freeze(): void;
  28612. /** @hidden */
  28613. _unFreeze(): void;
  28614. /**
  28615. * 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
  28616. * @param subMesh defines the subMesh to render
  28617. * @param enableAlphaMode defines if alpha mode can be changed
  28618. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28619. * @returns the current mesh
  28620. */
  28621. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28622. private _onBeforeDraw;
  28623. /**
  28624. * Renormalize the mesh and patch it up if there are no weights
  28625. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28626. * However in the case of zero weights then we set just a single influence to 1.
  28627. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28628. */
  28629. cleanMatrixWeights(): void;
  28630. private normalizeSkinFourWeights;
  28631. private normalizeSkinWeightsAndExtra;
  28632. /**
  28633. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28634. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28635. * the user know there was an issue with importing the mesh
  28636. * @returns a validation object with skinned, valid and report string
  28637. */
  28638. validateSkinning(): {
  28639. skinned: boolean;
  28640. valid: boolean;
  28641. report: string;
  28642. };
  28643. /** @hidden */
  28644. _checkDelayState(): Mesh;
  28645. private _queueLoad;
  28646. /**
  28647. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28648. * A mesh is in the frustum if its bounding box intersects the frustum
  28649. * @param frustumPlanes defines the frustum to test
  28650. * @returns true if the mesh is in the frustum planes
  28651. */
  28652. isInFrustum(frustumPlanes: Plane[]): boolean;
  28653. /**
  28654. * Sets the mesh material by the material or multiMaterial `id` property
  28655. * @param id is a string identifying the material or the multiMaterial
  28656. * @returns the current mesh
  28657. */
  28658. setMaterialByID(id: string): Mesh;
  28659. /**
  28660. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28661. * @returns an array of IAnimatable
  28662. */
  28663. getAnimatables(): IAnimatable[];
  28664. /**
  28665. * Modifies the mesh geometry according to the passed transformation matrix.
  28666. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28667. * The mesh normals are modified using the same transformation.
  28668. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28669. * @param transform defines the transform matrix to use
  28670. * @see http://doc.babylonjs.com/resources/baking_transformations
  28671. * @returns the current mesh
  28672. */
  28673. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28674. /**
  28675. * Modifies the mesh geometry according to its own current World Matrix.
  28676. * The mesh World Matrix is then reset.
  28677. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28678. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28679. * @see http://doc.babylonjs.com/resources/baking_transformations
  28680. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28681. * @returns the current mesh
  28682. */
  28683. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28684. /** @hidden */
  28685. get _positions(): Nullable<Vector3[]>;
  28686. /** @hidden */
  28687. _resetPointsArrayCache(): Mesh;
  28688. /** @hidden */
  28689. _generatePointsArray(): boolean;
  28690. /**
  28691. * Returns a new Mesh object generated from the current mesh properties.
  28692. * This method must not get confused with createInstance()
  28693. * @param name is a string, the name given to the new mesh
  28694. * @param newParent can be any Node object (default `null`)
  28695. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28696. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28697. * @returns a new mesh
  28698. */
  28699. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28700. /**
  28701. * Releases resources associated with this mesh.
  28702. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28703. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28704. */
  28705. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28706. /** @hidden */
  28707. _disposeInstanceSpecificData(): void;
  28708. /**
  28709. * Modifies the mesh geometry according to a displacement map.
  28710. * 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.
  28711. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28712. * @param url is a string, the URL from the image file is to be downloaded.
  28713. * @param minHeight is the lower limit of the displacement.
  28714. * @param maxHeight is the upper limit of the displacement.
  28715. * @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.
  28716. * @param uvOffset is an optional vector2 used to offset UV.
  28717. * @param uvScale is an optional vector2 used to scale UV.
  28718. * @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.
  28719. * @returns the Mesh.
  28720. */
  28721. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28722. /**
  28723. * Modifies the mesh geometry according to a displacementMap buffer.
  28724. * 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.
  28725. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28726. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28727. * @param heightMapWidth is the width of the buffer image.
  28728. * @param heightMapHeight is the height of the buffer image.
  28729. * @param minHeight is the lower limit of the displacement.
  28730. * @param maxHeight is the upper limit of the displacement.
  28731. * @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.
  28732. * @param uvOffset is an optional vector2 used to offset UV.
  28733. * @param uvScale is an optional vector2 used to scale UV.
  28734. * @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.
  28735. * @returns the Mesh.
  28736. */
  28737. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28738. /**
  28739. * Modify the mesh to get a flat shading rendering.
  28740. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28741. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28742. * @returns current mesh
  28743. */
  28744. convertToFlatShadedMesh(): Mesh;
  28745. /**
  28746. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28747. * In other words, more vertices, no more indices and a single bigger VBO.
  28748. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28749. * @returns current mesh
  28750. */
  28751. convertToUnIndexedMesh(): Mesh;
  28752. /**
  28753. * Inverses facet orientations.
  28754. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28755. * @param flipNormals will also inverts the normals
  28756. * @returns current mesh
  28757. */
  28758. flipFaces(flipNormals?: boolean): Mesh;
  28759. /**
  28760. * Increase the number of facets and hence vertices in a mesh
  28761. * Vertex normals are interpolated from existing vertex normals
  28762. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28763. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28764. */
  28765. increaseVertices(numberPerEdge: number): void;
  28766. /**
  28767. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28768. * This will undo any application of covertToFlatShadedMesh
  28769. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28770. */
  28771. forceSharedVertices(): void;
  28772. /** @hidden */
  28773. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28774. /** @hidden */
  28775. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28776. /**
  28777. * Creates a new InstancedMesh object from the mesh model.
  28778. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28779. * @param name defines the name of the new instance
  28780. * @returns a new InstancedMesh
  28781. */
  28782. createInstance(name: string): InstancedMesh;
  28783. /**
  28784. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28785. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28786. * @returns the current mesh
  28787. */
  28788. synchronizeInstances(): Mesh;
  28789. /**
  28790. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28791. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28792. * This should be used together with the simplification to avoid disappearing triangles.
  28793. * @param successCallback an optional success callback to be called after the optimization finished.
  28794. * @returns the current mesh
  28795. */
  28796. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28797. /**
  28798. * Serialize current mesh
  28799. * @param serializationObject defines the object which will receive the serialization data
  28800. */
  28801. serialize(serializationObject: any): void;
  28802. /** @hidden */
  28803. _syncGeometryWithMorphTargetManager(): void;
  28804. /** @hidden */
  28805. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28806. /**
  28807. * Returns a new Mesh object parsed from the source provided.
  28808. * @param parsedMesh is the source
  28809. * @param scene defines the hosting scene
  28810. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28811. * @returns a new Mesh
  28812. */
  28813. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28814. /**
  28815. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28816. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28817. * @param name defines the name of the mesh to create
  28818. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28819. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28820. * @param closePath creates a seam between the first and the last points of each path of the path array
  28821. * @param offset is taken in account only if the `pathArray` is containing a single path
  28822. * @param scene defines the hosting scene
  28823. * @param updatable defines if the mesh must be flagged as updatable
  28824. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28825. * @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)
  28826. * @returns a new Mesh
  28827. */
  28828. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28829. /**
  28830. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28831. * @param name defines the name of the mesh to create
  28832. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28833. * @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
  28834. * @param scene defines the hosting scene
  28835. * @param updatable defines if the mesh must be flagged as updatable
  28836. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28837. * @returns a new Mesh
  28838. */
  28839. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28840. /**
  28841. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28842. * @param name defines the name of the mesh to create
  28843. * @param size sets the size (float) of each box side (default 1)
  28844. * @param scene defines the hosting scene
  28845. * @param updatable defines if the mesh must be flagged as updatable
  28846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28847. * @returns a new Mesh
  28848. */
  28849. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28850. /**
  28851. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28852. * @param name defines the name of the mesh to create
  28853. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28854. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28855. * @param scene defines the hosting scene
  28856. * @param updatable defines if the mesh must be flagged as updatable
  28857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28858. * @returns a new Mesh
  28859. */
  28860. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28861. /**
  28862. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28863. * @param name defines the name of the mesh to create
  28864. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28865. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28866. * @param scene defines the hosting scene
  28867. * @returns a new Mesh
  28868. */
  28869. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28870. /**
  28871. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28872. * @param name defines the name of the mesh to create
  28873. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28874. * @param diameterTop set the top cap diameter (floats, default 1)
  28875. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28876. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28877. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28878. * @param scene defines the hosting scene
  28879. * @param updatable defines if the mesh must be flagged as updatable
  28880. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28881. * @returns a new Mesh
  28882. */
  28883. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28884. /**
  28885. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28886. * @param name defines the name of the mesh to create
  28887. * @param diameter sets the diameter size (float) of the torus (default 1)
  28888. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28889. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28890. * @param scene defines the hosting scene
  28891. * @param updatable defines if the mesh must be flagged as updatable
  28892. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28893. * @returns a new Mesh
  28894. */
  28895. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28896. /**
  28897. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28898. * @param name defines the name of the mesh to create
  28899. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28900. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28901. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28902. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28903. * @param p the number of windings on X axis (positive integers, default 2)
  28904. * @param q the number of windings on Y axis (positive integers, default 3)
  28905. * @param scene defines the hosting scene
  28906. * @param updatable defines if the mesh must be flagged as updatable
  28907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28908. * @returns a new Mesh
  28909. */
  28910. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28911. /**
  28912. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28913. * @param name defines the name of the mesh to create
  28914. * @param points is an array successive Vector3
  28915. * @param scene defines the hosting scene
  28916. * @param updatable defines if the mesh must be flagged as updatable
  28917. * @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).
  28918. * @returns a new Mesh
  28919. */
  28920. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28921. /**
  28922. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28923. * @param name defines the name of the mesh to create
  28924. * @param points is an array successive Vector3
  28925. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28926. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28927. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28928. * @param scene defines the hosting scene
  28929. * @param updatable defines if the mesh must be flagged as updatable
  28930. * @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)
  28931. * @returns a new Mesh
  28932. */
  28933. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28934. /**
  28935. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28936. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28937. * 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.
  28938. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28939. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28940. * Remember you can only change the shape positions, not their number when updating a polygon.
  28941. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28942. * @param name defines the name of the mesh to create
  28943. * @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
  28944. * @param scene defines the hosting scene
  28945. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28946. * @param updatable defines if the mesh must be flagged as updatable
  28947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28948. * @param earcutInjection can be used to inject your own earcut reference
  28949. * @returns a new Mesh
  28950. */
  28951. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28952. /**
  28953. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28954. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28955. * @param name defines the name of the mesh to create
  28956. * @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
  28957. * @param depth defines the height of extrusion
  28958. * @param scene defines the hosting scene
  28959. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28960. * @param updatable defines if the mesh must be flagged as updatable
  28961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28962. * @param earcutInjection can be used to inject your own earcut reference
  28963. * @returns a new Mesh
  28964. */
  28965. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28966. /**
  28967. * Creates an extruded shape mesh.
  28968. * 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
  28969. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28970. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28971. * @param name defines the name of the mesh to create
  28972. * @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
  28973. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28974. * @param scale is the value to scale the shape
  28975. * @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
  28976. * @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
  28977. * @param scene defines the hosting scene
  28978. * @param updatable defines if the mesh must be flagged as updatable
  28979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28980. * @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)
  28981. * @returns a new Mesh
  28982. */
  28983. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28984. /**
  28985. * Creates an custom extruded shape mesh.
  28986. * The custom extrusion is a parametric shape.
  28987. * It has no predefined shape. Its final shape will depend on the input parameters.
  28988. * Please consider using the same method from the MeshBuilder class instead
  28989. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28990. * @param name defines the name of the mesh to create
  28991. * @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
  28992. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28993. * @param scaleFunction is a custom Javascript function called on each path point
  28994. * @param rotationFunction is a custom Javascript function called on each path point
  28995. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28996. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28997. * @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
  28998. * @param scene defines the hosting scene
  28999. * @param updatable defines if the mesh must be flagged as updatable
  29000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29001. * @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)
  29002. * @returns a new Mesh
  29003. */
  29004. 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;
  29005. /**
  29006. * Creates lathe mesh.
  29007. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29008. * Please consider using the same method from the MeshBuilder class instead
  29009. * @param name defines the name of the mesh to create
  29010. * @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
  29011. * @param radius is the radius value of the lathe
  29012. * @param tessellation is the side number of the lathe.
  29013. * @param scene defines the hosting scene
  29014. * @param updatable defines if the mesh must be flagged as updatable
  29015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29016. * @returns a new Mesh
  29017. */
  29018. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29019. /**
  29020. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29021. * @param name defines the name of the mesh to create
  29022. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29023. * @param scene defines the hosting scene
  29024. * @param updatable defines if the mesh must be flagged as updatable
  29025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29026. * @returns a new Mesh
  29027. */
  29028. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29029. /**
  29030. * Creates a ground mesh.
  29031. * Please consider using the same method from the MeshBuilder class instead
  29032. * @param name defines the name of the mesh to create
  29033. * @param width set the width of the ground
  29034. * @param height set the height of the ground
  29035. * @param subdivisions sets the number of subdivisions per side
  29036. * @param scene defines the hosting scene
  29037. * @param updatable defines if the mesh must be flagged as updatable
  29038. * @returns a new Mesh
  29039. */
  29040. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29041. /**
  29042. * Creates a tiled ground mesh.
  29043. * Please consider using the same method from the MeshBuilder class instead
  29044. * @param name defines the name of the mesh to create
  29045. * @param xmin set the ground minimum X coordinate
  29046. * @param zmin set the ground minimum Y coordinate
  29047. * @param xmax set the ground maximum X coordinate
  29048. * @param zmax set the ground maximum Z coordinate
  29049. * @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
  29050. * @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
  29051. * @param scene defines the hosting scene
  29052. * @param updatable defines if the mesh must be flagged as updatable
  29053. * @returns a new Mesh
  29054. */
  29055. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29056. w: number;
  29057. h: number;
  29058. }, precision: {
  29059. w: number;
  29060. h: number;
  29061. }, scene: Scene, updatable?: boolean): Mesh;
  29062. /**
  29063. * Creates a ground mesh from a height map.
  29064. * Please consider using the same method from the MeshBuilder class instead
  29065. * @see http://doc.babylonjs.com/babylon101/height_map
  29066. * @param name defines the name of the mesh to create
  29067. * @param url sets the URL of the height map image resource
  29068. * @param width set the ground width size
  29069. * @param height set the ground height size
  29070. * @param subdivisions sets the number of subdivision per side
  29071. * @param minHeight is the minimum altitude on the ground
  29072. * @param maxHeight is the maximum altitude on the ground
  29073. * @param scene defines the hosting scene
  29074. * @param updatable defines if the mesh must be flagged as updatable
  29075. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29076. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29077. * @returns a new Mesh
  29078. */
  29079. 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;
  29080. /**
  29081. * Creates a tube mesh.
  29082. * The tube is a parametric shape.
  29083. * It has no predefined shape. Its final shape will depend on the input parameters.
  29084. * Please consider using the same method from the MeshBuilder class instead
  29085. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29086. * @param name defines the name of the mesh to create
  29087. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29088. * @param radius sets the tube radius size
  29089. * @param tessellation is the number of sides on the tubular surface
  29090. * @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
  29091. * @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
  29092. * @param scene defines the hosting scene
  29093. * @param updatable defines if the mesh must be flagged as updatable
  29094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29095. * @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)
  29096. * @returns a new Mesh
  29097. */
  29098. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29099. (i: number, distance: number): number;
  29100. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29101. /**
  29102. * Creates a polyhedron mesh.
  29103. * Please consider using the same method from the MeshBuilder class instead.
  29104. * * 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
  29105. * * The parameter `size` (positive float, default 1) sets the polygon size
  29106. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29107. * * 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`
  29108. * * 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
  29109. * * 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)`)
  29110. * * 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
  29111. * * 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
  29112. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29113. * * If you create a double-sided mesh, you can choose what parts of 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
  29114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29115. * @param name defines the name of the mesh to create
  29116. * @param options defines the options used to create the mesh
  29117. * @param scene defines the hosting scene
  29118. * @returns a new Mesh
  29119. */
  29120. static CreatePolyhedron(name: string, options: {
  29121. type?: number;
  29122. size?: number;
  29123. sizeX?: number;
  29124. sizeY?: number;
  29125. sizeZ?: number;
  29126. custom?: any;
  29127. faceUV?: Vector4[];
  29128. faceColors?: Color4[];
  29129. updatable?: boolean;
  29130. sideOrientation?: number;
  29131. }, scene: Scene): Mesh;
  29132. /**
  29133. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29134. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29135. * * 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`)
  29136. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29137. * * 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
  29138. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29139. * * If you create a double-sided mesh, you can choose what parts of 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
  29140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29141. * @param name defines the name of the mesh
  29142. * @param options defines the options used to create the mesh
  29143. * @param scene defines the hosting scene
  29144. * @returns a new Mesh
  29145. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29146. */
  29147. static CreateIcoSphere(name: string, options: {
  29148. radius?: number;
  29149. flat?: boolean;
  29150. subdivisions?: number;
  29151. sideOrientation?: number;
  29152. updatable?: boolean;
  29153. }, scene: Scene): Mesh;
  29154. /**
  29155. * Creates a decal mesh.
  29156. * Please consider using the same method from the MeshBuilder class instead.
  29157. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29158. * @param name defines the name of the mesh
  29159. * @param sourceMesh defines the mesh receiving the decal
  29160. * @param position sets the position of the decal in world coordinates
  29161. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29162. * @param size sets the decal scaling
  29163. * @param angle sets the angle to rotate the decal
  29164. * @returns a new Mesh
  29165. */
  29166. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29167. /**
  29168. * Prepare internal position array for software CPU skinning
  29169. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29170. */
  29171. setPositionsForCPUSkinning(): Float32Array;
  29172. /**
  29173. * Prepare internal normal array for software CPU skinning
  29174. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29175. */
  29176. setNormalsForCPUSkinning(): Float32Array;
  29177. /**
  29178. * Updates the vertex buffer by applying transformation from the bones
  29179. * @param skeleton defines the skeleton to apply to current mesh
  29180. * @returns the current mesh
  29181. */
  29182. applySkeleton(skeleton: Skeleton): Mesh;
  29183. /**
  29184. * 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
  29185. * @param meshes defines the list of meshes to scan
  29186. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29187. */
  29188. static MinMax(meshes: AbstractMesh[]): {
  29189. min: Vector3;
  29190. max: Vector3;
  29191. };
  29192. /**
  29193. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29194. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29195. * @returns a vector3
  29196. */
  29197. static Center(meshesOrMinMaxVector: {
  29198. min: Vector3;
  29199. max: Vector3;
  29200. } | AbstractMesh[]): Vector3;
  29201. /**
  29202. * Merge the array of meshes into a single mesh for performance reasons.
  29203. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29204. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29205. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29206. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29207. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29208. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29209. * @returns a new mesh
  29210. */
  29211. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29212. /** @hidden */
  29213. addInstance(instance: InstancedMesh): void;
  29214. /** @hidden */
  29215. removeInstance(instance: InstancedMesh): void;
  29216. }
  29217. }
  29218. declare module "babylonjs/Cameras/camera" {
  29219. import { SmartArray } from "babylonjs/Misc/smartArray";
  29220. import { Observable } from "babylonjs/Misc/observable";
  29221. import { Nullable } from "babylonjs/types";
  29222. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29223. import { Scene } from "babylonjs/scene";
  29224. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29225. import { Node } from "babylonjs/node";
  29226. import { Mesh } from "babylonjs/Meshes/mesh";
  29227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29228. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29229. import { Viewport } from "babylonjs/Maths/math.viewport";
  29230. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29231. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29232. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29233. import { Ray } from "babylonjs/Culling/ray";
  29234. /**
  29235. * This is the base class of all the camera used in the application.
  29236. * @see http://doc.babylonjs.com/features/cameras
  29237. */
  29238. export class Camera extends Node {
  29239. /** @hidden */
  29240. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29241. /**
  29242. * This is the default projection mode used by the cameras.
  29243. * It helps recreating a feeling of perspective and better appreciate depth.
  29244. * This is the best way to simulate real life cameras.
  29245. */
  29246. static readonly PERSPECTIVE_CAMERA: number;
  29247. /**
  29248. * This helps creating camera with an orthographic mode.
  29249. * 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.
  29250. */
  29251. static readonly ORTHOGRAPHIC_CAMERA: number;
  29252. /**
  29253. * This is the default FOV mode for perspective cameras.
  29254. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29255. */
  29256. static readonly FOVMODE_VERTICAL_FIXED: number;
  29257. /**
  29258. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29259. */
  29260. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29261. /**
  29262. * This specifies ther is no need for a camera rig.
  29263. * Basically only one eye is rendered corresponding to the camera.
  29264. */
  29265. static readonly RIG_MODE_NONE: number;
  29266. /**
  29267. * Simulates a camera Rig with one blue eye and one red eye.
  29268. * This can be use with 3d blue and red glasses.
  29269. */
  29270. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29271. /**
  29272. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29273. */
  29274. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29275. /**
  29276. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29277. */
  29278. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29279. /**
  29280. * Defines that both eyes of the camera will be rendered over under each other.
  29281. */
  29282. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29283. /**
  29284. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29285. */
  29286. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29287. /**
  29288. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29289. */
  29290. static readonly RIG_MODE_VR: number;
  29291. /**
  29292. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29293. */
  29294. static readonly RIG_MODE_WEBVR: number;
  29295. /**
  29296. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29297. */
  29298. static readonly RIG_MODE_CUSTOM: number;
  29299. /**
  29300. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29301. */
  29302. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29303. /**
  29304. * Define the input manager associated with the camera.
  29305. */
  29306. inputs: CameraInputsManager<Camera>;
  29307. /** @hidden */
  29308. _position: Vector3;
  29309. /**
  29310. * Define the current local position of the camera in the scene
  29311. */
  29312. get position(): Vector3;
  29313. set position(newPosition: Vector3);
  29314. /**
  29315. * The vector the camera should consider as up.
  29316. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29317. */
  29318. upVector: Vector3;
  29319. /**
  29320. * Define the current limit on the left side for an orthographic camera
  29321. * In scene unit
  29322. */
  29323. orthoLeft: Nullable<number>;
  29324. /**
  29325. * Define the current limit on the right side for an orthographic camera
  29326. * In scene unit
  29327. */
  29328. orthoRight: Nullable<number>;
  29329. /**
  29330. * Define the current limit on the bottom side for an orthographic camera
  29331. * In scene unit
  29332. */
  29333. orthoBottom: Nullable<number>;
  29334. /**
  29335. * Define the current limit on the top side for an orthographic camera
  29336. * In scene unit
  29337. */
  29338. orthoTop: Nullable<number>;
  29339. /**
  29340. * Field Of View is set in Radians. (default is 0.8)
  29341. */
  29342. fov: number;
  29343. /**
  29344. * Define the minimum distance the camera can see from.
  29345. * This is important to note that the depth buffer are not infinite and the closer it starts
  29346. * the more your scene might encounter depth fighting issue.
  29347. */
  29348. minZ: number;
  29349. /**
  29350. * Define the maximum distance the camera can see to.
  29351. * This is important to note that the depth buffer are not infinite and the further it end
  29352. * the more your scene might encounter depth fighting issue.
  29353. */
  29354. maxZ: number;
  29355. /**
  29356. * Define the default inertia of the camera.
  29357. * This helps giving a smooth feeling to the camera movement.
  29358. */
  29359. inertia: number;
  29360. /**
  29361. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29362. */
  29363. mode: number;
  29364. /**
  29365. * Define whether the camera is intermediate.
  29366. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29367. */
  29368. isIntermediate: boolean;
  29369. /**
  29370. * Define the viewport of the camera.
  29371. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29372. */
  29373. viewport: Viewport;
  29374. /**
  29375. * Restricts the camera to viewing objects with the same layerMask.
  29376. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29377. */
  29378. layerMask: number;
  29379. /**
  29380. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29381. */
  29382. fovMode: number;
  29383. /**
  29384. * Rig mode of the camera.
  29385. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29386. * This is normally controlled byt the camera themselves as internal use.
  29387. */
  29388. cameraRigMode: number;
  29389. /**
  29390. * Defines the distance between both "eyes" in case of a RIG
  29391. */
  29392. interaxialDistance: number;
  29393. /**
  29394. * Defines if stereoscopic rendering is done side by side or over under.
  29395. */
  29396. isStereoscopicSideBySide: boolean;
  29397. /**
  29398. * 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
  29399. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29400. * else in the scene. (Eg. security camera)
  29401. *
  29402. * 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)
  29403. */
  29404. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29405. /**
  29406. * When set, the camera will render to this render target instead of the default canvas
  29407. *
  29408. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29409. */
  29410. outputRenderTarget: Nullable<RenderTargetTexture>;
  29411. /**
  29412. * Observable triggered when the camera view matrix has changed.
  29413. */
  29414. onViewMatrixChangedObservable: Observable<Camera>;
  29415. /**
  29416. * Observable triggered when the camera Projection matrix has changed.
  29417. */
  29418. onProjectionMatrixChangedObservable: Observable<Camera>;
  29419. /**
  29420. * Observable triggered when the inputs have been processed.
  29421. */
  29422. onAfterCheckInputsObservable: Observable<Camera>;
  29423. /**
  29424. * Observable triggered when reset has been called and applied to the camera.
  29425. */
  29426. onRestoreStateObservable: Observable<Camera>;
  29427. /**
  29428. * Is this camera a part of a rig system?
  29429. */
  29430. isRigCamera: boolean;
  29431. /**
  29432. * If isRigCamera set to true this will be set with the parent camera.
  29433. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29434. */
  29435. rigParent?: Camera;
  29436. /** @hidden */
  29437. _cameraRigParams: any;
  29438. /** @hidden */
  29439. _rigCameras: Camera[];
  29440. /** @hidden */
  29441. _rigPostProcess: Nullable<PostProcess>;
  29442. protected _webvrViewMatrix: Matrix;
  29443. /** @hidden */
  29444. _skipRendering: boolean;
  29445. /** @hidden */
  29446. _projectionMatrix: Matrix;
  29447. /** @hidden */
  29448. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29449. /** @hidden */
  29450. _activeMeshes: SmartArray<AbstractMesh>;
  29451. protected _globalPosition: Vector3;
  29452. /** @hidden */
  29453. _computedViewMatrix: Matrix;
  29454. private _doNotComputeProjectionMatrix;
  29455. private _transformMatrix;
  29456. private _frustumPlanes;
  29457. private _refreshFrustumPlanes;
  29458. private _storedFov;
  29459. private _stateStored;
  29460. /**
  29461. * Instantiates a new camera object.
  29462. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29463. * @see http://doc.babylonjs.com/features/cameras
  29464. * @param name Defines the name of the camera in the scene
  29465. * @param position Defines the position of the camera
  29466. * @param scene Defines the scene the camera belongs too
  29467. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29468. */
  29469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29470. /**
  29471. * Store current camera state (fov, position, etc..)
  29472. * @returns the camera
  29473. */
  29474. storeState(): Camera;
  29475. /**
  29476. * Restores the camera state values if it has been stored. You must call storeState() first
  29477. */
  29478. protected _restoreStateValues(): boolean;
  29479. /**
  29480. * Restored camera state. You must call storeState() first.
  29481. * @returns true if restored and false otherwise
  29482. */
  29483. restoreState(): boolean;
  29484. /**
  29485. * Gets the class name of the camera.
  29486. * @returns the class name
  29487. */
  29488. getClassName(): string;
  29489. /** @hidden */
  29490. readonly _isCamera: boolean;
  29491. /**
  29492. * Gets a string representation of the camera useful for debug purpose.
  29493. * @param fullDetails Defines that a more verboe level of logging is required
  29494. * @returns the string representation
  29495. */
  29496. toString(fullDetails?: boolean): string;
  29497. /**
  29498. * Gets the current world space position of the camera.
  29499. */
  29500. get globalPosition(): Vector3;
  29501. /**
  29502. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29503. * @returns the active meshe list
  29504. */
  29505. getActiveMeshes(): SmartArray<AbstractMesh>;
  29506. /**
  29507. * Check whether a mesh is part of the current active mesh list of the camera
  29508. * @param mesh Defines the mesh to check
  29509. * @returns true if active, false otherwise
  29510. */
  29511. isActiveMesh(mesh: Mesh): boolean;
  29512. /**
  29513. * Is this camera ready to be used/rendered
  29514. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29515. * @return true if the camera is ready
  29516. */
  29517. isReady(completeCheck?: boolean): boolean;
  29518. /** @hidden */
  29519. _initCache(): void;
  29520. /** @hidden */
  29521. _updateCache(ignoreParentClass?: boolean): void;
  29522. /** @hidden */
  29523. _isSynchronized(): boolean;
  29524. /** @hidden */
  29525. _isSynchronizedViewMatrix(): boolean;
  29526. /** @hidden */
  29527. _isSynchronizedProjectionMatrix(): boolean;
  29528. /**
  29529. * Attach the input controls to a specific dom element to get the input from.
  29530. * @param element Defines the element the controls should be listened from
  29531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29532. */
  29533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29534. /**
  29535. * Detach the current controls from the specified dom element.
  29536. * @param element Defines the element to stop listening the inputs from
  29537. */
  29538. detachControl(element: HTMLElement): void;
  29539. /**
  29540. * Update the camera state according to the different inputs gathered during the frame.
  29541. */
  29542. update(): void;
  29543. /** @hidden */
  29544. _checkInputs(): void;
  29545. /** @hidden */
  29546. get rigCameras(): Camera[];
  29547. /**
  29548. * Gets the post process used by the rig cameras
  29549. */
  29550. get rigPostProcess(): Nullable<PostProcess>;
  29551. /**
  29552. * Internal, gets the first post proces.
  29553. * @returns the first post process to be run on this camera.
  29554. */
  29555. _getFirstPostProcess(): Nullable<PostProcess>;
  29556. private _cascadePostProcessesToRigCams;
  29557. /**
  29558. * Attach a post process to the camera.
  29559. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29560. * @param postProcess The post process to attach to the camera
  29561. * @param insertAt The position of the post process in case several of them are in use in the scene
  29562. * @returns the position the post process has been inserted at
  29563. */
  29564. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29565. /**
  29566. * Detach a post process to the camera.
  29567. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29568. * @param postProcess The post process to detach from the camera
  29569. */
  29570. detachPostProcess(postProcess: PostProcess): void;
  29571. /**
  29572. * Gets the current world matrix of the camera
  29573. */
  29574. getWorldMatrix(): Matrix;
  29575. /** @hidden */
  29576. _getViewMatrix(): Matrix;
  29577. /**
  29578. * Gets the current view matrix of the camera.
  29579. * @param force forces the camera to recompute the matrix without looking at the cached state
  29580. * @returns the view matrix
  29581. */
  29582. getViewMatrix(force?: boolean): Matrix;
  29583. /**
  29584. * Freeze the projection matrix.
  29585. * It will prevent the cache check of the camera projection compute and can speed up perf
  29586. * if no parameter of the camera are meant to change
  29587. * @param projection Defines manually a projection if necessary
  29588. */
  29589. freezeProjectionMatrix(projection?: Matrix): void;
  29590. /**
  29591. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29592. */
  29593. unfreezeProjectionMatrix(): void;
  29594. /**
  29595. * Gets the current projection matrix of the camera.
  29596. * @param force forces the camera to recompute the matrix without looking at the cached state
  29597. * @returns the projection matrix
  29598. */
  29599. getProjectionMatrix(force?: boolean): Matrix;
  29600. /**
  29601. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29602. * @returns a Matrix
  29603. */
  29604. getTransformationMatrix(): Matrix;
  29605. private _updateFrustumPlanes;
  29606. /**
  29607. * Checks if a cullable object (mesh...) is in the camera frustum
  29608. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29609. * @param target The object to check
  29610. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29611. * @returns true if the object is in frustum otherwise false
  29612. */
  29613. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29614. /**
  29615. * Checks if a cullable object (mesh...) is in the camera frustum
  29616. * Unlike isInFrustum this cheks the full bounding box
  29617. * @param target The object to check
  29618. * @returns true if the object is in frustum otherwise false
  29619. */
  29620. isCompletelyInFrustum(target: ICullable): boolean;
  29621. /**
  29622. * Gets a ray in the forward direction from the camera.
  29623. * @param length Defines the length of the ray to create
  29624. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29625. * @param origin Defines the start point of the ray which defaults to the camera position
  29626. * @returns the forward ray
  29627. */
  29628. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29629. /**
  29630. * Releases resources associated with this node.
  29631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29633. */
  29634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29635. /** @hidden */
  29636. _isLeftCamera: boolean;
  29637. /**
  29638. * Gets the left camera of a rig setup in case of Rigged Camera
  29639. */
  29640. get isLeftCamera(): boolean;
  29641. /** @hidden */
  29642. _isRightCamera: boolean;
  29643. /**
  29644. * Gets the right camera of a rig setup in case of Rigged Camera
  29645. */
  29646. get isRightCamera(): boolean;
  29647. /**
  29648. * Gets the left camera of a rig setup in case of Rigged Camera
  29649. */
  29650. get leftCamera(): Nullable<FreeCamera>;
  29651. /**
  29652. * Gets the right camera of a rig setup in case of Rigged Camera
  29653. */
  29654. get rightCamera(): Nullable<FreeCamera>;
  29655. /**
  29656. * Gets the left camera target of a rig setup in case of Rigged Camera
  29657. * @returns the target position
  29658. */
  29659. getLeftTarget(): Nullable<Vector3>;
  29660. /**
  29661. * Gets the right camera target of a rig setup in case of Rigged Camera
  29662. * @returns the target position
  29663. */
  29664. getRightTarget(): Nullable<Vector3>;
  29665. /**
  29666. * @hidden
  29667. */
  29668. setCameraRigMode(mode: number, rigParams: any): void;
  29669. /** @hidden */
  29670. static _setStereoscopicRigMode(camera: Camera): void;
  29671. /** @hidden */
  29672. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29673. /** @hidden */
  29674. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29675. /** @hidden */
  29676. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29677. /** @hidden */
  29678. _getVRProjectionMatrix(): Matrix;
  29679. protected _updateCameraRotationMatrix(): void;
  29680. protected _updateWebVRCameraRotationMatrix(): void;
  29681. /**
  29682. * This function MUST be overwritten by the different WebVR cameras available.
  29683. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29684. * @hidden
  29685. */
  29686. _getWebVRProjectionMatrix(): Matrix;
  29687. /**
  29688. * This function MUST be overwritten by the different WebVR cameras available.
  29689. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29690. * @hidden
  29691. */
  29692. _getWebVRViewMatrix(): Matrix;
  29693. /** @hidden */
  29694. setCameraRigParameter(name: string, value: any): void;
  29695. /**
  29696. * needs to be overridden by children so sub has required properties to be copied
  29697. * @hidden
  29698. */
  29699. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29700. /**
  29701. * May need to be overridden by children
  29702. * @hidden
  29703. */
  29704. _updateRigCameras(): void;
  29705. /** @hidden */
  29706. _setupInputs(): void;
  29707. /**
  29708. * Serialiaze the camera setup to a json represention
  29709. * @returns the JSON representation
  29710. */
  29711. serialize(): any;
  29712. /**
  29713. * Clones the current camera.
  29714. * @param name The cloned camera name
  29715. * @returns the cloned camera
  29716. */
  29717. clone(name: string): Camera;
  29718. /**
  29719. * Gets the direction of the camera relative to a given local axis.
  29720. * @param localAxis Defines the reference axis to provide a relative direction.
  29721. * @return the direction
  29722. */
  29723. getDirection(localAxis: Vector3): Vector3;
  29724. /**
  29725. * Returns the current camera absolute rotation
  29726. */
  29727. get absoluteRotation(): Quaternion;
  29728. /**
  29729. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29730. * @param localAxis Defines the reference axis to provide a relative direction.
  29731. * @param result Defines the vector to store the result in
  29732. */
  29733. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29734. /**
  29735. * Gets a camera constructor for a given camera type
  29736. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29737. * @param name The name of the camera the result will be able to instantiate
  29738. * @param scene The scene the result will construct the camera in
  29739. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29740. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29741. * @returns a factory method to construc the camera
  29742. */
  29743. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29744. /**
  29745. * Compute the world matrix of the camera.
  29746. * @returns the camera world matrix
  29747. */
  29748. computeWorldMatrix(): Matrix;
  29749. /**
  29750. * Parse a JSON and creates the camera from the parsed information
  29751. * @param parsedCamera The JSON to parse
  29752. * @param scene The scene to instantiate the camera in
  29753. * @returns the newly constructed camera
  29754. */
  29755. static Parse(parsedCamera: any, scene: Scene): Camera;
  29756. }
  29757. }
  29758. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29759. import { Nullable } from "babylonjs/types";
  29760. import { Scene } from "babylonjs/scene";
  29761. import { Vector4 } from "babylonjs/Maths/math.vector";
  29762. import { Mesh } from "babylonjs/Meshes/mesh";
  29763. /**
  29764. * Class containing static functions to help procedurally build meshes
  29765. */
  29766. export class DiscBuilder {
  29767. /**
  29768. * Creates a plane polygonal mesh. By default, this is a disc
  29769. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29770. * * 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
  29771. * * 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
  29772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29775. * @param name defines the name of the mesh
  29776. * @param options defines the options used to create the mesh
  29777. * @param scene defines the hosting scene
  29778. * @returns the plane polygonal mesh
  29779. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29780. */
  29781. static CreateDisc(name: string, options: {
  29782. radius?: number;
  29783. tessellation?: number;
  29784. arc?: number;
  29785. updatable?: boolean;
  29786. sideOrientation?: number;
  29787. frontUVs?: Vector4;
  29788. backUVs?: Vector4;
  29789. }, scene?: Nullable<Scene>): Mesh;
  29790. }
  29791. }
  29792. declare module "babylonjs/Materials/fresnelParameters" {
  29793. import { DeepImmutable } from "babylonjs/types";
  29794. import { Color3 } from "babylonjs/Maths/math.color";
  29795. /**
  29796. * Options to be used when creating a FresnelParameters.
  29797. */
  29798. export type IFresnelParametersCreationOptions = {
  29799. /**
  29800. * Define the color used on edges (grazing angle)
  29801. */
  29802. leftColor?: Color3;
  29803. /**
  29804. * Define the color used on center
  29805. */
  29806. rightColor?: Color3;
  29807. /**
  29808. * Define bias applied to computed fresnel term
  29809. */
  29810. bias?: number;
  29811. /**
  29812. * Defined the power exponent applied to fresnel term
  29813. */
  29814. power?: number;
  29815. /**
  29816. * Define if the fresnel effect is enable or not.
  29817. */
  29818. isEnabled?: boolean;
  29819. };
  29820. /**
  29821. * Serialized format for FresnelParameters.
  29822. */
  29823. export type IFresnelParametersSerialized = {
  29824. /**
  29825. * Define the color used on edges (grazing angle) [as an array]
  29826. */
  29827. leftColor: number[];
  29828. /**
  29829. * Define the color used on center [as an array]
  29830. */
  29831. rightColor: number[];
  29832. /**
  29833. * Define bias applied to computed fresnel term
  29834. */
  29835. bias: number;
  29836. /**
  29837. * Defined the power exponent applied to fresnel term
  29838. */
  29839. power?: number;
  29840. /**
  29841. * Define if the fresnel effect is enable or not.
  29842. */
  29843. isEnabled: boolean;
  29844. };
  29845. /**
  29846. * This represents all the required information to add a fresnel effect on a material:
  29847. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29848. */
  29849. export class FresnelParameters {
  29850. private _isEnabled;
  29851. /**
  29852. * Define if the fresnel effect is enable or not.
  29853. */
  29854. get isEnabled(): boolean;
  29855. set isEnabled(value: boolean);
  29856. /**
  29857. * Define the color used on edges (grazing angle)
  29858. */
  29859. leftColor: Color3;
  29860. /**
  29861. * Define the color used on center
  29862. */
  29863. rightColor: Color3;
  29864. /**
  29865. * Define bias applied to computed fresnel term
  29866. */
  29867. bias: number;
  29868. /**
  29869. * Defined the power exponent applied to fresnel term
  29870. */
  29871. power: number;
  29872. /**
  29873. * Creates a new FresnelParameters object.
  29874. *
  29875. * @param options provide your own settings to optionally to override defaults
  29876. */
  29877. constructor(options?: IFresnelParametersCreationOptions);
  29878. /**
  29879. * Clones the current fresnel and its valuues
  29880. * @returns a clone fresnel configuration
  29881. */
  29882. clone(): FresnelParameters;
  29883. /**
  29884. * Determines equality between FresnelParameters objects
  29885. * @param otherFresnelParameters defines the second operand
  29886. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29887. */
  29888. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29889. /**
  29890. * Serializes the current fresnel parameters to a JSON representation.
  29891. * @return the JSON serialization
  29892. */
  29893. serialize(): IFresnelParametersSerialized;
  29894. /**
  29895. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29896. * @param parsedFresnelParameters Define the JSON representation
  29897. * @returns the parsed parameters
  29898. */
  29899. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29900. }
  29901. }
  29902. declare module "babylonjs/Materials/materialFlags" {
  29903. /**
  29904. * This groups all the flags used to control the materials channel.
  29905. */
  29906. export class MaterialFlags {
  29907. private static _DiffuseTextureEnabled;
  29908. /**
  29909. * Are diffuse textures enabled in the application.
  29910. */
  29911. static get DiffuseTextureEnabled(): boolean;
  29912. static set DiffuseTextureEnabled(value: boolean);
  29913. private static _AmbientTextureEnabled;
  29914. /**
  29915. * Are ambient textures enabled in the application.
  29916. */
  29917. static get AmbientTextureEnabled(): boolean;
  29918. static set AmbientTextureEnabled(value: boolean);
  29919. private static _OpacityTextureEnabled;
  29920. /**
  29921. * Are opacity textures enabled in the application.
  29922. */
  29923. static get OpacityTextureEnabled(): boolean;
  29924. static set OpacityTextureEnabled(value: boolean);
  29925. private static _ReflectionTextureEnabled;
  29926. /**
  29927. * Are reflection textures enabled in the application.
  29928. */
  29929. static get ReflectionTextureEnabled(): boolean;
  29930. static set ReflectionTextureEnabled(value: boolean);
  29931. private static _EmissiveTextureEnabled;
  29932. /**
  29933. * Are emissive textures enabled in the application.
  29934. */
  29935. static get EmissiveTextureEnabled(): boolean;
  29936. static set EmissiveTextureEnabled(value: boolean);
  29937. private static _SpecularTextureEnabled;
  29938. /**
  29939. * Are specular textures enabled in the application.
  29940. */
  29941. static get SpecularTextureEnabled(): boolean;
  29942. static set SpecularTextureEnabled(value: boolean);
  29943. private static _BumpTextureEnabled;
  29944. /**
  29945. * Are bump textures enabled in the application.
  29946. */
  29947. static get BumpTextureEnabled(): boolean;
  29948. static set BumpTextureEnabled(value: boolean);
  29949. private static _LightmapTextureEnabled;
  29950. /**
  29951. * Are lightmap textures enabled in the application.
  29952. */
  29953. static get LightmapTextureEnabled(): boolean;
  29954. static set LightmapTextureEnabled(value: boolean);
  29955. private static _RefractionTextureEnabled;
  29956. /**
  29957. * Are refraction textures enabled in the application.
  29958. */
  29959. static get RefractionTextureEnabled(): boolean;
  29960. static set RefractionTextureEnabled(value: boolean);
  29961. private static _ColorGradingTextureEnabled;
  29962. /**
  29963. * Are color grading textures enabled in the application.
  29964. */
  29965. static get ColorGradingTextureEnabled(): boolean;
  29966. static set ColorGradingTextureEnabled(value: boolean);
  29967. private static _FresnelEnabled;
  29968. /**
  29969. * Are fresnels enabled in the application.
  29970. */
  29971. static get FresnelEnabled(): boolean;
  29972. static set FresnelEnabled(value: boolean);
  29973. private static _ClearCoatTextureEnabled;
  29974. /**
  29975. * Are clear coat textures enabled in the application.
  29976. */
  29977. static get ClearCoatTextureEnabled(): boolean;
  29978. static set ClearCoatTextureEnabled(value: boolean);
  29979. private static _ClearCoatBumpTextureEnabled;
  29980. /**
  29981. * Are clear coat bump textures enabled in the application.
  29982. */
  29983. static get ClearCoatBumpTextureEnabled(): boolean;
  29984. static set ClearCoatBumpTextureEnabled(value: boolean);
  29985. private static _ClearCoatTintTextureEnabled;
  29986. /**
  29987. * Are clear coat tint textures enabled in the application.
  29988. */
  29989. static get ClearCoatTintTextureEnabled(): boolean;
  29990. static set ClearCoatTintTextureEnabled(value: boolean);
  29991. private static _SheenTextureEnabled;
  29992. /**
  29993. * Are sheen textures enabled in the application.
  29994. */
  29995. static get SheenTextureEnabled(): boolean;
  29996. static set SheenTextureEnabled(value: boolean);
  29997. private static _AnisotropicTextureEnabled;
  29998. /**
  29999. * Are anisotropic textures enabled in the application.
  30000. */
  30001. static get AnisotropicTextureEnabled(): boolean;
  30002. static set AnisotropicTextureEnabled(value: boolean);
  30003. private static _ThicknessTextureEnabled;
  30004. /**
  30005. * Are thickness textures enabled in the application.
  30006. */
  30007. static get ThicknessTextureEnabled(): boolean;
  30008. static set ThicknessTextureEnabled(value: boolean);
  30009. }
  30010. }
  30011. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30012. /** @hidden */
  30013. export var defaultFragmentDeclaration: {
  30014. name: string;
  30015. shader: string;
  30016. };
  30017. }
  30018. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30019. /** @hidden */
  30020. export var defaultUboDeclaration: {
  30021. name: string;
  30022. shader: string;
  30023. };
  30024. }
  30025. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30026. /** @hidden */
  30027. export var lightFragmentDeclaration: {
  30028. name: string;
  30029. shader: string;
  30030. };
  30031. }
  30032. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30033. /** @hidden */
  30034. export var lightUboDeclaration: {
  30035. name: string;
  30036. shader: string;
  30037. };
  30038. }
  30039. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30040. /** @hidden */
  30041. export var lightsFragmentFunctions: {
  30042. name: string;
  30043. shader: string;
  30044. };
  30045. }
  30046. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30047. /** @hidden */
  30048. export var shadowsFragmentFunctions: {
  30049. name: string;
  30050. shader: string;
  30051. };
  30052. }
  30053. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30054. /** @hidden */
  30055. export var fresnelFunction: {
  30056. name: string;
  30057. shader: string;
  30058. };
  30059. }
  30060. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30061. /** @hidden */
  30062. export var bumpFragmentMainFunctions: {
  30063. name: string;
  30064. shader: string;
  30065. };
  30066. }
  30067. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30068. /** @hidden */
  30069. export var bumpFragmentFunctions: {
  30070. name: string;
  30071. shader: string;
  30072. };
  30073. }
  30074. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30075. /** @hidden */
  30076. export var logDepthDeclaration: {
  30077. name: string;
  30078. shader: string;
  30079. };
  30080. }
  30081. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30082. /** @hidden */
  30083. export var bumpFragment: {
  30084. name: string;
  30085. shader: string;
  30086. };
  30087. }
  30088. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30089. /** @hidden */
  30090. export var depthPrePass: {
  30091. name: string;
  30092. shader: string;
  30093. };
  30094. }
  30095. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30096. /** @hidden */
  30097. export var lightFragment: {
  30098. name: string;
  30099. shader: string;
  30100. };
  30101. }
  30102. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30103. /** @hidden */
  30104. export var logDepthFragment: {
  30105. name: string;
  30106. shader: string;
  30107. };
  30108. }
  30109. declare module "babylonjs/Shaders/default.fragment" {
  30110. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30111. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30112. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30113. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30114. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30115. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30116. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30117. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30118. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30119. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30120. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30121. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30122. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30123. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30124. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30125. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30126. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30127. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30128. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30129. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30130. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30131. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30132. /** @hidden */
  30133. export var defaultPixelShader: {
  30134. name: string;
  30135. shader: string;
  30136. };
  30137. }
  30138. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30139. /** @hidden */
  30140. export var defaultVertexDeclaration: {
  30141. name: string;
  30142. shader: string;
  30143. };
  30144. }
  30145. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30146. /** @hidden */
  30147. export var bumpVertexDeclaration: {
  30148. name: string;
  30149. shader: string;
  30150. };
  30151. }
  30152. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30153. /** @hidden */
  30154. export var bumpVertex: {
  30155. name: string;
  30156. shader: string;
  30157. };
  30158. }
  30159. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30160. /** @hidden */
  30161. export var fogVertex: {
  30162. name: string;
  30163. shader: string;
  30164. };
  30165. }
  30166. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30167. /** @hidden */
  30168. export var shadowsVertex: {
  30169. name: string;
  30170. shader: string;
  30171. };
  30172. }
  30173. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30174. /** @hidden */
  30175. export var pointCloudVertex: {
  30176. name: string;
  30177. shader: string;
  30178. };
  30179. }
  30180. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30181. /** @hidden */
  30182. export var logDepthVertex: {
  30183. name: string;
  30184. shader: string;
  30185. };
  30186. }
  30187. declare module "babylonjs/Shaders/default.vertex" {
  30188. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30189. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30191. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30192. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30193. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30194. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30195. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30196. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30197. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30199. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30200. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30204. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30205. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30206. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30207. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30208. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30209. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30210. /** @hidden */
  30211. export var defaultVertexShader: {
  30212. name: string;
  30213. shader: string;
  30214. };
  30215. }
  30216. declare module "babylonjs/Materials/standardMaterial" {
  30217. import { SmartArray } from "babylonjs/Misc/smartArray";
  30218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30219. import { Nullable } from "babylonjs/types";
  30220. import { Scene } from "babylonjs/scene";
  30221. import { Matrix } from "babylonjs/Maths/math.vector";
  30222. import { Color3 } from "babylonjs/Maths/math.color";
  30223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30225. import { Mesh } from "babylonjs/Meshes/mesh";
  30226. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30227. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30228. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30229. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30230. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30232. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30233. import "babylonjs/Shaders/default.fragment";
  30234. import "babylonjs/Shaders/default.vertex";
  30235. /** @hidden */
  30236. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30237. MAINUV1: boolean;
  30238. MAINUV2: boolean;
  30239. DIFFUSE: boolean;
  30240. DIFFUSEDIRECTUV: number;
  30241. AMBIENT: boolean;
  30242. AMBIENTDIRECTUV: number;
  30243. OPACITY: boolean;
  30244. OPACITYDIRECTUV: number;
  30245. OPACITYRGB: boolean;
  30246. REFLECTION: boolean;
  30247. EMISSIVE: boolean;
  30248. EMISSIVEDIRECTUV: number;
  30249. SPECULAR: boolean;
  30250. SPECULARDIRECTUV: number;
  30251. BUMP: boolean;
  30252. BUMPDIRECTUV: number;
  30253. PARALLAX: boolean;
  30254. PARALLAXOCCLUSION: boolean;
  30255. SPECULAROVERALPHA: boolean;
  30256. CLIPPLANE: boolean;
  30257. CLIPPLANE2: boolean;
  30258. CLIPPLANE3: boolean;
  30259. CLIPPLANE4: boolean;
  30260. CLIPPLANE5: boolean;
  30261. CLIPPLANE6: boolean;
  30262. ALPHATEST: boolean;
  30263. DEPTHPREPASS: boolean;
  30264. ALPHAFROMDIFFUSE: boolean;
  30265. POINTSIZE: boolean;
  30266. FOG: boolean;
  30267. SPECULARTERM: boolean;
  30268. DIFFUSEFRESNEL: boolean;
  30269. OPACITYFRESNEL: boolean;
  30270. REFLECTIONFRESNEL: boolean;
  30271. REFRACTIONFRESNEL: boolean;
  30272. EMISSIVEFRESNEL: boolean;
  30273. FRESNEL: boolean;
  30274. NORMAL: boolean;
  30275. UV1: boolean;
  30276. UV2: boolean;
  30277. VERTEXCOLOR: boolean;
  30278. VERTEXALPHA: boolean;
  30279. NUM_BONE_INFLUENCERS: number;
  30280. BonesPerMesh: number;
  30281. BONETEXTURE: boolean;
  30282. INSTANCES: boolean;
  30283. GLOSSINESS: boolean;
  30284. ROUGHNESS: boolean;
  30285. EMISSIVEASILLUMINATION: boolean;
  30286. LINKEMISSIVEWITHDIFFUSE: boolean;
  30287. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30288. LIGHTMAP: boolean;
  30289. LIGHTMAPDIRECTUV: number;
  30290. OBJECTSPACE_NORMALMAP: boolean;
  30291. USELIGHTMAPASSHADOWMAP: boolean;
  30292. REFLECTIONMAP_3D: boolean;
  30293. REFLECTIONMAP_SPHERICAL: boolean;
  30294. REFLECTIONMAP_PLANAR: boolean;
  30295. REFLECTIONMAP_CUBIC: boolean;
  30296. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30297. REFLECTIONMAP_PROJECTION: boolean;
  30298. REFLECTIONMAP_SKYBOX: boolean;
  30299. REFLECTIONMAP_EXPLICIT: boolean;
  30300. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30301. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30302. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30303. INVERTCUBICMAP: boolean;
  30304. LOGARITHMICDEPTH: boolean;
  30305. REFRACTION: boolean;
  30306. REFRACTIONMAP_3D: boolean;
  30307. REFLECTIONOVERALPHA: boolean;
  30308. TWOSIDEDLIGHTING: boolean;
  30309. SHADOWFLOAT: boolean;
  30310. MORPHTARGETS: boolean;
  30311. MORPHTARGETS_NORMAL: boolean;
  30312. MORPHTARGETS_TANGENT: boolean;
  30313. MORPHTARGETS_UV: boolean;
  30314. NUM_MORPH_INFLUENCERS: number;
  30315. NONUNIFORMSCALING: boolean;
  30316. PREMULTIPLYALPHA: boolean;
  30317. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30318. ALPHABLEND: boolean;
  30319. RGBDLIGHTMAP: boolean;
  30320. RGBDREFLECTION: boolean;
  30321. RGBDREFRACTION: boolean;
  30322. IMAGEPROCESSING: boolean;
  30323. VIGNETTE: boolean;
  30324. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30325. VIGNETTEBLENDMODEOPAQUE: boolean;
  30326. TONEMAPPING: boolean;
  30327. TONEMAPPING_ACES: boolean;
  30328. CONTRAST: boolean;
  30329. COLORCURVES: boolean;
  30330. COLORGRADING: boolean;
  30331. COLORGRADING3D: boolean;
  30332. SAMPLER3DGREENDEPTH: boolean;
  30333. SAMPLER3DBGRMAP: boolean;
  30334. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30335. MULTIVIEW: boolean;
  30336. /**
  30337. * If the reflection texture on this material is in linear color space
  30338. * @hidden
  30339. */
  30340. IS_REFLECTION_LINEAR: boolean;
  30341. /**
  30342. * If the refraction texture on this material is in linear color space
  30343. * @hidden
  30344. */
  30345. IS_REFRACTION_LINEAR: boolean;
  30346. EXPOSURE: boolean;
  30347. constructor();
  30348. setReflectionMode(modeToEnable: string): void;
  30349. }
  30350. /**
  30351. * This is the default material used in Babylon. It is the best trade off between quality
  30352. * and performances.
  30353. * @see http://doc.babylonjs.com/babylon101/materials
  30354. */
  30355. export class StandardMaterial extends PushMaterial {
  30356. private _diffuseTexture;
  30357. /**
  30358. * The basic texture of the material as viewed under a light.
  30359. */
  30360. diffuseTexture: Nullable<BaseTexture>;
  30361. private _ambientTexture;
  30362. /**
  30363. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30364. */
  30365. ambientTexture: Nullable<BaseTexture>;
  30366. private _opacityTexture;
  30367. /**
  30368. * Define the transparency of the material from a texture.
  30369. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30370. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30371. */
  30372. opacityTexture: Nullable<BaseTexture>;
  30373. private _reflectionTexture;
  30374. /**
  30375. * Define the texture used to display the reflection.
  30376. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30377. */
  30378. reflectionTexture: Nullable<BaseTexture>;
  30379. private _emissiveTexture;
  30380. /**
  30381. * Define texture of the material as if self lit.
  30382. * This will be mixed in the final result even in the absence of light.
  30383. */
  30384. emissiveTexture: Nullable<BaseTexture>;
  30385. private _specularTexture;
  30386. /**
  30387. * Define how the color and intensity of the highlight given by the light in the material.
  30388. */
  30389. specularTexture: Nullable<BaseTexture>;
  30390. private _bumpTexture;
  30391. /**
  30392. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30393. * 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.
  30394. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30395. */
  30396. bumpTexture: Nullable<BaseTexture>;
  30397. private _lightmapTexture;
  30398. /**
  30399. * Complex lighting can be computationally expensive to compute at runtime.
  30400. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30401. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30402. */
  30403. lightmapTexture: Nullable<BaseTexture>;
  30404. private _refractionTexture;
  30405. /**
  30406. * Define the texture used to display the refraction.
  30407. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30408. */
  30409. refractionTexture: Nullable<BaseTexture>;
  30410. /**
  30411. * The color of the material lit by the environmental background lighting.
  30412. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30413. */
  30414. ambientColor: Color3;
  30415. /**
  30416. * The basic color of the material as viewed under a light.
  30417. */
  30418. diffuseColor: Color3;
  30419. /**
  30420. * Define how the color and intensity of the highlight given by the light in the material.
  30421. */
  30422. specularColor: Color3;
  30423. /**
  30424. * Define the color of the material as if self lit.
  30425. * This will be mixed in the final result even in the absence of light.
  30426. */
  30427. emissiveColor: Color3;
  30428. /**
  30429. * Defines how sharp are the highlights in the material.
  30430. * The bigger the value the sharper giving a more glossy feeling to the result.
  30431. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30432. */
  30433. specularPower: number;
  30434. private _useAlphaFromDiffuseTexture;
  30435. /**
  30436. * Does the transparency come from the diffuse texture alpha channel.
  30437. */
  30438. useAlphaFromDiffuseTexture: boolean;
  30439. private _useEmissiveAsIllumination;
  30440. /**
  30441. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30442. */
  30443. useEmissiveAsIllumination: boolean;
  30444. private _linkEmissiveWithDiffuse;
  30445. /**
  30446. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30447. * the emissive level when the final color is close to one.
  30448. */
  30449. linkEmissiveWithDiffuse: boolean;
  30450. private _useSpecularOverAlpha;
  30451. /**
  30452. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30453. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30454. */
  30455. useSpecularOverAlpha: boolean;
  30456. private _useReflectionOverAlpha;
  30457. /**
  30458. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30459. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30460. */
  30461. useReflectionOverAlpha: boolean;
  30462. private _disableLighting;
  30463. /**
  30464. * Does lights from the scene impacts this material.
  30465. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30466. */
  30467. disableLighting: boolean;
  30468. private _useObjectSpaceNormalMap;
  30469. /**
  30470. * Allows using an object space normal map (instead of tangent space).
  30471. */
  30472. useObjectSpaceNormalMap: boolean;
  30473. private _useParallax;
  30474. /**
  30475. * Is parallax enabled or not.
  30476. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30477. */
  30478. useParallax: boolean;
  30479. private _useParallaxOcclusion;
  30480. /**
  30481. * Is parallax occlusion enabled or not.
  30482. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30483. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30484. */
  30485. useParallaxOcclusion: boolean;
  30486. /**
  30487. * 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.
  30488. */
  30489. parallaxScaleBias: number;
  30490. private _roughness;
  30491. /**
  30492. * Helps to define how blurry the reflections should appears in the material.
  30493. */
  30494. roughness: number;
  30495. /**
  30496. * In case of refraction, define the value of the index of refraction.
  30497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30498. */
  30499. indexOfRefraction: number;
  30500. /**
  30501. * Invert the refraction texture alongside the y axis.
  30502. * It can be useful with procedural textures or probe for instance.
  30503. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30504. */
  30505. invertRefractionY: boolean;
  30506. /**
  30507. * Defines the alpha limits in alpha test mode.
  30508. */
  30509. alphaCutOff: number;
  30510. private _useLightmapAsShadowmap;
  30511. /**
  30512. * In case of light mapping, define whether the map contains light or shadow informations.
  30513. */
  30514. useLightmapAsShadowmap: boolean;
  30515. private _diffuseFresnelParameters;
  30516. /**
  30517. * Define the diffuse fresnel parameters of the material.
  30518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30519. */
  30520. diffuseFresnelParameters: FresnelParameters;
  30521. private _opacityFresnelParameters;
  30522. /**
  30523. * Define the opacity fresnel parameters of the material.
  30524. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30525. */
  30526. opacityFresnelParameters: FresnelParameters;
  30527. private _reflectionFresnelParameters;
  30528. /**
  30529. * Define the reflection fresnel parameters of the material.
  30530. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30531. */
  30532. reflectionFresnelParameters: FresnelParameters;
  30533. private _refractionFresnelParameters;
  30534. /**
  30535. * Define the refraction fresnel parameters of the material.
  30536. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30537. */
  30538. refractionFresnelParameters: FresnelParameters;
  30539. private _emissiveFresnelParameters;
  30540. /**
  30541. * Define the emissive fresnel parameters of the material.
  30542. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30543. */
  30544. emissiveFresnelParameters: FresnelParameters;
  30545. private _useReflectionFresnelFromSpecular;
  30546. /**
  30547. * If true automatically deducts the fresnels values from the material specularity.
  30548. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30549. */
  30550. useReflectionFresnelFromSpecular: boolean;
  30551. private _useGlossinessFromSpecularMapAlpha;
  30552. /**
  30553. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30554. */
  30555. useGlossinessFromSpecularMapAlpha: boolean;
  30556. private _maxSimultaneousLights;
  30557. /**
  30558. * Defines the maximum number of lights that can be used in the material
  30559. */
  30560. maxSimultaneousLights: number;
  30561. private _invertNormalMapX;
  30562. /**
  30563. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30564. */
  30565. invertNormalMapX: boolean;
  30566. private _invertNormalMapY;
  30567. /**
  30568. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30569. */
  30570. invertNormalMapY: boolean;
  30571. private _twoSidedLighting;
  30572. /**
  30573. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30574. */
  30575. twoSidedLighting: boolean;
  30576. /**
  30577. * Default configuration related to image processing available in the standard Material.
  30578. */
  30579. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30580. /**
  30581. * Gets the image processing configuration used either in this material.
  30582. */
  30583. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30584. /**
  30585. * Sets the Default image processing configuration used either in the this material.
  30586. *
  30587. * If sets to null, the scene one is in use.
  30588. */
  30589. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30590. /**
  30591. * Keep track of the image processing observer to allow dispose and replace.
  30592. */
  30593. private _imageProcessingObserver;
  30594. /**
  30595. * Attaches a new image processing configuration to the Standard Material.
  30596. * @param configuration
  30597. */
  30598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30599. /**
  30600. * Gets wether the color curves effect is enabled.
  30601. */
  30602. get cameraColorCurvesEnabled(): boolean;
  30603. /**
  30604. * Sets wether the color curves effect is enabled.
  30605. */
  30606. set cameraColorCurvesEnabled(value: boolean);
  30607. /**
  30608. * Gets wether the color grading effect is enabled.
  30609. */
  30610. get cameraColorGradingEnabled(): boolean;
  30611. /**
  30612. * Gets wether the color grading effect is enabled.
  30613. */
  30614. set cameraColorGradingEnabled(value: boolean);
  30615. /**
  30616. * Gets wether tonemapping is enabled or not.
  30617. */
  30618. get cameraToneMappingEnabled(): boolean;
  30619. /**
  30620. * Sets wether tonemapping is enabled or not
  30621. */
  30622. set cameraToneMappingEnabled(value: boolean);
  30623. /**
  30624. * The camera exposure used on this material.
  30625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30626. * This corresponds to a photographic exposure.
  30627. */
  30628. get cameraExposure(): number;
  30629. /**
  30630. * The camera exposure used on this material.
  30631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30632. * This corresponds to a photographic exposure.
  30633. */
  30634. set cameraExposure(value: number);
  30635. /**
  30636. * Gets The camera contrast used on this material.
  30637. */
  30638. get cameraContrast(): number;
  30639. /**
  30640. * Sets The camera contrast used on this material.
  30641. */
  30642. set cameraContrast(value: number);
  30643. /**
  30644. * Gets the Color Grading 2D Lookup Texture.
  30645. */
  30646. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30647. /**
  30648. * Sets the Color Grading 2D Lookup Texture.
  30649. */
  30650. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30651. /**
  30652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30654. * 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;
  30655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30656. */
  30657. get cameraColorCurves(): Nullable<ColorCurves>;
  30658. /**
  30659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30661. * 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;
  30662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30663. */
  30664. set cameraColorCurves(value: Nullable<ColorCurves>);
  30665. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30666. protected _worldViewProjectionMatrix: Matrix;
  30667. protected _globalAmbientColor: Color3;
  30668. protected _useLogarithmicDepth: boolean;
  30669. protected _rebuildInParallel: boolean;
  30670. /**
  30671. * Instantiates a new standard material.
  30672. * This is the default material used in Babylon. It is the best trade off between quality
  30673. * and performances.
  30674. * @see http://doc.babylonjs.com/babylon101/materials
  30675. * @param name Define the name of the material in the scene
  30676. * @param scene Define the scene the material belong to
  30677. */
  30678. constructor(name: string, scene: Scene);
  30679. /**
  30680. * Gets a boolean indicating that current material needs to register RTT
  30681. */
  30682. get hasRenderTargetTextures(): boolean;
  30683. /**
  30684. * Gets the current class name of the material e.g. "StandardMaterial"
  30685. * Mainly use in serialization.
  30686. * @returns the class name
  30687. */
  30688. getClassName(): string;
  30689. /**
  30690. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30691. * You can try switching to logarithmic depth.
  30692. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30693. */
  30694. get useLogarithmicDepth(): boolean;
  30695. set useLogarithmicDepth(value: boolean);
  30696. /**
  30697. * Specifies if the material will require alpha blending
  30698. * @returns a boolean specifying if alpha blending is needed
  30699. */
  30700. needAlphaBlending(): boolean;
  30701. /**
  30702. * Specifies if this material should be rendered in alpha test mode
  30703. * @returns a boolean specifying if an alpha test is needed.
  30704. */
  30705. needAlphaTesting(): boolean;
  30706. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30707. /**
  30708. * Get the texture used for alpha test purpose.
  30709. * @returns the diffuse texture in case of the standard material.
  30710. */
  30711. getAlphaTestTexture(): Nullable<BaseTexture>;
  30712. /**
  30713. * Get if the submesh is ready to be used and all its information available.
  30714. * Child classes can use it to update shaders
  30715. * @param mesh defines the mesh to check
  30716. * @param subMesh defines which submesh to check
  30717. * @param useInstances specifies that instances should be used
  30718. * @returns a boolean indicating that the submesh is ready or not
  30719. */
  30720. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30721. /**
  30722. * Builds the material UBO layouts.
  30723. * Used internally during the effect preparation.
  30724. */
  30725. buildUniformLayout(): void;
  30726. /**
  30727. * Unbinds the material from the mesh
  30728. */
  30729. unbind(): void;
  30730. /**
  30731. * Binds the submesh to this material by preparing the effect and shader to draw
  30732. * @param world defines the world transformation matrix
  30733. * @param mesh defines the mesh containing the submesh
  30734. * @param subMesh defines the submesh to bind the material to
  30735. */
  30736. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30737. /**
  30738. * Get the list of animatables in the material.
  30739. * @returns the list of animatables object used in the material
  30740. */
  30741. getAnimatables(): IAnimatable[];
  30742. /**
  30743. * Gets the active textures from the material
  30744. * @returns an array of textures
  30745. */
  30746. getActiveTextures(): BaseTexture[];
  30747. /**
  30748. * Specifies if the material uses a texture
  30749. * @param texture defines the texture to check against the material
  30750. * @returns a boolean specifying if the material uses the texture
  30751. */
  30752. hasTexture(texture: BaseTexture): boolean;
  30753. /**
  30754. * Disposes the material
  30755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30756. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30757. */
  30758. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30759. /**
  30760. * Makes a duplicate of the material, and gives it a new name
  30761. * @param name defines the new name for the duplicated material
  30762. * @returns the cloned material
  30763. */
  30764. clone(name: string): StandardMaterial;
  30765. /**
  30766. * Serializes this material in a JSON representation
  30767. * @returns the serialized material object
  30768. */
  30769. serialize(): any;
  30770. /**
  30771. * Creates a standard material from parsed material data
  30772. * @param source defines the JSON representation of the material
  30773. * @param scene defines the hosting scene
  30774. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30775. * @returns a new standard material
  30776. */
  30777. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30778. /**
  30779. * Are diffuse textures enabled in the application.
  30780. */
  30781. static get DiffuseTextureEnabled(): boolean;
  30782. static set DiffuseTextureEnabled(value: boolean);
  30783. /**
  30784. * Are ambient textures enabled in the application.
  30785. */
  30786. static get AmbientTextureEnabled(): boolean;
  30787. static set AmbientTextureEnabled(value: boolean);
  30788. /**
  30789. * Are opacity textures enabled in the application.
  30790. */
  30791. static get OpacityTextureEnabled(): boolean;
  30792. static set OpacityTextureEnabled(value: boolean);
  30793. /**
  30794. * Are reflection textures enabled in the application.
  30795. */
  30796. static get ReflectionTextureEnabled(): boolean;
  30797. static set ReflectionTextureEnabled(value: boolean);
  30798. /**
  30799. * Are emissive textures enabled in the application.
  30800. */
  30801. static get EmissiveTextureEnabled(): boolean;
  30802. static set EmissiveTextureEnabled(value: boolean);
  30803. /**
  30804. * Are specular textures enabled in the application.
  30805. */
  30806. static get SpecularTextureEnabled(): boolean;
  30807. static set SpecularTextureEnabled(value: boolean);
  30808. /**
  30809. * Are bump textures enabled in the application.
  30810. */
  30811. static get BumpTextureEnabled(): boolean;
  30812. static set BumpTextureEnabled(value: boolean);
  30813. /**
  30814. * Are lightmap textures enabled in the application.
  30815. */
  30816. static get LightmapTextureEnabled(): boolean;
  30817. static set LightmapTextureEnabled(value: boolean);
  30818. /**
  30819. * Are refraction textures enabled in the application.
  30820. */
  30821. static get RefractionTextureEnabled(): boolean;
  30822. static set RefractionTextureEnabled(value: boolean);
  30823. /**
  30824. * Are color grading textures enabled in the application.
  30825. */
  30826. static get ColorGradingTextureEnabled(): boolean;
  30827. static set ColorGradingTextureEnabled(value: boolean);
  30828. /**
  30829. * Are fresnels enabled in the application.
  30830. */
  30831. static get FresnelEnabled(): boolean;
  30832. static set FresnelEnabled(value: boolean);
  30833. }
  30834. }
  30835. declare module "babylonjs/Particles/solidParticleSystem" {
  30836. import { Nullable } from "babylonjs/types";
  30837. import { Mesh } from "babylonjs/Meshes/mesh";
  30838. import { Scene, IDisposable } from "babylonjs/scene";
  30839. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30840. import { Material } from "babylonjs/Materials/material";
  30841. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30842. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30843. /**
  30844. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30845. *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.
  30846. * The SPS is also a particle system. It provides some methods to manage the particles.
  30847. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30848. *
  30849. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30850. */
  30851. export class SolidParticleSystem implements IDisposable {
  30852. /**
  30853. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30854. * Example : var p = SPS.particles[i];
  30855. */
  30856. particles: SolidParticle[];
  30857. /**
  30858. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30859. */
  30860. nbParticles: number;
  30861. /**
  30862. * If the particles must ever face the camera (default false). Useful for planar particles.
  30863. */
  30864. billboard: boolean;
  30865. /**
  30866. * Recompute normals when adding a shape
  30867. */
  30868. recomputeNormals: boolean;
  30869. /**
  30870. * This a counter ofr your own usage. It's not set by any SPS functions.
  30871. */
  30872. counter: number;
  30873. /**
  30874. * The SPS name. This name is also given to the underlying mesh.
  30875. */
  30876. name: string;
  30877. /**
  30878. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30879. */
  30880. mesh: Mesh;
  30881. /**
  30882. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30883. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30884. */
  30885. vars: any;
  30886. /**
  30887. * This array is populated when the SPS is set as 'pickable'.
  30888. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30889. * Each element of this array is an object `{idx: int, faceId: int}`.
  30890. * `idx` is the picked particle index in the `SPS.particles` array
  30891. * `faceId` is the picked face index counted within this particle.
  30892. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30893. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30894. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30895. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30896. */
  30897. pickedParticles: {
  30898. idx: number;
  30899. faceId: number;
  30900. }[];
  30901. /**
  30902. * This array is populated when the SPS is set as 'pickable'
  30903. * Each key of this array is a submesh index.
  30904. * Each element of this array is a second array defined like this :
  30905. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30906. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30907. * `idx` is the picked particle index in the `SPS.particles` array
  30908. * `faceId` is the picked face index counted within this particle.
  30909. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30910. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30911. */
  30912. pickedBySubMesh: {
  30913. idx: number;
  30914. faceId: number;
  30915. }[][];
  30916. /**
  30917. * This array is populated when `enableDepthSort` is set to true.
  30918. * Each element of this array is an instance of the class DepthSortedParticle.
  30919. */
  30920. depthSortedParticles: DepthSortedParticle[];
  30921. /**
  30922. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30923. * @hidden
  30924. */
  30925. _bSphereOnly: boolean;
  30926. /**
  30927. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30928. * @hidden
  30929. */
  30930. _bSphereRadiusFactor: number;
  30931. private _scene;
  30932. private _positions;
  30933. private _indices;
  30934. private _normals;
  30935. private _colors;
  30936. private _uvs;
  30937. private _indices32;
  30938. private _positions32;
  30939. private _normals32;
  30940. private _fixedNormal32;
  30941. private _colors32;
  30942. private _uvs32;
  30943. private _index;
  30944. private _updatable;
  30945. private _pickable;
  30946. private _isVisibilityBoxLocked;
  30947. private _alwaysVisible;
  30948. private _depthSort;
  30949. private _expandable;
  30950. private _shapeCounter;
  30951. private _copy;
  30952. private _color;
  30953. private _computeParticleColor;
  30954. private _computeParticleTexture;
  30955. private _computeParticleRotation;
  30956. private _computeParticleVertex;
  30957. private _computeBoundingBox;
  30958. private _depthSortParticles;
  30959. private _camera;
  30960. private _mustUnrotateFixedNormals;
  30961. private _particlesIntersect;
  30962. private _needs32Bits;
  30963. private _isNotBuilt;
  30964. private _lastParticleId;
  30965. private _idxOfId;
  30966. private _multimaterialEnabled;
  30967. private _useModelMaterial;
  30968. private _indicesByMaterial;
  30969. private _materialIndexes;
  30970. private _depthSortFunction;
  30971. private _materialSortFunction;
  30972. private _materials;
  30973. private _multimaterial;
  30974. private _materialIndexesById;
  30975. private _defaultMaterial;
  30976. private _autoUpdateSubMeshes;
  30977. private _tmpVertex;
  30978. /**
  30979. * Creates a SPS (Solid Particle System) object.
  30980. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30981. * @param scene (Scene) is the scene in which the SPS is added.
  30982. * @param options defines the options of the sps e.g.
  30983. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30984. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30985. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30986. * * 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.
  30987. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30988. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30989. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30990. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30991. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30992. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30993. */
  30994. constructor(name: string, scene: Scene, options?: {
  30995. updatable?: boolean;
  30996. isPickable?: boolean;
  30997. enableDepthSort?: boolean;
  30998. particleIntersection?: boolean;
  30999. boundingSphereOnly?: boolean;
  31000. bSphereRadiusFactor?: number;
  31001. expandable?: boolean;
  31002. useModelMaterial?: boolean;
  31003. enableMultiMaterial?: boolean;
  31004. });
  31005. /**
  31006. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31007. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31008. * @returns the created mesh
  31009. */
  31010. buildMesh(): Mesh;
  31011. /**
  31012. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31013. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31014. * Thus the particles generated from `digest()` have their property `position` set yet.
  31015. * @param mesh ( Mesh ) is the mesh to be digested
  31016. * @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
  31017. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31018. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31019. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31020. * @returns the current SPS
  31021. */
  31022. digest(mesh: Mesh, options?: {
  31023. facetNb?: number;
  31024. number?: number;
  31025. delta?: number;
  31026. storage?: [];
  31027. }): SolidParticleSystem;
  31028. /**
  31029. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31030. * @hidden
  31031. */
  31032. private _unrotateFixedNormals;
  31033. /**
  31034. * Resets the temporary working copy particle
  31035. * @hidden
  31036. */
  31037. private _resetCopy;
  31038. /**
  31039. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31040. * @param p the current index in the positions array to be updated
  31041. * @param ind the current index in the indices array
  31042. * @param shape a Vector3 array, the shape geometry
  31043. * @param positions the positions array to be updated
  31044. * @param meshInd the shape indices array
  31045. * @param indices the indices array to be updated
  31046. * @param meshUV the shape uv array
  31047. * @param uvs the uv array to be updated
  31048. * @param meshCol the shape color array
  31049. * @param colors the color array to be updated
  31050. * @param meshNor the shape normals array
  31051. * @param normals the normals array to be updated
  31052. * @param idx the particle index
  31053. * @param idxInShape the particle index in its shape
  31054. * @param options the addShape() method passed options
  31055. * @model the particle model
  31056. * @hidden
  31057. */
  31058. private _meshBuilder;
  31059. /**
  31060. * Returns a shape Vector3 array from positions float array
  31061. * @param positions float array
  31062. * @returns a vector3 array
  31063. * @hidden
  31064. */
  31065. private _posToShape;
  31066. /**
  31067. * Returns a shapeUV array from a float uvs (array deep copy)
  31068. * @param uvs as a float array
  31069. * @returns a shapeUV array
  31070. * @hidden
  31071. */
  31072. private _uvsToShapeUV;
  31073. /**
  31074. * Adds a new particle object in the particles array
  31075. * @param idx particle index in particles array
  31076. * @param id particle id
  31077. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31078. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31079. * @param model particle ModelShape object
  31080. * @param shapeId model shape identifier
  31081. * @param idxInShape index of the particle in the current model
  31082. * @param bInfo model bounding info object
  31083. * @param storage target storage array, if any
  31084. * @hidden
  31085. */
  31086. private _addParticle;
  31087. /**
  31088. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31089. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31090. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31091. * @param nb (positive integer) the number of particles to be created from this model
  31092. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31093. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31094. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31095. * @returns the number of shapes in the system
  31096. */
  31097. addShape(mesh: Mesh, nb: number, options?: {
  31098. positionFunction?: any;
  31099. vertexFunction?: any;
  31100. storage?: [];
  31101. }): number;
  31102. /**
  31103. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31104. * @hidden
  31105. */
  31106. private _rebuildParticle;
  31107. /**
  31108. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31109. * @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.
  31110. * @returns the SPS.
  31111. */
  31112. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31113. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31114. * Returns an array with the removed particles.
  31115. * 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.
  31116. * The SPS can't be empty so at least one particle needs to remain in place.
  31117. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31118. * @param start index of the first particle to remove
  31119. * @param end index of the last particle to remove (included)
  31120. * @returns an array populated with the removed particles
  31121. */
  31122. removeParticles(start: number, end: number): SolidParticle[];
  31123. /**
  31124. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31125. * @param solidParticleArray an array populated with Solid Particles objects
  31126. * @returns the SPS
  31127. */
  31128. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31129. /**
  31130. * Creates a new particle and modifies the SPS mesh geometry :
  31131. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31132. * - calls _addParticle() to populate the particle array
  31133. * factorized code from addShape() and insertParticlesFromArray()
  31134. * @param idx particle index in the particles array
  31135. * @param i particle index in its shape
  31136. * @param modelShape particle ModelShape object
  31137. * @param shape shape vertex array
  31138. * @param meshInd shape indices array
  31139. * @param meshUV shape uv array
  31140. * @param meshCol shape color array
  31141. * @param meshNor shape normals array
  31142. * @param bbInfo shape bounding info
  31143. * @param storage target particle storage
  31144. * @options addShape() passed options
  31145. * @hidden
  31146. */
  31147. private _insertNewParticle;
  31148. /**
  31149. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31150. * This method calls `updateParticle()` for each particle of the SPS.
  31151. * For an animated SPS, it is usually called within the render loop.
  31152. * 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.
  31153. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31154. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31155. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31156. * @returns the SPS.
  31157. */
  31158. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31159. /**
  31160. * Disposes the SPS.
  31161. */
  31162. dispose(): void;
  31163. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31164. * idx is the particle index in the SPS
  31165. * faceId is the picked face index counted within this particle.
  31166. * Returns null if the pickInfo can't identify a picked particle.
  31167. * @param pickingInfo (PickingInfo object)
  31168. * @returns {idx: number, faceId: number} or null
  31169. */
  31170. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31171. idx: number;
  31172. faceId: number;
  31173. }>;
  31174. /**
  31175. * Returns a SolidParticle object from its identifier : particle.id
  31176. * @param id (integer) the particle Id
  31177. * @returns the searched particle or null if not found in the SPS.
  31178. */
  31179. getParticleById(id: number): Nullable<SolidParticle>;
  31180. /**
  31181. * Returns a new array populated with the particles having the passed shapeId.
  31182. * @param shapeId (integer) the shape identifier
  31183. * @returns a new solid particle array
  31184. */
  31185. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31186. /**
  31187. * Populates the passed array "ref" with the particles having the passed shapeId.
  31188. * @param shapeId the shape identifier
  31189. * @returns the SPS
  31190. * @param ref
  31191. */
  31192. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31193. /**
  31194. * Computes the required SubMeshes according the materials assigned to the particles.
  31195. * @returns the solid particle system.
  31196. * Does nothing if called before the SPS mesh is built.
  31197. */
  31198. computeSubMeshes(): SolidParticleSystem;
  31199. /**
  31200. * Sorts the solid particles by material when MultiMaterial is enabled.
  31201. * Updates the indices32 array.
  31202. * Updates the indicesByMaterial array.
  31203. * Updates the mesh indices array.
  31204. * @returns the SPS
  31205. * @hidden
  31206. */
  31207. private _sortParticlesByMaterial;
  31208. /**
  31209. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31210. * @hidden
  31211. */
  31212. private _setMaterialIndexesById;
  31213. /**
  31214. * Returns an array with unique values of Materials from the passed array
  31215. * @param array the material array to be checked and filtered
  31216. * @hidden
  31217. */
  31218. private _filterUniqueMaterialId;
  31219. /**
  31220. * Sets a new Standard Material as _defaultMaterial if not already set.
  31221. * @hidden
  31222. */
  31223. private _setDefaultMaterial;
  31224. /**
  31225. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31226. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31227. * @returns the SPS.
  31228. */
  31229. refreshVisibleSize(): SolidParticleSystem;
  31230. /**
  31231. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31232. * @param size the size (float) of the visibility box
  31233. * note : this doesn't lock the SPS mesh bounding box.
  31234. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31235. */
  31236. setVisibilityBox(size: number): void;
  31237. /**
  31238. * Gets whether the SPS as always visible or not
  31239. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31240. */
  31241. get isAlwaysVisible(): boolean;
  31242. /**
  31243. * Sets the SPS as always visible or not
  31244. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31245. */
  31246. set isAlwaysVisible(val: boolean);
  31247. /**
  31248. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31250. */
  31251. set isVisibilityBoxLocked(val: boolean);
  31252. /**
  31253. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31255. */
  31256. get isVisibilityBoxLocked(): boolean;
  31257. /**
  31258. * Tells to `setParticles()` to compute the particle rotations or not.
  31259. * Default value : true. The SPS is faster when it's set to false.
  31260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31261. */
  31262. set computeParticleRotation(val: boolean);
  31263. /**
  31264. * Tells to `setParticles()` to compute the particle colors or not.
  31265. * Default value : true. The SPS is faster when it's set to false.
  31266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31267. */
  31268. set computeParticleColor(val: boolean);
  31269. set computeParticleTexture(val: boolean);
  31270. /**
  31271. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31272. * Default value : false. The SPS is faster when it's set to false.
  31273. * Note : the particle custom vertex positions aren't stored values.
  31274. */
  31275. set computeParticleVertex(val: boolean);
  31276. /**
  31277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31278. */
  31279. set computeBoundingBox(val: boolean);
  31280. /**
  31281. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31282. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31283. * Default : `true`
  31284. */
  31285. set depthSortParticles(val: boolean);
  31286. /**
  31287. * Gets if `setParticles()` computes the particle rotations or not.
  31288. * Default value : true. The SPS is faster when it's set to false.
  31289. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31290. */
  31291. get computeParticleRotation(): boolean;
  31292. /**
  31293. * Gets if `setParticles()` computes the particle colors or not.
  31294. * Default value : true. The SPS is faster when it's set to false.
  31295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31296. */
  31297. get computeParticleColor(): boolean;
  31298. /**
  31299. * Gets if `setParticles()` computes the particle textures or not.
  31300. * Default value : true. The SPS is faster when it's set to false.
  31301. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31302. */
  31303. get computeParticleTexture(): boolean;
  31304. /**
  31305. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31306. * Default value : false. The SPS is faster when it's set to false.
  31307. * Note : the particle custom vertex positions aren't stored values.
  31308. */
  31309. get computeParticleVertex(): boolean;
  31310. /**
  31311. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31312. */
  31313. get computeBoundingBox(): boolean;
  31314. /**
  31315. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31316. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31317. * Default : `true`
  31318. */
  31319. get depthSortParticles(): boolean;
  31320. /**
  31321. * Gets if the SPS is created as expandable at construction time.
  31322. * Default : `false`
  31323. */
  31324. get expandable(): boolean;
  31325. /**
  31326. * Gets if the SPS supports the Multi Materials
  31327. */
  31328. get multimaterialEnabled(): boolean;
  31329. /**
  31330. * Gets if the SPS uses the model materials for its own multimaterial.
  31331. */
  31332. get useModelMaterial(): boolean;
  31333. /**
  31334. * The SPS used material array.
  31335. */
  31336. get materials(): Material[];
  31337. /**
  31338. * Sets the SPS MultiMaterial from the passed materials.
  31339. * Note : the passed array is internally copied and not used then by reference.
  31340. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31341. */
  31342. setMultiMaterial(materials: Material[]): void;
  31343. /**
  31344. * The SPS computed multimaterial object
  31345. */
  31346. get multimaterial(): MultiMaterial;
  31347. set multimaterial(mm: MultiMaterial);
  31348. /**
  31349. * If the subMeshes must be updated on the next call to setParticles()
  31350. */
  31351. get autoUpdateSubMeshes(): boolean;
  31352. set autoUpdateSubMeshes(val: boolean);
  31353. /**
  31354. * This function does nothing. It may be overwritten to set all the particle first values.
  31355. * The SPS doesn't call this function, you may have to call it by your own.
  31356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31357. */
  31358. initParticles(): void;
  31359. /**
  31360. * This function does nothing. It may be overwritten to recycle a particle.
  31361. * The SPS doesn't call this function, you may have to call it by your own.
  31362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31363. * @param particle The particle to recycle
  31364. * @returns the recycled particle
  31365. */
  31366. recycleParticle(particle: SolidParticle): SolidParticle;
  31367. /**
  31368. * Updates a particle : this function should be overwritten by the user.
  31369. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31370. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31371. * @example : just set a particle position or velocity and recycle conditions
  31372. * @param particle The particle to update
  31373. * @returns the updated particle
  31374. */
  31375. updateParticle(particle: SolidParticle): SolidParticle;
  31376. /**
  31377. * Updates a vertex of a particle : it can be overwritten by the user.
  31378. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31379. * @param particle the current particle
  31380. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31381. * @param pt the index of the current vertex in the particle shape
  31382. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31383. * @example : just set a vertex particle position or color
  31384. * @returns the sps
  31385. */
  31386. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31387. /**
  31388. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31389. * This does nothing and may be overwritten by the user.
  31390. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31391. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31392. * @param update the boolean update value actually passed to setParticles()
  31393. */
  31394. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31395. /**
  31396. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31397. * This will be passed three parameters.
  31398. * This does nothing and may be overwritten by the user.
  31399. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31401. * @param update the boolean update value actually passed to setParticles()
  31402. */
  31403. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31404. }
  31405. }
  31406. declare module "babylonjs/Particles/solidParticle" {
  31407. import { Nullable } from "babylonjs/types";
  31408. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31409. import { Color4 } from "babylonjs/Maths/math.color";
  31410. import { Mesh } from "babylonjs/Meshes/mesh";
  31411. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31412. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31413. import { Plane } from "babylonjs/Maths/math.plane";
  31414. import { Material } from "babylonjs/Materials/material";
  31415. /**
  31416. * Represents one particle of a solid particle system.
  31417. */
  31418. export class SolidParticle {
  31419. /**
  31420. * particle global index
  31421. */
  31422. idx: number;
  31423. /**
  31424. * particle identifier
  31425. */
  31426. id: number;
  31427. /**
  31428. * The color of the particle
  31429. */
  31430. color: Nullable<Color4>;
  31431. /**
  31432. * The world space position of the particle.
  31433. */
  31434. position: Vector3;
  31435. /**
  31436. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31437. */
  31438. rotation: Vector3;
  31439. /**
  31440. * The world space rotation quaternion of the particle.
  31441. */
  31442. rotationQuaternion: Nullable<Quaternion>;
  31443. /**
  31444. * The scaling of the particle.
  31445. */
  31446. scaling: Vector3;
  31447. /**
  31448. * The uvs of the particle.
  31449. */
  31450. uvs: Vector4;
  31451. /**
  31452. * The current speed of the particle.
  31453. */
  31454. velocity: Vector3;
  31455. /**
  31456. * The pivot point in the particle local space.
  31457. */
  31458. pivot: Vector3;
  31459. /**
  31460. * Must the particle be translated from its pivot point in its local space ?
  31461. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31462. * Default : false
  31463. */
  31464. translateFromPivot: boolean;
  31465. /**
  31466. * Is the particle active or not ?
  31467. */
  31468. alive: boolean;
  31469. /**
  31470. * Is the particle visible or not ?
  31471. */
  31472. isVisible: boolean;
  31473. /**
  31474. * Index of this particle in the global "positions" array (Internal use)
  31475. * @hidden
  31476. */
  31477. _pos: number;
  31478. /**
  31479. * @hidden Index of this particle in the global "indices" array (Internal use)
  31480. */
  31481. _ind: number;
  31482. /**
  31483. * @hidden ModelShape of this particle (Internal use)
  31484. */
  31485. _model: ModelShape;
  31486. /**
  31487. * ModelShape id of this particle
  31488. */
  31489. shapeId: number;
  31490. /**
  31491. * Index of the particle in its shape id
  31492. */
  31493. idxInShape: number;
  31494. /**
  31495. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31496. */
  31497. _modelBoundingInfo: BoundingInfo;
  31498. /**
  31499. * @hidden Particle BoundingInfo object (Internal use)
  31500. */
  31501. _boundingInfo: BoundingInfo;
  31502. /**
  31503. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31504. */
  31505. _sps: SolidParticleSystem;
  31506. /**
  31507. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31508. */
  31509. _stillInvisible: boolean;
  31510. /**
  31511. * @hidden Last computed particle rotation matrix
  31512. */
  31513. _rotationMatrix: number[];
  31514. /**
  31515. * Parent particle Id, if any.
  31516. * Default null.
  31517. */
  31518. parentId: Nullable<number>;
  31519. /**
  31520. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31521. */
  31522. materialIndex: Nullable<number>;
  31523. /**
  31524. * Custom object or properties.
  31525. */
  31526. props: Nullable<any>;
  31527. /**
  31528. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31529. * The possible values are :
  31530. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31531. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31532. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31534. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31535. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31536. * */
  31537. cullingStrategy: number;
  31538. /**
  31539. * @hidden Internal global position in the SPS.
  31540. */
  31541. _globalPosition: Vector3;
  31542. /**
  31543. * Creates a Solid Particle object.
  31544. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31545. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31546. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31547. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31548. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31549. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31550. * @param shapeId (integer) is the model shape identifier in the SPS.
  31551. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31552. * @param sps defines the sps it is associated to
  31553. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31554. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31555. */
  31556. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31557. /**
  31558. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31559. * @param target the particle target
  31560. * @returns the current particle
  31561. */
  31562. copyToRef(target: SolidParticle): SolidParticle;
  31563. /**
  31564. * Legacy support, changed scale to scaling
  31565. */
  31566. get scale(): Vector3;
  31567. /**
  31568. * Legacy support, changed scale to scaling
  31569. */
  31570. set scale(scale: Vector3);
  31571. /**
  31572. * Legacy support, changed quaternion to rotationQuaternion
  31573. */
  31574. get quaternion(): Nullable<Quaternion>;
  31575. /**
  31576. * Legacy support, changed quaternion to rotationQuaternion
  31577. */
  31578. set quaternion(q: Nullable<Quaternion>);
  31579. /**
  31580. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31581. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31582. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31583. * @returns true if it intersects
  31584. */
  31585. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31586. /**
  31587. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31588. * A particle is in the frustum if its bounding box intersects the frustum
  31589. * @param frustumPlanes defines the frustum to test
  31590. * @returns true if the particle is in the frustum planes
  31591. */
  31592. isInFrustum(frustumPlanes: Plane[]): boolean;
  31593. /**
  31594. * get the rotation matrix of the particle
  31595. * @hidden
  31596. */
  31597. getRotationMatrix(m: Matrix): void;
  31598. }
  31599. /**
  31600. * Represents the shape of the model used by one particle of a solid particle system.
  31601. * SPS internal tool, don't use it manually.
  31602. */
  31603. export class ModelShape {
  31604. /**
  31605. * The shape id
  31606. * @hidden
  31607. */
  31608. shapeID: number;
  31609. /**
  31610. * flat array of model positions (internal use)
  31611. * @hidden
  31612. */
  31613. _shape: Vector3[];
  31614. /**
  31615. * flat array of model UVs (internal use)
  31616. * @hidden
  31617. */
  31618. _shapeUV: number[];
  31619. /**
  31620. * color array of the model
  31621. * @hidden
  31622. */
  31623. _shapeColors: number[];
  31624. /**
  31625. * indices array of the model
  31626. * @hidden
  31627. */
  31628. _indices: number[];
  31629. /**
  31630. * normals array of the model
  31631. * @hidden
  31632. */
  31633. _normals: number[];
  31634. /**
  31635. * length of the shape in the model indices array (internal use)
  31636. * @hidden
  31637. */
  31638. _indicesLength: number;
  31639. /**
  31640. * Custom position function (internal use)
  31641. * @hidden
  31642. */
  31643. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31644. /**
  31645. * Custom vertex function (internal use)
  31646. * @hidden
  31647. */
  31648. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31649. /**
  31650. * Model material (internal use)
  31651. * @hidden
  31652. */
  31653. _material: Nullable<Material>;
  31654. /**
  31655. * 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.
  31656. * SPS internal tool, don't use it manually.
  31657. * @hidden
  31658. */
  31659. 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>);
  31660. }
  31661. /**
  31662. * Represents a Depth Sorted Particle in the solid particle system.
  31663. * @hidden
  31664. */
  31665. export class DepthSortedParticle {
  31666. /**
  31667. * Particle index
  31668. */
  31669. idx: number;
  31670. /**
  31671. * Index of the particle in the "indices" array
  31672. */
  31673. ind: number;
  31674. /**
  31675. * Length of the particle shape in the "indices" array
  31676. */
  31677. indicesLength: number;
  31678. /**
  31679. * Squared distance from the particle to the camera
  31680. */
  31681. sqDistance: number;
  31682. /**
  31683. * Material index when used with MultiMaterials
  31684. */
  31685. materialIndex: number;
  31686. /**
  31687. * Creates a new sorted particle
  31688. * @param materialIndex
  31689. */
  31690. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31691. }
  31692. /**
  31693. * Represents a solid particle vertex
  31694. */
  31695. export class SolidParticleVertex {
  31696. /**
  31697. * Vertex position
  31698. */
  31699. position: Vector3;
  31700. /**
  31701. * Vertex color
  31702. */
  31703. color: Color4;
  31704. /**
  31705. * Vertex UV
  31706. */
  31707. uv: Vector2;
  31708. /**
  31709. * Creates a new solid particle vertex
  31710. */
  31711. constructor();
  31712. /** Vertex x coordinate */
  31713. get x(): number;
  31714. set x(val: number);
  31715. /** Vertex y coordinate */
  31716. get y(): number;
  31717. set y(val: number);
  31718. /** Vertex z coordinate */
  31719. get z(): number;
  31720. set z(val: number);
  31721. }
  31722. }
  31723. declare module "babylonjs/Collisions/meshCollisionData" {
  31724. import { Collider } from "babylonjs/Collisions/collider";
  31725. import { Vector3 } from "babylonjs/Maths/math.vector";
  31726. import { Nullable } from "babylonjs/types";
  31727. import { Observer } from "babylonjs/Misc/observable";
  31728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31729. /**
  31730. * @hidden
  31731. */
  31732. export class _MeshCollisionData {
  31733. _checkCollisions: boolean;
  31734. _collisionMask: number;
  31735. _collisionGroup: number;
  31736. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31737. _collider: Nullable<Collider>;
  31738. _oldPositionForCollisions: Vector3;
  31739. _diffPositionForCollisions: Vector3;
  31740. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31741. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31742. }
  31743. }
  31744. declare module "babylonjs/Meshes/abstractMesh" {
  31745. import { Observable } from "babylonjs/Misc/observable";
  31746. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31747. import { Camera } from "babylonjs/Cameras/camera";
  31748. import { Scene, IDisposable } from "babylonjs/scene";
  31749. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31750. import { Node } from "babylonjs/node";
  31751. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31752. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31754. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31755. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31756. import { Material } from "babylonjs/Materials/material";
  31757. import { Light } from "babylonjs/Lights/light";
  31758. import { Skeleton } from "babylonjs/Bones/skeleton";
  31759. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31760. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31761. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31762. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31763. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31764. import { Plane } from "babylonjs/Maths/math.plane";
  31765. import { Ray } from "babylonjs/Culling/ray";
  31766. import { Collider } from "babylonjs/Collisions/collider";
  31767. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31768. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31769. /** @hidden */
  31770. class _FacetDataStorage {
  31771. facetPositions: Vector3[];
  31772. facetNormals: Vector3[];
  31773. facetPartitioning: number[][];
  31774. facetNb: number;
  31775. partitioningSubdivisions: number;
  31776. partitioningBBoxRatio: number;
  31777. facetDataEnabled: boolean;
  31778. facetParameters: any;
  31779. bbSize: Vector3;
  31780. subDiv: {
  31781. max: number;
  31782. X: number;
  31783. Y: number;
  31784. Z: number;
  31785. };
  31786. facetDepthSort: boolean;
  31787. facetDepthSortEnabled: boolean;
  31788. depthSortedIndices: IndicesArray;
  31789. depthSortedFacets: {
  31790. ind: number;
  31791. sqDistance: number;
  31792. }[];
  31793. facetDepthSortFunction: (f1: {
  31794. ind: number;
  31795. sqDistance: number;
  31796. }, f2: {
  31797. ind: number;
  31798. sqDistance: number;
  31799. }) => number;
  31800. facetDepthSortFrom: Vector3;
  31801. facetDepthSortOrigin: Vector3;
  31802. invertedMatrix: Matrix;
  31803. }
  31804. /**
  31805. * @hidden
  31806. **/
  31807. class _InternalAbstractMeshDataInfo {
  31808. _hasVertexAlpha: boolean;
  31809. _useVertexColors: boolean;
  31810. _numBoneInfluencers: number;
  31811. _applyFog: boolean;
  31812. _receiveShadows: boolean;
  31813. _facetData: _FacetDataStorage;
  31814. _visibility: number;
  31815. _skeleton: Nullable<Skeleton>;
  31816. _layerMask: number;
  31817. _computeBonesUsingShaders: boolean;
  31818. _isActive: boolean;
  31819. _onlyForInstances: boolean;
  31820. _isActiveIntermediate: boolean;
  31821. _onlyForInstancesIntermediate: boolean;
  31822. _actAsRegularMesh: boolean;
  31823. }
  31824. /**
  31825. * Class used to store all common mesh properties
  31826. */
  31827. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31828. /** No occlusion */
  31829. static OCCLUSION_TYPE_NONE: number;
  31830. /** Occlusion set to optimisitic */
  31831. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31832. /** Occlusion set to strict */
  31833. static OCCLUSION_TYPE_STRICT: number;
  31834. /** Use an accurante occlusion algorithm */
  31835. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31836. /** Use a conservative occlusion algorithm */
  31837. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31838. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31839. * Test order :
  31840. * Is the bounding sphere outside the frustum ?
  31841. * If not, are the bounding box vertices outside the frustum ?
  31842. * It not, then the cullable object is in the frustum.
  31843. */
  31844. static readonly CULLINGSTRATEGY_STANDARD: number;
  31845. /** Culling strategy : Bounding Sphere Only.
  31846. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31847. * It's also less accurate than the standard because some not visible objects can still be selected.
  31848. * Test : is the bounding sphere outside the frustum ?
  31849. * If not, then the cullable object is in the frustum.
  31850. */
  31851. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31852. /** Culling strategy : Optimistic Inclusion.
  31853. * This in an inclusion test first, then the standard exclusion test.
  31854. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31855. * 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.
  31856. * Anyway, it's as accurate as the standard strategy.
  31857. * Test :
  31858. * Is the cullable object bounding sphere center in the frustum ?
  31859. * If not, apply the default culling strategy.
  31860. */
  31861. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31862. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31863. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31864. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31865. * 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.
  31866. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31867. * Test :
  31868. * Is the cullable object bounding sphere center in the frustum ?
  31869. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31870. */
  31871. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31872. /**
  31873. * No billboard
  31874. */
  31875. static get BILLBOARDMODE_NONE(): number;
  31876. /** Billboard on X axis */
  31877. static get BILLBOARDMODE_X(): number;
  31878. /** Billboard on Y axis */
  31879. static get BILLBOARDMODE_Y(): number;
  31880. /** Billboard on Z axis */
  31881. static get BILLBOARDMODE_Z(): number;
  31882. /** Billboard on all axes */
  31883. static get BILLBOARDMODE_ALL(): number;
  31884. /** Billboard on using position instead of orientation */
  31885. static get BILLBOARDMODE_USE_POSITION(): number;
  31886. /** @hidden */
  31887. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31888. /**
  31889. * The culling strategy to use to check whether the mesh must be rendered or not.
  31890. * This value can be changed at any time and will be used on the next render mesh selection.
  31891. * The possible values are :
  31892. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31893. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31894. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31895. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31896. * Please read each static variable documentation to get details about the culling process.
  31897. * */
  31898. cullingStrategy: number;
  31899. /**
  31900. * Gets the number of facets in the mesh
  31901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31902. */
  31903. get facetNb(): number;
  31904. /**
  31905. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31907. */
  31908. get partitioningSubdivisions(): number;
  31909. set partitioningSubdivisions(nb: number);
  31910. /**
  31911. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31912. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31914. */
  31915. get partitioningBBoxRatio(): number;
  31916. set partitioningBBoxRatio(ratio: number);
  31917. /**
  31918. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31919. * Works only for updatable meshes.
  31920. * Doesn't work with multi-materials
  31921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31922. */
  31923. get mustDepthSortFacets(): boolean;
  31924. set mustDepthSortFacets(sort: boolean);
  31925. /**
  31926. * The location (Vector3) where the facet depth sort must be computed from.
  31927. * By default, the active camera position.
  31928. * Used only when facet depth sort is enabled
  31929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31930. */
  31931. get facetDepthSortFrom(): Vector3;
  31932. set facetDepthSortFrom(location: Vector3);
  31933. /**
  31934. * gets a boolean indicating if facetData is enabled
  31935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31936. */
  31937. get isFacetDataEnabled(): boolean;
  31938. /** @hidden */
  31939. _updateNonUniformScalingState(value: boolean): boolean;
  31940. /**
  31941. * An event triggered when this mesh collides with another one
  31942. */
  31943. onCollideObservable: Observable<AbstractMesh>;
  31944. /** Set a function to call when this mesh collides with another one */
  31945. set onCollide(callback: () => void);
  31946. /**
  31947. * An event triggered when the collision's position changes
  31948. */
  31949. onCollisionPositionChangeObservable: Observable<Vector3>;
  31950. /** Set a function to call when the collision's position changes */
  31951. set onCollisionPositionChange(callback: () => void);
  31952. /**
  31953. * An event triggered when material is changed
  31954. */
  31955. onMaterialChangedObservable: Observable<AbstractMesh>;
  31956. /**
  31957. * Gets or sets the orientation for POV movement & rotation
  31958. */
  31959. definedFacingForward: boolean;
  31960. /** @hidden */
  31961. _occlusionQuery: Nullable<WebGLQuery>;
  31962. /** @hidden */
  31963. _renderingGroup: Nullable<RenderingGroup>;
  31964. /**
  31965. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31966. */
  31967. get visibility(): number;
  31968. /**
  31969. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31970. */
  31971. set visibility(value: number);
  31972. /** Gets or sets the alpha index used to sort transparent meshes
  31973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31974. */
  31975. alphaIndex: number;
  31976. /**
  31977. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31978. */
  31979. isVisible: boolean;
  31980. /**
  31981. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31982. */
  31983. isPickable: boolean;
  31984. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31985. showSubMeshesBoundingBox: boolean;
  31986. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31987. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31988. */
  31989. isBlocker: boolean;
  31990. /**
  31991. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31992. */
  31993. enablePointerMoveEvents: boolean;
  31994. /**
  31995. * Specifies the rendering group id for this mesh (0 by default)
  31996. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31997. */
  31998. renderingGroupId: number;
  31999. private _material;
  32000. /** Gets or sets current material */
  32001. get material(): Nullable<Material>;
  32002. set material(value: Nullable<Material>);
  32003. /**
  32004. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32005. * @see http://doc.babylonjs.com/babylon101/shadows
  32006. */
  32007. get receiveShadows(): boolean;
  32008. set receiveShadows(value: boolean);
  32009. /** Defines color to use when rendering outline */
  32010. outlineColor: Color3;
  32011. /** Define width to use when rendering outline */
  32012. outlineWidth: number;
  32013. /** Defines color to use when rendering overlay */
  32014. overlayColor: Color3;
  32015. /** Defines alpha to use when rendering overlay */
  32016. overlayAlpha: number;
  32017. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32018. get hasVertexAlpha(): boolean;
  32019. set hasVertexAlpha(value: boolean);
  32020. /** 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) */
  32021. get useVertexColors(): boolean;
  32022. set useVertexColors(value: boolean);
  32023. /**
  32024. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32025. */
  32026. get computeBonesUsingShaders(): boolean;
  32027. set computeBonesUsingShaders(value: boolean);
  32028. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32029. get numBoneInfluencers(): number;
  32030. set numBoneInfluencers(value: number);
  32031. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32032. get applyFog(): boolean;
  32033. set applyFog(value: boolean);
  32034. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32035. useOctreeForRenderingSelection: boolean;
  32036. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32037. useOctreeForPicking: boolean;
  32038. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32039. useOctreeForCollisions: boolean;
  32040. /**
  32041. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32042. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32043. */
  32044. get layerMask(): number;
  32045. set layerMask(value: number);
  32046. /**
  32047. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32048. */
  32049. alwaysSelectAsActiveMesh: boolean;
  32050. /**
  32051. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32052. */
  32053. doNotSyncBoundingInfo: boolean;
  32054. /**
  32055. * Gets or sets the current action manager
  32056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32057. */
  32058. actionManager: Nullable<AbstractActionManager>;
  32059. private _meshCollisionData;
  32060. /**
  32061. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32063. */
  32064. ellipsoid: Vector3;
  32065. /**
  32066. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32068. */
  32069. ellipsoidOffset: Vector3;
  32070. /**
  32071. * Gets or sets a collision mask used to mask collisions (default is -1).
  32072. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32073. */
  32074. get collisionMask(): number;
  32075. set collisionMask(mask: number);
  32076. /**
  32077. * Gets or sets the current collision group mask (-1 by default).
  32078. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32079. */
  32080. get collisionGroup(): number;
  32081. set collisionGroup(mask: number);
  32082. /**
  32083. * Gets or sets current surrounding meshes (null by default).
  32084. *
  32085. * By default collision detection is tested against every mesh in the scene.
  32086. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32087. * meshes will be tested for the collision.
  32088. *
  32089. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32090. */
  32091. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32092. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32093. /**
  32094. * Defines edge width used when edgesRenderer is enabled
  32095. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32096. */
  32097. edgesWidth: number;
  32098. /**
  32099. * Defines edge color used when edgesRenderer is enabled
  32100. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32101. */
  32102. edgesColor: Color4;
  32103. /** @hidden */
  32104. _edgesRenderer: Nullable<IEdgesRenderer>;
  32105. /** @hidden */
  32106. _masterMesh: Nullable<AbstractMesh>;
  32107. /** @hidden */
  32108. _boundingInfo: Nullable<BoundingInfo>;
  32109. /** @hidden */
  32110. _renderId: number;
  32111. /**
  32112. * Gets or sets the list of subMeshes
  32113. * @see http://doc.babylonjs.com/how_to/multi_materials
  32114. */
  32115. subMeshes: SubMesh[];
  32116. /** @hidden */
  32117. _intersectionsInProgress: AbstractMesh[];
  32118. /** @hidden */
  32119. _unIndexed: boolean;
  32120. /** @hidden */
  32121. _lightSources: Light[];
  32122. /** Gets the list of lights affecting that mesh */
  32123. get lightSources(): Light[];
  32124. /** @hidden */
  32125. get _positions(): Nullable<Vector3[]>;
  32126. /** @hidden */
  32127. _waitingData: {
  32128. lods: Nullable<any>;
  32129. actions: Nullable<any>;
  32130. freezeWorldMatrix: Nullable<boolean>;
  32131. };
  32132. /** @hidden */
  32133. _bonesTransformMatrices: Nullable<Float32Array>;
  32134. /** @hidden */
  32135. _transformMatrixTexture: Nullable<RawTexture>;
  32136. /**
  32137. * Gets or sets a skeleton to apply skining transformations
  32138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32139. */
  32140. set skeleton(value: Nullable<Skeleton>);
  32141. get skeleton(): Nullable<Skeleton>;
  32142. /**
  32143. * An event triggered when the mesh is rebuilt.
  32144. */
  32145. onRebuildObservable: Observable<AbstractMesh>;
  32146. /**
  32147. * Creates a new AbstractMesh
  32148. * @param name defines the name of the mesh
  32149. * @param scene defines the hosting scene
  32150. */
  32151. constructor(name: string, scene?: Nullable<Scene>);
  32152. /**
  32153. * Returns the string "AbstractMesh"
  32154. * @returns "AbstractMesh"
  32155. */
  32156. getClassName(): string;
  32157. /**
  32158. * Gets a string representation of the current mesh
  32159. * @param fullDetails defines a boolean indicating if full details must be included
  32160. * @returns a string representation of the current mesh
  32161. */
  32162. toString(fullDetails?: boolean): string;
  32163. /**
  32164. * @hidden
  32165. */
  32166. protected _getEffectiveParent(): Nullable<Node>;
  32167. /** @hidden */
  32168. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32169. /** @hidden */
  32170. _rebuild(): void;
  32171. /** @hidden */
  32172. _resyncLightSources(): void;
  32173. /** @hidden */
  32174. _resyncLightSource(light: Light): void;
  32175. /** @hidden */
  32176. _unBindEffect(): void;
  32177. /** @hidden */
  32178. _removeLightSource(light: Light, dispose: boolean): void;
  32179. private _markSubMeshesAsDirty;
  32180. /** @hidden */
  32181. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32182. /** @hidden */
  32183. _markSubMeshesAsAttributesDirty(): void;
  32184. /** @hidden */
  32185. _markSubMeshesAsMiscDirty(): void;
  32186. /**
  32187. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32188. */
  32189. get scaling(): Vector3;
  32190. set scaling(newScaling: Vector3);
  32191. /**
  32192. * Returns true if the mesh is blocked. Implemented by child classes
  32193. */
  32194. get isBlocked(): boolean;
  32195. /**
  32196. * Returns the mesh itself by default. Implemented by child classes
  32197. * @param camera defines the camera to use to pick the right LOD level
  32198. * @returns the currentAbstractMesh
  32199. */
  32200. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32201. /**
  32202. * Returns 0 by default. Implemented by child classes
  32203. * @returns an integer
  32204. */
  32205. getTotalVertices(): number;
  32206. /**
  32207. * Returns a positive integer : the total number of indices in this mesh geometry.
  32208. * @returns the numner of indices or zero if the mesh has no geometry.
  32209. */
  32210. getTotalIndices(): number;
  32211. /**
  32212. * Returns null by default. Implemented by child classes
  32213. * @returns null
  32214. */
  32215. getIndices(): Nullable<IndicesArray>;
  32216. /**
  32217. * Returns the array of the requested vertex data kind. Implemented by child classes
  32218. * @param kind defines the vertex data kind to use
  32219. * @returns null
  32220. */
  32221. getVerticesData(kind: string): Nullable<FloatArray>;
  32222. /**
  32223. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32224. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32225. * Note that a new underlying VertexBuffer object is created each call.
  32226. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32227. * @param kind defines vertex data kind:
  32228. * * VertexBuffer.PositionKind
  32229. * * VertexBuffer.UVKind
  32230. * * VertexBuffer.UV2Kind
  32231. * * VertexBuffer.UV3Kind
  32232. * * VertexBuffer.UV4Kind
  32233. * * VertexBuffer.UV5Kind
  32234. * * VertexBuffer.UV6Kind
  32235. * * VertexBuffer.ColorKind
  32236. * * VertexBuffer.MatricesIndicesKind
  32237. * * VertexBuffer.MatricesIndicesExtraKind
  32238. * * VertexBuffer.MatricesWeightsKind
  32239. * * VertexBuffer.MatricesWeightsExtraKind
  32240. * @param data defines the data source
  32241. * @param updatable defines if the data must be flagged as updatable (or static)
  32242. * @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
  32243. * @returns the current mesh
  32244. */
  32245. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32246. /**
  32247. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32248. * If the mesh has no geometry, it is simply returned as it is.
  32249. * @param kind defines vertex data kind:
  32250. * * VertexBuffer.PositionKind
  32251. * * VertexBuffer.UVKind
  32252. * * VertexBuffer.UV2Kind
  32253. * * VertexBuffer.UV3Kind
  32254. * * VertexBuffer.UV4Kind
  32255. * * VertexBuffer.UV5Kind
  32256. * * VertexBuffer.UV6Kind
  32257. * * VertexBuffer.ColorKind
  32258. * * VertexBuffer.MatricesIndicesKind
  32259. * * VertexBuffer.MatricesIndicesExtraKind
  32260. * * VertexBuffer.MatricesWeightsKind
  32261. * * VertexBuffer.MatricesWeightsExtraKind
  32262. * @param data defines the data source
  32263. * @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
  32264. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32265. * @returns the current mesh
  32266. */
  32267. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32268. /**
  32269. * Sets the mesh indices,
  32270. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32271. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32272. * @param totalVertices Defines the total number of vertices
  32273. * @returns the current mesh
  32274. */
  32275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32276. /**
  32277. * Gets a boolean indicating if specific vertex data is present
  32278. * @param kind defines the vertex data kind to use
  32279. * @returns true is data kind is present
  32280. */
  32281. isVerticesDataPresent(kind: string): boolean;
  32282. /**
  32283. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32284. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32285. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32286. * @returns a BoundingInfo
  32287. */
  32288. getBoundingInfo(): BoundingInfo;
  32289. /**
  32290. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32291. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32292. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32293. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32294. * @returns the current mesh
  32295. */
  32296. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32297. /**
  32298. * Overwrite the current bounding info
  32299. * @param boundingInfo defines the new bounding info
  32300. * @returns the current mesh
  32301. */
  32302. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32303. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32304. get useBones(): boolean;
  32305. /** @hidden */
  32306. _preActivate(): void;
  32307. /** @hidden */
  32308. _preActivateForIntermediateRendering(renderId: number): void;
  32309. /** @hidden */
  32310. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32311. /** @hidden */
  32312. _postActivate(): void;
  32313. /** @hidden */
  32314. _freeze(): void;
  32315. /** @hidden */
  32316. _unFreeze(): void;
  32317. /**
  32318. * Gets the current world matrix
  32319. * @returns a Matrix
  32320. */
  32321. getWorldMatrix(): Matrix;
  32322. /** @hidden */
  32323. _getWorldMatrixDeterminant(): number;
  32324. /**
  32325. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32326. */
  32327. get isAnInstance(): boolean;
  32328. /**
  32329. * Gets a boolean indicating if this mesh has instances
  32330. */
  32331. get hasInstances(): boolean;
  32332. /**
  32333. * Perform relative position change from the point of view of behind the front of the mesh.
  32334. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32335. * Supports definition of mesh facing forward or backward
  32336. * @param amountRight defines the distance on the right axis
  32337. * @param amountUp defines the distance on the up axis
  32338. * @param amountForward defines the distance on the forward axis
  32339. * @returns the current mesh
  32340. */
  32341. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32342. /**
  32343. * Calculate relative position change from the point of view of behind the front of the mesh.
  32344. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32345. * Supports definition of mesh facing forward or backward
  32346. * @param amountRight defines the distance on the right axis
  32347. * @param amountUp defines the distance on the up axis
  32348. * @param amountForward defines the distance on the forward axis
  32349. * @returns the new displacement vector
  32350. */
  32351. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32352. /**
  32353. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32354. * Supports definition of mesh facing forward or backward
  32355. * @param flipBack defines the flip
  32356. * @param twirlClockwise defines the twirl
  32357. * @param tiltRight defines the tilt
  32358. * @returns the current mesh
  32359. */
  32360. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32361. /**
  32362. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32363. * Supports definition of mesh facing forward or backward.
  32364. * @param flipBack defines the flip
  32365. * @param twirlClockwise defines the twirl
  32366. * @param tiltRight defines the tilt
  32367. * @returns the new rotation vector
  32368. */
  32369. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32370. /**
  32371. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32372. * This means the mesh underlying bounding box and sphere are recomputed.
  32373. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32374. * @returns the current mesh
  32375. */
  32376. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32377. /** @hidden */
  32378. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32379. /** @hidden */
  32380. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32381. /** @hidden */
  32382. _updateBoundingInfo(): AbstractMesh;
  32383. /** @hidden */
  32384. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32385. /** @hidden */
  32386. protected _afterComputeWorldMatrix(): void;
  32387. /** @hidden */
  32388. get _effectiveMesh(): AbstractMesh;
  32389. /**
  32390. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32391. * A mesh is in the frustum if its bounding box intersects the frustum
  32392. * @param frustumPlanes defines the frustum to test
  32393. * @returns true if the mesh is in the frustum planes
  32394. */
  32395. isInFrustum(frustumPlanes: Plane[]): boolean;
  32396. /**
  32397. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32398. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32399. * @param frustumPlanes defines the frustum to test
  32400. * @returns true if the mesh is completely in the frustum planes
  32401. */
  32402. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32403. /**
  32404. * True if the mesh intersects another mesh or a SolidParticle object
  32405. * @param mesh defines a target mesh or SolidParticle to test
  32406. * @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)
  32407. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32408. * @returns true if there is an intersection
  32409. */
  32410. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32411. /**
  32412. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32413. * @param point defines the point to test
  32414. * @returns true if there is an intersection
  32415. */
  32416. intersectsPoint(point: Vector3): boolean;
  32417. /**
  32418. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32420. */
  32421. get checkCollisions(): boolean;
  32422. set checkCollisions(collisionEnabled: boolean);
  32423. /**
  32424. * Gets Collider object used to compute collisions (not physics)
  32425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32426. */
  32427. get collider(): Nullable<Collider>;
  32428. /**
  32429. * Move the mesh using collision engine
  32430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32431. * @param displacement defines the requested displacement vector
  32432. * @returns the current mesh
  32433. */
  32434. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32435. private _onCollisionPositionChange;
  32436. /** @hidden */
  32437. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32438. /** @hidden */
  32439. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32440. /** @hidden */
  32441. _checkCollision(collider: Collider): AbstractMesh;
  32442. /** @hidden */
  32443. _generatePointsArray(): boolean;
  32444. /**
  32445. * Checks if the passed Ray intersects with the mesh
  32446. * @param ray defines the ray to use
  32447. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32448. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32449. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32450. * @returns the picking info
  32451. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32452. */
  32453. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32454. /**
  32455. * Clones the current mesh
  32456. * @param name defines the mesh name
  32457. * @param newParent defines the new mesh parent
  32458. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32459. * @returns the new mesh
  32460. */
  32461. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32462. /**
  32463. * Disposes all the submeshes of the current meshnp
  32464. * @returns the current mesh
  32465. */
  32466. releaseSubMeshes(): AbstractMesh;
  32467. /**
  32468. * Releases resources associated with this abstract mesh.
  32469. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32470. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32471. */
  32472. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32473. /**
  32474. * Adds the passed mesh as a child to the current mesh
  32475. * @param mesh defines the child mesh
  32476. * @returns the current mesh
  32477. */
  32478. addChild(mesh: AbstractMesh): AbstractMesh;
  32479. /**
  32480. * Removes the passed mesh from the current mesh children list
  32481. * @param mesh defines the child mesh
  32482. * @returns the current mesh
  32483. */
  32484. removeChild(mesh: AbstractMesh): AbstractMesh;
  32485. /** @hidden */
  32486. private _initFacetData;
  32487. /**
  32488. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32489. * This method can be called within the render loop.
  32490. * 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
  32491. * @returns the current mesh
  32492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32493. */
  32494. updateFacetData(): AbstractMesh;
  32495. /**
  32496. * Returns the facetLocalNormals array.
  32497. * The normals are expressed in the mesh local spac
  32498. * @returns an array of Vector3
  32499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32500. */
  32501. getFacetLocalNormals(): Vector3[];
  32502. /**
  32503. * Returns the facetLocalPositions array.
  32504. * The facet positions are expressed in the mesh local space
  32505. * @returns an array of Vector3
  32506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32507. */
  32508. getFacetLocalPositions(): Vector3[];
  32509. /**
  32510. * Returns the facetLocalPartioning array
  32511. * @returns an array of array of numbers
  32512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32513. */
  32514. getFacetLocalPartitioning(): number[][];
  32515. /**
  32516. * Returns the i-th facet position in the world system.
  32517. * This method allocates a new Vector3 per call
  32518. * @param i defines the facet index
  32519. * @returns a new Vector3
  32520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32521. */
  32522. getFacetPosition(i: number): Vector3;
  32523. /**
  32524. * Sets the reference Vector3 with the i-th facet position in the world system
  32525. * @param i defines the facet index
  32526. * @param ref defines the target vector
  32527. * @returns the current mesh
  32528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32529. */
  32530. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32531. /**
  32532. * Returns the i-th facet normal in the world system.
  32533. * This method allocates a new Vector3 per call
  32534. * @param i defines the facet index
  32535. * @returns a new Vector3
  32536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32537. */
  32538. getFacetNormal(i: number): Vector3;
  32539. /**
  32540. * Sets the reference Vector3 with the i-th facet normal in the world system
  32541. * @param i defines the facet index
  32542. * @param ref defines the target vector
  32543. * @returns the current mesh
  32544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32545. */
  32546. getFacetNormalToRef(i: number, ref: Vector3): this;
  32547. /**
  32548. * 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)
  32549. * @param x defines x coordinate
  32550. * @param y defines y coordinate
  32551. * @param z defines z coordinate
  32552. * @returns the array of facet indexes
  32553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32554. */
  32555. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32556. /**
  32557. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32558. * @param projected sets as the (x,y,z) world projection on the facet
  32559. * @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
  32560. * @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
  32561. * @param x defines x coordinate
  32562. * @param y defines y coordinate
  32563. * @param z defines z coordinate
  32564. * @returns the face index if found (or null instead)
  32565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32566. */
  32567. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32568. /**
  32569. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32570. * @param projected sets as the (x,y,z) local projection on the facet
  32571. * @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
  32572. * @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
  32573. * @param x defines x coordinate
  32574. * @param y defines y coordinate
  32575. * @param z defines z coordinate
  32576. * @returns the face index if found (or null instead)
  32577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32578. */
  32579. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32580. /**
  32581. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32582. * @returns the parameters
  32583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32584. */
  32585. getFacetDataParameters(): any;
  32586. /**
  32587. * Disables the feature FacetData and frees the related memory
  32588. * @returns the current mesh
  32589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32590. */
  32591. disableFacetData(): AbstractMesh;
  32592. /**
  32593. * Updates the AbstractMesh indices array
  32594. * @param indices defines the data source
  32595. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32596. * @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)
  32597. * @returns the current mesh
  32598. */
  32599. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32600. /**
  32601. * Creates new normals data for the mesh
  32602. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32603. * @returns the current mesh
  32604. */
  32605. createNormals(updatable: boolean): AbstractMesh;
  32606. /**
  32607. * Align the mesh with a normal
  32608. * @param normal defines the normal to use
  32609. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32610. * @returns the current mesh
  32611. */
  32612. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32613. /** @hidden */
  32614. _checkOcclusionQuery(): boolean;
  32615. /**
  32616. * Disables the mesh edge rendering mode
  32617. * @returns the currentAbstractMesh
  32618. */
  32619. disableEdgesRendering(): AbstractMesh;
  32620. /**
  32621. * Enables the edge rendering mode on the mesh.
  32622. * This mode makes the mesh edges visible
  32623. * @param epsilon defines the maximal distance between two angles to detect a face
  32624. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32625. * @returns the currentAbstractMesh
  32626. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32627. */
  32628. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32629. }
  32630. }
  32631. declare module "babylonjs/Actions/actionEvent" {
  32632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32633. import { Nullable } from "babylonjs/types";
  32634. import { Sprite } from "babylonjs/Sprites/sprite";
  32635. import { Scene } from "babylonjs/scene";
  32636. import { Vector2 } from "babylonjs/Maths/math.vector";
  32637. /**
  32638. * Interface used to define ActionEvent
  32639. */
  32640. export interface IActionEvent {
  32641. /** The mesh or sprite that triggered the action */
  32642. source: any;
  32643. /** The X mouse cursor position at the time of the event */
  32644. pointerX: number;
  32645. /** The Y mouse cursor position at the time of the event */
  32646. pointerY: number;
  32647. /** The mesh that is currently pointed at (can be null) */
  32648. meshUnderPointer: Nullable<AbstractMesh>;
  32649. /** the original (browser) event that triggered the ActionEvent */
  32650. sourceEvent?: any;
  32651. /** additional data for the event */
  32652. additionalData?: any;
  32653. }
  32654. /**
  32655. * ActionEvent is the event being sent when an action is triggered.
  32656. */
  32657. export class ActionEvent implements IActionEvent {
  32658. /** The mesh or sprite that triggered the action */
  32659. source: any;
  32660. /** The X mouse cursor position at the time of the event */
  32661. pointerX: number;
  32662. /** The Y mouse cursor position at the time of the event */
  32663. pointerY: number;
  32664. /** The mesh that is currently pointed at (can be null) */
  32665. meshUnderPointer: Nullable<AbstractMesh>;
  32666. /** the original (browser) event that triggered the ActionEvent */
  32667. sourceEvent?: any;
  32668. /** additional data for the event */
  32669. additionalData?: any;
  32670. /**
  32671. * Creates a new ActionEvent
  32672. * @param source The mesh or sprite that triggered the action
  32673. * @param pointerX The X mouse cursor position at the time of the event
  32674. * @param pointerY The Y mouse cursor position at the time of the event
  32675. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32676. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32677. * @param additionalData additional data for the event
  32678. */
  32679. constructor(
  32680. /** The mesh or sprite that triggered the action */
  32681. source: any,
  32682. /** The X mouse cursor position at the time of the event */
  32683. pointerX: number,
  32684. /** The Y mouse cursor position at the time of the event */
  32685. pointerY: number,
  32686. /** The mesh that is currently pointed at (can be null) */
  32687. meshUnderPointer: Nullable<AbstractMesh>,
  32688. /** the original (browser) event that triggered the ActionEvent */
  32689. sourceEvent?: any,
  32690. /** additional data for the event */
  32691. additionalData?: any);
  32692. /**
  32693. * Helper function to auto-create an ActionEvent from a source mesh.
  32694. * @param source The source mesh that triggered the event
  32695. * @param evt The original (browser) event
  32696. * @param additionalData additional data for the event
  32697. * @returns the new ActionEvent
  32698. */
  32699. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32700. /**
  32701. * Helper function to auto-create an ActionEvent from a source sprite
  32702. * @param source The source sprite that triggered the event
  32703. * @param scene Scene associated with the sprite
  32704. * @param evt The original (browser) event
  32705. * @param additionalData additional data for the event
  32706. * @returns the new ActionEvent
  32707. */
  32708. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32709. /**
  32710. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32711. * @param scene the scene where the event occurred
  32712. * @param evt The original (browser) event
  32713. * @returns the new ActionEvent
  32714. */
  32715. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32716. /**
  32717. * Helper function to auto-create an ActionEvent from a primitive
  32718. * @param prim defines the target primitive
  32719. * @param pointerPos defines the pointer position
  32720. * @param evt The original (browser) event
  32721. * @param additionalData additional data for the event
  32722. * @returns the new ActionEvent
  32723. */
  32724. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32725. }
  32726. }
  32727. declare module "babylonjs/Actions/abstractActionManager" {
  32728. import { IDisposable } from "babylonjs/scene";
  32729. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32730. import { IAction } from "babylonjs/Actions/action";
  32731. import { Nullable } from "babylonjs/types";
  32732. /**
  32733. * Abstract class used to decouple action Manager from scene and meshes.
  32734. * Do not instantiate.
  32735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32736. */
  32737. export abstract class AbstractActionManager implements IDisposable {
  32738. /** Gets the list of active triggers */
  32739. static Triggers: {
  32740. [key: string]: number;
  32741. };
  32742. /** Gets the cursor to use when hovering items */
  32743. hoverCursor: string;
  32744. /** Gets the list of actions */
  32745. actions: IAction[];
  32746. /**
  32747. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32748. */
  32749. isRecursive: boolean;
  32750. /**
  32751. * Releases all associated resources
  32752. */
  32753. abstract dispose(): void;
  32754. /**
  32755. * Does this action manager has pointer triggers
  32756. */
  32757. abstract get hasPointerTriggers(): boolean;
  32758. /**
  32759. * Does this action manager has pick triggers
  32760. */
  32761. abstract get hasPickTriggers(): boolean;
  32762. /**
  32763. * Process a specific trigger
  32764. * @param trigger defines the trigger to process
  32765. * @param evt defines the event details to be processed
  32766. */
  32767. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32768. /**
  32769. * Does this action manager handles actions of any of the given triggers
  32770. * @param triggers defines the triggers to be tested
  32771. * @return a boolean indicating whether one (or more) of the triggers is handled
  32772. */
  32773. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32774. /**
  32775. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32776. * speed.
  32777. * @param triggerA defines the trigger to be tested
  32778. * @param triggerB defines the trigger to be tested
  32779. * @return a boolean indicating whether one (or more) of the triggers is handled
  32780. */
  32781. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32782. /**
  32783. * Does this action manager handles actions of a given trigger
  32784. * @param trigger defines the trigger to be tested
  32785. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32786. * @return whether the trigger is handled
  32787. */
  32788. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32789. /**
  32790. * Serialize this manager to a JSON object
  32791. * @param name defines the property name to store this manager
  32792. * @returns a JSON representation of this manager
  32793. */
  32794. abstract serialize(name: string): any;
  32795. /**
  32796. * Registers an action to this action manager
  32797. * @param action defines the action to be registered
  32798. * @return the action amended (prepared) after registration
  32799. */
  32800. abstract registerAction(action: IAction): Nullable<IAction>;
  32801. /**
  32802. * Unregisters an action to this action manager
  32803. * @param action defines the action to be unregistered
  32804. * @return a boolean indicating whether the action has been unregistered
  32805. */
  32806. abstract unregisterAction(action: IAction): Boolean;
  32807. /**
  32808. * Does exist one action manager with at least one trigger
  32809. **/
  32810. static get HasTriggers(): boolean;
  32811. /**
  32812. * Does exist one action manager with at least one pick trigger
  32813. **/
  32814. static get HasPickTriggers(): boolean;
  32815. /**
  32816. * Does exist one action manager that handles actions of a given trigger
  32817. * @param trigger defines the trigger to be tested
  32818. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32819. **/
  32820. static HasSpecificTrigger(trigger: number): boolean;
  32821. }
  32822. }
  32823. declare module "babylonjs/node" {
  32824. import { Scene } from "babylonjs/scene";
  32825. import { Nullable } from "babylonjs/types";
  32826. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32827. import { Engine } from "babylonjs/Engines/engine";
  32828. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32829. import { Observable } from "babylonjs/Misc/observable";
  32830. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32831. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32832. import { Animatable } from "babylonjs/Animations/animatable";
  32833. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32834. import { Animation } from "babylonjs/Animations/animation";
  32835. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32837. /**
  32838. * Defines how a node can be built from a string name.
  32839. */
  32840. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32841. /**
  32842. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32843. */
  32844. export class Node implements IBehaviorAware<Node> {
  32845. /** @hidden */
  32846. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  32847. private static _NodeConstructors;
  32848. /**
  32849. * Add a new node constructor
  32850. * @param type defines the type name of the node to construct
  32851. * @param constructorFunc defines the constructor function
  32852. */
  32853. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32854. /**
  32855. * Returns a node constructor based on type name
  32856. * @param type defines the type name
  32857. * @param name defines the new node name
  32858. * @param scene defines the hosting scene
  32859. * @param options defines optional options to transmit to constructors
  32860. * @returns the new constructor or null
  32861. */
  32862. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32863. /**
  32864. * Gets or sets the name of the node
  32865. */
  32866. name: string;
  32867. /**
  32868. * Gets or sets the id of the node
  32869. */
  32870. id: string;
  32871. /**
  32872. * Gets or sets the unique id of the node
  32873. */
  32874. uniqueId: number;
  32875. /**
  32876. * Gets or sets a string used to store user defined state for the node
  32877. */
  32878. state: string;
  32879. /**
  32880. * Gets or sets an object used to store user defined information for the node
  32881. */
  32882. metadata: any;
  32883. /**
  32884. * For internal use only. Please do not use.
  32885. */
  32886. reservedDataStore: any;
  32887. /**
  32888. * List of inspectable custom properties (used by the Inspector)
  32889. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32890. */
  32891. inspectableCustomProperties: IInspectable[];
  32892. private _doNotSerialize;
  32893. /**
  32894. * Gets or sets a boolean used to define if the node must be serialized
  32895. */
  32896. get doNotSerialize(): boolean;
  32897. set doNotSerialize(value: boolean);
  32898. /** @hidden */
  32899. _isDisposed: boolean;
  32900. /**
  32901. * Gets a list of Animations associated with the node
  32902. */
  32903. animations: import("babylonjs/Animations/animation").Animation[];
  32904. protected _ranges: {
  32905. [name: string]: Nullable<AnimationRange>;
  32906. };
  32907. /**
  32908. * Callback raised when the node is ready to be used
  32909. */
  32910. onReady: Nullable<(node: Node) => void>;
  32911. private _isEnabled;
  32912. private _isParentEnabled;
  32913. private _isReady;
  32914. /** @hidden */
  32915. _currentRenderId: number;
  32916. private _parentUpdateId;
  32917. /** @hidden */
  32918. _childUpdateId: number;
  32919. /** @hidden */
  32920. _waitingParentId: Nullable<string>;
  32921. /** @hidden */
  32922. _scene: Scene;
  32923. /** @hidden */
  32924. _cache: any;
  32925. private _parentNode;
  32926. private _children;
  32927. /** @hidden */
  32928. _worldMatrix: Matrix;
  32929. /** @hidden */
  32930. _worldMatrixDeterminant: number;
  32931. /** @hidden */
  32932. _worldMatrixDeterminantIsDirty: boolean;
  32933. /** @hidden */
  32934. private _sceneRootNodesIndex;
  32935. /**
  32936. * Gets a boolean indicating if the node has been disposed
  32937. * @returns true if the node was disposed
  32938. */
  32939. isDisposed(): boolean;
  32940. /**
  32941. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32942. * @see https://doc.babylonjs.com/how_to/parenting
  32943. */
  32944. set parent(parent: Nullable<Node>);
  32945. get parent(): Nullable<Node>;
  32946. /** @hidden */
  32947. _addToSceneRootNodes(): void;
  32948. /** @hidden */
  32949. _removeFromSceneRootNodes(): void;
  32950. private _animationPropertiesOverride;
  32951. /**
  32952. * Gets or sets the animation properties override
  32953. */
  32954. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32955. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32956. /**
  32957. * Gets a string idenfifying the name of the class
  32958. * @returns "Node" string
  32959. */
  32960. getClassName(): string;
  32961. /** @hidden */
  32962. readonly _isNode: boolean;
  32963. /**
  32964. * An event triggered when the mesh is disposed
  32965. */
  32966. onDisposeObservable: Observable<Node>;
  32967. private _onDisposeObserver;
  32968. /**
  32969. * Sets a callback that will be raised when the node will be disposed
  32970. */
  32971. set onDispose(callback: () => void);
  32972. /**
  32973. * Creates a new Node
  32974. * @param name the name and id to be given to this node
  32975. * @param scene the scene this node will be added to
  32976. */
  32977. constructor(name: string, scene?: Nullable<Scene>);
  32978. /**
  32979. * Gets the scene of the node
  32980. * @returns a scene
  32981. */
  32982. getScene(): Scene;
  32983. /**
  32984. * Gets the engine of the node
  32985. * @returns a Engine
  32986. */
  32987. getEngine(): Engine;
  32988. private _behaviors;
  32989. /**
  32990. * Attach a behavior to the node
  32991. * @see http://doc.babylonjs.com/features/behaviour
  32992. * @param behavior defines the behavior to attach
  32993. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32994. * @returns the current Node
  32995. */
  32996. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32997. /**
  32998. * Remove an attached behavior
  32999. * @see http://doc.babylonjs.com/features/behaviour
  33000. * @param behavior defines the behavior to attach
  33001. * @returns the current Node
  33002. */
  33003. removeBehavior(behavior: Behavior<Node>): Node;
  33004. /**
  33005. * Gets the list of attached behaviors
  33006. * @see http://doc.babylonjs.com/features/behaviour
  33007. */
  33008. get behaviors(): Behavior<Node>[];
  33009. /**
  33010. * Gets an attached behavior by name
  33011. * @param name defines the name of the behavior to look for
  33012. * @see http://doc.babylonjs.com/features/behaviour
  33013. * @returns null if behavior was not found else the requested behavior
  33014. */
  33015. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33016. /**
  33017. * Returns the latest update of the World matrix
  33018. * @returns a Matrix
  33019. */
  33020. getWorldMatrix(): Matrix;
  33021. /** @hidden */
  33022. _getWorldMatrixDeterminant(): number;
  33023. /**
  33024. * Returns directly the latest state of the mesh World matrix.
  33025. * A Matrix is returned.
  33026. */
  33027. get worldMatrixFromCache(): Matrix;
  33028. /** @hidden */
  33029. _initCache(): void;
  33030. /** @hidden */
  33031. updateCache(force?: boolean): void;
  33032. /** @hidden */
  33033. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33034. /** @hidden */
  33035. _updateCache(ignoreParentClass?: boolean): void;
  33036. /** @hidden */
  33037. _isSynchronized(): boolean;
  33038. /** @hidden */
  33039. _markSyncedWithParent(): void;
  33040. /** @hidden */
  33041. isSynchronizedWithParent(): boolean;
  33042. /** @hidden */
  33043. isSynchronized(): boolean;
  33044. /**
  33045. * Is this node ready to be used/rendered
  33046. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33047. * @return true if the node is ready
  33048. */
  33049. isReady(completeCheck?: boolean): boolean;
  33050. /**
  33051. * Is this node enabled?
  33052. * 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
  33053. * @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
  33054. * @return whether this node (and its parent) is enabled
  33055. */
  33056. isEnabled(checkAncestors?: boolean): boolean;
  33057. /** @hidden */
  33058. protected _syncParentEnabledState(): void;
  33059. /**
  33060. * Set the enabled state of this node
  33061. * @param value defines the new enabled state
  33062. */
  33063. setEnabled(value: boolean): void;
  33064. /**
  33065. * Is this node a descendant of the given node?
  33066. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33067. * @param ancestor defines the parent node to inspect
  33068. * @returns a boolean indicating if this node is a descendant of the given node
  33069. */
  33070. isDescendantOf(ancestor: Node): boolean;
  33071. /** @hidden */
  33072. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33073. /**
  33074. * Will return all nodes that have this node as ascendant
  33075. * @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
  33076. * @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
  33077. * @return all children nodes of all types
  33078. */
  33079. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33080. /**
  33081. * Get all child-meshes of this node
  33082. * @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)
  33083. * @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
  33084. * @returns an array of AbstractMesh
  33085. */
  33086. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33087. /**
  33088. * Get all direct children of this node
  33089. * @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
  33090. * @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)
  33091. * @returns an array of Node
  33092. */
  33093. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33094. /** @hidden */
  33095. _setReady(state: boolean): void;
  33096. /**
  33097. * Get an animation by name
  33098. * @param name defines the name of the animation to look for
  33099. * @returns null if not found else the requested animation
  33100. */
  33101. getAnimationByName(name: string): Nullable<Animation>;
  33102. /**
  33103. * Creates an animation range for this node
  33104. * @param name defines the name of the range
  33105. * @param from defines the starting key
  33106. * @param to defines the end key
  33107. */
  33108. createAnimationRange(name: string, from: number, to: number): void;
  33109. /**
  33110. * Delete a specific animation range
  33111. * @param name defines the name of the range to delete
  33112. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33113. */
  33114. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33115. /**
  33116. * Get an animation range by name
  33117. * @param name defines the name of the animation range to look for
  33118. * @returns null if not found else the requested animation range
  33119. */
  33120. getAnimationRange(name: string): Nullable<AnimationRange>;
  33121. /**
  33122. * Gets the list of all animation ranges defined on this node
  33123. * @returns an array
  33124. */
  33125. getAnimationRanges(): Nullable<AnimationRange>[];
  33126. /**
  33127. * Will start the animation sequence
  33128. * @param name defines the range frames for animation sequence
  33129. * @param loop defines if the animation should loop (false by default)
  33130. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33131. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33132. * @returns the object created for this animation. If range does not exist, it will return null
  33133. */
  33134. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33135. /**
  33136. * Serialize animation ranges into a JSON compatible object
  33137. * @returns serialization object
  33138. */
  33139. serializeAnimationRanges(): any;
  33140. /**
  33141. * Computes the world matrix of the node
  33142. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33143. * @returns the world matrix
  33144. */
  33145. computeWorldMatrix(force?: boolean): Matrix;
  33146. /**
  33147. * Releases resources associated with this node.
  33148. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33149. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33150. */
  33151. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33152. /**
  33153. * Parse animation range data from a serialization object and store them into a given node
  33154. * @param node defines where to store the animation ranges
  33155. * @param parsedNode defines the serialization object to read data from
  33156. * @param scene defines the hosting scene
  33157. */
  33158. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33159. /**
  33160. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33161. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33162. * @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
  33163. * @returns the new bounding vectors
  33164. */
  33165. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33166. min: Vector3;
  33167. max: Vector3;
  33168. };
  33169. }
  33170. }
  33171. declare module "babylonjs/Animations/animation" {
  33172. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33173. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33174. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33175. import { Nullable } from "babylonjs/types";
  33176. import { Scene } from "babylonjs/scene";
  33177. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33178. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33179. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33180. import { Node } from "babylonjs/node";
  33181. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33182. import { Size } from "babylonjs/Maths/math.size";
  33183. import { Animatable } from "babylonjs/Animations/animatable";
  33184. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33185. /**
  33186. * @hidden
  33187. */
  33188. export class _IAnimationState {
  33189. key: number;
  33190. repeatCount: number;
  33191. workValue?: any;
  33192. loopMode?: number;
  33193. offsetValue?: any;
  33194. highLimitValue?: any;
  33195. }
  33196. /**
  33197. * Class used to store any kind of animation
  33198. */
  33199. export class Animation {
  33200. /**Name of the animation */
  33201. name: string;
  33202. /**Property to animate */
  33203. targetProperty: string;
  33204. /**The frames per second of the animation */
  33205. framePerSecond: number;
  33206. /**The data type of the animation */
  33207. dataType: number;
  33208. /**The loop mode of the animation */
  33209. loopMode?: number | undefined;
  33210. /**Specifies if blending should be enabled */
  33211. enableBlending?: boolean | undefined;
  33212. /**
  33213. * Use matrix interpolation instead of using direct key value when animating matrices
  33214. */
  33215. static AllowMatricesInterpolation: boolean;
  33216. /**
  33217. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33218. */
  33219. static AllowMatrixDecomposeForInterpolation: boolean;
  33220. /**
  33221. * Stores the key frames of the animation
  33222. */
  33223. private _keys;
  33224. /**
  33225. * Stores the easing function of the animation
  33226. */
  33227. private _easingFunction;
  33228. /**
  33229. * @hidden Internal use only
  33230. */
  33231. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33232. /**
  33233. * The set of event that will be linked to this animation
  33234. */
  33235. private _events;
  33236. /**
  33237. * Stores an array of target property paths
  33238. */
  33239. targetPropertyPath: string[];
  33240. /**
  33241. * Stores the blending speed of the animation
  33242. */
  33243. blendingSpeed: number;
  33244. /**
  33245. * Stores the animation ranges for the animation
  33246. */
  33247. private _ranges;
  33248. /**
  33249. * @hidden Internal use
  33250. */
  33251. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33252. /**
  33253. * Sets up an animation
  33254. * @param property The property to animate
  33255. * @param animationType The animation type to apply
  33256. * @param framePerSecond The frames per second of the animation
  33257. * @param easingFunction The easing function used in the animation
  33258. * @returns The created animation
  33259. */
  33260. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33261. /**
  33262. * Create and start an animation on a node
  33263. * @param name defines the name of the global animation that will be run on all nodes
  33264. * @param node defines the root node where the animation will take place
  33265. * @param targetProperty defines property to animate
  33266. * @param framePerSecond defines the number of frame per second yo use
  33267. * @param totalFrame defines the number of frames in total
  33268. * @param from defines the initial value
  33269. * @param to defines the final value
  33270. * @param loopMode defines which loop mode you want to use (off by default)
  33271. * @param easingFunction defines the easing function to use (linear by default)
  33272. * @param onAnimationEnd defines the callback to call when animation end
  33273. * @returns the animatable created for this animation
  33274. */
  33275. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33276. /**
  33277. * Create and start an animation on a node and its descendants
  33278. * @param name defines the name of the global animation that will be run on all nodes
  33279. * @param node defines the root node where the animation will take place
  33280. * @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
  33281. * @param targetProperty defines property to animate
  33282. * @param framePerSecond defines the number of frame per second to use
  33283. * @param totalFrame defines the number of frames in total
  33284. * @param from defines the initial value
  33285. * @param to defines the final value
  33286. * @param loopMode defines which loop mode you want to use (off by default)
  33287. * @param easingFunction defines the easing function to use (linear by default)
  33288. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33289. * @returns the list of animatables created for all nodes
  33290. * @example https://www.babylonjs-playground.com/#MH0VLI
  33291. */
  33292. 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[]>;
  33293. /**
  33294. * Creates a new animation, merges it with the existing animations and starts it
  33295. * @param name Name of the animation
  33296. * @param node Node which contains the scene that begins the animations
  33297. * @param targetProperty Specifies which property to animate
  33298. * @param framePerSecond The frames per second of the animation
  33299. * @param totalFrame The total number of frames
  33300. * @param from The frame at the beginning of the animation
  33301. * @param to The frame at the end of the animation
  33302. * @param loopMode Specifies the loop mode of the animation
  33303. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33304. * @param onAnimationEnd Callback to run once the animation is complete
  33305. * @returns Nullable animation
  33306. */
  33307. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33308. /**
  33309. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33310. * @param sourceAnimation defines the Animation containing keyframes to convert
  33311. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33312. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33313. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33314. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33315. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33316. */
  33317. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33318. /**
  33319. * Transition property of an host to the target Value
  33320. * @param property The property to transition
  33321. * @param targetValue The target Value of the property
  33322. * @param host The object where the property to animate belongs
  33323. * @param scene Scene used to run the animation
  33324. * @param frameRate Framerate (in frame/s) to use
  33325. * @param transition The transition type we want to use
  33326. * @param duration The duration of the animation, in milliseconds
  33327. * @param onAnimationEnd Callback trigger at the end of the animation
  33328. * @returns Nullable animation
  33329. */
  33330. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33331. /**
  33332. * Return the array of runtime animations currently using this animation
  33333. */
  33334. get runtimeAnimations(): RuntimeAnimation[];
  33335. /**
  33336. * Specifies if any of the runtime animations are currently running
  33337. */
  33338. get hasRunningRuntimeAnimations(): boolean;
  33339. /**
  33340. * Initializes the animation
  33341. * @param name Name of the animation
  33342. * @param targetProperty Property to animate
  33343. * @param framePerSecond The frames per second of the animation
  33344. * @param dataType The data type of the animation
  33345. * @param loopMode The loop mode of the animation
  33346. * @param enableBlending Specifies if blending should be enabled
  33347. */
  33348. constructor(
  33349. /**Name of the animation */
  33350. name: string,
  33351. /**Property to animate */
  33352. targetProperty: string,
  33353. /**The frames per second of the animation */
  33354. framePerSecond: number,
  33355. /**The data type of the animation */
  33356. dataType: number,
  33357. /**The loop mode of the animation */
  33358. loopMode?: number | undefined,
  33359. /**Specifies if blending should be enabled */
  33360. enableBlending?: boolean | undefined);
  33361. /**
  33362. * Converts the animation to a string
  33363. * @param fullDetails support for multiple levels of logging within scene loading
  33364. * @returns String form of the animation
  33365. */
  33366. toString(fullDetails?: boolean): string;
  33367. /**
  33368. * Add an event to this animation
  33369. * @param event Event to add
  33370. */
  33371. addEvent(event: AnimationEvent): void;
  33372. /**
  33373. * Remove all events found at the given frame
  33374. * @param frame The frame to remove events from
  33375. */
  33376. removeEvents(frame: number): void;
  33377. /**
  33378. * Retrieves all the events from the animation
  33379. * @returns Events from the animation
  33380. */
  33381. getEvents(): AnimationEvent[];
  33382. /**
  33383. * Creates an animation range
  33384. * @param name Name of the animation range
  33385. * @param from Starting frame of the animation range
  33386. * @param to Ending frame of the animation
  33387. */
  33388. createRange(name: string, from: number, to: number): void;
  33389. /**
  33390. * Deletes an animation range by name
  33391. * @param name Name of the animation range to delete
  33392. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33393. */
  33394. deleteRange(name: string, deleteFrames?: boolean): void;
  33395. /**
  33396. * Gets the animation range by name, or null if not defined
  33397. * @param name Name of the animation range
  33398. * @returns Nullable animation range
  33399. */
  33400. getRange(name: string): Nullable<AnimationRange>;
  33401. /**
  33402. * Gets the key frames from the animation
  33403. * @returns The key frames of the animation
  33404. */
  33405. getKeys(): Array<IAnimationKey>;
  33406. /**
  33407. * Gets the highest frame rate of the animation
  33408. * @returns Highest frame rate of the animation
  33409. */
  33410. getHighestFrame(): number;
  33411. /**
  33412. * Gets the easing function of the animation
  33413. * @returns Easing function of the animation
  33414. */
  33415. getEasingFunction(): IEasingFunction;
  33416. /**
  33417. * Sets the easing function of the animation
  33418. * @param easingFunction A custom mathematical formula for animation
  33419. */
  33420. setEasingFunction(easingFunction: EasingFunction): void;
  33421. /**
  33422. * Interpolates a scalar linearly
  33423. * @param startValue Start value of the animation curve
  33424. * @param endValue End value of the animation curve
  33425. * @param gradient Scalar amount to interpolate
  33426. * @returns Interpolated scalar value
  33427. */
  33428. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33429. /**
  33430. * Interpolates a scalar cubically
  33431. * @param startValue Start value of the animation curve
  33432. * @param outTangent End tangent of the animation
  33433. * @param endValue End value of the animation curve
  33434. * @param inTangent Start tangent of the animation curve
  33435. * @param gradient Scalar amount to interpolate
  33436. * @returns Interpolated scalar value
  33437. */
  33438. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33439. /**
  33440. * Interpolates a quaternion using a spherical linear interpolation
  33441. * @param startValue Start value of the animation curve
  33442. * @param endValue End value of the animation curve
  33443. * @param gradient Scalar amount to interpolate
  33444. * @returns Interpolated quaternion value
  33445. */
  33446. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33447. /**
  33448. * Interpolates a quaternion cubically
  33449. * @param startValue Start value of the animation curve
  33450. * @param outTangent End tangent of the animation curve
  33451. * @param endValue End value of the animation curve
  33452. * @param inTangent Start tangent of the animation curve
  33453. * @param gradient Scalar amount to interpolate
  33454. * @returns Interpolated quaternion value
  33455. */
  33456. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33457. /**
  33458. * Interpolates a Vector3 linearl
  33459. * @param startValue Start value of the animation curve
  33460. * @param endValue End value of the animation curve
  33461. * @param gradient Scalar amount to interpolate
  33462. * @returns Interpolated scalar value
  33463. */
  33464. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33465. /**
  33466. * Interpolates a Vector3 cubically
  33467. * @param startValue Start value of the animation curve
  33468. * @param outTangent End tangent of the animation
  33469. * @param endValue End value of the animation curve
  33470. * @param inTangent Start tangent of the animation curve
  33471. * @param gradient Scalar amount to interpolate
  33472. * @returns InterpolatedVector3 value
  33473. */
  33474. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33475. /**
  33476. * Interpolates a Vector2 linearly
  33477. * @param startValue Start value of the animation curve
  33478. * @param endValue End value of the animation curve
  33479. * @param gradient Scalar amount to interpolate
  33480. * @returns Interpolated Vector2 value
  33481. */
  33482. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33483. /**
  33484. * Interpolates a Vector2 cubically
  33485. * @param startValue Start value of the animation curve
  33486. * @param outTangent End tangent of the animation
  33487. * @param endValue End value of the animation curve
  33488. * @param inTangent Start tangent of the animation curve
  33489. * @param gradient Scalar amount to interpolate
  33490. * @returns Interpolated Vector2 value
  33491. */
  33492. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33493. /**
  33494. * Interpolates a size linearly
  33495. * @param startValue Start value of the animation curve
  33496. * @param endValue End value of the animation curve
  33497. * @param gradient Scalar amount to interpolate
  33498. * @returns Interpolated Size value
  33499. */
  33500. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33501. /**
  33502. * Interpolates a Color3 linearly
  33503. * @param startValue Start value of the animation curve
  33504. * @param endValue End value of the animation curve
  33505. * @param gradient Scalar amount to interpolate
  33506. * @returns Interpolated Color3 value
  33507. */
  33508. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33509. /**
  33510. * Interpolates a Color4 linearly
  33511. * @param startValue Start value of the animation curve
  33512. * @param endValue End value of the animation curve
  33513. * @param gradient Scalar amount to interpolate
  33514. * @returns Interpolated Color3 value
  33515. */
  33516. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33517. /**
  33518. * @hidden Internal use only
  33519. */
  33520. _getKeyValue(value: any): any;
  33521. /**
  33522. * @hidden Internal use only
  33523. */
  33524. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33525. /**
  33526. * Defines the function to use to interpolate matrices
  33527. * @param startValue defines the start matrix
  33528. * @param endValue defines the end matrix
  33529. * @param gradient defines the gradient between both matrices
  33530. * @param result defines an optional target matrix where to store the interpolation
  33531. * @returns the interpolated matrix
  33532. */
  33533. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33534. /**
  33535. * Makes a copy of the animation
  33536. * @returns Cloned animation
  33537. */
  33538. clone(): Animation;
  33539. /**
  33540. * Sets the key frames of the animation
  33541. * @param values The animation key frames to set
  33542. */
  33543. setKeys(values: Array<IAnimationKey>): void;
  33544. /**
  33545. * Serializes the animation to an object
  33546. * @returns Serialized object
  33547. */
  33548. serialize(): any;
  33549. /**
  33550. * Float animation type
  33551. */
  33552. static readonly ANIMATIONTYPE_FLOAT: number;
  33553. /**
  33554. * Vector3 animation type
  33555. */
  33556. static readonly ANIMATIONTYPE_VECTOR3: number;
  33557. /**
  33558. * Quaternion animation type
  33559. */
  33560. static readonly ANIMATIONTYPE_QUATERNION: number;
  33561. /**
  33562. * Matrix animation type
  33563. */
  33564. static readonly ANIMATIONTYPE_MATRIX: number;
  33565. /**
  33566. * Color3 animation type
  33567. */
  33568. static readonly ANIMATIONTYPE_COLOR3: number;
  33569. /**
  33570. * Color3 animation type
  33571. */
  33572. static readonly ANIMATIONTYPE_COLOR4: number;
  33573. /**
  33574. * Vector2 animation type
  33575. */
  33576. static readonly ANIMATIONTYPE_VECTOR2: number;
  33577. /**
  33578. * Size animation type
  33579. */
  33580. static readonly ANIMATIONTYPE_SIZE: number;
  33581. /**
  33582. * Relative Loop Mode
  33583. */
  33584. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33585. /**
  33586. * Cycle Loop Mode
  33587. */
  33588. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33589. /**
  33590. * Constant Loop Mode
  33591. */
  33592. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33593. /** @hidden */
  33594. static _UniversalLerp(left: any, right: any, amount: number): any;
  33595. /**
  33596. * Parses an animation object and creates an animation
  33597. * @param parsedAnimation Parsed animation object
  33598. * @returns Animation object
  33599. */
  33600. static Parse(parsedAnimation: any): Animation;
  33601. /**
  33602. * Appends the serialized animations from the source animations
  33603. * @param source Source containing the animations
  33604. * @param destination Target to store the animations
  33605. */
  33606. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33607. }
  33608. }
  33609. declare module "babylonjs/Animations/animatable.interface" {
  33610. import { Nullable } from "babylonjs/types";
  33611. import { Animation } from "babylonjs/Animations/animation";
  33612. /**
  33613. * Interface containing an array of animations
  33614. */
  33615. export interface IAnimatable {
  33616. /**
  33617. * Array of animations
  33618. */
  33619. animations: Nullable<Array<Animation>>;
  33620. }
  33621. }
  33622. declare module "babylonjs/Misc/decorators" {
  33623. import { Nullable } from "babylonjs/types";
  33624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33625. import { Scene } from "babylonjs/scene";
  33626. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33627. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33628. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33629. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33630. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33631. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33632. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33633. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33634. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33635. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33636. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33637. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33638. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33639. /**
  33640. * Decorator used to define property that can be serialized as reference to a camera
  33641. * @param sourceName defines the name of the property to decorate
  33642. */
  33643. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33644. /**
  33645. * Class used to help serialization objects
  33646. */
  33647. export class SerializationHelper {
  33648. /** @hidden */
  33649. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33650. /** @hidden */
  33651. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33652. /** @hidden */
  33653. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33654. /** @hidden */
  33655. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33656. /**
  33657. * Appends the serialized animations from the source animations
  33658. * @param source Source containing the animations
  33659. * @param destination Target to store the animations
  33660. */
  33661. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33662. /**
  33663. * Static function used to serialized a specific entity
  33664. * @param entity defines the entity to serialize
  33665. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33666. * @returns a JSON compatible object representing the serialization of the entity
  33667. */
  33668. static Serialize<T>(entity: T, serializationObject?: any): any;
  33669. /**
  33670. * Creates a new entity from a serialization data object
  33671. * @param creationFunction defines a function used to instanciated the new entity
  33672. * @param source defines the source serialization data
  33673. * @param scene defines the hosting scene
  33674. * @param rootUrl defines the root url for resources
  33675. * @returns a new entity
  33676. */
  33677. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33678. /**
  33679. * Clones an object
  33680. * @param creationFunction defines the function used to instanciate the new object
  33681. * @param source defines the source object
  33682. * @returns the cloned object
  33683. */
  33684. static Clone<T>(creationFunction: () => T, source: T): T;
  33685. /**
  33686. * Instanciates a new object based on a source one (some data will be shared between both object)
  33687. * @param creationFunction defines the function used to instanciate the new object
  33688. * @param source defines the source object
  33689. * @returns the new object
  33690. */
  33691. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33692. }
  33693. }
  33694. declare module "babylonjs/Materials/Textures/baseTexture" {
  33695. import { Observable } from "babylonjs/Misc/observable";
  33696. import { Nullable } from "babylonjs/types";
  33697. import { Scene } from "babylonjs/scene";
  33698. import { Matrix } from "babylonjs/Maths/math.vector";
  33699. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33700. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33701. import { ISize } from "babylonjs/Maths/math.size";
  33702. import "babylonjs/Misc/fileTools";
  33703. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33704. /**
  33705. * Base class of all the textures in babylon.
  33706. * It groups all the common properties the materials, post process, lights... might need
  33707. * in order to make a correct use of the texture.
  33708. */
  33709. export class BaseTexture implements IAnimatable {
  33710. /**
  33711. * Default anisotropic filtering level for the application.
  33712. * It is set to 4 as a good tradeoff between perf and quality.
  33713. */
  33714. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33715. /**
  33716. * Gets or sets the unique id of the texture
  33717. */
  33718. uniqueId: number;
  33719. /**
  33720. * Define the name of the texture.
  33721. */
  33722. name: string;
  33723. /**
  33724. * Gets or sets an object used to store user defined information.
  33725. */
  33726. metadata: any;
  33727. /**
  33728. * For internal use only. Please do not use.
  33729. */
  33730. reservedDataStore: any;
  33731. private _hasAlpha;
  33732. /**
  33733. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33734. */
  33735. set hasAlpha(value: boolean);
  33736. get hasAlpha(): boolean;
  33737. /**
  33738. * Defines if the alpha value should be determined via the rgb values.
  33739. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33740. */
  33741. getAlphaFromRGB: boolean;
  33742. /**
  33743. * Intensity or strength of the texture.
  33744. * It is commonly used by materials to fine tune the intensity of the texture
  33745. */
  33746. level: number;
  33747. /**
  33748. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33749. * This is part of the texture as textures usually maps to one uv set.
  33750. */
  33751. coordinatesIndex: number;
  33752. private _coordinatesMode;
  33753. /**
  33754. * How a texture is mapped.
  33755. *
  33756. * | Value | Type | Description |
  33757. * | ----- | ----------------------------------- | ----------- |
  33758. * | 0 | EXPLICIT_MODE | |
  33759. * | 1 | SPHERICAL_MODE | |
  33760. * | 2 | PLANAR_MODE | |
  33761. * | 3 | CUBIC_MODE | |
  33762. * | 4 | PROJECTION_MODE | |
  33763. * | 5 | SKYBOX_MODE | |
  33764. * | 6 | INVCUBIC_MODE | |
  33765. * | 7 | EQUIRECTANGULAR_MODE | |
  33766. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33767. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33768. */
  33769. set coordinatesMode(value: number);
  33770. get coordinatesMode(): number;
  33771. /**
  33772. * | Value | Type | Description |
  33773. * | ----- | ------------------ | ----------- |
  33774. * | 0 | CLAMP_ADDRESSMODE | |
  33775. * | 1 | WRAP_ADDRESSMODE | |
  33776. * | 2 | MIRROR_ADDRESSMODE | |
  33777. */
  33778. wrapU: number;
  33779. /**
  33780. * | Value | Type | Description |
  33781. * | ----- | ------------------ | ----------- |
  33782. * | 0 | CLAMP_ADDRESSMODE | |
  33783. * | 1 | WRAP_ADDRESSMODE | |
  33784. * | 2 | MIRROR_ADDRESSMODE | |
  33785. */
  33786. wrapV: number;
  33787. /**
  33788. * | Value | Type | Description |
  33789. * | ----- | ------------------ | ----------- |
  33790. * | 0 | CLAMP_ADDRESSMODE | |
  33791. * | 1 | WRAP_ADDRESSMODE | |
  33792. * | 2 | MIRROR_ADDRESSMODE | |
  33793. */
  33794. wrapR: number;
  33795. /**
  33796. * With compliant hardware and browser (supporting anisotropic filtering)
  33797. * this defines the level of anisotropic filtering in the texture.
  33798. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33799. */
  33800. anisotropicFilteringLevel: number;
  33801. /**
  33802. * Define if the texture is a cube texture or if false a 2d texture.
  33803. */
  33804. get isCube(): boolean;
  33805. set isCube(value: boolean);
  33806. /**
  33807. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33808. */
  33809. get is3D(): boolean;
  33810. set is3D(value: boolean);
  33811. /**
  33812. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33813. */
  33814. get is2DArray(): boolean;
  33815. set is2DArray(value: boolean);
  33816. /**
  33817. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33818. * HDR texture are usually stored in linear space.
  33819. * This only impacts the PBR and Background materials
  33820. */
  33821. gammaSpace: boolean;
  33822. /**
  33823. * Gets or sets whether or not the texture contains RGBD data.
  33824. */
  33825. get isRGBD(): boolean;
  33826. set isRGBD(value: boolean);
  33827. /**
  33828. * Is Z inverted in the texture (useful in a cube texture).
  33829. */
  33830. invertZ: boolean;
  33831. /**
  33832. * Are mip maps generated for this texture or not.
  33833. */
  33834. get noMipmap(): boolean;
  33835. /**
  33836. * @hidden
  33837. */
  33838. lodLevelInAlpha: boolean;
  33839. /**
  33840. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33841. */
  33842. get lodGenerationOffset(): number;
  33843. set lodGenerationOffset(value: number);
  33844. /**
  33845. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33846. */
  33847. get lodGenerationScale(): number;
  33848. set lodGenerationScale(value: number);
  33849. /**
  33850. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33851. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33852. * average roughness values.
  33853. */
  33854. get linearSpecularLOD(): boolean;
  33855. set linearSpecularLOD(value: boolean);
  33856. /**
  33857. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33858. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33859. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33860. */
  33861. get irradianceTexture(): Nullable<BaseTexture>;
  33862. set irradianceTexture(value: Nullable<BaseTexture>);
  33863. /**
  33864. * Define if the texture is a render target.
  33865. */
  33866. isRenderTarget: boolean;
  33867. /**
  33868. * Define the unique id of the texture in the scene.
  33869. */
  33870. get uid(): string;
  33871. /**
  33872. * Return a string representation of the texture.
  33873. * @returns the texture as a string
  33874. */
  33875. toString(): string;
  33876. /**
  33877. * Get the class name of the texture.
  33878. * @returns "BaseTexture"
  33879. */
  33880. getClassName(): string;
  33881. private _realTimeFiltering;
  33882. /**
  33883. * Enables realtime filtering on the texture.
  33884. */
  33885. get realTimeFiltering(): boolean;
  33886. set realTimeFiltering(b: boolean);
  33887. private _realTimeFilteringQuality;
  33888. /**
  33889. * Quality switch for realtime filtering
  33890. */
  33891. get realTimeFilteringQuality(): number;
  33892. set realTimeFilteringQuality(n: number);
  33893. /**
  33894. * Define the list of animation attached to the texture.
  33895. */
  33896. animations: import("babylonjs/Animations/animation").Animation[];
  33897. /**
  33898. * An event triggered when the texture is disposed.
  33899. */
  33900. onDisposeObservable: Observable<BaseTexture>;
  33901. private _onDisposeObserver;
  33902. /**
  33903. * Callback triggered when the texture has been disposed.
  33904. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33905. */
  33906. set onDispose(callback: () => void);
  33907. /**
  33908. * Define the current state of the loading sequence when in delayed load mode.
  33909. */
  33910. delayLoadState: number;
  33911. private _scene;
  33912. private _engine;
  33913. /** @hidden */
  33914. _texture: Nullable<InternalTexture>;
  33915. private _uid;
  33916. /**
  33917. * Define if the texture is preventinga material to render or not.
  33918. * If not and the texture is not ready, the engine will use a default black texture instead.
  33919. */
  33920. get isBlocking(): boolean;
  33921. /**
  33922. * Instantiates a new BaseTexture.
  33923. * Base class of all the textures in babylon.
  33924. * It groups all the common properties the materials, post process, lights... might need
  33925. * in order to make a correct use of the texture.
  33926. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33927. */
  33928. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33929. /**
  33930. * Get the scene the texture belongs to.
  33931. * @returns the scene or null if undefined
  33932. */
  33933. getScene(): Nullable<Scene>;
  33934. /** @hidden */
  33935. protected _getEngine(): Nullable<ThinEngine>;
  33936. /**
  33937. * Get the texture transform matrix used to offset tile the texture for istance.
  33938. * @returns the transformation matrix
  33939. */
  33940. getTextureMatrix(): Matrix;
  33941. /**
  33942. * Get the texture reflection matrix used to rotate/transform the reflection.
  33943. * @returns the reflection matrix
  33944. */
  33945. getReflectionTextureMatrix(): Matrix;
  33946. /**
  33947. * Get the underlying lower level texture from Babylon.
  33948. * @returns the insternal texture
  33949. */
  33950. getInternalTexture(): Nullable<InternalTexture>;
  33951. /**
  33952. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33953. * @returns true if ready or not blocking
  33954. */
  33955. isReadyOrNotBlocking(): boolean;
  33956. /**
  33957. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33958. * @returns true if fully ready
  33959. */
  33960. isReady(): boolean;
  33961. private _cachedSize;
  33962. /**
  33963. * Get the size of the texture.
  33964. * @returns the texture size.
  33965. */
  33966. getSize(): ISize;
  33967. /**
  33968. * Get the base size of the texture.
  33969. * It can be different from the size if the texture has been resized for POT for instance
  33970. * @returns the base size
  33971. */
  33972. getBaseSize(): ISize;
  33973. /**
  33974. * Update the sampling mode of the texture.
  33975. * Default is Trilinear mode.
  33976. *
  33977. * | Value | Type | Description |
  33978. * | ----- | ------------------ | ----------- |
  33979. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33980. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33981. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33982. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33983. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33984. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33985. * | 7 | NEAREST_LINEAR | |
  33986. * | 8 | NEAREST_NEAREST | |
  33987. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33988. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33989. * | 11 | LINEAR_LINEAR | |
  33990. * | 12 | LINEAR_NEAREST | |
  33991. *
  33992. * > _mag_: magnification filter (close to the viewer)
  33993. * > _min_: minification filter (far from the viewer)
  33994. * > _mip_: filter used between mip map levels
  33995. *@param samplingMode Define the new sampling mode of the texture
  33996. */
  33997. updateSamplingMode(samplingMode: number): void;
  33998. /**
  33999. * Scales the texture if is `canRescale()`
  34000. * @param ratio the resize factor we want to use to rescale
  34001. */
  34002. scale(ratio: number): void;
  34003. /**
  34004. * Get if the texture can rescale.
  34005. */
  34006. get canRescale(): boolean;
  34007. /** @hidden */
  34008. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34009. /** @hidden */
  34010. _rebuild(): void;
  34011. /**
  34012. * Triggers the load sequence in delayed load mode.
  34013. */
  34014. delayLoad(): void;
  34015. /**
  34016. * Clones the texture.
  34017. * @returns the cloned texture
  34018. */
  34019. clone(): Nullable<BaseTexture>;
  34020. /**
  34021. * Get the texture underlying type (INT, FLOAT...)
  34022. */
  34023. get textureType(): number;
  34024. /**
  34025. * Get the texture underlying format (RGB, RGBA...)
  34026. */
  34027. get textureFormat(): number;
  34028. /**
  34029. * Indicates that textures need to be re-calculated for all materials
  34030. */
  34031. protected _markAllSubMeshesAsTexturesDirty(): void;
  34032. /**
  34033. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34034. * This will returns an RGBA array buffer containing either in values (0-255) or
  34035. * float values (0-1) depending of the underlying buffer type.
  34036. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34037. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34038. * @param buffer defines a user defined buffer to fill with data (can be null)
  34039. * @returns The Array buffer containing the pixels data.
  34040. */
  34041. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34042. /**
  34043. * Release and destroy the underlying lower level texture aka internalTexture.
  34044. */
  34045. releaseInternalTexture(): void;
  34046. /** @hidden */
  34047. get _lodTextureHigh(): Nullable<BaseTexture>;
  34048. /** @hidden */
  34049. get _lodTextureMid(): Nullable<BaseTexture>;
  34050. /** @hidden */
  34051. get _lodTextureLow(): Nullable<BaseTexture>;
  34052. /**
  34053. * Dispose the texture and release its associated resources.
  34054. */
  34055. dispose(): void;
  34056. /**
  34057. * Serialize the texture into a JSON representation that can be parsed later on.
  34058. * @returns the JSON representation of the texture
  34059. */
  34060. serialize(): any;
  34061. /**
  34062. * Helper function to be called back once a list of texture contains only ready textures.
  34063. * @param textures Define the list of textures to wait for
  34064. * @param callback Define the callback triggered once the entire list will be ready
  34065. */
  34066. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34067. private static _isScene;
  34068. }
  34069. }
  34070. declare module "babylonjs/Materials/effect" {
  34071. import { Observable } from "babylonjs/Misc/observable";
  34072. import { Nullable } from "babylonjs/types";
  34073. import { IDisposable } from "babylonjs/scene";
  34074. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34076. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34077. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34078. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34079. import { Engine } from "babylonjs/Engines/engine";
  34080. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34083. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34084. /**
  34085. * Options to be used when creating an effect.
  34086. */
  34087. export interface IEffectCreationOptions {
  34088. /**
  34089. * Atrributes that will be used in the shader.
  34090. */
  34091. attributes: string[];
  34092. /**
  34093. * Uniform varible names that will be set in the shader.
  34094. */
  34095. uniformsNames: string[];
  34096. /**
  34097. * Uniform buffer variable names that will be set in the shader.
  34098. */
  34099. uniformBuffersNames: string[];
  34100. /**
  34101. * Sampler texture variable names that will be set in the shader.
  34102. */
  34103. samplers: string[];
  34104. /**
  34105. * Define statements that will be set in the shader.
  34106. */
  34107. defines: any;
  34108. /**
  34109. * Possible fallbacks for this effect to improve performance when needed.
  34110. */
  34111. fallbacks: Nullable<IEffectFallbacks>;
  34112. /**
  34113. * Callback that will be called when the shader is compiled.
  34114. */
  34115. onCompiled: Nullable<(effect: Effect) => void>;
  34116. /**
  34117. * Callback that will be called if an error occurs during shader compilation.
  34118. */
  34119. onError: Nullable<(effect: Effect, errors: string) => void>;
  34120. /**
  34121. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34122. */
  34123. indexParameters?: any;
  34124. /**
  34125. * Max number of lights that can be used in the shader.
  34126. */
  34127. maxSimultaneousLights?: number;
  34128. /**
  34129. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34130. */
  34131. transformFeedbackVaryings?: Nullable<string[]>;
  34132. }
  34133. /**
  34134. * Effect containing vertex and fragment shader that can be executed on an object.
  34135. */
  34136. export class Effect implements IDisposable {
  34137. /**
  34138. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34139. */
  34140. static ShadersRepository: string;
  34141. /**
  34142. * Enable logging of the shader code when a compilation error occurs
  34143. */
  34144. static LogShaderCodeOnCompilationError: boolean;
  34145. /**
  34146. * Name of the effect.
  34147. */
  34148. name: any;
  34149. /**
  34150. * String container all the define statements that should be set on the shader.
  34151. */
  34152. defines: string;
  34153. /**
  34154. * Callback that will be called when the shader is compiled.
  34155. */
  34156. onCompiled: Nullable<(effect: Effect) => void>;
  34157. /**
  34158. * Callback that will be called if an error occurs during shader compilation.
  34159. */
  34160. onError: Nullable<(effect: Effect, errors: string) => void>;
  34161. /**
  34162. * Callback that will be called when effect is bound.
  34163. */
  34164. onBind: Nullable<(effect: Effect) => void>;
  34165. /**
  34166. * Unique ID of the effect.
  34167. */
  34168. uniqueId: number;
  34169. /**
  34170. * Observable that will be called when the shader is compiled.
  34171. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34172. */
  34173. onCompileObservable: Observable<Effect>;
  34174. /**
  34175. * Observable that will be called if an error occurs during shader compilation.
  34176. */
  34177. onErrorObservable: Observable<Effect>;
  34178. /** @hidden */
  34179. _onBindObservable: Nullable<Observable<Effect>>;
  34180. /**
  34181. * @hidden
  34182. * Specifies if the effect was previously ready
  34183. */
  34184. _wasPreviouslyReady: boolean;
  34185. /**
  34186. * Observable that will be called when effect is bound.
  34187. */
  34188. get onBindObservable(): Observable<Effect>;
  34189. /** @hidden */
  34190. _bonesComputationForcedToCPU: boolean;
  34191. private static _uniqueIdSeed;
  34192. private _engine;
  34193. private _uniformBuffersNames;
  34194. private _uniformBuffersNamesList;
  34195. private _uniformsNames;
  34196. private _samplerList;
  34197. private _samplers;
  34198. private _isReady;
  34199. private _compilationError;
  34200. private _allFallbacksProcessed;
  34201. private _attributesNames;
  34202. private _attributes;
  34203. private _attributeLocationByName;
  34204. private _uniforms;
  34205. /**
  34206. * Key for the effect.
  34207. * @hidden
  34208. */
  34209. _key: string;
  34210. private _indexParameters;
  34211. private _fallbacks;
  34212. private _vertexSourceCode;
  34213. private _fragmentSourceCode;
  34214. private _vertexSourceCodeOverride;
  34215. private _fragmentSourceCodeOverride;
  34216. private _transformFeedbackVaryings;
  34217. /**
  34218. * Compiled shader to webGL program.
  34219. * @hidden
  34220. */
  34221. _pipelineContext: Nullable<IPipelineContext>;
  34222. private _valueCache;
  34223. private static _baseCache;
  34224. /**
  34225. * Instantiates an effect.
  34226. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34227. * @param baseName Name of the effect.
  34228. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34229. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34230. * @param samplers List of sampler variables that will be passed to the shader.
  34231. * @param engine Engine to be used to render the effect
  34232. * @param defines Define statements to be added to the shader.
  34233. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34234. * @param onCompiled Callback that will be called when the shader is compiled.
  34235. * @param onError Callback that will be called if an error occurs during shader compilation.
  34236. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34237. */
  34238. 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);
  34239. private _useFinalCode;
  34240. /**
  34241. * Unique key for this effect
  34242. */
  34243. get key(): string;
  34244. /**
  34245. * If the effect has been compiled and prepared.
  34246. * @returns if the effect is compiled and prepared.
  34247. */
  34248. isReady(): boolean;
  34249. private _isReadyInternal;
  34250. /**
  34251. * The engine the effect was initialized with.
  34252. * @returns the engine.
  34253. */
  34254. getEngine(): Engine;
  34255. /**
  34256. * The pipeline context for this effect
  34257. * @returns the associated pipeline context
  34258. */
  34259. getPipelineContext(): Nullable<IPipelineContext>;
  34260. /**
  34261. * The set of names of attribute variables for the shader.
  34262. * @returns An array of attribute names.
  34263. */
  34264. getAttributesNames(): string[];
  34265. /**
  34266. * Returns the attribute at the given index.
  34267. * @param index The index of the attribute.
  34268. * @returns The location of the attribute.
  34269. */
  34270. getAttributeLocation(index: number): number;
  34271. /**
  34272. * Returns the attribute based on the name of the variable.
  34273. * @param name of the attribute to look up.
  34274. * @returns the attribute location.
  34275. */
  34276. getAttributeLocationByName(name: string): number;
  34277. /**
  34278. * The number of attributes.
  34279. * @returns the numnber of attributes.
  34280. */
  34281. getAttributesCount(): number;
  34282. /**
  34283. * Gets the index of a uniform variable.
  34284. * @param uniformName of the uniform to look up.
  34285. * @returns the index.
  34286. */
  34287. getUniformIndex(uniformName: string): number;
  34288. /**
  34289. * Returns the attribute based on the name of the variable.
  34290. * @param uniformName of the uniform to look up.
  34291. * @returns the location of the uniform.
  34292. */
  34293. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34294. /**
  34295. * Returns an array of sampler variable names
  34296. * @returns The array of sampler variable names.
  34297. */
  34298. getSamplers(): string[];
  34299. /**
  34300. * Returns an array of uniform variable names
  34301. * @returns The array of uniform variable names.
  34302. */
  34303. getUniformNames(): string[];
  34304. /**
  34305. * Returns an array of uniform buffer variable names
  34306. * @returns The array of uniform buffer variable names.
  34307. */
  34308. getUniformBuffersNames(): string[];
  34309. /**
  34310. * Returns the index parameters used to create the effect
  34311. * @returns The index parameters object
  34312. */
  34313. getIndexParameters(): any;
  34314. /**
  34315. * The error from the last compilation.
  34316. * @returns the error string.
  34317. */
  34318. getCompilationError(): string;
  34319. /**
  34320. * Gets a boolean indicating that all fallbacks were used during compilation
  34321. * @returns true if all fallbacks were used
  34322. */
  34323. allFallbacksProcessed(): boolean;
  34324. /**
  34325. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34326. * @param func The callback to be used.
  34327. */
  34328. executeWhenCompiled(func: (effect: Effect) => void): void;
  34329. private _checkIsReady;
  34330. private _loadShader;
  34331. /**
  34332. * Gets the vertex shader source code of this effect
  34333. */
  34334. get vertexSourceCode(): string;
  34335. /**
  34336. * Gets the fragment shader source code of this effect
  34337. */
  34338. get fragmentSourceCode(): string;
  34339. /**
  34340. * Recompiles the webGL program
  34341. * @param vertexSourceCode The source code for the vertex shader.
  34342. * @param fragmentSourceCode The source code for the fragment shader.
  34343. * @param onCompiled Callback called when completed.
  34344. * @param onError Callback called on error.
  34345. * @hidden
  34346. */
  34347. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34348. /**
  34349. * Prepares the effect
  34350. * @hidden
  34351. */
  34352. _prepareEffect(): void;
  34353. private _getShaderCodeAndErrorLine;
  34354. private _processCompilationErrors;
  34355. /**
  34356. * Checks if the effect is supported. (Must be called after compilation)
  34357. */
  34358. get isSupported(): boolean;
  34359. /**
  34360. * Binds a texture to the engine to be used as output of the shader.
  34361. * @param channel Name of the output variable.
  34362. * @param texture Texture to bind.
  34363. * @hidden
  34364. */
  34365. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34366. /**
  34367. * Sets a texture on the engine to be used in the shader.
  34368. * @param channel Name of the sampler variable.
  34369. * @param texture Texture to set.
  34370. */
  34371. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34372. /**
  34373. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34374. * @param channel Name of the sampler variable.
  34375. * @param texture Texture to set.
  34376. */
  34377. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34378. /**
  34379. * Sets an array of textures on the engine to be used in the shader.
  34380. * @param channel Name of the variable.
  34381. * @param textures Textures to set.
  34382. */
  34383. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34384. /**
  34385. * 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)
  34386. * @param channel Name of the sampler variable.
  34387. * @param postProcess Post process to get the input texture from.
  34388. */
  34389. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34390. /**
  34391. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34392. * 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)
  34393. * @param channel Name of the sampler variable.
  34394. * @param postProcess Post process to get the output texture from.
  34395. */
  34396. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34397. /** @hidden */
  34398. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34399. /** @hidden */
  34400. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34401. /** @hidden */
  34402. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34403. /** @hidden */
  34404. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34405. /**
  34406. * Binds a buffer to a uniform.
  34407. * @param buffer Buffer to bind.
  34408. * @param name Name of the uniform variable to bind to.
  34409. */
  34410. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34411. /**
  34412. * Binds block to a uniform.
  34413. * @param blockName Name of the block to bind.
  34414. * @param index Index to bind.
  34415. */
  34416. bindUniformBlock(blockName: string, index: number): void;
  34417. /**
  34418. * Sets an interger value on a uniform variable.
  34419. * @param uniformName Name of the variable.
  34420. * @param value Value to be set.
  34421. * @returns this effect.
  34422. */
  34423. setInt(uniformName: string, value: number): Effect;
  34424. /**
  34425. * Sets an int array on a uniform variable.
  34426. * @param uniformName Name of the variable.
  34427. * @param array array to be set.
  34428. * @returns this effect.
  34429. */
  34430. setIntArray(uniformName: string, array: Int32Array): Effect;
  34431. /**
  34432. * 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)
  34433. * @param uniformName Name of the variable.
  34434. * @param array array to be set.
  34435. * @returns this effect.
  34436. */
  34437. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34438. /**
  34439. * 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)
  34440. * @param uniformName Name of the variable.
  34441. * @param array array to be set.
  34442. * @returns this effect.
  34443. */
  34444. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34445. /**
  34446. * 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)
  34447. * @param uniformName Name of the variable.
  34448. * @param array array to be set.
  34449. * @returns this effect.
  34450. */
  34451. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34452. /**
  34453. * Sets an float array on a uniform variable.
  34454. * @param uniformName Name of the variable.
  34455. * @param array array to be set.
  34456. * @returns this effect.
  34457. */
  34458. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34459. /**
  34460. * 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)
  34461. * @param uniformName Name of the variable.
  34462. * @param array array to be set.
  34463. * @returns this effect.
  34464. */
  34465. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34466. /**
  34467. * 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)
  34468. * @param uniformName Name of the variable.
  34469. * @param array array to be set.
  34470. * @returns this effect.
  34471. */
  34472. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34473. /**
  34474. * 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)
  34475. * @param uniformName Name of the variable.
  34476. * @param array array to be set.
  34477. * @returns this effect.
  34478. */
  34479. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34480. /**
  34481. * Sets an array on a uniform variable.
  34482. * @param uniformName Name of the variable.
  34483. * @param array array to be set.
  34484. * @returns this effect.
  34485. */
  34486. setArray(uniformName: string, array: number[]): Effect;
  34487. /**
  34488. * 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)
  34489. * @param uniformName Name of the variable.
  34490. * @param array array to be set.
  34491. * @returns this effect.
  34492. */
  34493. setArray2(uniformName: string, array: number[]): Effect;
  34494. /**
  34495. * 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)
  34496. * @param uniformName Name of the variable.
  34497. * @param array array to be set.
  34498. * @returns this effect.
  34499. */
  34500. setArray3(uniformName: string, array: number[]): Effect;
  34501. /**
  34502. * 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)
  34503. * @param uniformName Name of the variable.
  34504. * @param array array to be set.
  34505. * @returns this effect.
  34506. */
  34507. setArray4(uniformName: string, array: number[]): Effect;
  34508. /**
  34509. * Sets matrices on a uniform variable.
  34510. * @param uniformName Name of the variable.
  34511. * @param matrices matrices to be set.
  34512. * @returns this effect.
  34513. */
  34514. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34515. /**
  34516. * Sets matrix on a uniform variable.
  34517. * @param uniformName Name of the variable.
  34518. * @param matrix matrix to be set.
  34519. * @returns this effect.
  34520. */
  34521. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34522. /**
  34523. * 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)
  34524. * @param uniformName Name of the variable.
  34525. * @param matrix matrix to be set.
  34526. * @returns this effect.
  34527. */
  34528. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34529. /**
  34530. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34531. * @param uniformName Name of the variable.
  34532. * @param matrix matrix to be set.
  34533. * @returns this effect.
  34534. */
  34535. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34536. /**
  34537. * Sets a float on a uniform variable.
  34538. * @param uniformName Name of the variable.
  34539. * @param value value to be set.
  34540. * @returns this effect.
  34541. */
  34542. setFloat(uniformName: string, value: number): Effect;
  34543. /**
  34544. * Sets a boolean on a uniform variable.
  34545. * @param uniformName Name of the variable.
  34546. * @param bool value to be set.
  34547. * @returns this effect.
  34548. */
  34549. setBool(uniformName: string, bool: boolean): Effect;
  34550. /**
  34551. * Sets a Vector2 on a uniform variable.
  34552. * @param uniformName Name of the variable.
  34553. * @param vector2 vector2 to be set.
  34554. * @returns this effect.
  34555. */
  34556. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34557. /**
  34558. * Sets a float2 on a uniform variable.
  34559. * @param uniformName Name of the variable.
  34560. * @param x First float in float2.
  34561. * @param y Second float in float2.
  34562. * @returns this effect.
  34563. */
  34564. setFloat2(uniformName: string, x: number, y: number): Effect;
  34565. /**
  34566. * Sets a Vector3 on a uniform variable.
  34567. * @param uniformName Name of the variable.
  34568. * @param vector3 Value to be set.
  34569. * @returns this effect.
  34570. */
  34571. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34572. /**
  34573. * Sets a float3 on a uniform variable.
  34574. * @param uniformName Name of the variable.
  34575. * @param x First float in float3.
  34576. * @param y Second float in float3.
  34577. * @param z Third float in float3.
  34578. * @returns this effect.
  34579. */
  34580. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34581. /**
  34582. * Sets a Vector4 on a uniform variable.
  34583. * @param uniformName Name of the variable.
  34584. * @param vector4 Value to be set.
  34585. * @returns this effect.
  34586. */
  34587. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34588. /**
  34589. * Sets a float4 on a uniform variable.
  34590. * @param uniformName Name of the variable.
  34591. * @param x First float in float4.
  34592. * @param y Second float in float4.
  34593. * @param z Third float in float4.
  34594. * @param w Fourth float in float4.
  34595. * @returns this effect.
  34596. */
  34597. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34598. /**
  34599. * Sets a Color3 on a uniform variable.
  34600. * @param uniformName Name of the variable.
  34601. * @param color3 Value to be set.
  34602. * @returns this effect.
  34603. */
  34604. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34605. /**
  34606. * Sets a Color4 on a uniform variable.
  34607. * @param uniformName Name of the variable.
  34608. * @param color3 Value to be set.
  34609. * @param alpha Alpha value to be set.
  34610. * @returns this effect.
  34611. */
  34612. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34613. /**
  34614. * Sets a Color4 on a uniform variable
  34615. * @param uniformName defines the name of the variable
  34616. * @param color4 defines the value to be set
  34617. * @returns this effect.
  34618. */
  34619. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34620. /** Release all associated resources */
  34621. dispose(): void;
  34622. /**
  34623. * This function will add a new shader to the shader store
  34624. * @param name the name of the shader
  34625. * @param pixelShader optional pixel shader content
  34626. * @param vertexShader optional vertex shader content
  34627. */
  34628. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34629. /**
  34630. * Store of each shader (The can be looked up using effect.key)
  34631. */
  34632. static ShadersStore: {
  34633. [key: string]: string;
  34634. };
  34635. /**
  34636. * Store of each included file for a shader (The can be looked up using effect.key)
  34637. */
  34638. static IncludesShadersStore: {
  34639. [key: string]: string;
  34640. };
  34641. /**
  34642. * Resets the cache of effects.
  34643. */
  34644. static ResetCache(): void;
  34645. }
  34646. }
  34647. declare module "babylonjs/Engines/engineCapabilities" {
  34648. /**
  34649. * Interface used to describe the capabilities of the engine relatively to the current browser
  34650. */
  34651. export interface EngineCapabilities {
  34652. /** Maximum textures units per fragment shader */
  34653. maxTexturesImageUnits: number;
  34654. /** Maximum texture units per vertex shader */
  34655. maxVertexTextureImageUnits: number;
  34656. /** Maximum textures units in the entire pipeline */
  34657. maxCombinedTexturesImageUnits: number;
  34658. /** Maximum texture size */
  34659. maxTextureSize: number;
  34660. /** Maximum texture samples */
  34661. maxSamples?: number;
  34662. /** Maximum cube texture size */
  34663. maxCubemapTextureSize: number;
  34664. /** Maximum render texture size */
  34665. maxRenderTextureSize: number;
  34666. /** Maximum number of vertex attributes */
  34667. maxVertexAttribs: number;
  34668. /** Maximum number of varyings */
  34669. maxVaryingVectors: number;
  34670. /** Maximum number of uniforms per vertex shader */
  34671. maxVertexUniformVectors: number;
  34672. /** Maximum number of uniforms per fragment shader */
  34673. maxFragmentUniformVectors: number;
  34674. /** Defines if standard derivates (dx/dy) are supported */
  34675. standardDerivatives: boolean;
  34676. /** Defines if s3tc texture compression is supported */
  34677. s3tc?: WEBGL_compressed_texture_s3tc;
  34678. /** Defines if pvrtc texture compression is supported */
  34679. pvrtc: any;
  34680. /** Defines if etc1 texture compression is supported */
  34681. etc1: any;
  34682. /** Defines if etc2 texture compression is supported */
  34683. etc2: any;
  34684. /** Defines if astc texture compression is supported */
  34685. astc: any;
  34686. /** Defines if float textures are supported */
  34687. textureFloat: boolean;
  34688. /** Defines if vertex array objects are supported */
  34689. vertexArrayObject: boolean;
  34690. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34691. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34692. /** Gets the maximum level of anisotropy supported */
  34693. maxAnisotropy: number;
  34694. /** Defines if instancing is supported */
  34695. instancedArrays: boolean;
  34696. /** Defines if 32 bits indices are supported */
  34697. uintIndices: boolean;
  34698. /** Defines if high precision shaders are supported */
  34699. highPrecisionShaderSupported: boolean;
  34700. /** Defines if depth reading in the fragment shader is supported */
  34701. fragmentDepthSupported: boolean;
  34702. /** Defines if float texture linear filtering is supported*/
  34703. textureFloatLinearFiltering: boolean;
  34704. /** Defines if rendering to float textures is supported */
  34705. textureFloatRender: boolean;
  34706. /** Defines if half float textures are supported*/
  34707. textureHalfFloat: boolean;
  34708. /** Defines if half float texture linear filtering is supported*/
  34709. textureHalfFloatLinearFiltering: boolean;
  34710. /** Defines if rendering to half float textures is supported */
  34711. textureHalfFloatRender: boolean;
  34712. /** Defines if textureLOD shader command is supported */
  34713. textureLOD: boolean;
  34714. /** Defines if draw buffers extension is supported */
  34715. drawBuffersExtension: boolean;
  34716. /** Defines if depth textures are supported */
  34717. depthTextureExtension: boolean;
  34718. /** Defines if float color buffer are supported */
  34719. colorBufferFloat: boolean;
  34720. /** Gets disjoint timer query extension (null if not supported) */
  34721. timerQuery?: EXT_disjoint_timer_query;
  34722. /** Defines if timestamp can be used with timer query */
  34723. canUseTimestampForTimerQuery: boolean;
  34724. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34725. multiview?: any;
  34726. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34727. oculusMultiview?: any;
  34728. /** Function used to let the system compiles shaders in background */
  34729. parallelShaderCompile?: {
  34730. COMPLETION_STATUS_KHR: number;
  34731. };
  34732. /** Max number of texture samples for MSAA */
  34733. maxMSAASamples: number;
  34734. /** Defines if the blend min max extension is supported */
  34735. blendMinMax: boolean;
  34736. }
  34737. }
  34738. declare module "babylonjs/States/depthCullingState" {
  34739. import { Nullable } from "babylonjs/types";
  34740. /**
  34741. * @hidden
  34742. **/
  34743. export class DepthCullingState {
  34744. private _isDepthTestDirty;
  34745. private _isDepthMaskDirty;
  34746. private _isDepthFuncDirty;
  34747. private _isCullFaceDirty;
  34748. private _isCullDirty;
  34749. private _isZOffsetDirty;
  34750. private _isFrontFaceDirty;
  34751. private _depthTest;
  34752. private _depthMask;
  34753. private _depthFunc;
  34754. private _cull;
  34755. private _cullFace;
  34756. private _zOffset;
  34757. private _frontFace;
  34758. /**
  34759. * Initializes the state.
  34760. */
  34761. constructor();
  34762. get isDirty(): boolean;
  34763. get zOffset(): number;
  34764. set zOffset(value: number);
  34765. get cullFace(): Nullable<number>;
  34766. set cullFace(value: Nullable<number>);
  34767. get cull(): Nullable<boolean>;
  34768. set cull(value: Nullable<boolean>);
  34769. get depthFunc(): Nullable<number>;
  34770. set depthFunc(value: Nullable<number>);
  34771. get depthMask(): boolean;
  34772. set depthMask(value: boolean);
  34773. get depthTest(): boolean;
  34774. set depthTest(value: boolean);
  34775. get frontFace(): Nullable<number>;
  34776. set frontFace(value: Nullable<number>);
  34777. reset(): void;
  34778. apply(gl: WebGLRenderingContext): void;
  34779. }
  34780. }
  34781. declare module "babylonjs/States/stencilState" {
  34782. /**
  34783. * @hidden
  34784. **/
  34785. export class StencilState {
  34786. /** 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 */
  34787. static readonly ALWAYS: number;
  34788. /** Passed to stencilOperation to specify that stencil value must be kept */
  34789. static readonly KEEP: number;
  34790. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34791. static readonly REPLACE: number;
  34792. private _isStencilTestDirty;
  34793. private _isStencilMaskDirty;
  34794. private _isStencilFuncDirty;
  34795. private _isStencilOpDirty;
  34796. private _stencilTest;
  34797. private _stencilMask;
  34798. private _stencilFunc;
  34799. private _stencilFuncRef;
  34800. private _stencilFuncMask;
  34801. private _stencilOpStencilFail;
  34802. private _stencilOpDepthFail;
  34803. private _stencilOpStencilDepthPass;
  34804. get isDirty(): boolean;
  34805. get stencilFunc(): number;
  34806. set stencilFunc(value: number);
  34807. get stencilFuncRef(): number;
  34808. set stencilFuncRef(value: number);
  34809. get stencilFuncMask(): number;
  34810. set stencilFuncMask(value: number);
  34811. get stencilOpStencilFail(): number;
  34812. set stencilOpStencilFail(value: number);
  34813. get stencilOpDepthFail(): number;
  34814. set stencilOpDepthFail(value: number);
  34815. get stencilOpStencilDepthPass(): number;
  34816. set stencilOpStencilDepthPass(value: number);
  34817. get stencilMask(): number;
  34818. set stencilMask(value: number);
  34819. get stencilTest(): boolean;
  34820. set stencilTest(value: boolean);
  34821. constructor();
  34822. reset(): void;
  34823. apply(gl: WebGLRenderingContext): void;
  34824. }
  34825. }
  34826. declare module "babylonjs/States/alphaCullingState" {
  34827. /**
  34828. * @hidden
  34829. **/
  34830. export class AlphaState {
  34831. private _isAlphaBlendDirty;
  34832. private _isBlendFunctionParametersDirty;
  34833. private _isBlendEquationParametersDirty;
  34834. private _isBlendConstantsDirty;
  34835. private _alphaBlend;
  34836. private _blendFunctionParameters;
  34837. private _blendEquationParameters;
  34838. private _blendConstants;
  34839. /**
  34840. * Initializes the state.
  34841. */
  34842. constructor();
  34843. get isDirty(): boolean;
  34844. get alphaBlend(): boolean;
  34845. set alphaBlend(value: boolean);
  34846. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34847. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34848. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34849. reset(): void;
  34850. apply(gl: WebGLRenderingContext): void;
  34851. }
  34852. }
  34853. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  34854. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  34855. /** @hidden */
  34856. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34857. attributeProcessor(attribute: string): string;
  34858. varyingProcessor(varying: string, isFragment: boolean): string;
  34859. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34860. }
  34861. }
  34862. declare module "babylonjs/Engines/instancingAttributeInfo" {
  34863. /**
  34864. * Interface for attribute information associated with buffer instanciation
  34865. */
  34866. export interface InstancingAttributeInfo {
  34867. /**
  34868. * Name of the GLSL attribute
  34869. * if attribute index is not specified, this is used to retrieve the index from the effect
  34870. */
  34871. attributeName: string;
  34872. /**
  34873. * Index/offset of the attribute in the vertex shader
  34874. * if not specified, this will be computes from the name.
  34875. */
  34876. index?: number;
  34877. /**
  34878. * size of the attribute, 1, 2, 3 or 4
  34879. */
  34880. attributeSize: number;
  34881. /**
  34882. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34883. */
  34884. offset: number;
  34885. /**
  34886. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34887. * default to 1
  34888. */
  34889. divisor?: number;
  34890. /**
  34891. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34892. * default is FLOAT
  34893. */
  34894. attributeType?: number;
  34895. /**
  34896. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34897. */
  34898. normalized?: boolean;
  34899. }
  34900. }
  34901. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  34902. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34903. import { Nullable } from "babylonjs/types";
  34904. module "babylonjs/Engines/thinEngine" {
  34905. interface ThinEngine {
  34906. /**
  34907. * Update a video texture
  34908. * @param texture defines the texture to update
  34909. * @param video defines the video element to use
  34910. * @param invertY defines if data must be stored with Y axis inverted
  34911. */
  34912. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34913. }
  34914. }
  34915. }
  34916. declare module "babylonjs/Materials/Textures/videoTexture" {
  34917. import { Observable } from "babylonjs/Misc/observable";
  34918. import { Nullable } from "babylonjs/types";
  34919. import { Scene } from "babylonjs/scene";
  34920. import { Texture } from "babylonjs/Materials/Textures/texture";
  34921. import "babylonjs/Engines/Extensions/engine.videoTexture";
  34922. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  34923. /**
  34924. * Settings for finer control over video usage
  34925. */
  34926. export interface VideoTextureSettings {
  34927. /**
  34928. * Applies `autoplay` to video, if specified
  34929. */
  34930. autoPlay?: boolean;
  34931. /**
  34932. * Applies `loop` to video, if specified
  34933. */
  34934. loop?: boolean;
  34935. /**
  34936. * Automatically updates internal texture from video at every frame in the render loop
  34937. */
  34938. autoUpdateTexture: boolean;
  34939. /**
  34940. * Image src displayed during the video loading or until the user interacts with the video.
  34941. */
  34942. poster?: string;
  34943. }
  34944. /**
  34945. * If you want to display a video in your scene, this is the special texture for that.
  34946. * This special texture works similar to other textures, with the exception of a few parameters.
  34947. * @see https://doc.babylonjs.com/how_to/video_texture
  34948. */
  34949. export class VideoTexture extends Texture {
  34950. /**
  34951. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34952. */
  34953. readonly autoUpdateTexture: boolean;
  34954. /**
  34955. * The video instance used by the texture internally
  34956. */
  34957. readonly video: HTMLVideoElement;
  34958. private _onUserActionRequestedObservable;
  34959. /**
  34960. * Event triggerd when a dom action is required by the user to play the video.
  34961. * This happens due to recent changes in browser policies preventing video to auto start.
  34962. */
  34963. get onUserActionRequestedObservable(): Observable<Texture>;
  34964. private _generateMipMaps;
  34965. private _stillImageCaptured;
  34966. private _displayingPosterTexture;
  34967. private _settings;
  34968. private _createInternalTextureOnEvent;
  34969. private _frameId;
  34970. private _currentSrc;
  34971. /**
  34972. * Creates a video texture.
  34973. * If you want to display a video in your scene, this is the special texture for that.
  34974. * This special texture works similar to other textures, with the exception of a few parameters.
  34975. * @see https://doc.babylonjs.com/how_to/video_texture
  34976. * @param name optional name, will detect from video source, if not defined
  34977. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34978. * @param scene is obviously the current scene.
  34979. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34980. * @param invertY is false by default but can be used to invert video on Y axis
  34981. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34982. * @param settings allows finer control over video usage
  34983. */
  34984. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34985. private _getName;
  34986. private _getVideo;
  34987. private _createInternalTexture;
  34988. private reset;
  34989. /**
  34990. * @hidden Internal method to initiate `update`.
  34991. */
  34992. _rebuild(): void;
  34993. /**
  34994. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34995. */
  34996. update(): void;
  34997. /**
  34998. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34999. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35000. */
  35001. updateTexture(isVisible: boolean): void;
  35002. protected _updateInternalTexture: () => void;
  35003. /**
  35004. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35005. * @param url New url.
  35006. */
  35007. updateURL(url: string): void;
  35008. /**
  35009. * Clones the texture.
  35010. * @returns the cloned texture
  35011. */
  35012. clone(): VideoTexture;
  35013. /**
  35014. * Dispose the texture and release its associated resources.
  35015. */
  35016. dispose(): void;
  35017. /**
  35018. * Creates a video texture straight from a stream.
  35019. * @param scene Define the scene the texture should be created in
  35020. * @param stream Define the stream the texture should be created from
  35021. * @returns The created video texture as a promise
  35022. */
  35023. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35024. /**
  35025. * Creates a video texture straight from your WebCam video feed.
  35026. * @param scene Define the scene the texture should be created in
  35027. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35028. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35029. * @returns The created video texture as a promise
  35030. */
  35031. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35032. minWidth: number;
  35033. maxWidth: number;
  35034. minHeight: number;
  35035. maxHeight: number;
  35036. deviceId: string;
  35037. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35038. /**
  35039. * Creates a video texture straight from your WebCam video feed.
  35040. * @param scene Define the scene the texture should be created in
  35041. * @param onReady Define a callback to triggered once the texture will be ready
  35042. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35043. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35044. */
  35045. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35046. minWidth: number;
  35047. maxWidth: number;
  35048. minHeight: number;
  35049. maxHeight: number;
  35050. deviceId: string;
  35051. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35052. }
  35053. }
  35054. declare module "babylonjs/Engines/thinEngine" {
  35055. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35056. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35057. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35058. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35059. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35060. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35061. import { Observable } from "babylonjs/Misc/observable";
  35062. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35063. import { StencilState } from "babylonjs/States/stencilState";
  35064. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35066. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35067. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35068. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35069. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35070. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35071. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35072. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35074. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35075. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35076. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35077. import { WebRequest } from "babylonjs/Misc/webRequest";
  35078. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35079. /**
  35080. * Defines the interface used by objects working like Scene
  35081. * @hidden
  35082. */
  35083. export interface ISceneLike {
  35084. _addPendingData(data: any): void;
  35085. _removePendingData(data: any): void;
  35086. offlineProvider: IOfflineProvider;
  35087. }
  35088. /** Interface defining initialization parameters for Engine class */
  35089. export interface EngineOptions extends WebGLContextAttributes {
  35090. /**
  35091. * Defines if the engine should no exceed a specified device ratio
  35092. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35093. */
  35094. limitDeviceRatio?: number;
  35095. /**
  35096. * Defines if webvr should be enabled automatically
  35097. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35098. */
  35099. autoEnableWebVR?: boolean;
  35100. /**
  35101. * Defines if webgl2 should be turned off even if supported
  35102. * @see http://doc.babylonjs.com/features/webgl2
  35103. */
  35104. disableWebGL2Support?: boolean;
  35105. /**
  35106. * Defines if webaudio should be initialized as well
  35107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35108. */
  35109. audioEngine?: boolean;
  35110. /**
  35111. * Defines if animations should run using a deterministic lock step
  35112. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35113. */
  35114. deterministicLockstep?: boolean;
  35115. /** Defines the maximum steps to use with deterministic lock step mode */
  35116. lockstepMaxSteps?: number;
  35117. /** Defines the seconds between each deterministic lock step */
  35118. timeStep?: number;
  35119. /**
  35120. * Defines that engine should ignore context lost events
  35121. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35122. */
  35123. doNotHandleContextLost?: boolean;
  35124. /**
  35125. * Defines that engine should ignore modifying touch action attribute and style
  35126. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35127. */
  35128. doNotHandleTouchAction?: boolean;
  35129. /**
  35130. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35131. */
  35132. useHighPrecisionFloats?: boolean;
  35133. }
  35134. /**
  35135. * The base engine class (root of all engines)
  35136. */
  35137. export class ThinEngine {
  35138. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35139. static ExceptionList: ({
  35140. key: string;
  35141. capture: string;
  35142. captureConstraint: number;
  35143. targets: string[];
  35144. } | {
  35145. key: string;
  35146. capture: null;
  35147. captureConstraint: null;
  35148. targets: string[];
  35149. })[];
  35150. /** @hidden */
  35151. static _TextureLoaders: IInternalTextureLoader[];
  35152. /**
  35153. * Returns the current npm package of the sdk
  35154. */
  35155. static get NpmPackage(): string;
  35156. /**
  35157. * Returns the current version of the framework
  35158. */
  35159. static get Version(): string;
  35160. /**
  35161. * Returns a string describing the current engine
  35162. */
  35163. get description(): string;
  35164. /**
  35165. * Gets or sets the epsilon value used by collision engine
  35166. */
  35167. static CollisionsEpsilon: number;
  35168. /**
  35169. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35170. */
  35171. static get ShadersRepository(): string;
  35172. static set ShadersRepository(value: string);
  35173. /** @hidden */
  35174. _shaderProcessor: IShaderProcessor;
  35175. /**
  35176. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35177. */
  35178. forcePOTTextures: boolean;
  35179. /**
  35180. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35181. */
  35182. isFullscreen: boolean;
  35183. /**
  35184. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35185. */
  35186. cullBackFaces: boolean;
  35187. /**
  35188. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35189. */
  35190. renderEvenInBackground: boolean;
  35191. /**
  35192. * Gets or sets a boolean indicating that cache can be kept between frames
  35193. */
  35194. preventCacheWipeBetweenFrames: boolean;
  35195. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35196. validateShaderPrograms: boolean;
  35197. /**
  35198. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35199. * This can provide greater z depth for distant objects.
  35200. */
  35201. useReverseDepthBuffer: boolean;
  35202. /**
  35203. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35204. */
  35205. disableUniformBuffers: boolean;
  35206. /** @hidden */
  35207. _uniformBuffers: UniformBuffer[];
  35208. /**
  35209. * Gets a boolean indicating that the engine supports uniform buffers
  35210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35211. */
  35212. get supportsUniformBuffers(): boolean;
  35213. /** @hidden */
  35214. _gl: WebGLRenderingContext;
  35215. /** @hidden */
  35216. _webGLVersion: number;
  35217. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35218. protected _windowIsBackground: boolean;
  35219. protected _creationOptions: EngineOptions;
  35220. protected _highPrecisionShadersAllowed: boolean;
  35221. /** @hidden */
  35222. get _shouldUseHighPrecisionShader(): boolean;
  35223. /**
  35224. * Gets a boolean indicating that only power of 2 textures are supported
  35225. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35226. */
  35227. get needPOTTextures(): boolean;
  35228. /** @hidden */
  35229. _badOS: boolean;
  35230. /** @hidden */
  35231. _badDesktopOS: boolean;
  35232. private _hardwareScalingLevel;
  35233. /** @hidden */
  35234. _caps: EngineCapabilities;
  35235. private _isStencilEnable;
  35236. private _glVersion;
  35237. private _glRenderer;
  35238. private _glVendor;
  35239. /** @hidden */
  35240. _videoTextureSupported: boolean;
  35241. protected _renderingQueueLaunched: boolean;
  35242. protected _activeRenderLoops: (() => void)[];
  35243. /**
  35244. * Observable signaled when a context lost event is raised
  35245. */
  35246. onContextLostObservable: Observable<ThinEngine>;
  35247. /**
  35248. * Observable signaled when a context restored event is raised
  35249. */
  35250. onContextRestoredObservable: Observable<ThinEngine>;
  35251. private _onContextLost;
  35252. private _onContextRestored;
  35253. protected _contextWasLost: boolean;
  35254. /** @hidden */
  35255. _doNotHandleContextLost: boolean;
  35256. /**
  35257. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35259. */
  35260. get doNotHandleContextLost(): boolean;
  35261. set doNotHandleContextLost(value: boolean);
  35262. /**
  35263. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35264. */
  35265. disableVertexArrayObjects: boolean;
  35266. /** @hidden */
  35267. protected _colorWrite: boolean;
  35268. /** @hidden */
  35269. protected _colorWriteChanged: boolean;
  35270. /** @hidden */
  35271. protected _depthCullingState: DepthCullingState;
  35272. /** @hidden */
  35273. protected _stencilState: StencilState;
  35274. /** @hidden */
  35275. _alphaState: AlphaState;
  35276. /** @hidden */
  35277. _alphaMode: number;
  35278. /** @hidden */
  35279. _alphaEquation: number;
  35280. /** @hidden */
  35281. _internalTexturesCache: InternalTexture[];
  35282. /** @hidden */
  35283. protected _activeChannel: number;
  35284. private _currentTextureChannel;
  35285. /** @hidden */
  35286. protected _boundTexturesCache: {
  35287. [key: string]: Nullable<InternalTexture>;
  35288. };
  35289. /** @hidden */
  35290. protected _currentEffect: Nullable<Effect>;
  35291. /** @hidden */
  35292. protected _currentProgram: Nullable<WebGLProgram>;
  35293. private _compiledEffects;
  35294. private _vertexAttribArraysEnabled;
  35295. /** @hidden */
  35296. protected _cachedViewport: Nullable<IViewportLike>;
  35297. private _cachedVertexArrayObject;
  35298. /** @hidden */
  35299. protected _cachedVertexBuffers: any;
  35300. /** @hidden */
  35301. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35302. /** @hidden */
  35303. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35304. /** @hidden */
  35305. _currentRenderTarget: Nullable<InternalTexture>;
  35306. private _uintIndicesCurrentlySet;
  35307. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35308. /** @hidden */
  35309. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35310. /** @hidden */
  35311. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35312. private _currentBufferPointers;
  35313. private _currentInstanceLocations;
  35314. private _currentInstanceBuffers;
  35315. private _textureUnits;
  35316. /** @hidden */
  35317. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35318. /** @hidden */
  35319. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35320. /** @hidden */
  35321. _boundRenderFunction: any;
  35322. private _vaoRecordInProgress;
  35323. private _mustWipeVertexAttributes;
  35324. private _emptyTexture;
  35325. private _emptyCubeTexture;
  35326. private _emptyTexture3D;
  35327. private _emptyTexture2DArray;
  35328. /** @hidden */
  35329. _frameHandler: number;
  35330. private _nextFreeTextureSlots;
  35331. private _maxSimultaneousTextures;
  35332. private _activeRequests;
  35333. /** @hidden */
  35334. _transformTextureUrl: Nullable<(url: string) => string>;
  35335. protected get _supportsHardwareTextureRescaling(): boolean;
  35336. private _framebufferDimensionsObject;
  35337. /**
  35338. * sets the object from which width and height will be taken from when getting render width and height
  35339. * Will fallback to the gl object
  35340. * @param dimensions the framebuffer width and height that will be used.
  35341. */
  35342. set framebufferDimensionsObject(dimensions: Nullable<{
  35343. framebufferWidth: number;
  35344. framebufferHeight: number;
  35345. }>);
  35346. /**
  35347. * Gets the current viewport
  35348. */
  35349. get currentViewport(): Nullable<IViewportLike>;
  35350. /**
  35351. * Gets the default empty texture
  35352. */
  35353. get emptyTexture(): InternalTexture;
  35354. /**
  35355. * Gets the default empty 3D texture
  35356. */
  35357. get emptyTexture3D(): InternalTexture;
  35358. /**
  35359. * Gets the default empty 2D array texture
  35360. */
  35361. get emptyTexture2DArray(): InternalTexture;
  35362. /**
  35363. * Gets the default empty cube texture
  35364. */
  35365. get emptyCubeTexture(): InternalTexture;
  35366. /**
  35367. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35368. */
  35369. readonly premultipliedAlpha: boolean;
  35370. /**
  35371. * Observable event triggered before each texture is initialized
  35372. */
  35373. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35374. /**
  35375. * Creates a new engine
  35376. * @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
  35377. * @param antialias defines enable antialiasing (default: false)
  35378. * @param options defines further options to be sent to the getContext() function
  35379. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35380. */
  35381. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35382. private _rebuildInternalTextures;
  35383. private _rebuildEffects;
  35384. /**
  35385. * Gets a boolean indicating if all created effects are ready
  35386. * @returns true if all effects are ready
  35387. */
  35388. areAllEffectsReady(): boolean;
  35389. protected _rebuildBuffers(): void;
  35390. protected _initGLContext(): void;
  35391. /**
  35392. * Gets version of the current webGL context
  35393. */
  35394. get webGLVersion(): number;
  35395. /**
  35396. * Gets a string idenfifying the name of the class
  35397. * @returns "Engine" string
  35398. */
  35399. getClassName(): string;
  35400. /**
  35401. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35402. */
  35403. get isStencilEnable(): boolean;
  35404. /** @hidden */
  35405. _prepareWorkingCanvas(): void;
  35406. /**
  35407. * Reset the texture cache to empty state
  35408. */
  35409. resetTextureCache(): void;
  35410. /**
  35411. * Gets an object containing information about the current webGL context
  35412. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35413. */
  35414. getGlInfo(): {
  35415. vendor: string;
  35416. renderer: string;
  35417. version: string;
  35418. };
  35419. /**
  35420. * Defines the hardware scaling level.
  35421. * By default the hardware scaling level is computed from the window device ratio.
  35422. * 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.
  35423. * @param level defines the level to use
  35424. */
  35425. setHardwareScalingLevel(level: number): void;
  35426. /**
  35427. * Gets the current hardware scaling level.
  35428. * By default the hardware scaling level is computed from the window device ratio.
  35429. * 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.
  35430. * @returns a number indicating the current hardware scaling level
  35431. */
  35432. getHardwareScalingLevel(): number;
  35433. /**
  35434. * Gets the list of loaded textures
  35435. * @returns an array containing all loaded textures
  35436. */
  35437. getLoadedTexturesCache(): InternalTexture[];
  35438. /**
  35439. * Gets the object containing all engine capabilities
  35440. * @returns the EngineCapabilities object
  35441. */
  35442. getCaps(): EngineCapabilities;
  35443. /**
  35444. * stop executing a render loop function and remove it from the execution array
  35445. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35446. */
  35447. stopRenderLoop(renderFunction?: () => void): void;
  35448. /** @hidden */
  35449. _renderLoop(): void;
  35450. /**
  35451. * Gets the HTML canvas attached with the current webGL context
  35452. * @returns a HTML canvas
  35453. */
  35454. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35455. /**
  35456. * Gets host window
  35457. * @returns the host window object
  35458. */
  35459. getHostWindow(): Nullable<Window>;
  35460. /**
  35461. * Gets the current render width
  35462. * @param useScreen defines if screen size must be used (or the current render target if any)
  35463. * @returns a number defining the current render width
  35464. */
  35465. getRenderWidth(useScreen?: boolean): number;
  35466. /**
  35467. * Gets the current render height
  35468. * @param useScreen defines if screen size must be used (or the current render target if any)
  35469. * @returns a number defining the current render height
  35470. */
  35471. getRenderHeight(useScreen?: boolean): number;
  35472. /**
  35473. * Can be used to override the current requestAnimationFrame requester.
  35474. * @hidden
  35475. */
  35476. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35477. /**
  35478. * Register and execute a render loop. The engine can have more than one render function
  35479. * @param renderFunction defines the function to continuously execute
  35480. */
  35481. runRenderLoop(renderFunction: () => void): void;
  35482. /**
  35483. * Clear the current render buffer or the current render target (if any is set up)
  35484. * @param color defines the color to use
  35485. * @param backBuffer defines if the back buffer must be cleared
  35486. * @param depth defines if the depth buffer must be cleared
  35487. * @param stencil defines if the stencil buffer must be cleared
  35488. */
  35489. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35490. private _viewportCached;
  35491. /** @hidden */
  35492. _viewport(x: number, y: number, width: number, height: number): void;
  35493. /**
  35494. * Set the WebGL's viewport
  35495. * @param viewport defines the viewport element to be used
  35496. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35497. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35498. */
  35499. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35500. /**
  35501. * Begin a new frame
  35502. */
  35503. beginFrame(): void;
  35504. /**
  35505. * Enf the current frame
  35506. */
  35507. endFrame(): void;
  35508. /**
  35509. * Resize the view according to the canvas' size
  35510. */
  35511. resize(): void;
  35512. /**
  35513. * Force a specific size of the canvas
  35514. * @param width defines the new canvas' width
  35515. * @param height defines the new canvas' height
  35516. */
  35517. setSize(width: number, height: number): void;
  35518. /**
  35519. * Binds the frame buffer to the specified texture.
  35520. * @param texture The texture to render to or null for the default canvas
  35521. * @param faceIndex The face of the texture to render to in case of cube texture
  35522. * @param requiredWidth The width of the target to render to
  35523. * @param requiredHeight The height of the target to render to
  35524. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35525. * @param lodLevel defines the lod level to bind to the frame buffer
  35526. * @param layer defines the 2d array index to bind to frame buffer to
  35527. */
  35528. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35529. /** @hidden */
  35530. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35531. /**
  35532. * Unbind the current render target texture from the webGL context
  35533. * @param texture defines the render target texture to unbind
  35534. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35535. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35536. */
  35537. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35538. /**
  35539. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35540. */
  35541. flushFramebuffer(): void;
  35542. /**
  35543. * Unbind the current render target and bind the default framebuffer
  35544. */
  35545. restoreDefaultFramebuffer(): void;
  35546. /** @hidden */
  35547. protected _resetVertexBufferBinding(): void;
  35548. /**
  35549. * Creates a vertex buffer
  35550. * @param data the data for the vertex buffer
  35551. * @returns the new WebGL static buffer
  35552. */
  35553. createVertexBuffer(data: DataArray): DataBuffer;
  35554. private _createVertexBuffer;
  35555. /**
  35556. * Creates a dynamic vertex buffer
  35557. * @param data the data for the dynamic vertex buffer
  35558. * @returns the new WebGL dynamic buffer
  35559. */
  35560. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35561. protected _resetIndexBufferBinding(): void;
  35562. /**
  35563. * Creates a new index buffer
  35564. * @param indices defines the content of the index buffer
  35565. * @param updatable defines if the index buffer must be updatable
  35566. * @returns a new webGL buffer
  35567. */
  35568. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35569. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35570. /**
  35571. * Bind a webGL buffer to the webGL context
  35572. * @param buffer defines the buffer to bind
  35573. */
  35574. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35575. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35576. private bindBuffer;
  35577. /**
  35578. * update the bound buffer with the given data
  35579. * @param data defines the data to update
  35580. */
  35581. updateArrayBuffer(data: Float32Array): void;
  35582. private _vertexAttribPointer;
  35583. /** @hidden */
  35584. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35585. private _bindVertexBuffersAttributes;
  35586. /**
  35587. * Records a vertex array object
  35588. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35589. * @param vertexBuffers defines the list of vertex buffers to store
  35590. * @param indexBuffer defines the index buffer to store
  35591. * @param effect defines the effect to store
  35592. * @returns the new vertex array object
  35593. */
  35594. recordVertexArrayObject(vertexBuffers: {
  35595. [key: string]: VertexBuffer;
  35596. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35597. /**
  35598. * Bind a specific vertex array object
  35599. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35600. * @param vertexArrayObject defines the vertex array object to bind
  35601. * @param indexBuffer defines the index buffer to bind
  35602. */
  35603. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35604. /**
  35605. * Bind webGl buffers directly to the webGL context
  35606. * @param vertexBuffer defines the vertex buffer to bind
  35607. * @param indexBuffer defines the index buffer to bind
  35608. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35609. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35610. * @param effect defines the effect associated with the vertex buffer
  35611. */
  35612. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35613. private _unbindVertexArrayObject;
  35614. /**
  35615. * Bind a list of vertex buffers to the webGL context
  35616. * @param vertexBuffers defines the list of vertex buffers to bind
  35617. * @param indexBuffer defines the index buffer to bind
  35618. * @param effect defines the effect associated with the vertex buffers
  35619. */
  35620. bindBuffers(vertexBuffers: {
  35621. [key: string]: Nullable<VertexBuffer>;
  35622. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35623. /**
  35624. * Unbind all instance attributes
  35625. */
  35626. unbindInstanceAttributes(): void;
  35627. /**
  35628. * Release and free the memory of a vertex array object
  35629. * @param vao defines the vertex array object to delete
  35630. */
  35631. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35632. /** @hidden */
  35633. _releaseBuffer(buffer: DataBuffer): boolean;
  35634. protected _deleteBuffer(buffer: DataBuffer): void;
  35635. /**
  35636. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35637. * @param instancesBuffer defines the webGL buffer to update and bind
  35638. * @param data defines the data to store in the buffer
  35639. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35640. */
  35641. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35642. /**
  35643. * Bind the content of a webGL buffer used with instantiation
  35644. * @param instancesBuffer defines the webGL buffer to bind
  35645. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35646. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35647. */
  35648. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35649. /**
  35650. * Disable the instance attribute corresponding to the name in parameter
  35651. * @param name defines the name of the attribute to disable
  35652. */
  35653. disableInstanceAttributeByName(name: string): void;
  35654. /**
  35655. * Disable the instance attribute corresponding to the location in parameter
  35656. * @param attributeLocation defines the attribute location of the attribute to disable
  35657. */
  35658. disableInstanceAttribute(attributeLocation: number): void;
  35659. /**
  35660. * Disable the attribute corresponding to the location in parameter
  35661. * @param attributeLocation defines the attribute location of the attribute to disable
  35662. */
  35663. disableAttributeByIndex(attributeLocation: number): void;
  35664. /**
  35665. * Send a draw order
  35666. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35667. * @param indexStart defines the starting index
  35668. * @param indexCount defines the number of index to draw
  35669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35670. */
  35671. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35672. /**
  35673. * Draw a list of points
  35674. * @param verticesStart defines the index of first vertex to draw
  35675. * @param verticesCount defines the count of vertices to draw
  35676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35677. */
  35678. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35679. /**
  35680. * Draw a list of unindexed primitives
  35681. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35682. * @param verticesStart defines the index of first vertex to draw
  35683. * @param verticesCount defines the count of vertices to draw
  35684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35685. */
  35686. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35687. /**
  35688. * Draw a list of indexed primitives
  35689. * @param fillMode defines the primitive to use
  35690. * @param indexStart defines the starting index
  35691. * @param indexCount defines the number of index to draw
  35692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35693. */
  35694. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35695. /**
  35696. * Draw a list of unindexed primitives
  35697. * @param fillMode defines the primitive to use
  35698. * @param verticesStart defines the index of first vertex to draw
  35699. * @param verticesCount defines the count of vertices to draw
  35700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35701. */
  35702. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35703. private _drawMode;
  35704. /** @hidden */
  35705. protected _reportDrawCall(): void;
  35706. /** @hidden */
  35707. _releaseEffect(effect: Effect): void;
  35708. /** @hidden */
  35709. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35710. /**
  35711. * Create a new effect (used to store vertex/fragment shaders)
  35712. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35713. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35714. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35715. * @param samplers defines an array of string used to represent textures
  35716. * @param defines defines the string containing the defines to use to compile the shaders
  35717. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35718. * @param onCompiled defines a function to call when the effect creation is successful
  35719. * @param onError defines a function to call when the effect creation has failed
  35720. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35721. * @returns the new Effect
  35722. */
  35723. 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;
  35724. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35725. private _compileShader;
  35726. private _compileRawShader;
  35727. /** @hidden */
  35728. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35729. /**
  35730. * Directly creates a webGL program
  35731. * @param pipelineContext defines the pipeline context to attach to
  35732. * @param vertexCode defines the vertex shader code to use
  35733. * @param fragmentCode defines the fragment shader code to use
  35734. * @param context defines the webGL context to use (if not set, the current one will be used)
  35735. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35736. * @returns the new webGL program
  35737. */
  35738. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35739. /**
  35740. * Creates a webGL program
  35741. * @param pipelineContext defines the pipeline context to attach to
  35742. * @param vertexCode defines the vertex shader code to use
  35743. * @param fragmentCode defines the fragment shader code to use
  35744. * @param defines defines the string containing the defines to use to compile the shaders
  35745. * @param context defines the webGL context to use (if not set, the current one will be used)
  35746. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35747. * @returns the new webGL program
  35748. */
  35749. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35750. /**
  35751. * Creates a new pipeline context
  35752. * @returns the new pipeline
  35753. */
  35754. createPipelineContext(): IPipelineContext;
  35755. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35756. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35757. /** @hidden */
  35758. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35759. /** @hidden */
  35760. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35761. /** @hidden */
  35762. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35763. /**
  35764. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35765. * @param pipelineContext defines the pipeline context to use
  35766. * @param uniformsNames defines the list of uniform names
  35767. * @returns an array of webGL uniform locations
  35768. */
  35769. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35770. /**
  35771. * Gets the lsit of active attributes for a given webGL program
  35772. * @param pipelineContext defines the pipeline context to use
  35773. * @param attributesNames defines the list of attribute names to get
  35774. * @returns an array of indices indicating the offset of each attribute
  35775. */
  35776. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35777. /**
  35778. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35779. * @param effect defines the effect to activate
  35780. */
  35781. enableEffect(effect: Nullable<Effect>): void;
  35782. /**
  35783. * Set the value of an uniform to a number (int)
  35784. * @param uniform defines the webGL uniform location where to store the value
  35785. * @param value defines the int number to store
  35786. */
  35787. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35788. /**
  35789. * Set the value of an uniform to an array of int32
  35790. * @param uniform defines the webGL uniform location where to store the value
  35791. * @param array defines the array of int32 to store
  35792. */
  35793. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35794. /**
  35795. * Set the value of an uniform to an array of int32 (stored as vec2)
  35796. * @param uniform defines the webGL uniform location where to store the value
  35797. * @param array defines the array of int32 to store
  35798. */
  35799. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35800. /**
  35801. * Set the value of an uniform to an array of int32 (stored as vec3)
  35802. * @param uniform defines the webGL uniform location where to store the value
  35803. * @param array defines the array of int32 to store
  35804. */
  35805. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35806. /**
  35807. * Set the value of an uniform to an array of int32 (stored as vec4)
  35808. * @param uniform defines the webGL uniform location where to store the value
  35809. * @param array defines the array of int32 to store
  35810. */
  35811. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35812. /**
  35813. * Set the value of an uniform to an array of number
  35814. * @param uniform defines the webGL uniform location where to store the value
  35815. * @param array defines the array of number to store
  35816. */
  35817. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35818. /**
  35819. * Set the value of an uniform to an array of number (stored as vec2)
  35820. * @param uniform defines the webGL uniform location where to store the value
  35821. * @param array defines the array of number to store
  35822. */
  35823. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35824. /**
  35825. * Set the value of an uniform to an array of number (stored as vec3)
  35826. * @param uniform defines the webGL uniform location where to store the value
  35827. * @param array defines the array of number to store
  35828. */
  35829. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35830. /**
  35831. * Set the value of an uniform to an array of number (stored as vec4)
  35832. * @param uniform defines the webGL uniform location where to store the value
  35833. * @param array defines the array of number to store
  35834. */
  35835. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35836. /**
  35837. * Set the value of an uniform to an array of float32 (stored as matrices)
  35838. * @param uniform defines the webGL uniform location where to store the value
  35839. * @param matrices defines the array of float32 to store
  35840. */
  35841. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35842. /**
  35843. * Set the value of an uniform to a matrix (3x3)
  35844. * @param uniform defines the webGL uniform location where to store the value
  35845. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35846. */
  35847. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35848. /**
  35849. * Set the value of an uniform to a matrix (2x2)
  35850. * @param uniform defines the webGL uniform location where to store the value
  35851. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35852. */
  35853. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35854. /**
  35855. * Set the value of an uniform to a number (float)
  35856. * @param uniform defines the webGL uniform location where to store the value
  35857. * @param value defines the float number to store
  35858. */
  35859. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35860. /**
  35861. * Set the value of an uniform to a vec2
  35862. * @param uniform defines the webGL uniform location where to store the value
  35863. * @param x defines the 1st component of the value
  35864. * @param y defines the 2nd component of the value
  35865. */
  35866. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35867. /**
  35868. * Set the value of an uniform to a vec3
  35869. * @param uniform defines the webGL uniform location where to store the value
  35870. * @param x defines the 1st component of the value
  35871. * @param y defines the 2nd component of the value
  35872. * @param z defines the 3rd component of the value
  35873. */
  35874. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35875. /**
  35876. * Set the value of an uniform to a vec4
  35877. * @param uniform defines the webGL uniform location where to store the value
  35878. * @param x defines the 1st component of the value
  35879. * @param y defines the 2nd component of the value
  35880. * @param z defines the 3rd component of the value
  35881. * @param w defines the 4th component of the value
  35882. */
  35883. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35884. /**
  35885. * Apply all cached states (depth, culling, stencil and alpha)
  35886. */
  35887. applyStates(): void;
  35888. /**
  35889. * Enable or disable color writing
  35890. * @param enable defines the state to set
  35891. */
  35892. setColorWrite(enable: boolean): void;
  35893. /**
  35894. * Gets a boolean indicating if color writing is enabled
  35895. * @returns the current color writing state
  35896. */
  35897. getColorWrite(): boolean;
  35898. /**
  35899. * Gets the depth culling state manager
  35900. */
  35901. get depthCullingState(): DepthCullingState;
  35902. /**
  35903. * Gets the alpha state manager
  35904. */
  35905. get alphaState(): AlphaState;
  35906. /**
  35907. * Gets the stencil state manager
  35908. */
  35909. get stencilState(): StencilState;
  35910. /**
  35911. * Clears the list of texture accessible through engine.
  35912. * This can help preventing texture load conflict due to name collision.
  35913. */
  35914. clearInternalTexturesCache(): void;
  35915. /**
  35916. * Force the entire cache to be cleared
  35917. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35918. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35919. */
  35920. wipeCaches(bruteForce?: boolean): void;
  35921. /** @hidden */
  35922. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35923. min: number;
  35924. mag: number;
  35925. };
  35926. /** @hidden */
  35927. _createTexture(): WebGLTexture;
  35928. /**
  35929. * Usually called from Texture.ts.
  35930. * Passed information to create a WebGLTexture
  35931. * @param url defines a value which contains one of the following:
  35932. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35933. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35934. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35935. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35936. * @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)
  35937. * @param scene needed for loading to the correct scene
  35938. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35939. * @param onLoad optional callback to be called upon successful completion
  35940. * @param onError optional callback to be called upon failure
  35941. * @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
  35942. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35943. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35944. * @param forcedExtension defines the extension to use to pick the right loader
  35945. * @param mimeType defines an optional mime type
  35946. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35947. */
  35948. 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;
  35949. /**
  35950. * Loads an image as an HTMLImageElement.
  35951. * @param input url string, ArrayBuffer, or Blob to load
  35952. * @param onLoad callback called when the image successfully loads
  35953. * @param onError callback called when the image fails to load
  35954. * @param offlineProvider offline provider for caching
  35955. * @param mimeType optional mime type
  35956. * @returns the HTMLImageElement of the loaded image
  35957. * @hidden
  35958. */
  35959. 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>;
  35960. /**
  35961. * @hidden
  35962. */
  35963. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35964. private _unpackFlipYCached;
  35965. /**
  35966. * In case you are sharing the context with other applications, it might
  35967. * be interested to not cache the unpack flip y state to ensure a consistent
  35968. * value would be set.
  35969. */
  35970. enableUnpackFlipYCached: boolean;
  35971. /** @hidden */
  35972. _unpackFlipY(value: boolean): void;
  35973. /** @hidden */
  35974. _getUnpackAlignement(): number;
  35975. private _getTextureTarget;
  35976. /**
  35977. * Update the sampling mode of a given texture
  35978. * @param samplingMode defines the required sampling mode
  35979. * @param texture defines the texture to update
  35980. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35981. */
  35982. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35983. /**
  35984. * Update the sampling mode of a given texture
  35985. * @param texture defines the texture to update
  35986. * @param wrapU defines the texture wrap mode of the u coordinates
  35987. * @param wrapV defines the texture wrap mode of the v coordinates
  35988. * @param wrapR defines the texture wrap mode of the r coordinates
  35989. */
  35990. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35991. /** @hidden */
  35992. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35993. width: number;
  35994. height: number;
  35995. layers?: number;
  35996. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35997. /** @hidden */
  35998. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35999. /** @hidden */
  36000. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36001. /**
  36002. * Update a portion of an internal texture
  36003. * @param texture defines the texture to update
  36004. * @param imageData defines the data to store into the texture
  36005. * @param xOffset defines the x coordinates of the update rectangle
  36006. * @param yOffset defines the y coordinates of the update rectangle
  36007. * @param width defines the width of the update rectangle
  36008. * @param height defines the height of the update rectangle
  36009. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36010. * @param lod defines the lod level to update (0 by default)
  36011. */
  36012. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36013. /** @hidden */
  36014. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36015. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36016. private _prepareWebGLTexture;
  36017. /** @hidden */
  36018. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36019. private _getDepthStencilBuffer;
  36020. /** @hidden */
  36021. _releaseFramebufferObjects(texture: InternalTexture): void;
  36022. /** @hidden */
  36023. _releaseTexture(texture: InternalTexture): void;
  36024. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36025. protected _setProgram(program: WebGLProgram): void;
  36026. protected _boundUniforms: {
  36027. [key: number]: WebGLUniformLocation;
  36028. };
  36029. /**
  36030. * Binds an effect to the webGL context
  36031. * @param effect defines the effect to bind
  36032. */
  36033. bindSamplers(effect: Effect): void;
  36034. private _activateCurrentTexture;
  36035. /** @hidden */
  36036. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36037. /** @hidden */
  36038. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36039. /**
  36040. * Unbind all textures from the webGL context
  36041. */
  36042. unbindAllTextures(): void;
  36043. /**
  36044. * Sets a texture to the according uniform.
  36045. * @param channel The texture channel
  36046. * @param uniform The uniform to set
  36047. * @param texture The texture to apply
  36048. */
  36049. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36050. private _bindSamplerUniformToChannel;
  36051. private _getTextureWrapMode;
  36052. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36053. /**
  36054. * Sets an array of texture to the webGL context
  36055. * @param channel defines the channel where the texture array must be set
  36056. * @param uniform defines the associated uniform location
  36057. * @param textures defines the array of textures to bind
  36058. */
  36059. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36060. /** @hidden */
  36061. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36062. private _setTextureParameterFloat;
  36063. private _setTextureParameterInteger;
  36064. /**
  36065. * Unbind all vertex attributes from the webGL context
  36066. */
  36067. unbindAllAttributes(): void;
  36068. /**
  36069. * 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
  36070. */
  36071. releaseEffects(): void;
  36072. /**
  36073. * Dispose and release all associated resources
  36074. */
  36075. dispose(): void;
  36076. /**
  36077. * Attach a new callback raised when context lost event is fired
  36078. * @param callback defines the callback to call
  36079. */
  36080. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36081. /**
  36082. * Attach a new callback raised when context restored event is fired
  36083. * @param callback defines the callback to call
  36084. */
  36085. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36086. /**
  36087. * Get the current error code of the webGL context
  36088. * @returns the error code
  36089. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36090. */
  36091. getError(): number;
  36092. private _canRenderToFloatFramebuffer;
  36093. private _canRenderToHalfFloatFramebuffer;
  36094. private _canRenderToFramebuffer;
  36095. /** @hidden */
  36096. _getWebGLTextureType(type: number): number;
  36097. /** @hidden */
  36098. _getInternalFormat(format: number): number;
  36099. /** @hidden */
  36100. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36101. /** @hidden */
  36102. _getRGBAMultiSampleBufferFormat(type: number): number;
  36103. /** @hidden */
  36104. _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;
  36105. /**
  36106. * Loads a file from a url
  36107. * @param url url to load
  36108. * @param onSuccess callback called when the file successfully loads
  36109. * @param onProgress callback called while file is loading (if the server supports this mode)
  36110. * @param offlineProvider defines the offline provider for caching
  36111. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36112. * @param onError callback called when the file fails to load
  36113. * @returns a file request object
  36114. * @hidden
  36115. */
  36116. 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;
  36117. /**
  36118. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36119. * @param x defines the x coordinate of the rectangle where pixels must be read
  36120. * @param y defines the y coordinate of the rectangle where pixels must be read
  36121. * @param width defines the width of the rectangle where pixels must be read
  36122. * @param height defines the height of the rectangle where pixels must be read
  36123. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36124. * @returns a Uint8Array containing RGBA colors
  36125. */
  36126. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36127. private static _isSupported;
  36128. /**
  36129. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36130. * @returns true if the engine can be created
  36131. * @ignorenaming
  36132. */
  36133. static isSupported(): boolean;
  36134. /**
  36135. * Find the next highest power of two.
  36136. * @param x Number to start search from.
  36137. * @return Next highest power of two.
  36138. */
  36139. static CeilingPOT(x: number): number;
  36140. /**
  36141. * Find the next lowest power of two.
  36142. * @param x Number to start search from.
  36143. * @return Next lowest power of two.
  36144. */
  36145. static FloorPOT(x: number): number;
  36146. /**
  36147. * Find the nearest power of two.
  36148. * @param x Number to start search from.
  36149. * @return Next nearest power of two.
  36150. */
  36151. static NearestPOT(x: number): number;
  36152. /**
  36153. * Get the closest exponent of two
  36154. * @param value defines the value to approximate
  36155. * @param max defines the maximum value to return
  36156. * @param mode defines how to define the closest value
  36157. * @returns closest exponent of two of the given value
  36158. */
  36159. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36160. /**
  36161. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36162. * @param func - the function to be called
  36163. * @param requester - the object that will request the next frame. Falls back to window.
  36164. * @returns frame number
  36165. */
  36166. static QueueNewFrame(func: () => void, requester?: any): number;
  36167. /**
  36168. * Gets host document
  36169. * @returns the host document object
  36170. */
  36171. getHostDocument(): Nullable<Document>;
  36172. }
  36173. }
  36174. declare module "babylonjs/Maths/sphericalPolynomial" {
  36175. import { Vector3 } from "babylonjs/Maths/math.vector";
  36176. import { Color3 } from "babylonjs/Maths/math.color";
  36177. /**
  36178. * Class representing spherical harmonics coefficients to the 3rd degree
  36179. */
  36180. export class SphericalHarmonics {
  36181. /**
  36182. * Defines whether or not the harmonics have been prescaled for rendering.
  36183. */
  36184. preScaled: boolean;
  36185. /**
  36186. * The l0,0 coefficients of the spherical harmonics
  36187. */
  36188. l00: Vector3;
  36189. /**
  36190. * The l1,-1 coefficients of the spherical harmonics
  36191. */
  36192. l1_1: Vector3;
  36193. /**
  36194. * The l1,0 coefficients of the spherical harmonics
  36195. */
  36196. l10: Vector3;
  36197. /**
  36198. * The l1,1 coefficients of the spherical harmonics
  36199. */
  36200. l11: Vector3;
  36201. /**
  36202. * The l2,-2 coefficients of the spherical harmonics
  36203. */
  36204. l2_2: Vector3;
  36205. /**
  36206. * The l2,-1 coefficients of the spherical harmonics
  36207. */
  36208. l2_1: Vector3;
  36209. /**
  36210. * The l2,0 coefficients of the spherical harmonics
  36211. */
  36212. l20: Vector3;
  36213. /**
  36214. * The l2,1 coefficients of the spherical harmonics
  36215. */
  36216. l21: Vector3;
  36217. /**
  36218. * The l2,2 coefficients of the spherical harmonics
  36219. */
  36220. l22: Vector3;
  36221. /**
  36222. * Adds a light to the spherical harmonics
  36223. * @param direction the direction of the light
  36224. * @param color the color of the light
  36225. * @param deltaSolidAngle the delta solid angle of the light
  36226. */
  36227. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36228. /**
  36229. * Scales the spherical harmonics by the given amount
  36230. * @param scale the amount to scale
  36231. */
  36232. scaleInPlace(scale: number): void;
  36233. /**
  36234. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36235. *
  36236. * ```
  36237. * E_lm = A_l * L_lm
  36238. * ```
  36239. *
  36240. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36241. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36242. * the scaling factors are given in equation 9.
  36243. */
  36244. convertIncidentRadianceToIrradiance(): void;
  36245. /**
  36246. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36247. *
  36248. * ```
  36249. * L = (1/pi) * E * rho
  36250. * ```
  36251. *
  36252. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36253. */
  36254. convertIrradianceToLambertianRadiance(): void;
  36255. /**
  36256. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36257. * required operations at run time.
  36258. *
  36259. * This is simply done by scaling back the SH with Ylm constants parameter.
  36260. * The trigonometric part being applied by the shader at run time.
  36261. */
  36262. preScaleForRendering(): void;
  36263. /**
  36264. * Constructs a spherical harmonics from an array.
  36265. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36266. * @returns the spherical harmonics
  36267. */
  36268. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36269. /**
  36270. * Gets the spherical harmonics from polynomial
  36271. * @param polynomial the spherical polynomial
  36272. * @returns the spherical harmonics
  36273. */
  36274. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36275. }
  36276. /**
  36277. * Class representing spherical polynomial coefficients to the 3rd degree
  36278. */
  36279. export class SphericalPolynomial {
  36280. private _harmonics;
  36281. /**
  36282. * The spherical harmonics used to create the polynomials.
  36283. */
  36284. get preScaledHarmonics(): SphericalHarmonics;
  36285. /**
  36286. * The x coefficients of the spherical polynomial
  36287. */
  36288. x: Vector3;
  36289. /**
  36290. * The y coefficients of the spherical polynomial
  36291. */
  36292. y: Vector3;
  36293. /**
  36294. * The z coefficients of the spherical polynomial
  36295. */
  36296. z: Vector3;
  36297. /**
  36298. * The xx coefficients of the spherical polynomial
  36299. */
  36300. xx: Vector3;
  36301. /**
  36302. * The yy coefficients of the spherical polynomial
  36303. */
  36304. yy: Vector3;
  36305. /**
  36306. * The zz coefficients of the spherical polynomial
  36307. */
  36308. zz: Vector3;
  36309. /**
  36310. * The xy coefficients of the spherical polynomial
  36311. */
  36312. xy: Vector3;
  36313. /**
  36314. * The yz coefficients of the spherical polynomial
  36315. */
  36316. yz: Vector3;
  36317. /**
  36318. * The zx coefficients of the spherical polynomial
  36319. */
  36320. zx: Vector3;
  36321. /**
  36322. * Adds an ambient color to the spherical polynomial
  36323. * @param color the color to add
  36324. */
  36325. addAmbient(color: Color3): void;
  36326. /**
  36327. * Scales the spherical polynomial by the given amount
  36328. * @param scale the amount to scale
  36329. */
  36330. scaleInPlace(scale: number): void;
  36331. /**
  36332. * Gets the spherical polynomial from harmonics
  36333. * @param harmonics the spherical harmonics
  36334. * @returns the spherical polynomial
  36335. */
  36336. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36337. /**
  36338. * Constructs a spherical polynomial from an array.
  36339. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36340. * @returns the spherical polynomial
  36341. */
  36342. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36343. }
  36344. }
  36345. declare module "babylonjs/Materials/Textures/internalTexture" {
  36346. import { Observable } from "babylonjs/Misc/observable";
  36347. import { Nullable, int } from "babylonjs/types";
  36348. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36350. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36351. /**
  36352. * Defines the source of the internal texture
  36353. */
  36354. export enum InternalTextureSource {
  36355. /**
  36356. * The source of the texture data is unknown
  36357. */
  36358. Unknown = 0,
  36359. /**
  36360. * Texture data comes from an URL
  36361. */
  36362. Url = 1,
  36363. /**
  36364. * Texture data is only used for temporary storage
  36365. */
  36366. Temp = 2,
  36367. /**
  36368. * Texture data comes from raw data (ArrayBuffer)
  36369. */
  36370. Raw = 3,
  36371. /**
  36372. * Texture content is dynamic (video or dynamic texture)
  36373. */
  36374. Dynamic = 4,
  36375. /**
  36376. * Texture content is generated by rendering to it
  36377. */
  36378. RenderTarget = 5,
  36379. /**
  36380. * Texture content is part of a multi render target process
  36381. */
  36382. MultiRenderTarget = 6,
  36383. /**
  36384. * Texture data comes from a cube data file
  36385. */
  36386. Cube = 7,
  36387. /**
  36388. * Texture data comes from a raw cube data
  36389. */
  36390. CubeRaw = 8,
  36391. /**
  36392. * Texture data come from a prefiltered cube data file
  36393. */
  36394. CubePrefiltered = 9,
  36395. /**
  36396. * Texture content is raw 3D data
  36397. */
  36398. Raw3D = 10,
  36399. /**
  36400. * Texture content is raw 2D array data
  36401. */
  36402. Raw2DArray = 11,
  36403. /**
  36404. * Texture content is a depth texture
  36405. */
  36406. Depth = 12,
  36407. /**
  36408. * Texture data comes from a raw cube data encoded with RGBD
  36409. */
  36410. CubeRawRGBD = 13
  36411. }
  36412. /**
  36413. * Class used to store data associated with WebGL texture data for the engine
  36414. * This class should not be used directly
  36415. */
  36416. export class InternalTexture {
  36417. /** @hidden */
  36418. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36419. /**
  36420. * Defines if the texture is ready
  36421. */
  36422. isReady: boolean;
  36423. /**
  36424. * Defines if the texture is a cube texture
  36425. */
  36426. isCube: boolean;
  36427. /**
  36428. * Defines if the texture contains 3D data
  36429. */
  36430. is3D: boolean;
  36431. /**
  36432. * Defines if the texture contains 2D array data
  36433. */
  36434. is2DArray: boolean;
  36435. /**
  36436. * Defines if the texture contains multiview data
  36437. */
  36438. isMultiview: boolean;
  36439. /**
  36440. * Gets the URL used to load this texture
  36441. */
  36442. url: string;
  36443. /**
  36444. * Gets the sampling mode of the texture
  36445. */
  36446. samplingMode: number;
  36447. /**
  36448. * Gets a boolean indicating if the texture needs mipmaps generation
  36449. */
  36450. generateMipMaps: boolean;
  36451. /**
  36452. * Gets the number of samples used by the texture (WebGL2+ only)
  36453. */
  36454. samples: number;
  36455. /**
  36456. * Gets the type of the texture (int, float...)
  36457. */
  36458. type: number;
  36459. /**
  36460. * Gets the format of the texture (RGB, RGBA...)
  36461. */
  36462. format: number;
  36463. /**
  36464. * Observable called when the texture is loaded
  36465. */
  36466. onLoadedObservable: Observable<InternalTexture>;
  36467. /**
  36468. * Gets the width of the texture
  36469. */
  36470. width: number;
  36471. /**
  36472. * Gets the height of the texture
  36473. */
  36474. height: number;
  36475. /**
  36476. * Gets the depth of the texture
  36477. */
  36478. depth: number;
  36479. /**
  36480. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36481. */
  36482. baseWidth: number;
  36483. /**
  36484. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36485. */
  36486. baseHeight: number;
  36487. /**
  36488. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36489. */
  36490. baseDepth: number;
  36491. /**
  36492. * Gets a boolean indicating if the texture is inverted on Y axis
  36493. */
  36494. invertY: boolean;
  36495. /** @hidden */
  36496. _invertVScale: boolean;
  36497. /** @hidden */
  36498. _associatedChannel: number;
  36499. /** @hidden */
  36500. _source: InternalTextureSource;
  36501. /** @hidden */
  36502. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36503. /** @hidden */
  36504. _bufferView: Nullable<ArrayBufferView>;
  36505. /** @hidden */
  36506. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36507. /** @hidden */
  36508. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36509. /** @hidden */
  36510. _size: number;
  36511. /** @hidden */
  36512. _extension: string;
  36513. /** @hidden */
  36514. _files: Nullable<string[]>;
  36515. /** @hidden */
  36516. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36517. /** @hidden */
  36518. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36519. /** @hidden */
  36520. _framebuffer: Nullable<WebGLFramebuffer>;
  36521. /** @hidden */
  36522. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36523. /** @hidden */
  36524. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36525. /** @hidden */
  36526. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36527. /** @hidden */
  36528. _attachments: Nullable<number[]>;
  36529. /** @hidden */
  36530. _cachedCoordinatesMode: Nullable<number>;
  36531. /** @hidden */
  36532. _cachedWrapU: Nullable<number>;
  36533. /** @hidden */
  36534. _cachedWrapV: Nullable<number>;
  36535. /** @hidden */
  36536. _cachedWrapR: Nullable<number>;
  36537. /** @hidden */
  36538. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36539. /** @hidden */
  36540. _isDisabled: boolean;
  36541. /** @hidden */
  36542. _compression: Nullable<string>;
  36543. /** @hidden */
  36544. _generateStencilBuffer: boolean;
  36545. /** @hidden */
  36546. _generateDepthBuffer: boolean;
  36547. /** @hidden */
  36548. _comparisonFunction: number;
  36549. /** @hidden */
  36550. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36551. /** @hidden */
  36552. _lodGenerationScale: number;
  36553. /** @hidden */
  36554. _lodGenerationOffset: number;
  36555. /** @hidden */
  36556. _depthStencilTexture: Nullable<InternalTexture>;
  36557. /** @hidden */
  36558. _colorTextureArray: Nullable<WebGLTexture>;
  36559. /** @hidden */
  36560. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36561. /** @hidden */
  36562. _lodTextureHigh: Nullable<BaseTexture>;
  36563. /** @hidden */
  36564. _lodTextureMid: Nullable<BaseTexture>;
  36565. /** @hidden */
  36566. _lodTextureLow: Nullable<BaseTexture>;
  36567. /** @hidden */
  36568. _isRGBD: boolean;
  36569. /** @hidden */
  36570. _linearSpecularLOD: boolean;
  36571. /** @hidden */
  36572. _irradianceTexture: Nullable<BaseTexture>;
  36573. /** @hidden */
  36574. _webGLTexture: Nullable<WebGLTexture>;
  36575. /** @hidden */
  36576. _references: number;
  36577. private _engine;
  36578. /**
  36579. * Gets the Engine the texture belongs to.
  36580. * @returns The babylon engine
  36581. */
  36582. getEngine(): ThinEngine;
  36583. /**
  36584. * Gets the data source type of the texture
  36585. */
  36586. get source(): InternalTextureSource;
  36587. /**
  36588. * Creates a new InternalTexture
  36589. * @param engine defines the engine to use
  36590. * @param source defines the type of data that will be used
  36591. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36592. */
  36593. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36594. /**
  36595. * Increments the number of references (ie. the number of Texture that point to it)
  36596. */
  36597. incrementReferences(): void;
  36598. /**
  36599. * Change the size of the texture (not the size of the content)
  36600. * @param width defines the new width
  36601. * @param height defines the new height
  36602. * @param depth defines the new depth (1 by default)
  36603. */
  36604. updateSize(width: int, height: int, depth?: int): void;
  36605. /** @hidden */
  36606. _rebuild(): void;
  36607. /** @hidden */
  36608. _swapAndDie(target: InternalTexture): void;
  36609. /**
  36610. * Dispose the current allocated resources
  36611. */
  36612. dispose(): void;
  36613. }
  36614. }
  36615. declare module "babylonjs/Audio/analyser" {
  36616. import { Scene } from "babylonjs/scene";
  36617. /**
  36618. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36620. */
  36621. export class Analyser {
  36622. /**
  36623. * Gets or sets the smoothing
  36624. * @ignorenaming
  36625. */
  36626. SMOOTHING: number;
  36627. /**
  36628. * Gets or sets the FFT table size
  36629. * @ignorenaming
  36630. */
  36631. FFT_SIZE: number;
  36632. /**
  36633. * Gets or sets the bar graph amplitude
  36634. * @ignorenaming
  36635. */
  36636. BARGRAPHAMPLITUDE: number;
  36637. /**
  36638. * Gets or sets the position of the debug canvas
  36639. * @ignorenaming
  36640. */
  36641. DEBUGCANVASPOS: {
  36642. x: number;
  36643. y: number;
  36644. };
  36645. /**
  36646. * Gets or sets the debug canvas size
  36647. * @ignorenaming
  36648. */
  36649. DEBUGCANVASSIZE: {
  36650. width: number;
  36651. height: number;
  36652. };
  36653. private _byteFreqs;
  36654. private _byteTime;
  36655. private _floatFreqs;
  36656. private _webAudioAnalyser;
  36657. private _debugCanvas;
  36658. private _debugCanvasContext;
  36659. private _scene;
  36660. private _registerFunc;
  36661. private _audioEngine;
  36662. /**
  36663. * Creates a new analyser
  36664. * @param scene defines hosting scene
  36665. */
  36666. constructor(scene: Scene);
  36667. /**
  36668. * Get the number of data values you will have to play with for the visualization
  36669. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36670. * @returns a number
  36671. */
  36672. getFrequencyBinCount(): number;
  36673. /**
  36674. * Gets the current frequency data as a byte array
  36675. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36676. * @returns a Uint8Array
  36677. */
  36678. getByteFrequencyData(): Uint8Array;
  36679. /**
  36680. * Gets the current waveform as a byte array
  36681. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36682. * @returns a Uint8Array
  36683. */
  36684. getByteTimeDomainData(): Uint8Array;
  36685. /**
  36686. * Gets the current frequency data as a float array
  36687. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36688. * @returns a Float32Array
  36689. */
  36690. getFloatFrequencyData(): Float32Array;
  36691. /**
  36692. * Renders the debug canvas
  36693. */
  36694. drawDebugCanvas(): void;
  36695. /**
  36696. * Stops rendering the debug canvas and removes it
  36697. */
  36698. stopDebugCanvas(): void;
  36699. /**
  36700. * Connects two audio nodes
  36701. * @param inputAudioNode defines first node to connect
  36702. * @param outputAudioNode defines second node to connect
  36703. */
  36704. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36705. /**
  36706. * Releases all associated resources
  36707. */
  36708. dispose(): void;
  36709. }
  36710. }
  36711. declare module "babylonjs/Audio/audioEngine" {
  36712. import { IDisposable } from "babylonjs/scene";
  36713. import { Analyser } from "babylonjs/Audio/analyser";
  36714. import { Nullable } from "babylonjs/types";
  36715. import { Observable } from "babylonjs/Misc/observable";
  36716. /**
  36717. * This represents an audio engine and it is responsible
  36718. * to play, synchronize and analyse sounds throughout the application.
  36719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36720. */
  36721. export interface IAudioEngine extends IDisposable {
  36722. /**
  36723. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36724. */
  36725. readonly canUseWebAudio: boolean;
  36726. /**
  36727. * Gets the current AudioContext if available.
  36728. */
  36729. readonly audioContext: Nullable<AudioContext>;
  36730. /**
  36731. * The master gain node defines the global audio volume of your audio engine.
  36732. */
  36733. readonly masterGain: GainNode;
  36734. /**
  36735. * Gets whether or not mp3 are supported by your browser.
  36736. */
  36737. readonly isMP3supported: boolean;
  36738. /**
  36739. * Gets whether or not ogg are supported by your browser.
  36740. */
  36741. readonly isOGGsupported: boolean;
  36742. /**
  36743. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36744. * @ignoreNaming
  36745. */
  36746. WarnedWebAudioUnsupported: boolean;
  36747. /**
  36748. * Defines if the audio engine relies on a custom unlocked button.
  36749. * In this case, the embedded button will not be displayed.
  36750. */
  36751. useCustomUnlockedButton: boolean;
  36752. /**
  36753. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36754. */
  36755. readonly unlocked: boolean;
  36756. /**
  36757. * Event raised when audio has been unlocked on the browser.
  36758. */
  36759. onAudioUnlockedObservable: Observable<AudioEngine>;
  36760. /**
  36761. * Event raised when audio has been locked on the browser.
  36762. */
  36763. onAudioLockedObservable: Observable<AudioEngine>;
  36764. /**
  36765. * Flags the audio engine in Locked state.
  36766. * This happens due to new browser policies preventing audio to autoplay.
  36767. */
  36768. lock(): void;
  36769. /**
  36770. * Unlocks the audio engine once a user action has been done on the dom.
  36771. * This is helpful to resume play once browser policies have been satisfied.
  36772. */
  36773. unlock(): void;
  36774. /**
  36775. * Gets the global volume sets on the master gain.
  36776. * @returns the global volume if set or -1 otherwise
  36777. */
  36778. getGlobalVolume(): number;
  36779. /**
  36780. * Sets the global volume of your experience (sets on the master gain).
  36781. * @param newVolume Defines the new global volume of the application
  36782. */
  36783. setGlobalVolume(newVolume: number): void;
  36784. /**
  36785. * Connect the audio engine to an audio analyser allowing some amazing
  36786. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36788. * @param analyser The analyser to connect to the engine
  36789. */
  36790. connectToAnalyser(analyser: Analyser): void;
  36791. }
  36792. /**
  36793. * This represents the default audio engine used in babylon.
  36794. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36796. */
  36797. export class AudioEngine implements IAudioEngine {
  36798. private _audioContext;
  36799. private _audioContextInitialized;
  36800. private _muteButton;
  36801. private _hostElement;
  36802. /**
  36803. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36804. */
  36805. canUseWebAudio: boolean;
  36806. /**
  36807. * The master gain node defines the global audio volume of your audio engine.
  36808. */
  36809. masterGain: GainNode;
  36810. /**
  36811. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36812. * @ignoreNaming
  36813. */
  36814. WarnedWebAudioUnsupported: boolean;
  36815. /**
  36816. * Gets whether or not mp3 are supported by your browser.
  36817. */
  36818. isMP3supported: boolean;
  36819. /**
  36820. * Gets whether or not ogg are supported by your browser.
  36821. */
  36822. isOGGsupported: boolean;
  36823. /**
  36824. * Gets whether audio has been unlocked on the device.
  36825. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36826. * a user interaction has happened.
  36827. */
  36828. unlocked: boolean;
  36829. /**
  36830. * Defines if the audio engine relies on a custom unlocked button.
  36831. * In this case, the embedded button will not be displayed.
  36832. */
  36833. useCustomUnlockedButton: boolean;
  36834. /**
  36835. * Event raised when audio has been unlocked on the browser.
  36836. */
  36837. onAudioUnlockedObservable: Observable<AudioEngine>;
  36838. /**
  36839. * Event raised when audio has been locked on the browser.
  36840. */
  36841. onAudioLockedObservable: Observable<AudioEngine>;
  36842. /**
  36843. * Gets the current AudioContext if available.
  36844. */
  36845. get audioContext(): Nullable<AudioContext>;
  36846. private _connectedAnalyser;
  36847. /**
  36848. * Instantiates a new audio engine.
  36849. *
  36850. * There should be only one per page as some browsers restrict the number
  36851. * of audio contexts you can create.
  36852. * @param hostElement defines the host element where to display the mute icon if necessary
  36853. */
  36854. constructor(hostElement?: Nullable<HTMLElement>);
  36855. /**
  36856. * Flags the audio engine in Locked state.
  36857. * This happens due to new browser policies preventing audio to autoplay.
  36858. */
  36859. lock(): void;
  36860. /**
  36861. * Unlocks the audio engine once a user action has been done on the dom.
  36862. * This is helpful to resume play once browser policies have been satisfied.
  36863. */
  36864. unlock(): void;
  36865. private _resumeAudioContext;
  36866. private _initializeAudioContext;
  36867. private _tryToRun;
  36868. private _triggerRunningState;
  36869. private _triggerSuspendedState;
  36870. private _displayMuteButton;
  36871. private _moveButtonToTopLeft;
  36872. private _onResize;
  36873. private _hideMuteButton;
  36874. /**
  36875. * Destroy and release the resources associated with the audio ccontext.
  36876. */
  36877. dispose(): void;
  36878. /**
  36879. * Gets the global volume sets on the master gain.
  36880. * @returns the global volume if set or -1 otherwise
  36881. */
  36882. getGlobalVolume(): number;
  36883. /**
  36884. * Sets the global volume of your experience (sets on the master gain).
  36885. * @param newVolume Defines the new global volume of the application
  36886. */
  36887. setGlobalVolume(newVolume: number): void;
  36888. /**
  36889. * Connect the audio engine to an audio analyser allowing some amazing
  36890. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36892. * @param analyser The analyser to connect to the engine
  36893. */
  36894. connectToAnalyser(analyser: Analyser): void;
  36895. }
  36896. }
  36897. declare module "babylonjs/Loading/loadingScreen" {
  36898. /**
  36899. * Interface used to present a loading screen while loading a scene
  36900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36901. */
  36902. export interface ILoadingScreen {
  36903. /**
  36904. * Function called to display the loading screen
  36905. */
  36906. displayLoadingUI: () => void;
  36907. /**
  36908. * Function called to hide the loading screen
  36909. */
  36910. hideLoadingUI: () => void;
  36911. /**
  36912. * Gets or sets the color to use for the background
  36913. */
  36914. loadingUIBackgroundColor: string;
  36915. /**
  36916. * Gets or sets the text to display while loading
  36917. */
  36918. loadingUIText: string;
  36919. }
  36920. /**
  36921. * Class used for the default loading screen
  36922. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36923. */
  36924. export class DefaultLoadingScreen implements ILoadingScreen {
  36925. private _renderingCanvas;
  36926. private _loadingText;
  36927. private _loadingDivBackgroundColor;
  36928. private _loadingDiv;
  36929. private _loadingTextDiv;
  36930. /** Gets or sets the logo url to use for the default loading screen */
  36931. static DefaultLogoUrl: string;
  36932. /** Gets or sets the spinner url to use for the default loading screen */
  36933. static DefaultSpinnerUrl: string;
  36934. /**
  36935. * Creates a new default loading screen
  36936. * @param _renderingCanvas defines the canvas used to render the scene
  36937. * @param _loadingText defines the default text to display
  36938. * @param _loadingDivBackgroundColor defines the default background color
  36939. */
  36940. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36941. /**
  36942. * Function called to display the loading screen
  36943. */
  36944. displayLoadingUI(): void;
  36945. /**
  36946. * Function called to hide the loading screen
  36947. */
  36948. hideLoadingUI(): void;
  36949. /**
  36950. * Gets or sets the text to display while loading
  36951. */
  36952. set loadingUIText(text: string);
  36953. get loadingUIText(): string;
  36954. /**
  36955. * Gets or sets the color to use for the background
  36956. */
  36957. get loadingUIBackgroundColor(): string;
  36958. set loadingUIBackgroundColor(color: string);
  36959. private _resizeLoadingUI;
  36960. }
  36961. }
  36962. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  36963. /**
  36964. * Interface for any object that can request an animation frame
  36965. */
  36966. export interface ICustomAnimationFrameRequester {
  36967. /**
  36968. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36969. */
  36970. renderFunction?: Function;
  36971. /**
  36972. * Called to request the next frame to render to
  36973. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36974. */
  36975. requestAnimationFrame: Function;
  36976. /**
  36977. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36978. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36979. */
  36980. requestID?: number;
  36981. }
  36982. }
  36983. declare module "babylonjs/Misc/performanceMonitor" {
  36984. /**
  36985. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36986. */
  36987. export class PerformanceMonitor {
  36988. private _enabled;
  36989. private _rollingFrameTime;
  36990. private _lastFrameTimeMs;
  36991. /**
  36992. * constructor
  36993. * @param frameSampleSize The number of samples required to saturate the sliding window
  36994. */
  36995. constructor(frameSampleSize?: number);
  36996. /**
  36997. * Samples current frame
  36998. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36999. */
  37000. sampleFrame(timeMs?: number): void;
  37001. /**
  37002. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37003. */
  37004. get averageFrameTime(): number;
  37005. /**
  37006. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37007. */
  37008. get averageFrameTimeVariance(): number;
  37009. /**
  37010. * Returns the frame time of the most recent frame
  37011. */
  37012. get instantaneousFrameTime(): number;
  37013. /**
  37014. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37015. */
  37016. get averageFPS(): number;
  37017. /**
  37018. * Returns the average framerate in frames per second using the most recent frame time
  37019. */
  37020. get instantaneousFPS(): number;
  37021. /**
  37022. * Returns true if enough samples have been taken to completely fill the sliding window
  37023. */
  37024. get isSaturated(): boolean;
  37025. /**
  37026. * Enables contributions to the sliding window sample set
  37027. */
  37028. enable(): void;
  37029. /**
  37030. * Disables contributions to the sliding window sample set
  37031. * Samples will not be interpolated over the disabled period
  37032. */
  37033. disable(): void;
  37034. /**
  37035. * Returns true if sampling is enabled
  37036. */
  37037. get isEnabled(): boolean;
  37038. /**
  37039. * Resets performance monitor
  37040. */
  37041. reset(): void;
  37042. }
  37043. /**
  37044. * RollingAverage
  37045. *
  37046. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37047. */
  37048. export class RollingAverage {
  37049. /**
  37050. * Current average
  37051. */
  37052. average: number;
  37053. /**
  37054. * Current variance
  37055. */
  37056. variance: number;
  37057. protected _samples: Array<number>;
  37058. protected _sampleCount: number;
  37059. protected _pos: number;
  37060. protected _m2: number;
  37061. /**
  37062. * constructor
  37063. * @param length The number of samples required to saturate the sliding window
  37064. */
  37065. constructor(length: number);
  37066. /**
  37067. * Adds a sample to the sample set
  37068. * @param v The sample value
  37069. */
  37070. add(v: number): void;
  37071. /**
  37072. * Returns previously added values or null if outside of history or outside the sliding window domain
  37073. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37074. * @return Value previously recorded with add() or null if outside of range
  37075. */
  37076. history(i: number): number;
  37077. /**
  37078. * Returns true if enough samples have been taken to completely fill the sliding window
  37079. * @return true if sample-set saturated
  37080. */
  37081. isSaturated(): boolean;
  37082. /**
  37083. * Resets the rolling average (equivalent to 0 samples taken so far)
  37084. */
  37085. reset(): void;
  37086. /**
  37087. * Wraps a value around the sample range boundaries
  37088. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37089. * @return Wrapped position in sample range
  37090. */
  37091. protected _wrapPosition(i: number): number;
  37092. }
  37093. }
  37094. declare module "babylonjs/Misc/perfCounter" {
  37095. /**
  37096. * This class is used to track a performance counter which is number based.
  37097. * The user has access to many properties which give statistics of different nature.
  37098. *
  37099. * The implementer can track two kinds of Performance Counter: time and count.
  37100. * 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.
  37101. * 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.
  37102. */
  37103. export class PerfCounter {
  37104. /**
  37105. * Gets or sets a global boolean to turn on and off all the counters
  37106. */
  37107. static Enabled: boolean;
  37108. /**
  37109. * Returns the smallest value ever
  37110. */
  37111. get min(): number;
  37112. /**
  37113. * Returns the biggest value ever
  37114. */
  37115. get max(): number;
  37116. /**
  37117. * Returns the average value since the performance counter is running
  37118. */
  37119. get average(): number;
  37120. /**
  37121. * Returns the average value of the last second the counter was monitored
  37122. */
  37123. get lastSecAverage(): number;
  37124. /**
  37125. * Returns the current value
  37126. */
  37127. get current(): number;
  37128. /**
  37129. * Gets the accumulated total
  37130. */
  37131. get total(): number;
  37132. /**
  37133. * Gets the total value count
  37134. */
  37135. get count(): number;
  37136. /**
  37137. * Creates a new counter
  37138. */
  37139. constructor();
  37140. /**
  37141. * Call this method to start monitoring a new frame.
  37142. * 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.
  37143. */
  37144. fetchNewFrame(): void;
  37145. /**
  37146. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37147. * @param newCount the count value to add to the monitored count
  37148. * @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.
  37149. */
  37150. addCount(newCount: number, fetchResult: boolean): void;
  37151. /**
  37152. * Start monitoring this performance counter
  37153. */
  37154. beginMonitoring(): void;
  37155. /**
  37156. * Compute the time lapsed since the previous beginMonitoring() call.
  37157. * @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
  37158. */
  37159. endMonitoring(newFrame?: boolean): void;
  37160. private _fetchResult;
  37161. private _startMonitoringTime;
  37162. private _min;
  37163. private _max;
  37164. private _average;
  37165. private _current;
  37166. private _totalValueCount;
  37167. private _totalAccumulated;
  37168. private _lastSecAverage;
  37169. private _lastSecAccumulated;
  37170. private _lastSecTime;
  37171. private _lastSecValueCount;
  37172. }
  37173. }
  37174. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37175. module "babylonjs/Engines/thinEngine" {
  37176. interface ThinEngine {
  37177. /**
  37178. * Sets alpha constants used by some alpha blending modes
  37179. * @param r defines the red component
  37180. * @param g defines the green component
  37181. * @param b defines the blue component
  37182. * @param a defines the alpha component
  37183. */
  37184. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37185. /**
  37186. * Sets the current alpha mode
  37187. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37188. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37189. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37190. */
  37191. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37192. /**
  37193. * Gets the current alpha mode
  37194. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37195. * @returns the current alpha mode
  37196. */
  37197. getAlphaMode(): number;
  37198. /**
  37199. * Sets the current alpha equation
  37200. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37201. */
  37202. setAlphaEquation(equation: number): void;
  37203. /**
  37204. * Gets the current alpha equation.
  37205. * @returns the current alpha equation
  37206. */
  37207. getAlphaEquation(): number;
  37208. }
  37209. }
  37210. }
  37211. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37213. import { Nullable } from "babylonjs/types";
  37214. module "babylonjs/Engines/thinEngine" {
  37215. interface ThinEngine {
  37216. /** @hidden */
  37217. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37218. }
  37219. }
  37220. }
  37221. declare module "babylonjs/Engines/engine" {
  37222. import { Observable } from "babylonjs/Misc/observable";
  37223. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37224. import { Scene } from "babylonjs/scene";
  37225. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37226. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37227. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37228. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37229. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37230. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37231. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37232. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37233. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37235. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37236. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37237. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37238. import "babylonjs/Engines/Extensions/engine.alpha";
  37239. import "babylonjs/Engines/Extensions/engine.readTexture";
  37240. import { Material } from "babylonjs/Materials/material";
  37241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37242. /**
  37243. * Defines the interface used by display changed events
  37244. */
  37245. export interface IDisplayChangedEventArgs {
  37246. /** Gets the vrDisplay object (if any) */
  37247. vrDisplay: Nullable<any>;
  37248. /** Gets a boolean indicating if webVR is supported */
  37249. vrSupported: boolean;
  37250. }
  37251. /**
  37252. * Defines the interface used by objects containing a viewport (like a camera)
  37253. */
  37254. interface IViewportOwnerLike {
  37255. /**
  37256. * Gets or sets the viewport
  37257. */
  37258. viewport: IViewportLike;
  37259. }
  37260. /**
  37261. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37262. */
  37263. export class Engine extends ThinEngine {
  37264. /** Defines that alpha blending is disabled */
  37265. static readonly ALPHA_DISABLE: number;
  37266. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37267. static readonly ALPHA_ADD: number;
  37268. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37269. static readonly ALPHA_COMBINE: number;
  37270. /** Defines that alpha blending to DEST - SRC * DEST */
  37271. static readonly ALPHA_SUBTRACT: number;
  37272. /** Defines that alpha blending to SRC * DEST */
  37273. static readonly ALPHA_MULTIPLY: number;
  37274. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37275. static readonly ALPHA_MAXIMIZED: number;
  37276. /** Defines that alpha blending to SRC + DEST */
  37277. static readonly ALPHA_ONEONE: number;
  37278. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37279. static readonly ALPHA_PREMULTIPLIED: number;
  37280. /**
  37281. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37282. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37283. */
  37284. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37285. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37286. static readonly ALPHA_INTERPOLATE: number;
  37287. /**
  37288. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37289. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37290. */
  37291. static readonly ALPHA_SCREENMODE: number;
  37292. /** Defines that the ressource is not delayed*/
  37293. static readonly DELAYLOADSTATE_NONE: number;
  37294. /** Defines that the ressource was successfully delay loaded */
  37295. static readonly DELAYLOADSTATE_LOADED: number;
  37296. /** Defines that the ressource is currently delay loading */
  37297. static readonly DELAYLOADSTATE_LOADING: number;
  37298. /** Defines that the ressource is delayed and has not started loading */
  37299. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37301. static readonly NEVER: number;
  37302. /** 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 */
  37303. static readonly ALWAYS: number;
  37304. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37305. static readonly LESS: number;
  37306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37307. static readonly EQUAL: number;
  37308. /** 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 */
  37309. static readonly LEQUAL: number;
  37310. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37311. static readonly GREATER: number;
  37312. /** 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 */
  37313. static readonly GEQUAL: number;
  37314. /** 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 */
  37315. static readonly NOTEQUAL: number;
  37316. /** Passed to stencilOperation to specify that stencil value must be kept */
  37317. static readonly KEEP: number;
  37318. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37319. static readonly REPLACE: number;
  37320. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37321. static readonly INCR: number;
  37322. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37323. static readonly DECR: number;
  37324. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37325. static readonly INVERT: number;
  37326. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37327. static readonly INCR_WRAP: number;
  37328. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37329. static readonly DECR_WRAP: number;
  37330. /** Texture is not repeating outside of 0..1 UVs */
  37331. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37332. /** Texture is repeating outside of 0..1 UVs */
  37333. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37334. /** Texture is repeating and mirrored */
  37335. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37336. /** ALPHA */
  37337. static readonly TEXTUREFORMAT_ALPHA: number;
  37338. /** LUMINANCE */
  37339. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37340. /** LUMINANCE_ALPHA */
  37341. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37342. /** RGB */
  37343. static readonly TEXTUREFORMAT_RGB: number;
  37344. /** RGBA */
  37345. static readonly TEXTUREFORMAT_RGBA: number;
  37346. /** RED */
  37347. static readonly TEXTUREFORMAT_RED: number;
  37348. /** RED (2nd reference) */
  37349. static readonly TEXTUREFORMAT_R: number;
  37350. /** RG */
  37351. static readonly TEXTUREFORMAT_RG: number;
  37352. /** RED_INTEGER */
  37353. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37354. /** RED_INTEGER (2nd reference) */
  37355. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37356. /** RG_INTEGER */
  37357. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37358. /** RGB_INTEGER */
  37359. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37360. /** RGBA_INTEGER */
  37361. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37362. /** UNSIGNED_BYTE */
  37363. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37364. /** UNSIGNED_BYTE (2nd reference) */
  37365. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37366. /** FLOAT */
  37367. static readonly TEXTURETYPE_FLOAT: number;
  37368. /** HALF_FLOAT */
  37369. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37370. /** BYTE */
  37371. static readonly TEXTURETYPE_BYTE: number;
  37372. /** SHORT */
  37373. static readonly TEXTURETYPE_SHORT: number;
  37374. /** UNSIGNED_SHORT */
  37375. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37376. /** INT */
  37377. static readonly TEXTURETYPE_INT: number;
  37378. /** UNSIGNED_INT */
  37379. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37380. /** UNSIGNED_SHORT_4_4_4_4 */
  37381. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37382. /** UNSIGNED_SHORT_5_5_5_1 */
  37383. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37384. /** UNSIGNED_SHORT_5_6_5 */
  37385. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37386. /** UNSIGNED_INT_2_10_10_10_REV */
  37387. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37388. /** UNSIGNED_INT_24_8 */
  37389. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37390. /** UNSIGNED_INT_10F_11F_11F_REV */
  37391. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37392. /** UNSIGNED_INT_5_9_9_9_REV */
  37393. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37394. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37395. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37396. /** nearest is mag = nearest and min = nearest and mip = linear */
  37397. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37398. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37399. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37400. /** Trilinear is mag = linear and min = linear and mip = linear */
  37401. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37402. /** nearest is mag = nearest and min = nearest and mip = linear */
  37403. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37405. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37406. /** Trilinear is mag = linear and min = linear and mip = linear */
  37407. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37408. /** mag = nearest and min = nearest and mip = nearest */
  37409. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37410. /** mag = nearest and min = linear and mip = nearest */
  37411. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37412. /** mag = nearest and min = linear and mip = linear */
  37413. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37414. /** mag = nearest and min = linear and mip = none */
  37415. static readonly TEXTURE_NEAREST_LINEAR: number;
  37416. /** mag = nearest and min = nearest and mip = none */
  37417. static readonly TEXTURE_NEAREST_NEAREST: number;
  37418. /** mag = linear and min = nearest and mip = nearest */
  37419. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37420. /** mag = linear and min = nearest and mip = linear */
  37421. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37422. /** mag = linear and min = linear and mip = none */
  37423. static readonly TEXTURE_LINEAR_LINEAR: number;
  37424. /** mag = linear and min = nearest and mip = none */
  37425. static readonly TEXTURE_LINEAR_NEAREST: number;
  37426. /** Explicit coordinates mode */
  37427. static readonly TEXTURE_EXPLICIT_MODE: number;
  37428. /** Spherical coordinates mode */
  37429. static readonly TEXTURE_SPHERICAL_MODE: number;
  37430. /** Planar coordinates mode */
  37431. static readonly TEXTURE_PLANAR_MODE: number;
  37432. /** Cubic coordinates mode */
  37433. static readonly TEXTURE_CUBIC_MODE: number;
  37434. /** Projection coordinates mode */
  37435. static readonly TEXTURE_PROJECTION_MODE: number;
  37436. /** Skybox coordinates mode */
  37437. static readonly TEXTURE_SKYBOX_MODE: number;
  37438. /** Inverse Cubic coordinates mode */
  37439. static readonly TEXTURE_INVCUBIC_MODE: number;
  37440. /** Equirectangular coordinates mode */
  37441. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37442. /** Equirectangular Fixed coordinates mode */
  37443. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37444. /** Equirectangular Fixed Mirrored coordinates mode */
  37445. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37446. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37447. static readonly SCALEMODE_FLOOR: number;
  37448. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37449. static readonly SCALEMODE_NEAREST: number;
  37450. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37451. static readonly SCALEMODE_CEILING: number;
  37452. /**
  37453. * Returns the current npm package of the sdk
  37454. */
  37455. static get NpmPackage(): string;
  37456. /**
  37457. * Returns the current version of the framework
  37458. */
  37459. static get Version(): string;
  37460. /** Gets the list of created engines */
  37461. static get Instances(): Engine[];
  37462. /**
  37463. * Gets the latest created engine
  37464. */
  37465. static get LastCreatedEngine(): Nullable<Engine>;
  37466. /**
  37467. * Gets the latest created scene
  37468. */
  37469. static get LastCreatedScene(): Nullable<Scene>;
  37470. /**
  37471. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37472. * @param flag defines which part of the materials must be marked as dirty
  37473. * @param predicate defines a predicate used to filter which materials should be affected
  37474. */
  37475. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37476. /**
  37477. * Method called to create the default loading screen.
  37478. * This can be overriden in your own app.
  37479. * @param canvas The rendering canvas element
  37480. * @returns The loading screen
  37481. */
  37482. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37483. /**
  37484. * Method called to create the default rescale post process on each engine.
  37485. */
  37486. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37487. /**
  37488. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37489. **/
  37490. enableOfflineSupport: boolean;
  37491. /**
  37492. * 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)
  37493. **/
  37494. disableManifestCheck: boolean;
  37495. /**
  37496. * Gets the list of created scenes
  37497. */
  37498. scenes: Scene[];
  37499. /**
  37500. * Event raised when a new scene is created
  37501. */
  37502. onNewSceneAddedObservable: Observable<Scene>;
  37503. /**
  37504. * Gets the list of created postprocesses
  37505. */
  37506. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37507. /**
  37508. * Gets a boolean indicating if the pointer is currently locked
  37509. */
  37510. isPointerLock: boolean;
  37511. /**
  37512. * Observable event triggered each time the rendering canvas is resized
  37513. */
  37514. onResizeObservable: Observable<Engine>;
  37515. /**
  37516. * Observable event triggered each time the canvas loses focus
  37517. */
  37518. onCanvasBlurObservable: Observable<Engine>;
  37519. /**
  37520. * Observable event triggered each time the canvas gains focus
  37521. */
  37522. onCanvasFocusObservable: Observable<Engine>;
  37523. /**
  37524. * Observable event triggered each time the canvas receives pointerout event
  37525. */
  37526. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37527. /**
  37528. * Observable raised when the engine begins a new frame
  37529. */
  37530. onBeginFrameObservable: Observable<Engine>;
  37531. /**
  37532. * If set, will be used to request the next animation frame for the render loop
  37533. */
  37534. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37535. /**
  37536. * Observable raised when the engine ends the current frame
  37537. */
  37538. onEndFrameObservable: Observable<Engine>;
  37539. /**
  37540. * Observable raised when the engine is about to compile a shader
  37541. */
  37542. onBeforeShaderCompilationObservable: Observable<Engine>;
  37543. /**
  37544. * Observable raised when the engine has jsut compiled a shader
  37545. */
  37546. onAfterShaderCompilationObservable: Observable<Engine>;
  37547. /**
  37548. * Gets the audio engine
  37549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37550. * @ignorenaming
  37551. */
  37552. static audioEngine: IAudioEngine;
  37553. /**
  37554. * Default AudioEngine factory responsible of creating the Audio Engine.
  37555. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37556. */
  37557. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37558. /**
  37559. * Default offline support factory responsible of creating a tool used to store data locally.
  37560. * By default, this will create a Database object if the workload has been embedded.
  37561. */
  37562. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37563. private _loadingScreen;
  37564. private _pointerLockRequested;
  37565. private _rescalePostProcess;
  37566. private _deterministicLockstep;
  37567. private _lockstepMaxSteps;
  37568. private _timeStep;
  37569. protected get _supportsHardwareTextureRescaling(): boolean;
  37570. private _fps;
  37571. private _deltaTime;
  37572. /** @hidden */
  37573. _drawCalls: PerfCounter;
  37574. /** 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 */
  37575. canvasTabIndex: number;
  37576. /**
  37577. * Turn this value on if you want to pause FPS computation when in background
  37578. */
  37579. disablePerformanceMonitorInBackground: boolean;
  37580. private _performanceMonitor;
  37581. /**
  37582. * Gets the performance monitor attached to this engine
  37583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37584. */
  37585. get performanceMonitor(): PerformanceMonitor;
  37586. private _onFocus;
  37587. private _onBlur;
  37588. private _onCanvasPointerOut;
  37589. private _onCanvasBlur;
  37590. private _onCanvasFocus;
  37591. private _onFullscreenChange;
  37592. private _onPointerLockChange;
  37593. /**
  37594. * Gets the HTML element used to attach event listeners
  37595. * @returns a HTML element
  37596. */
  37597. getInputElement(): Nullable<HTMLElement>;
  37598. /**
  37599. * Creates a new engine
  37600. * @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
  37601. * @param antialias defines enable antialiasing (default: false)
  37602. * @param options defines further options to be sent to the getContext() function
  37603. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37604. */
  37605. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37606. /**
  37607. * Gets current aspect ratio
  37608. * @param viewportOwner defines the camera to use to get the aspect ratio
  37609. * @param useScreen defines if screen size must be used (or the current render target if any)
  37610. * @returns a number defining the aspect ratio
  37611. */
  37612. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37613. /**
  37614. * Gets current screen aspect ratio
  37615. * @returns a number defining the aspect ratio
  37616. */
  37617. getScreenAspectRatio(): number;
  37618. /**
  37619. * Gets the client rect of the HTML canvas attached with the current webGL context
  37620. * @returns a client rectanglee
  37621. */
  37622. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37623. /**
  37624. * Gets the client rect of the HTML element used for events
  37625. * @returns a client rectanglee
  37626. */
  37627. getInputElementClientRect(): Nullable<ClientRect>;
  37628. /**
  37629. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37630. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37631. * @returns true if engine is in deterministic lock step mode
  37632. */
  37633. isDeterministicLockStep(): boolean;
  37634. /**
  37635. * Gets the max steps when engine is running in deterministic lock step
  37636. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37637. * @returns the max steps
  37638. */
  37639. getLockstepMaxSteps(): number;
  37640. /**
  37641. * Returns the time in ms between steps when using deterministic lock step.
  37642. * @returns time step in (ms)
  37643. */
  37644. getTimeStep(): number;
  37645. /**
  37646. * Force the mipmap generation for the given render target texture
  37647. * @param texture defines the render target texture to use
  37648. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37649. */
  37650. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37651. /** States */
  37652. /**
  37653. * Set various states to the webGL context
  37654. * @param culling defines backface culling state
  37655. * @param zOffset defines the value to apply to zOffset (0 by default)
  37656. * @param force defines if states must be applied even if cache is up to date
  37657. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37658. */
  37659. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37660. /**
  37661. * Set the z offset to apply to current rendering
  37662. * @param value defines the offset to apply
  37663. */
  37664. setZOffset(value: number): void;
  37665. /**
  37666. * Gets the current value of the zOffset
  37667. * @returns the current zOffset state
  37668. */
  37669. getZOffset(): number;
  37670. /**
  37671. * Enable or disable depth buffering
  37672. * @param enable defines the state to set
  37673. */
  37674. setDepthBuffer(enable: boolean): void;
  37675. /**
  37676. * Gets a boolean indicating if depth writing is enabled
  37677. * @returns the current depth writing state
  37678. */
  37679. getDepthWrite(): boolean;
  37680. /**
  37681. * Enable or disable depth writing
  37682. * @param enable defines the state to set
  37683. */
  37684. setDepthWrite(enable: boolean): void;
  37685. /**
  37686. * Gets a boolean indicating if stencil buffer is enabled
  37687. * @returns the current stencil buffer state
  37688. */
  37689. getStencilBuffer(): boolean;
  37690. /**
  37691. * Enable or disable the stencil buffer
  37692. * @param enable defines if the stencil buffer must be enabled or disabled
  37693. */
  37694. setStencilBuffer(enable: boolean): void;
  37695. /**
  37696. * Gets the current stencil mask
  37697. * @returns a number defining the new stencil mask to use
  37698. */
  37699. getStencilMask(): number;
  37700. /**
  37701. * Sets the current stencil mask
  37702. * @param mask defines the new stencil mask to use
  37703. */
  37704. setStencilMask(mask: number): void;
  37705. /**
  37706. * Gets the current stencil function
  37707. * @returns a number defining the stencil function to use
  37708. */
  37709. getStencilFunction(): number;
  37710. /**
  37711. * Gets the current stencil reference value
  37712. * @returns a number defining the stencil reference value to use
  37713. */
  37714. getStencilFunctionReference(): number;
  37715. /**
  37716. * Gets the current stencil mask
  37717. * @returns a number defining the stencil mask to use
  37718. */
  37719. getStencilFunctionMask(): number;
  37720. /**
  37721. * Sets the current stencil function
  37722. * @param stencilFunc defines the new stencil function to use
  37723. */
  37724. setStencilFunction(stencilFunc: number): void;
  37725. /**
  37726. * Sets the current stencil reference
  37727. * @param reference defines the new stencil reference to use
  37728. */
  37729. setStencilFunctionReference(reference: number): void;
  37730. /**
  37731. * Sets the current stencil mask
  37732. * @param mask defines the new stencil mask to use
  37733. */
  37734. setStencilFunctionMask(mask: number): void;
  37735. /**
  37736. * Gets the current stencil operation when stencil fails
  37737. * @returns a number defining stencil operation to use when stencil fails
  37738. */
  37739. getStencilOperationFail(): number;
  37740. /**
  37741. * Gets the current stencil operation when depth fails
  37742. * @returns a number defining stencil operation to use when depth fails
  37743. */
  37744. getStencilOperationDepthFail(): number;
  37745. /**
  37746. * Gets the current stencil operation when stencil passes
  37747. * @returns a number defining stencil operation to use when stencil passes
  37748. */
  37749. getStencilOperationPass(): number;
  37750. /**
  37751. * Sets the stencil operation to use when stencil fails
  37752. * @param operation defines the stencil operation to use when stencil fails
  37753. */
  37754. setStencilOperationFail(operation: number): void;
  37755. /**
  37756. * Sets the stencil operation to use when depth fails
  37757. * @param operation defines the stencil operation to use when depth fails
  37758. */
  37759. setStencilOperationDepthFail(operation: number): void;
  37760. /**
  37761. * Sets the stencil operation to use when stencil passes
  37762. * @param operation defines the stencil operation to use when stencil passes
  37763. */
  37764. setStencilOperationPass(operation: number): void;
  37765. /**
  37766. * Sets a boolean indicating if the dithering state is enabled or disabled
  37767. * @param value defines the dithering state
  37768. */
  37769. setDitheringState(value: boolean): void;
  37770. /**
  37771. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37772. * @param value defines the rasterizer state
  37773. */
  37774. setRasterizerState(value: boolean): void;
  37775. /**
  37776. * Gets the current depth function
  37777. * @returns a number defining the depth function
  37778. */
  37779. getDepthFunction(): Nullable<number>;
  37780. /**
  37781. * Sets the current depth function
  37782. * @param depthFunc defines the function to use
  37783. */
  37784. setDepthFunction(depthFunc: number): void;
  37785. /**
  37786. * Sets the current depth function to GREATER
  37787. */
  37788. setDepthFunctionToGreater(): void;
  37789. /**
  37790. * Sets the current depth function to GEQUAL
  37791. */
  37792. setDepthFunctionToGreaterOrEqual(): void;
  37793. /**
  37794. * Sets the current depth function to LESS
  37795. */
  37796. setDepthFunctionToLess(): void;
  37797. /**
  37798. * Sets the current depth function to LEQUAL
  37799. */
  37800. setDepthFunctionToLessOrEqual(): void;
  37801. private _cachedStencilBuffer;
  37802. private _cachedStencilFunction;
  37803. private _cachedStencilMask;
  37804. private _cachedStencilOperationPass;
  37805. private _cachedStencilOperationFail;
  37806. private _cachedStencilOperationDepthFail;
  37807. private _cachedStencilReference;
  37808. /**
  37809. * Caches the the state of the stencil buffer
  37810. */
  37811. cacheStencilState(): void;
  37812. /**
  37813. * Restores the state of the stencil buffer
  37814. */
  37815. restoreStencilState(): void;
  37816. /**
  37817. * Directly set the WebGL Viewport
  37818. * @param x defines the x coordinate of the viewport (in screen space)
  37819. * @param y defines the y coordinate of the viewport (in screen space)
  37820. * @param width defines the width of the viewport (in screen space)
  37821. * @param height defines the height of the viewport (in screen space)
  37822. * @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
  37823. */
  37824. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37825. /**
  37826. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37827. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37828. * @param y defines the y-coordinate of the corner of the clear rectangle
  37829. * @param width defines the width of the clear rectangle
  37830. * @param height defines the height of the clear rectangle
  37831. * @param clearColor defines the clear color
  37832. */
  37833. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37834. /**
  37835. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37836. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37837. * @param y defines the y-coordinate of the corner of the clear rectangle
  37838. * @param width defines the width of the clear rectangle
  37839. * @param height defines the height of the clear rectangle
  37840. */
  37841. enableScissor(x: number, y: number, width: number, height: number): void;
  37842. /**
  37843. * Disable previously set scissor test rectangle
  37844. */
  37845. disableScissor(): void;
  37846. protected _reportDrawCall(): void;
  37847. /**
  37848. * Initializes a webVR display and starts listening to display change events
  37849. * The onVRDisplayChangedObservable will be notified upon these changes
  37850. * @returns The onVRDisplayChangedObservable
  37851. */
  37852. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37853. /** @hidden */
  37854. _prepareVRComponent(): void;
  37855. /** @hidden */
  37856. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37857. /** @hidden */
  37858. _submitVRFrame(): void;
  37859. /**
  37860. * Call this function to leave webVR mode
  37861. * Will do nothing if webVR is not supported or if there is no webVR device
  37862. * @see http://doc.babylonjs.com/how_to/webvr_camera
  37863. */
  37864. disableVR(): void;
  37865. /**
  37866. * Gets a boolean indicating that the system is in VR mode and is presenting
  37867. * @returns true if VR mode is engaged
  37868. */
  37869. isVRPresenting(): boolean;
  37870. /** @hidden */
  37871. _requestVRFrame(): void;
  37872. /** @hidden */
  37873. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37874. /**
  37875. * Gets the source code of the vertex shader associated with a specific webGL program
  37876. * @param program defines the program to use
  37877. * @returns a string containing the source code of the vertex shader associated with the program
  37878. */
  37879. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37880. /**
  37881. * Gets the source code of the fragment shader associated with a specific webGL program
  37882. * @param program defines the program to use
  37883. * @returns a string containing the source code of the fragment shader associated with the program
  37884. */
  37885. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37886. /**
  37887. * Sets a depth stencil texture from a render target to the according uniform.
  37888. * @param channel The texture channel
  37889. * @param uniform The uniform to set
  37890. * @param texture The render target texture containing the depth stencil texture to apply
  37891. */
  37892. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37893. /**
  37894. * Sets a texture to the webGL context from a postprocess
  37895. * @param channel defines the channel to use
  37896. * @param postProcess defines the source postprocess
  37897. */
  37898. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37899. /**
  37900. * Binds the output of the passed in post process to the texture channel specified
  37901. * @param channel The channel the texture should be bound to
  37902. * @param postProcess The post process which's output should be bound
  37903. */
  37904. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37905. protected _rebuildBuffers(): void;
  37906. /** @hidden */
  37907. _renderFrame(): void;
  37908. _renderLoop(): void;
  37909. /** @hidden */
  37910. _renderViews(): boolean;
  37911. /**
  37912. * Toggle full screen mode
  37913. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37914. */
  37915. switchFullscreen(requestPointerLock: boolean): void;
  37916. /**
  37917. * Enters full screen mode
  37918. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37919. */
  37920. enterFullscreen(requestPointerLock: boolean): void;
  37921. /**
  37922. * Exits full screen mode
  37923. */
  37924. exitFullscreen(): void;
  37925. /**
  37926. * Enters Pointerlock mode
  37927. */
  37928. enterPointerlock(): void;
  37929. /**
  37930. * Exits Pointerlock mode
  37931. */
  37932. exitPointerlock(): void;
  37933. /**
  37934. * Begin a new frame
  37935. */
  37936. beginFrame(): void;
  37937. /**
  37938. * Enf the current frame
  37939. */
  37940. endFrame(): void;
  37941. resize(): void;
  37942. /**
  37943. * Force a specific size of the canvas
  37944. * @param width defines the new canvas' width
  37945. * @param height defines the new canvas' height
  37946. */
  37947. setSize(width: number, height: number): void;
  37948. /**
  37949. * Updates a dynamic vertex buffer.
  37950. * @param vertexBuffer the vertex buffer to update
  37951. * @param data the data used to update the vertex buffer
  37952. * @param byteOffset the byte offset of the data
  37953. * @param byteLength the byte length of the data
  37954. */
  37955. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37956. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37957. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37958. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37959. _releaseTexture(texture: InternalTexture): void;
  37960. /**
  37961. * @hidden
  37962. * Rescales a texture
  37963. * @param source input texutre
  37964. * @param destination destination texture
  37965. * @param scene scene to use to render the resize
  37966. * @param internalFormat format to use when resizing
  37967. * @param onComplete callback to be called when resize has completed
  37968. */
  37969. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37970. /**
  37971. * Gets the current framerate
  37972. * @returns a number representing the framerate
  37973. */
  37974. getFps(): number;
  37975. /**
  37976. * Gets the time spent between current and previous frame
  37977. * @returns a number representing the delta time in ms
  37978. */
  37979. getDeltaTime(): number;
  37980. private _measureFps;
  37981. /** @hidden */
  37982. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37983. /**
  37984. * Update a dynamic index buffer
  37985. * @param indexBuffer defines the target index buffer
  37986. * @param indices defines the data to update
  37987. * @param offset defines the offset in the target index buffer where update should start
  37988. */
  37989. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37990. /**
  37991. * Updates the sample count of a render target texture
  37992. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37993. * @param texture defines the texture to update
  37994. * @param samples defines the sample count to set
  37995. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37996. */
  37997. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37998. /**
  37999. * Updates a depth texture Comparison Mode and Function.
  38000. * If the comparison Function is equal to 0, the mode will be set to none.
  38001. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38002. * @param texture The texture to set the comparison function for
  38003. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38004. */
  38005. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38006. /**
  38007. * Creates a webGL buffer to use with instanciation
  38008. * @param capacity defines the size of the buffer
  38009. * @returns the webGL buffer
  38010. */
  38011. createInstancesBuffer(capacity: number): DataBuffer;
  38012. /**
  38013. * Delete a webGL buffer used with instanciation
  38014. * @param buffer defines the webGL buffer to delete
  38015. */
  38016. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38017. private _clientWaitAsync;
  38018. /** @hidden */
  38019. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38020. dispose(): void;
  38021. private _disableTouchAction;
  38022. /**
  38023. * Display the loading screen
  38024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38025. */
  38026. displayLoadingUI(): void;
  38027. /**
  38028. * Hide the loading screen
  38029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38030. */
  38031. hideLoadingUI(): void;
  38032. /**
  38033. * Gets the current loading screen object
  38034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38035. */
  38036. get loadingScreen(): ILoadingScreen;
  38037. /**
  38038. * Sets the current loading screen object
  38039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38040. */
  38041. set loadingScreen(loadingScreen: ILoadingScreen);
  38042. /**
  38043. * Sets the current loading screen text
  38044. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38045. */
  38046. set loadingUIText(text: string);
  38047. /**
  38048. * Sets the current loading screen background color
  38049. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38050. */
  38051. set loadingUIBackgroundColor(color: string);
  38052. /** Pointerlock and fullscreen */
  38053. /**
  38054. * Ask the browser to promote the current element to pointerlock mode
  38055. * @param element defines the DOM element to promote
  38056. */
  38057. static _RequestPointerlock(element: HTMLElement): void;
  38058. /**
  38059. * Asks the browser to exit pointerlock mode
  38060. */
  38061. static _ExitPointerlock(): void;
  38062. /**
  38063. * Ask the browser to promote the current element to fullscreen rendering mode
  38064. * @param element defines the DOM element to promote
  38065. */
  38066. static _RequestFullscreen(element: HTMLElement): void;
  38067. /**
  38068. * Asks the browser to exit fullscreen mode
  38069. */
  38070. static _ExitFullscreen(): void;
  38071. }
  38072. }
  38073. declare module "babylonjs/Engines/engineStore" {
  38074. import { Nullable } from "babylonjs/types";
  38075. import { Engine } from "babylonjs/Engines/engine";
  38076. import { Scene } from "babylonjs/scene";
  38077. /**
  38078. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38079. * during the life time of the application.
  38080. */
  38081. export class EngineStore {
  38082. /** Gets the list of created engines */
  38083. static Instances: import("babylonjs/Engines/engine").Engine[];
  38084. /** @hidden */
  38085. static _LastCreatedScene: Nullable<Scene>;
  38086. /**
  38087. * Gets the latest created engine
  38088. */
  38089. static get LastCreatedEngine(): Nullable<Engine>;
  38090. /**
  38091. * Gets the latest created scene
  38092. */
  38093. static get LastCreatedScene(): Nullable<Scene>;
  38094. /**
  38095. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38096. * @ignorenaming
  38097. */
  38098. static UseFallbackTexture: boolean;
  38099. /**
  38100. * Texture content used if a texture cannot loaded
  38101. * @ignorenaming
  38102. */
  38103. static FallbackTexture: string;
  38104. }
  38105. }
  38106. declare module "babylonjs/Misc/promise" {
  38107. /**
  38108. * Helper class that provides a small promise polyfill
  38109. */
  38110. export class PromisePolyfill {
  38111. /**
  38112. * Static function used to check if the polyfill is required
  38113. * If this is the case then the function will inject the polyfill to window.Promise
  38114. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38115. */
  38116. static Apply(force?: boolean): void;
  38117. }
  38118. }
  38119. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38120. /**
  38121. * Interface for screenshot methods with describe argument called `size` as object with options
  38122. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38123. */
  38124. export interface IScreenshotSize {
  38125. /**
  38126. * number in pixels for canvas height
  38127. */
  38128. height?: number;
  38129. /**
  38130. * multiplier allowing render at a higher or lower resolution
  38131. * If value is defined then height and width will be ignored and taken from camera
  38132. */
  38133. precision?: number;
  38134. /**
  38135. * number in pixels for canvas width
  38136. */
  38137. width?: number;
  38138. }
  38139. }
  38140. declare module "babylonjs/Misc/tools" {
  38141. import { Nullable, float } from "babylonjs/types";
  38142. import { DomManagement } from "babylonjs/Misc/domManagement";
  38143. import { WebRequest } from "babylonjs/Misc/webRequest";
  38144. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38145. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38146. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38147. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38148. import { Camera } from "babylonjs/Cameras/camera";
  38149. import { Engine } from "babylonjs/Engines/engine";
  38150. interface IColor4Like {
  38151. r: float;
  38152. g: float;
  38153. b: float;
  38154. a: float;
  38155. }
  38156. /**
  38157. * Class containing a set of static utilities functions
  38158. */
  38159. export class Tools {
  38160. /**
  38161. * Gets or sets the base URL to use to load assets
  38162. */
  38163. static get BaseUrl(): string;
  38164. static set BaseUrl(value: string);
  38165. /**
  38166. * Enable/Disable Custom HTTP Request Headers globally.
  38167. * default = false
  38168. * @see CustomRequestHeaders
  38169. */
  38170. static UseCustomRequestHeaders: boolean;
  38171. /**
  38172. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38173. * i.e. when loading files, where the server/service expects an Authorization header
  38174. */
  38175. static CustomRequestHeaders: {
  38176. [key: string]: string;
  38177. };
  38178. /**
  38179. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38180. */
  38181. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38182. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38183. /**
  38184. * Default behaviour for cors in the application.
  38185. * It can be a string if the expected behavior is identical in the entire app.
  38186. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38187. */
  38188. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38189. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38190. /**
  38191. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38192. * @ignorenaming
  38193. */
  38194. static get UseFallbackTexture(): boolean;
  38195. static set UseFallbackTexture(value: boolean);
  38196. /**
  38197. * Use this object to register external classes like custom textures or material
  38198. * to allow the laoders to instantiate them
  38199. */
  38200. static get RegisteredExternalClasses(): {
  38201. [key: string]: Object;
  38202. };
  38203. static set RegisteredExternalClasses(classes: {
  38204. [key: string]: Object;
  38205. });
  38206. /**
  38207. * Texture content used if a texture cannot loaded
  38208. * @ignorenaming
  38209. */
  38210. static get fallbackTexture(): string;
  38211. static set fallbackTexture(value: string);
  38212. /**
  38213. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38214. * @param u defines the coordinate on X axis
  38215. * @param v defines the coordinate on Y axis
  38216. * @param width defines the width of the source data
  38217. * @param height defines the height of the source data
  38218. * @param pixels defines the source byte array
  38219. * @param color defines the output color
  38220. */
  38221. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38222. /**
  38223. * Interpolates between a and b via alpha
  38224. * @param a The lower value (returned when alpha = 0)
  38225. * @param b The upper value (returned when alpha = 1)
  38226. * @param alpha The interpolation-factor
  38227. * @return The mixed value
  38228. */
  38229. static Mix(a: number, b: number, alpha: number): number;
  38230. /**
  38231. * Tries to instantiate a new object from a given class name
  38232. * @param className defines the class name to instantiate
  38233. * @returns the new object or null if the system was not able to do the instantiation
  38234. */
  38235. static Instantiate(className: string): any;
  38236. /**
  38237. * Provides a slice function that will work even on IE
  38238. * @param data defines the array to slice
  38239. * @param start defines the start of the data (optional)
  38240. * @param end defines the end of the data (optional)
  38241. * @returns the new sliced array
  38242. */
  38243. static Slice<T>(data: T, start?: number, end?: number): T;
  38244. /**
  38245. * Polyfill for setImmediate
  38246. * @param action defines the action to execute after the current execution block
  38247. */
  38248. static SetImmediate(action: () => void): void;
  38249. /**
  38250. * Function indicating if a number is an exponent of 2
  38251. * @param value defines the value to test
  38252. * @returns true if the value is an exponent of 2
  38253. */
  38254. static IsExponentOfTwo(value: number): boolean;
  38255. private static _tmpFloatArray;
  38256. /**
  38257. * Returns the nearest 32-bit single precision float representation of a Number
  38258. * @param value A Number. If the parameter is of a different type, it will get converted
  38259. * to a number or to NaN if it cannot be converted
  38260. * @returns number
  38261. */
  38262. static FloatRound(value: number): number;
  38263. /**
  38264. * Extracts the filename from a path
  38265. * @param path defines the path to use
  38266. * @returns the filename
  38267. */
  38268. static GetFilename(path: string): string;
  38269. /**
  38270. * Extracts the "folder" part of a path (everything before the filename).
  38271. * @param uri The URI to extract the info from
  38272. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38273. * @returns The "folder" part of the path
  38274. */
  38275. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38276. /**
  38277. * Extracts text content from a DOM element hierarchy
  38278. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38279. */
  38280. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38281. /**
  38282. * Convert an angle in radians to degrees
  38283. * @param angle defines the angle to convert
  38284. * @returns the angle in degrees
  38285. */
  38286. static ToDegrees(angle: number): number;
  38287. /**
  38288. * Convert an angle in degrees to radians
  38289. * @param angle defines the angle to convert
  38290. * @returns the angle in radians
  38291. */
  38292. static ToRadians(angle: number): number;
  38293. /**
  38294. * Returns an array if obj is not an array
  38295. * @param obj defines the object to evaluate as an array
  38296. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38297. * @returns either obj directly if obj is an array or a new array containing obj
  38298. */
  38299. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38300. /**
  38301. * Gets the pointer prefix to use
  38302. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38303. */
  38304. static GetPointerPrefix(): string;
  38305. /**
  38306. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38307. * @param url define the url we are trying
  38308. * @param element define the dom element where to configure the cors policy
  38309. */
  38310. static SetCorsBehavior(url: string | string[], element: {
  38311. crossOrigin: string | null;
  38312. }): void;
  38313. /**
  38314. * Removes unwanted characters from an url
  38315. * @param url defines the url to clean
  38316. * @returns the cleaned url
  38317. */
  38318. static CleanUrl(url: string): string;
  38319. /**
  38320. * Gets or sets a function used to pre-process url before using them to load assets
  38321. */
  38322. static get PreprocessUrl(): (url: string) => string;
  38323. static set PreprocessUrl(processor: (url: string) => string);
  38324. /**
  38325. * Loads an image as an HTMLImageElement.
  38326. * @param input url string, ArrayBuffer, or Blob to load
  38327. * @param onLoad callback called when the image successfully loads
  38328. * @param onError callback called when the image fails to load
  38329. * @param offlineProvider offline provider for caching
  38330. * @param mimeType optional mime type
  38331. * @returns the HTMLImageElement of the loaded image
  38332. */
  38333. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38334. /**
  38335. * Loads a file from a url
  38336. * @param url url string, ArrayBuffer, or Blob to load
  38337. * @param onSuccess callback called when the file successfully loads
  38338. * @param onProgress callback called while file is loading (if the server supports this mode)
  38339. * @param offlineProvider defines the offline provider for caching
  38340. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38341. * @param onError callback called when the file fails to load
  38342. * @returns a file request object
  38343. */
  38344. 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;
  38345. /**
  38346. * Loads a file from a url
  38347. * @param url the file url to load
  38348. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38349. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38350. */
  38351. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38352. /**
  38353. * Load a script (identified by an url). When the url returns, the
  38354. * content of this file is added into a new script element, attached to the DOM (body element)
  38355. * @param scriptUrl defines the url of the script to laod
  38356. * @param onSuccess defines the callback called when the script is loaded
  38357. * @param onError defines the callback to call if an error occurs
  38358. * @param scriptId defines the id of the script element
  38359. */
  38360. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38361. /**
  38362. * Load an asynchronous script (identified by an url). When the url returns, the
  38363. * content of this file is added into a new script element, attached to the DOM (body element)
  38364. * @param scriptUrl defines the url of the script to laod
  38365. * @param scriptId defines the id of the script element
  38366. * @returns a promise request object
  38367. */
  38368. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38369. /**
  38370. * Loads a file from a blob
  38371. * @param fileToLoad defines the blob to use
  38372. * @param callback defines the callback to call when data is loaded
  38373. * @param progressCallback defines the callback to call during loading process
  38374. * @returns a file request object
  38375. */
  38376. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38377. /**
  38378. * Reads a file from a File object
  38379. * @param file defines the file to load
  38380. * @param onSuccess defines the callback to call when data is loaded
  38381. * @param onProgress defines the callback to call during loading process
  38382. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38383. * @param onError defines the callback to call when an error occurs
  38384. * @returns a file request object
  38385. */
  38386. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38387. /**
  38388. * Creates a data url from a given string content
  38389. * @param content defines the content to convert
  38390. * @returns the new data url link
  38391. */
  38392. static FileAsURL(content: string): string;
  38393. /**
  38394. * Format the given number to a specific decimal format
  38395. * @param value defines the number to format
  38396. * @param decimals defines the number of decimals to use
  38397. * @returns the formatted string
  38398. */
  38399. static Format(value: number, decimals?: number): string;
  38400. /**
  38401. * Tries to copy an object by duplicating every property
  38402. * @param source defines the source object
  38403. * @param destination defines the target object
  38404. * @param doNotCopyList defines a list of properties to avoid
  38405. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38406. */
  38407. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38408. /**
  38409. * Gets a boolean indicating if the given object has no own property
  38410. * @param obj defines the object to test
  38411. * @returns true if object has no own property
  38412. */
  38413. static IsEmpty(obj: any): boolean;
  38414. /**
  38415. * Function used to register events at window level
  38416. * @param windowElement defines the Window object to use
  38417. * @param events defines the events to register
  38418. */
  38419. static RegisterTopRootEvents(windowElement: Window, events: {
  38420. name: string;
  38421. handler: Nullable<(e: FocusEvent) => any>;
  38422. }[]): void;
  38423. /**
  38424. * Function used to unregister events from window level
  38425. * @param windowElement defines the Window object to use
  38426. * @param events defines the events to unregister
  38427. */
  38428. static UnregisterTopRootEvents(windowElement: Window, events: {
  38429. name: string;
  38430. handler: Nullable<(e: FocusEvent) => any>;
  38431. }[]): void;
  38432. /**
  38433. * @ignore
  38434. */
  38435. static _ScreenshotCanvas: HTMLCanvasElement;
  38436. /**
  38437. * Dumps the current bound framebuffer
  38438. * @param width defines the rendering width
  38439. * @param height defines the rendering height
  38440. * @param engine defines the hosting engine
  38441. * @param successCallback defines the callback triggered once the data are available
  38442. * @param mimeType defines the mime type of the result
  38443. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38444. */
  38445. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38446. /**
  38447. * Converts the canvas data to blob.
  38448. * This acts as a polyfill for browsers not supporting the to blob function.
  38449. * @param canvas Defines the canvas to extract the data from
  38450. * @param successCallback Defines the callback triggered once the data are available
  38451. * @param mimeType Defines the mime type of the result
  38452. */
  38453. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38454. /**
  38455. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38456. * @param successCallback defines the callback triggered once the data are available
  38457. * @param mimeType defines the mime type of the result
  38458. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38459. */
  38460. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38461. /**
  38462. * Downloads a blob in the browser
  38463. * @param blob defines the blob to download
  38464. * @param fileName defines the name of the downloaded file
  38465. */
  38466. static Download(blob: Blob, fileName: string): void;
  38467. /**
  38468. * Captures a screenshot of the current rendering
  38469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38470. * @param engine defines the rendering engine
  38471. * @param camera defines the source camera
  38472. * @param size This parameter can be set to a single number or to an object with the
  38473. * following (optional) properties: precision, width, height. If a single number is passed,
  38474. * it will be used for both width and height. If an object is passed, the screenshot size
  38475. * will be derived from the parameters. The precision property is a multiplier allowing
  38476. * rendering at a higher or lower resolution
  38477. * @param successCallback defines the callback receives a single parameter which contains the
  38478. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38479. * src parameter of an <img> to display it
  38480. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38481. * Check your browser for supported MIME types
  38482. */
  38483. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38484. /**
  38485. * Captures a screenshot of the current rendering
  38486. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38487. * @param engine defines the rendering engine
  38488. * @param camera defines the source camera
  38489. * @param size This parameter can be set to a single number or to an object with the
  38490. * following (optional) properties: precision, width, height. If a single number is passed,
  38491. * it will be used for both width and height. If an object is passed, the screenshot size
  38492. * will be derived from the parameters. The precision property is a multiplier allowing
  38493. * rendering at a higher or lower resolution
  38494. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38495. * Check your browser for supported MIME types
  38496. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38497. * to the src parameter of an <img> to display it
  38498. */
  38499. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38500. /**
  38501. * Generates an image screenshot from the specified camera.
  38502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38503. * @param engine The engine to use for rendering
  38504. * @param camera The camera to use for rendering
  38505. * @param size This parameter can be set to a single number or to an object with the
  38506. * following (optional) properties: precision, width, height. If a single number is passed,
  38507. * it will be used for both width and height. If an object is passed, the screenshot size
  38508. * will be derived from the parameters. The precision property is a multiplier allowing
  38509. * rendering at a higher or lower resolution
  38510. * @param successCallback The callback receives a single parameter which contains the
  38511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38512. * src parameter of an <img> to display it
  38513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38514. * Check your browser for supported MIME types
  38515. * @param samples Texture samples (default: 1)
  38516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38517. * @param fileName A name for for the downloaded file.
  38518. */
  38519. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38520. /**
  38521. * Generates an image screenshot from the specified camera.
  38522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38523. * @param engine The engine to use for rendering
  38524. * @param camera The camera to use for rendering
  38525. * @param size This parameter can be set to a single number or to an object with the
  38526. * following (optional) properties: precision, width, height. If a single number is passed,
  38527. * it will be used for both width and height. If an object is passed, the screenshot size
  38528. * will be derived from the parameters. The precision property is a multiplier allowing
  38529. * rendering at a higher or lower resolution
  38530. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38531. * Check your browser for supported MIME types
  38532. * @param samples Texture samples (default: 1)
  38533. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38534. * @param fileName A name for for the downloaded file.
  38535. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38536. * to the src parameter of an <img> to display it
  38537. */
  38538. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38539. /**
  38540. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38541. * Be aware Math.random() could cause collisions, but:
  38542. * "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"
  38543. * @returns a pseudo random id
  38544. */
  38545. static RandomId(): string;
  38546. /**
  38547. * Test if the given uri is a base64 string
  38548. * @param uri The uri to test
  38549. * @return True if the uri is a base64 string or false otherwise
  38550. */
  38551. static IsBase64(uri: string): boolean;
  38552. /**
  38553. * Decode the given base64 uri.
  38554. * @param uri The uri to decode
  38555. * @return The decoded base64 data.
  38556. */
  38557. static DecodeBase64(uri: string): ArrayBuffer;
  38558. /**
  38559. * Gets the absolute url.
  38560. * @param url the input url
  38561. * @return the absolute url
  38562. */
  38563. static GetAbsoluteUrl(url: string): string;
  38564. /**
  38565. * No log
  38566. */
  38567. static readonly NoneLogLevel: number;
  38568. /**
  38569. * Only message logs
  38570. */
  38571. static readonly MessageLogLevel: number;
  38572. /**
  38573. * Only warning logs
  38574. */
  38575. static readonly WarningLogLevel: number;
  38576. /**
  38577. * Only error logs
  38578. */
  38579. static readonly ErrorLogLevel: number;
  38580. /**
  38581. * All logs
  38582. */
  38583. static readonly AllLogLevel: number;
  38584. /**
  38585. * Gets a value indicating the number of loading errors
  38586. * @ignorenaming
  38587. */
  38588. static get errorsCount(): number;
  38589. /**
  38590. * Callback called when a new log is added
  38591. */
  38592. static OnNewCacheEntry: (entry: string) => void;
  38593. /**
  38594. * Log a message to the console
  38595. * @param message defines the message to log
  38596. */
  38597. static Log(message: string): void;
  38598. /**
  38599. * Write a warning message to the console
  38600. * @param message defines the message to log
  38601. */
  38602. static Warn(message: string): void;
  38603. /**
  38604. * Write an error message to the console
  38605. * @param message defines the message to log
  38606. */
  38607. static Error(message: string): void;
  38608. /**
  38609. * Gets current log cache (list of logs)
  38610. */
  38611. static get LogCache(): string;
  38612. /**
  38613. * Clears the log cache
  38614. */
  38615. static ClearLogCache(): void;
  38616. /**
  38617. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38618. */
  38619. static set LogLevels(level: number);
  38620. /**
  38621. * Checks if the window object exists
  38622. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38623. */
  38624. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38625. /**
  38626. * No performance log
  38627. */
  38628. static readonly PerformanceNoneLogLevel: number;
  38629. /**
  38630. * Use user marks to log performance
  38631. */
  38632. static readonly PerformanceUserMarkLogLevel: number;
  38633. /**
  38634. * Log performance to the console
  38635. */
  38636. static readonly PerformanceConsoleLogLevel: number;
  38637. private static _performance;
  38638. /**
  38639. * Sets the current performance log level
  38640. */
  38641. static set PerformanceLogLevel(level: number);
  38642. private static _StartPerformanceCounterDisabled;
  38643. private static _EndPerformanceCounterDisabled;
  38644. private static _StartUserMark;
  38645. private static _EndUserMark;
  38646. private static _StartPerformanceConsole;
  38647. private static _EndPerformanceConsole;
  38648. /**
  38649. * Starts a performance counter
  38650. */
  38651. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38652. /**
  38653. * Ends a specific performance coutner
  38654. */
  38655. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38656. /**
  38657. * Gets either window.performance.now() if supported or Date.now() else
  38658. */
  38659. static get Now(): number;
  38660. /**
  38661. * This method will return the name of the class used to create the instance of the given object.
  38662. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38663. * @param object the object to get the class name from
  38664. * @param isType defines if the object is actually a type
  38665. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38666. */
  38667. static GetClassName(object: any, isType?: boolean): string;
  38668. /**
  38669. * Gets the first element of an array satisfying a given predicate
  38670. * @param array defines the array to browse
  38671. * @param predicate defines the predicate to use
  38672. * @returns null if not found or the element
  38673. */
  38674. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38675. /**
  38676. * This method will return the name of the full name of the class, including its owning module (if any).
  38677. * 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).
  38678. * @param object the object to get the class name from
  38679. * @param isType defines if the object is actually a type
  38680. * @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.
  38681. * @ignorenaming
  38682. */
  38683. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38684. /**
  38685. * Returns a promise that resolves after the given amount of time.
  38686. * @param delay Number of milliseconds to delay
  38687. * @returns Promise that resolves after the given amount of time
  38688. */
  38689. static DelayAsync(delay: number): Promise<void>;
  38690. /**
  38691. * Utility function to detect if the current user agent is Safari
  38692. * @returns whether or not the current user agent is safari
  38693. */
  38694. static IsSafari(): boolean;
  38695. }
  38696. /**
  38697. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38698. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38699. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38700. * @param name The name of the class, case should be preserved
  38701. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38702. */
  38703. export function className(name: string, module?: string): (target: Object) => void;
  38704. /**
  38705. * An implementation of a loop for asynchronous functions.
  38706. */
  38707. export class AsyncLoop {
  38708. /**
  38709. * Defines the number of iterations for the loop
  38710. */
  38711. iterations: number;
  38712. /**
  38713. * Defines the current index of the loop.
  38714. */
  38715. index: number;
  38716. private _done;
  38717. private _fn;
  38718. private _successCallback;
  38719. /**
  38720. * Constructor.
  38721. * @param iterations the number of iterations.
  38722. * @param func the function to run each iteration
  38723. * @param successCallback the callback that will be called upon succesful execution
  38724. * @param offset starting offset.
  38725. */
  38726. constructor(
  38727. /**
  38728. * Defines the number of iterations for the loop
  38729. */
  38730. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38731. /**
  38732. * Execute the next iteration. Must be called after the last iteration was finished.
  38733. */
  38734. executeNext(): void;
  38735. /**
  38736. * Break the loop and run the success callback.
  38737. */
  38738. breakLoop(): void;
  38739. /**
  38740. * Create and run an async loop.
  38741. * @param iterations the number of iterations.
  38742. * @param fn the function to run each iteration
  38743. * @param successCallback the callback that will be called upon succesful execution
  38744. * @param offset starting offset.
  38745. * @returns the created async loop object
  38746. */
  38747. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38748. /**
  38749. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38750. * @param iterations total number of iterations
  38751. * @param syncedIterations number of synchronous iterations in each async iteration.
  38752. * @param fn the function to call each iteration.
  38753. * @param callback a success call back that will be called when iterating stops.
  38754. * @param breakFunction a break condition (optional)
  38755. * @param timeout timeout settings for the setTimeout function. default - 0.
  38756. * @returns the created async loop object
  38757. */
  38758. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38759. }
  38760. }
  38761. declare module "babylonjs/Misc/stringDictionary" {
  38762. import { Nullable } from "babylonjs/types";
  38763. /**
  38764. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38765. * The underlying implementation relies on an associative array to ensure the best performances.
  38766. * The value can be anything including 'null' but except 'undefined'
  38767. */
  38768. export class StringDictionary<T> {
  38769. /**
  38770. * This will clear this dictionary and copy the content from the 'source' one.
  38771. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38772. * @param source the dictionary to take the content from and copy to this dictionary
  38773. */
  38774. copyFrom(source: StringDictionary<T>): void;
  38775. /**
  38776. * Get a value based from its key
  38777. * @param key the given key to get the matching value from
  38778. * @return the value if found, otherwise undefined is returned
  38779. */
  38780. get(key: string): T | undefined;
  38781. /**
  38782. * Get a value from its key or add it if it doesn't exist.
  38783. * This method will ensure you that a given key/data will be present in the dictionary.
  38784. * @param key the given key to get the matching value from
  38785. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38786. * The factory will only be invoked if there's no data for the given key.
  38787. * @return the value corresponding to the key.
  38788. */
  38789. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38790. /**
  38791. * Get a value from its key if present in the dictionary otherwise add it
  38792. * @param key the key to get the value from
  38793. * @param val if there's no such key/value pair in the dictionary add it with this value
  38794. * @return the value corresponding to the key
  38795. */
  38796. getOrAdd(key: string, val: T): T;
  38797. /**
  38798. * Check if there's a given key in the dictionary
  38799. * @param key the key to check for
  38800. * @return true if the key is present, false otherwise
  38801. */
  38802. contains(key: string): boolean;
  38803. /**
  38804. * Add a new key and its corresponding value
  38805. * @param key the key to add
  38806. * @param value the value corresponding to the key
  38807. * @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
  38808. */
  38809. add(key: string, value: T): boolean;
  38810. /**
  38811. * Update a specific value associated to a key
  38812. * @param key defines the key to use
  38813. * @param value defines the value to store
  38814. * @returns true if the value was updated (or false if the key was not found)
  38815. */
  38816. set(key: string, value: T): boolean;
  38817. /**
  38818. * Get the element of the given key and remove it from the dictionary
  38819. * @param key defines the key to search
  38820. * @returns the value associated with the key or null if not found
  38821. */
  38822. getAndRemove(key: string): Nullable<T>;
  38823. /**
  38824. * Remove a key/value from the dictionary.
  38825. * @param key the key to remove
  38826. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38827. */
  38828. remove(key: string): boolean;
  38829. /**
  38830. * Clear the whole content of the dictionary
  38831. */
  38832. clear(): void;
  38833. /**
  38834. * Gets the current count
  38835. */
  38836. get count(): number;
  38837. /**
  38838. * Execute a callback on each key/val of the dictionary.
  38839. * Note that you can remove any element in this dictionary in the callback implementation
  38840. * @param callback the callback to execute on a given key/value pair
  38841. */
  38842. forEach(callback: (key: string, val: T) => void): void;
  38843. /**
  38844. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38845. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38846. * Note that you can remove any element in this dictionary in the callback implementation
  38847. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38848. * @returns the first item
  38849. */
  38850. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38851. private _count;
  38852. private _data;
  38853. }
  38854. }
  38855. declare module "babylonjs/Collisions/collisionCoordinator" {
  38856. import { Nullable } from "babylonjs/types";
  38857. import { Scene } from "babylonjs/scene";
  38858. import { Vector3 } from "babylonjs/Maths/math.vector";
  38859. import { Collider } from "babylonjs/Collisions/collider";
  38860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38861. /** @hidden */
  38862. export interface ICollisionCoordinator {
  38863. createCollider(): Collider;
  38864. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38865. init(scene: Scene): void;
  38866. }
  38867. /** @hidden */
  38868. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38869. private _scene;
  38870. private _scaledPosition;
  38871. private _scaledVelocity;
  38872. private _finalPosition;
  38873. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38874. createCollider(): Collider;
  38875. init(scene: Scene): void;
  38876. private _collideWithWorld;
  38877. }
  38878. }
  38879. declare module "babylonjs/Inputs/scene.inputManager" {
  38880. import { Nullable } from "babylonjs/types";
  38881. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  38882. import { Vector2 } from "babylonjs/Maths/math.vector";
  38883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38884. import { Scene } from "babylonjs/scene";
  38885. /**
  38886. * Class used to manage all inputs for the scene.
  38887. */
  38888. export class InputManager {
  38889. /** The distance in pixel that you have to move to prevent some events */
  38890. static DragMovementThreshold: number;
  38891. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38892. static LongPressDelay: number;
  38893. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38894. static DoubleClickDelay: number;
  38895. /** If you need to check double click without raising a single click at first click, enable this flag */
  38896. static ExclusiveDoubleClickMode: boolean;
  38897. private _wheelEventName;
  38898. private _onPointerMove;
  38899. private _onPointerDown;
  38900. private _onPointerUp;
  38901. private _initClickEvent;
  38902. private _initActionManager;
  38903. private _delayedSimpleClick;
  38904. private _delayedSimpleClickTimeout;
  38905. private _previousDelayedSimpleClickTimeout;
  38906. private _meshPickProceed;
  38907. private _previousButtonPressed;
  38908. private _currentPickResult;
  38909. private _previousPickResult;
  38910. private _totalPointersPressed;
  38911. private _doubleClickOccured;
  38912. private _pointerOverMesh;
  38913. private _pickedDownMesh;
  38914. private _pickedUpMesh;
  38915. private _pointerX;
  38916. private _pointerY;
  38917. private _unTranslatedPointerX;
  38918. private _unTranslatedPointerY;
  38919. private _startingPointerPosition;
  38920. private _previousStartingPointerPosition;
  38921. private _startingPointerTime;
  38922. private _previousStartingPointerTime;
  38923. private _pointerCaptures;
  38924. private _onKeyDown;
  38925. private _onKeyUp;
  38926. private _onCanvasFocusObserver;
  38927. private _onCanvasBlurObserver;
  38928. private _scene;
  38929. /**
  38930. * Creates a new InputManager
  38931. * @param scene defines the hosting scene
  38932. */
  38933. constructor(scene: Scene);
  38934. /**
  38935. * Gets the mesh that is currently under the pointer
  38936. */
  38937. get meshUnderPointer(): Nullable<AbstractMesh>;
  38938. /**
  38939. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38940. */
  38941. get unTranslatedPointer(): Vector2;
  38942. /**
  38943. * Gets or sets the current on-screen X position of the pointer
  38944. */
  38945. get pointerX(): number;
  38946. set pointerX(value: number);
  38947. /**
  38948. * Gets or sets the current on-screen Y position of the pointer
  38949. */
  38950. get pointerY(): number;
  38951. set pointerY(value: number);
  38952. private _updatePointerPosition;
  38953. private _processPointerMove;
  38954. private _setRayOnPointerInfo;
  38955. private _checkPrePointerObservable;
  38956. /**
  38957. * Use this method to simulate a pointer move on a mesh
  38958. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38959. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38960. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38961. */
  38962. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38963. /**
  38964. * Use this method to simulate a pointer down on a mesh
  38965. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38966. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38967. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38968. */
  38969. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38970. private _processPointerDown;
  38971. /** @hidden */
  38972. _isPointerSwiping(): boolean;
  38973. /**
  38974. * Use this method to simulate a pointer up on a mesh
  38975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38978. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38979. */
  38980. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38981. private _processPointerUp;
  38982. /**
  38983. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38984. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38985. * @returns true if the pointer was captured
  38986. */
  38987. isPointerCaptured(pointerId?: number): boolean;
  38988. /**
  38989. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38990. * @param attachUp defines if you want to attach events to pointerup
  38991. * @param attachDown defines if you want to attach events to pointerdown
  38992. * @param attachMove defines if you want to attach events to pointermove
  38993. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38994. */
  38995. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38996. /**
  38997. * Detaches all event handlers
  38998. */
  38999. detachControl(): void;
  39000. /**
  39001. * Force the value of meshUnderPointer
  39002. * @param mesh defines the mesh to use
  39003. */
  39004. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39005. /**
  39006. * Gets the mesh under the pointer
  39007. * @returns a Mesh or null if no mesh is under the pointer
  39008. */
  39009. getPointerOverMesh(): Nullable<AbstractMesh>;
  39010. }
  39011. }
  39012. declare module "babylonjs/Animations/animationGroup" {
  39013. import { Animatable } from "babylonjs/Animations/animatable";
  39014. import { Animation } from "babylonjs/Animations/animation";
  39015. import { Scene, IDisposable } from "babylonjs/scene";
  39016. import { Observable } from "babylonjs/Misc/observable";
  39017. import { Nullable } from "babylonjs/types";
  39018. import "babylonjs/Animations/animatable";
  39019. /**
  39020. * This class defines the direct association between an animation and a target
  39021. */
  39022. export class TargetedAnimation {
  39023. /**
  39024. * Animation to perform
  39025. */
  39026. animation: Animation;
  39027. /**
  39028. * Target to animate
  39029. */
  39030. target: any;
  39031. /**
  39032. * Serialize the object
  39033. * @returns the JSON object representing the current entity
  39034. */
  39035. serialize(): any;
  39036. }
  39037. /**
  39038. * Use this class to create coordinated animations on multiple targets
  39039. */
  39040. export class AnimationGroup implements IDisposable {
  39041. /** The name of the animation group */
  39042. name: string;
  39043. private _scene;
  39044. private _targetedAnimations;
  39045. private _animatables;
  39046. private _from;
  39047. private _to;
  39048. private _isStarted;
  39049. private _isPaused;
  39050. private _speedRatio;
  39051. private _loopAnimation;
  39052. private _isAdditive;
  39053. /**
  39054. * Gets or sets the unique id of the node
  39055. */
  39056. uniqueId: number;
  39057. /**
  39058. * This observable will notify when one animation have ended
  39059. */
  39060. onAnimationEndObservable: Observable<TargetedAnimation>;
  39061. /**
  39062. * Observer raised when one animation loops
  39063. */
  39064. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39065. /**
  39066. * Observer raised when all animations have looped
  39067. */
  39068. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39069. /**
  39070. * This observable will notify when all animations have ended.
  39071. */
  39072. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39073. /**
  39074. * This observable will notify when all animations have paused.
  39075. */
  39076. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39077. /**
  39078. * This observable will notify when all animations are playing.
  39079. */
  39080. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39081. /**
  39082. * Gets the first frame
  39083. */
  39084. get from(): number;
  39085. /**
  39086. * Gets the last frame
  39087. */
  39088. get to(): number;
  39089. /**
  39090. * Define if the animations are started
  39091. */
  39092. get isStarted(): boolean;
  39093. /**
  39094. * Gets a value indicating that the current group is playing
  39095. */
  39096. get isPlaying(): boolean;
  39097. /**
  39098. * Gets or sets the speed ratio to use for all animations
  39099. */
  39100. get speedRatio(): number;
  39101. /**
  39102. * Gets or sets the speed ratio to use for all animations
  39103. */
  39104. set speedRatio(value: number);
  39105. /**
  39106. * Gets or sets if all animations should loop or not
  39107. */
  39108. get loopAnimation(): boolean;
  39109. set loopAnimation(value: boolean);
  39110. /**
  39111. * Gets or sets if all animations should be evaluated additively
  39112. */
  39113. get isAdditive(): boolean;
  39114. set isAdditive(value: boolean);
  39115. /**
  39116. * Gets the targeted animations for this animation group
  39117. */
  39118. get targetedAnimations(): Array<TargetedAnimation>;
  39119. /**
  39120. * returning the list of animatables controlled by this animation group.
  39121. */
  39122. get animatables(): Array<Animatable>;
  39123. /**
  39124. * Instantiates a new Animation Group.
  39125. * This helps managing several animations at once.
  39126. * @see http://doc.babylonjs.com/how_to/group
  39127. * @param name Defines the name of the group
  39128. * @param scene Defines the scene the group belongs to
  39129. */
  39130. constructor(
  39131. /** The name of the animation group */
  39132. name: string, scene?: Nullable<Scene>);
  39133. /**
  39134. * Add an animation (with its target) in the group
  39135. * @param animation defines the animation we want to add
  39136. * @param target defines the target of the animation
  39137. * @returns the TargetedAnimation object
  39138. */
  39139. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39140. /**
  39141. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39142. * It can add constant keys at begin or end
  39143. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39144. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39145. * @returns the animation group
  39146. */
  39147. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39148. private _animationLoopCount;
  39149. private _animationLoopFlags;
  39150. private _processLoop;
  39151. /**
  39152. * Start all animations on given targets
  39153. * @param loop defines if animations must loop
  39154. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39155. * @param from defines the from key (optional)
  39156. * @param to defines the to key (optional)
  39157. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39158. * @returns the current animation group
  39159. */
  39160. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39161. /**
  39162. * Pause all animations
  39163. * @returns the animation group
  39164. */
  39165. pause(): AnimationGroup;
  39166. /**
  39167. * Play all animations to initial state
  39168. * This function will start() the animations if they were not started or will restart() them if they were paused
  39169. * @param loop defines if animations must loop
  39170. * @returns the animation group
  39171. */
  39172. play(loop?: boolean): AnimationGroup;
  39173. /**
  39174. * Reset all animations to initial state
  39175. * @returns the animation group
  39176. */
  39177. reset(): AnimationGroup;
  39178. /**
  39179. * Restart animations from key 0
  39180. * @returns the animation group
  39181. */
  39182. restart(): AnimationGroup;
  39183. /**
  39184. * Stop all animations
  39185. * @returns the animation group
  39186. */
  39187. stop(): AnimationGroup;
  39188. /**
  39189. * Set animation weight for all animatables
  39190. * @param weight defines the weight to use
  39191. * @return the animationGroup
  39192. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39193. */
  39194. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39195. /**
  39196. * Synchronize and normalize all animatables with a source animatable
  39197. * @param root defines the root animatable to synchronize with
  39198. * @return the animationGroup
  39199. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39200. */
  39201. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39202. /**
  39203. * Goes to a specific frame in this animation group
  39204. * @param frame the frame number to go to
  39205. * @return the animationGroup
  39206. */
  39207. goToFrame(frame: number): AnimationGroup;
  39208. /**
  39209. * Dispose all associated resources
  39210. */
  39211. dispose(): void;
  39212. private _checkAnimationGroupEnded;
  39213. /**
  39214. * Clone the current animation group and returns a copy
  39215. * @param newName defines the name of the new group
  39216. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39217. * @returns the new aniamtion group
  39218. */
  39219. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39220. /**
  39221. * Serializes the animationGroup to an object
  39222. * @returns Serialized object
  39223. */
  39224. serialize(): any;
  39225. /**
  39226. * Returns a new AnimationGroup object parsed from the source provided.
  39227. * @param parsedAnimationGroup defines the source
  39228. * @param scene defines the scene that will receive the animationGroup
  39229. * @returns a new AnimationGroup
  39230. */
  39231. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39232. /**
  39233. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39234. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39235. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39236. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39237. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39238. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39239. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39240. */
  39241. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39242. /**
  39243. * Returns the string "AnimationGroup"
  39244. * @returns "AnimationGroup"
  39245. */
  39246. getClassName(): string;
  39247. /**
  39248. * Creates a detailled string about the object
  39249. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39250. * @returns a string representing the object
  39251. */
  39252. toString(fullDetails?: boolean): string;
  39253. }
  39254. }
  39255. declare module "babylonjs/scene" {
  39256. import { Nullable } from "babylonjs/types";
  39257. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39258. import { Observable } from "babylonjs/Misc/observable";
  39259. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39260. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39261. import { Geometry } from "babylonjs/Meshes/geometry";
  39262. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39263. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39265. import { Mesh } from "babylonjs/Meshes/mesh";
  39266. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39267. import { Bone } from "babylonjs/Bones/bone";
  39268. import { Skeleton } from "babylonjs/Bones/skeleton";
  39269. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39270. import { Camera } from "babylonjs/Cameras/camera";
  39271. import { AbstractScene } from "babylonjs/abstractScene";
  39272. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39273. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39274. import { Material } from "babylonjs/Materials/material";
  39275. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39276. import { Effect } from "babylonjs/Materials/effect";
  39277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39278. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39279. import { Light } from "babylonjs/Lights/light";
  39280. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39281. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39282. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39283. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39284. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39285. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39286. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39287. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39288. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39289. import { Engine } from "babylonjs/Engines/engine";
  39290. import { Node } from "babylonjs/node";
  39291. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39292. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39293. import { WebRequest } from "babylonjs/Misc/webRequest";
  39294. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39295. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39296. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39297. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39298. import { Plane } from "babylonjs/Maths/math.plane";
  39299. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39300. import { Ray } from "babylonjs/Culling/ray";
  39301. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39302. import { Animation } from "babylonjs/Animations/animation";
  39303. import { Animatable } from "babylonjs/Animations/animatable";
  39304. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39305. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39306. import { Collider } from "babylonjs/Collisions/collider";
  39307. /**
  39308. * Define an interface for all classes that will hold resources
  39309. */
  39310. export interface IDisposable {
  39311. /**
  39312. * Releases all held resources
  39313. */
  39314. dispose(): void;
  39315. }
  39316. /** Interface defining initialization parameters for Scene class */
  39317. export interface SceneOptions {
  39318. /**
  39319. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39320. * It will improve performance when the number of geometries becomes important.
  39321. */
  39322. useGeometryUniqueIdsMap?: boolean;
  39323. /**
  39324. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39325. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39326. */
  39327. useMaterialMeshMap?: boolean;
  39328. /**
  39329. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39330. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39331. */
  39332. useClonedMeshMap?: boolean;
  39333. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39334. virtual?: boolean;
  39335. }
  39336. /**
  39337. * Represents a scene to be rendered by the engine.
  39338. * @see http://doc.babylonjs.com/features/scene
  39339. */
  39340. export class Scene extends AbstractScene implements IAnimatable {
  39341. /** The fog is deactivated */
  39342. static readonly FOGMODE_NONE: number;
  39343. /** The fog density is following an exponential function */
  39344. static readonly FOGMODE_EXP: number;
  39345. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39346. static readonly FOGMODE_EXP2: number;
  39347. /** The fog density is following a linear function. */
  39348. static readonly FOGMODE_LINEAR: number;
  39349. /**
  39350. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39352. */
  39353. static MinDeltaTime: number;
  39354. /**
  39355. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39357. */
  39358. static MaxDeltaTime: number;
  39359. /**
  39360. * Factory used to create the default material.
  39361. * @param name The name of the material to create
  39362. * @param scene The scene to create the material for
  39363. * @returns The default material
  39364. */
  39365. static DefaultMaterialFactory(scene: Scene): Material;
  39366. /**
  39367. * Factory used to create the a collision coordinator.
  39368. * @returns The collision coordinator
  39369. */
  39370. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39371. /** @hidden */
  39372. _inputManager: InputManager;
  39373. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39374. cameraToUseForPointers: Nullable<Camera>;
  39375. /** @hidden */
  39376. readonly _isScene: boolean;
  39377. /** @hidden */
  39378. _blockEntityCollection: boolean;
  39379. /**
  39380. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39381. */
  39382. autoClear: boolean;
  39383. /**
  39384. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39385. */
  39386. autoClearDepthAndStencil: boolean;
  39387. /**
  39388. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39389. */
  39390. clearColor: Color4;
  39391. /**
  39392. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39393. */
  39394. ambientColor: Color3;
  39395. /**
  39396. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39397. * It should only be one of the following (if not the default embedded one):
  39398. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39399. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39400. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39401. * The material properties need to be setup according to the type of texture in use.
  39402. */
  39403. environmentBRDFTexture: BaseTexture;
  39404. /** @hidden */
  39405. protected _environmentTexture: Nullable<BaseTexture>;
  39406. /**
  39407. * Texture used in all pbr material as the reflection texture.
  39408. * As in the majority of the scene they are the same (exception for multi room and so on),
  39409. * this is easier to reference from here than from all the materials.
  39410. */
  39411. get environmentTexture(): Nullable<BaseTexture>;
  39412. /**
  39413. * Texture used in all pbr material as the reflection texture.
  39414. * As in the majority of the scene they are the same (exception for multi room and so on),
  39415. * this is easier to set here than in all the materials.
  39416. */
  39417. set environmentTexture(value: Nullable<BaseTexture>);
  39418. /** @hidden */
  39419. protected _environmentIntensity: number;
  39420. /**
  39421. * Intensity of the environment in all pbr material.
  39422. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39423. * As in the majority of the scene they are the same (exception for multi room and so on),
  39424. * this is easier to reference from here than from all the materials.
  39425. */
  39426. get environmentIntensity(): number;
  39427. /**
  39428. * Intensity of the environment in all pbr material.
  39429. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39430. * As in the majority of the scene they are the same (exception for multi room and so on),
  39431. * this is easier to set here than in all the materials.
  39432. */
  39433. set environmentIntensity(value: number);
  39434. /** @hidden */
  39435. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39436. /**
  39437. * Default image processing configuration used either in the rendering
  39438. * Forward main pass or through the imageProcessingPostProcess if present.
  39439. * As in the majority of the scene they are the same (exception for multi camera),
  39440. * this is easier to reference from here than from all the materials and post process.
  39441. *
  39442. * No setter as we it is a shared configuration, you can set the values instead.
  39443. */
  39444. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39445. private _forceWireframe;
  39446. /**
  39447. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39448. */
  39449. set forceWireframe(value: boolean);
  39450. get forceWireframe(): boolean;
  39451. private _skipFrustumClipping;
  39452. /**
  39453. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39454. */
  39455. set skipFrustumClipping(value: boolean);
  39456. get skipFrustumClipping(): boolean;
  39457. private _forcePointsCloud;
  39458. /**
  39459. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39460. */
  39461. set forcePointsCloud(value: boolean);
  39462. get forcePointsCloud(): boolean;
  39463. /**
  39464. * Gets or sets the active clipplane 1
  39465. */
  39466. clipPlane: Nullable<Plane>;
  39467. /**
  39468. * Gets or sets the active clipplane 2
  39469. */
  39470. clipPlane2: Nullable<Plane>;
  39471. /**
  39472. * Gets or sets the active clipplane 3
  39473. */
  39474. clipPlane3: Nullable<Plane>;
  39475. /**
  39476. * Gets or sets the active clipplane 4
  39477. */
  39478. clipPlane4: Nullable<Plane>;
  39479. /**
  39480. * Gets or sets the active clipplane 5
  39481. */
  39482. clipPlane5: Nullable<Plane>;
  39483. /**
  39484. * Gets or sets the active clipplane 6
  39485. */
  39486. clipPlane6: Nullable<Plane>;
  39487. /**
  39488. * Gets or sets a boolean indicating if animations are enabled
  39489. */
  39490. animationsEnabled: boolean;
  39491. private _animationPropertiesOverride;
  39492. /**
  39493. * Gets or sets the animation properties override
  39494. */
  39495. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39496. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39497. /**
  39498. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39499. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39500. */
  39501. useConstantAnimationDeltaTime: boolean;
  39502. /**
  39503. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39504. * Please note that it requires to run a ray cast through the scene on every frame
  39505. */
  39506. constantlyUpdateMeshUnderPointer: boolean;
  39507. /**
  39508. * Defines the HTML cursor to use when hovering over interactive elements
  39509. */
  39510. hoverCursor: string;
  39511. /**
  39512. * Defines the HTML default cursor to use (empty by default)
  39513. */
  39514. defaultCursor: string;
  39515. /**
  39516. * Defines whether cursors are handled by the scene.
  39517. */
  39518. doNotHandleCursors: boolean;
  39519. /**
  39520. * This is used to call preventDefault() on pointer down
  39521. * in order to block unwanted artifacts like system double clicks
  39522. */
  39523. preventDefaultOnPointerDown: boolean;
  39524. /**
  39525. * This is used to call preventDefault() on pointer up
  39526. * in order to block unwanted artifacts like system double clicks
  39527. */
  39528. preventDefaultOnPointerUp: boolean;
  39529. /**
  39530. * Gets or sets user defined metadata
  39531. */
  39532. metadata: any;
  39533. /**
  39534. * For internal use only. Please do not use.
  39535. */
  39536. reservedDataStore: any;
  39537. /**
  39538. * Gets the name of the plugin used to load this scene (null by default)
  39539. */
  39540. loadingPluginName: string;
  39541. /**
  39542. * Use this array to add regular expressions used to disable offline support for specific urls
  39543. */
  39544. disableOfflineSupportExceptionRules: RegExp[];
  39545. /**
  39546. * An event triggered when the scene is disposed.
  39547. */
  39548. onDisposeObservable: Observable<Scene>;
  39549. private _onDisposeObserver;
  39550. /** Sets a function to be executed when this scene is disposed. */
  39551. set onDispose(callback: () => void);
  39552. /**
  39553. * An event triggered before rendering the scene (right after animations and physics)
  39554. */
  39555. onBeforeRenderObservable: Observable<Scene>;
  39556. private _onBeforeRenderObserver;
  39557. /** Sets a function to be executed before rendering this scene */
  39558. set beforeRender(callback: Nullable<() => void>);
  39559. /**
  39560. * An event triggered after rendering the scene
  39561. */
  39562. onAfterRenderObservable: Observable<Scene>;
  39563. /**
  39564. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39565. */
  39566. onAfterRenderCameraObservable: Observable<Camera>;
  39567. private _onAfterRenderObserver;
  39568. /** Sets a function to be executed after rendering this scene */
  39569. set afterRender(callback: Nullable<() => void>);
  39570. /**
  39571. * An event triggered before animating the scene
  39572. */
  39573. onBeforeAnimationsObservable: Observable<Scene>;
  39574. /**
  39575. * An event triggered after animations processing
  39576. */
  39577. onAfterAnimationsObservable: Observable<Scene>;
  39578. /**
  39579. * An event triggered before draw calls are ready to be sent
  39580. */
  39581. onBeforeDrawPhaseObservable: Observable<Scene>;
  39582. /**
  39583. * An event triggered after draw calls have been sent
  39584. */
  39585. onAfterDrawPhaseObservable: Observable<Scene>;
  39586. /**
  39587. * An event triggered when the scene is ready
  39588. */
  39589. onReadyObservable: Observable<Scene>;
  39590. /**
  39591. * An event triggered before rendering a camera
  39592. */
  39593. onBeforeCameraRenderObservable: Observable<Camera>;
  39594. private _onBeforeCameraRenderObserver;
  39595. /** Sets a function to be executed before rendering a camera*/
  39596. set beforeCameraRender(callback: () => void);
  39597. /**
  39598. * An event triggered after rendering a camera
  39599. */
  39600. onAfterCameraRenderObservable: Observable<Camera>;
  39601. private _onAfterCameraRenderObserver;
  39602. /** Sets a function to be executed after rendering a camera*/
  39603. set afterCameraRender(callback: () => void);
  39604. /**
  39605. * An event triggered when active meshes evaluation is about to start
  39606. */
  39607. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39608. /**
  39609. * An event triggered when active meshes evaluation is done
  39610. */
  39611. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39612. /**
  39613. * An event triggered when particles rendering is about to start
  39614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39615. */
  39616. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39617. /**
  39618. * An event triggered when particles rendering is done
  39619. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39620. */
  39621. onAfterParticlesRenderingObservable: Observable<Scene>;
  39622. /**
  39623. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39624. */
  39625. onDataLoadedObservable: Observable<Scene>;
  39626. /**
  39627. * An event triggered when a camera is created
  39628. */
  39629. onNewCameraAddedObservable: Observable<Camera>;
  39630. /**
  39631. * An event triggered when a camera is removed
  39632. */
  39633. onCameraRemovedObservable: Observable<Camera>;
  39634. /**
  39635. * An event triggered when a light is created
  39636. */
  39637. onNewLightAddedObservable: Observable<Light>;
  39638. /**
  39639. * An event triggered when a light is removed
  39640. */
  39641. onLightRemovedObservable: Observable<Light>;
  39642. /**
  39643. * An event triggered when a geometry is created
  39644. */
  39645. onNewGeometryAddedObservable: Observable<Geometry>;
  39646. /**
  39647. * An event triggered when a geometry is removed
  39648. */
  39649. onGeometryRemovedObservable: Observable<Geometry>;
  39650. /**
  39651. * An event triggered when a transform node is created
  39652. */
  39653. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39654. /**
  39655. * An event triggered when a transform node is removed
  39656. */
  39657. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39658. /**
  39659. * An event triggered when a mesh is created
  39660. */
  39661. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39662. /**
  39663. * An event triggered when a mesh is removed
  39664. */
  39665. onMeshRemovedObservable: Observable<AbstractMesh>;
  39666. /**
  39667. * An event triggered when a skeleton is created
  39668. */
  39669. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39670. /**
  39671. * An event triggered when a skeleton is removed
  39672. */
  39673. onSkeletonRemovedObservable: Observable<Skeleton>;
  39674. /**
  39675. * An event triggered when a material is created
  39676. */
  39677. onNewMaterialAddedObservable: Observable<Material>;
  39678. /**
  39679. * An event triggered when a material is removed
  39680. */
  39681. onMaterialRemovedObservable: Observable<Material>;
  39682. /**
  39683. * An event triggered when a texture is created
  39684. */
  39685. onNewTextureAddedObservable: Observable<BaseTexture>;
  39686. /**
  39687. * An event triggered when a texture is removed
  39688. */
  39689. onTextureRemovedObservable: Observable<BaseTexture>;
  39690. /**
  39691. * An event triggered when render targets are about to be rendered
  39692. * Can happen multiple times per frame.
  39693. */
  39694. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39695. /**
  39696. * An event triggered when render targets were rendered.
  39697. * Can happen multiple times per frame.
  39698. */
  39699. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39700. /**
  39701. * An event triggered before calculating deterministic simulation step
  39702. */
  39703. onBeforeStepObservable: Observable<Scene>;
  39704. /**
  39705. * An event triggered after calculating deterministic simulation step
  39706. */
  39707. onAfterStepObservable: Observable<Scene>;
  39708. /**
  39709. * An event triggered when the activeCamera property is updated
  39710. */
  39711. onActiveCameraChanged: Observable<Scene>;
  39712. /**
  39713. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39714. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39715. * 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)
  39716. */
  39717. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39718. /**
  39719. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39720. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39721. * 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)
  39722. */
  39723. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39724. /**
  39725. * This Observable will when a mesh has been imported into the scene.
  39726. */
  39727. onMeshImportedObservable: Observable<AbstractMesh>;
  39728. /**
  39729. * This Observable will when an animation file has been imported into the scene.
  39730. */
  39731. onAnimationFileImportedObservable: Observable<Scene>;
  39732. /**
  39733. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39734. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39735. */
  39736. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39737. /** @hidden */
  39738. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39739. /**
  39740. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39741. */
  39742. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39743. /**
  39744. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39745. */
  39746. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39747. /**
  39748. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39749. */
  39750. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39751. /** Callback called when a pointer move is detected */
  39752. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39753. /** Callback called when a pointer down is detected */
  39754. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39755. /** Callback called when a pointer up is detected */
  39756. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39757. /** Callback called when a pointer pick is detected */
  39758. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39759. /**
  39760. * 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).
  39761. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39762. */
  39763. onPrePointerObservable: Observable<PointerInfoPre>;
  39764. /**
  39765. * Observable event triggered each time an input event is received from the rendering canvas
  39766. */
  39767. onPointerObservable: Observable<PointerInfo>;
  39768. /**
  39769. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39770. */
  39771. get unTranslatedPointer(): Vector2;
  39772. /**
  39773. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39774. */
  39775. static get DragMovementThreshold(): number;
  39776. static set DragMovementThreshold(value: number);
  39777. /**
  39778. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39779. */
  39780. static get LongPressDelay(): number;
  39781. static set LongPressDelay(value: number);
  39782. /**
  39783. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39784. */
  39785. static get DoubleClickDelay(): number;
  39786. static set DoubleClickDelay(value: number);
  39787. /** If you need to check double click without raising a single click at first click, enable this flag */
  39788. static get ExclusiveDoubleClickMode(): boolean;
  39789. static set ExclusiveDoubleClickMode(value: boolean);
  39790. /** @hidden */
  39791. _mirroredCameraPosition: Nullable<Vector3>;
  39792. /**
  39793. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39794. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39795. */
  39796. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39797. /**
  39798. * Observable event triggered each time an keyboard event is received from the hosting window
  39799. */
  39800. onKeyboardObservable: Observable<KeyboardInfo>;
  39801. private _useRightHandedSystem;
  39802. /**
  39803. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39804. */
  39805. set useRightHandedSystem(value: boolean);
  39806. get useRightHandedSystem(): boolean;
  39807. private _timeAccumulator;
  39808. private _currentStepId;
  39809. private _currentInternalStep;
  39810. /**
  39811. * Sets the step Id used by deterministic lock step
  39812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39813. * @param newStepId defines the step Id
  39814. */
  39815. setStepId(newStepId: number): void;
  39816. /**
  39817. * Gets the step Id used by deterministic lock step
  39818. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39819. * @returns the step Id
  39820. */
  39821. getStepId(): number;
  39822. /**
  39823. * Gets the internal step used by deterministic lock step
  39824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39825. * @returns the internal step
  39826. */
  39827. getInternalStep(): number;
  39828. private _fogEnabled;
  39829. /**
  39830. * Gets or sets a boolean indicating if fog is enabled on this scene
  39831. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39832. * (Default is true)
  39833. */
  39834. set fogEnabled(value: boolean);
  39835. get fogEnabled(): boolean;
  39836. private _fogMode;
  39837. /**
  39838. * Gets or sets the fog mode to use
  39839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39840. * | mode | value |
  39841. * | --- | --- |
  39842. * | FOGMODE_NONE | 0 |
  39843. * | FOGMODE_EXP | 1 |
  39844. * | FOGMODE_EXP2 | 2 |
  39845. * | FOGMODE_LINEAR | 3 |
  39846. */
  39847. set fogMode(value: number);
  39848. get fogMode(): number;
  39849. /**
  39850. * Gets or sets the fog color to use
  39851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39852. * (Default is Color3(0.2, 0.2, 0.3))
  39853. */
  39854. fogColor: Color3;
  39855. /**
  39856. * Gets or sets the fog density to use
  39857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39858. * (Default is 0.1)
  39859. */
  39860. fogDensity: number;
  39861. /**
  39862. * Gets or sets the fog start distance to use
  39863. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39864. * (Default is 0)
  39865. */
  39866. fogStart: number;
  39867. /**
  39868. * Gets or sets the fog end distance to use
  39869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39870. * (Default is 1000)
  39871. */
  39872. fogEnd: number;
  39873. private _shadowsEnabled;
  39874. /**
  39875. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39876. */
  39877. set shadowsEnabled(value: boolean);
  39878. get shadowsEnabled(): boolean;
  39879. private _lightsEnabled;
  39880. /**
  39881. * Gets or sets a boolean indicating if lights are enabled on this scene
  39882. */
  39883. set lightsEnabled(value: boolean);
  39884. get lightsEnabled(): boolean;
  39885. /** All of the active cameras added to this scene. */
  39886. activeCameras: Camera[];
  39887. /** @hidden */
  39888. _activeCamera: Nullable<Camera>;
  39889. /** Gets or sets the current active camera */
  39890. get activeCamera(): Nullable<Camera>;
  39891. set activeCamera(value: Nullable<Camera>);
  39892. private _defaultMaterial;
  39893. /** The default material used on meshes when no material is affected */
  39894. get defaultMaterial(): Material;
  39895. /** The default material used on meshes when no material is affected */
  39896. set defaultMaterial(value: Material);
  39897. private _texturesEnabled;
  39898. /**
  39899. * Gets or sets a boolean indicating if textures are enabled on this scene
  39900. */
  39901. set texturesEnabled(value: boolean);
  39902. get texturesEnabled(): boolean;
  39903. /**
  39904. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39905. */
  39906. physicsEnabled: boolean;
  39907. /**
  39908. * Gets or sets a boolean indicating if particles are enabled on this scene
  39909. */
  39910. particlesEnabled: boolean;
  39911. /**
  39912. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39913. */
  39914. spritesEnabled: boolean;
  39915. private _skeletonsEnabled;
  39916. /**
  39917. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39918. */
  39919. set skeletonsEnabled(value: boolean);
  39920. get skeletonsEnabled(): boolean;
  39921. /**
  39922. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39923. */
  39924. lensFlaresEnabled: boolean;
  39925. /**
  39926. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39928. */
  39929. collisionsEnabled: boolean;
  39930. private _collisionCoordinator;
  39931. /** @hidden */
  39932. get collisionCoordinator(): ICollisionCoordinator;
  39933. /**
  39934. * Defines the gravity applied to this scene (used only for collisions)
  39935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39936. */
  39937. gravity: Vector3;
  39938. /**
  39939. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39940. */
  39941. postProcessesEnabled: boolean;
  39942. /**
  39943. * The list of postprocesses added to the scene
  39944. */
  39945. postProcesses: PostProcess[];
  39946. /**
  39947. * Gets the current postprocess manager
  39948. */
  39949. postProcessManager: PostProcessManager;
  39950. /**
  39951. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39952. */
  39953. renderTargetsEnabled: boolean;
  39954. /**
  39955. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39956. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39957. */
  39958. dumpNextRenderTargets: boolean;
  39959. /**
  39960. * The list of user defined render targets added to the scene
  39961. */
  39962. customRenderTargets: RenderTargetTexture[];
  39963. /**
  39964. * Defines if texture loading must be delayed
  39965. * If true, textures will only be loaded when they need to be rendered
  39966. */
  39967. useDelayedTextureLoading: boolean;
  39968. /**
  39969. * Gets the list of meshes imported to the scene through SceneLoader
  39970. */
  39971. importedMeshesFiles: String[];
  39972. /**
  39973. * Gets or sets a boolean indicating if probes are enabled on this scene
  39974. */
  39975. probesEnabled: boolean;
  39976. /**
  39977. * Gets or sets the current offline provider to use to store scene data
  39978. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39979. */
  39980. offlineProvider: IOfflineProvider;
  39981. /**
  39982. * Gets or sets the action manager associated with the scene
  39983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39984. */
  39985. actionManager: AbstractActionManager;
  39986. private _meshesForIntersections;
  39987. /**
  39988. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39989. */
  39990. proceduralTexturesEnabled: boolean;
  39991. private _engine;
  39992. private _totalVertices;
  39993. /** @hidden */
  39994. _activeIndices: PerfCounter;
  39995. /** @hidden */
  39996. _activeParticles: PerfCounter;
  39997. /** @hidden */
  39998. _activeBones: PerfCounter;
  39999. private _animationRatio;
  40000. /** @hidden */
  40001. _animationTimeLast: number;
  40002. /** @hidden */
  40003. _animationTime: number;
  40004. /**
  40005. * Gets or sets a general scale for animation speed
  40006. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40007. */
  40008. animationTimeScale: number;
  40009. /** @hidden */
  40010. _cachedMaterial: Nullable<Material>;
  40011. /** @hidden */
  40012. _cachedEffect: Nullable<Effect>;
  40013. /** @hidden */
  40014. _cachedVisibility: Nullable<number>;
  40015. private _renderId;
  40016. private _frameId;
  40017. private _executeWhenReadyTimeoutId;
  40018. private _intermediateRendering;
  40019. private _viewUpdateFlag;
  40020. private _projectionUpdateFlag;
  40021. /** @hidden */
  40022. _toBeDisposed: Nullable<IDisposable>[];
  40023. private _activeRequests;
  40024. /** @hidden */
  40025. _pendingData: any[];
  40026. private _isDisposed;
  40027. /**
  40028. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40029. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40030. */
  40031. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40032. private _activeMeshes;
  40033. private _processedMaterials;
  40034. private _renderTargets;
  40035. /** @hidden */
  40036. _activeParticleSystems: SmartArray<IParticleSystem>;
  40037. private _activeSkeletons;
  40038. private _softwareSkinnedMeshes;
  40039. private _renderingManager;
  40040. /** @hidden */
  40041. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40042. private _transformMatrix;
  40043. private _sceneUbo;
  40044. /** @hidden */
  40045. _viewMatrix: Matrix;
  40046. private _projectionMatrix;
  40047. /** @hidden */
  40048. _forcedViewPosition: Nullable<Vector3>;
  40049. /** @hidden */
  40050. _frustumPlanes: Plane[];
  40051. /**
  40052. * Gets the list of frustum planes (built from the active camera)
  40053. */
  40054. get frustumPlanes(): Plane[];
  40055. /**
  40056. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40057. * This is useful if there are more lights that the maximum simulteanous authorized
  40058. */
  40059. requireLightSorting: boolean;
  40060. /** @hidden */
  40061. readonly useMaterialMeshMap: boolean;
  40062. /** @hidden */
  40063. readonly useClonedMeshMap: boolean;
  40064. private _externalData;
  40065. private _uid;
  40066. /**
  40067. * @hidden
  40068. * Backing store of defined scene components.
  40069. */
  40070. _components: ISceneComponent[];
  40071. /**
  40072. * @hidden
  40073. * Backing store of defined scene components.
  40074. */
  40075. _serializableComponents: ISceneSerializableComponent[];
  40076. /**
  40077. * List of components to register on the next registration step.
  40078. */
  40079. private _transientComponents;
  40080. /**
  40081. * Registers the transient components if needed.
  40082. */
  40083. private _registerTransientComponents;
  40084. /**
  40085. * @hidden
  40086. * Add a component to the scene.
  40087. * Note that the ccomponent could be registered on th next frame if this is called after
  40088. * the register component stage.
  40089. * @param component Defines the component to add to the scene
  40090. */
  40091. _addComponent(component: ISceneComponent): void;
  40092. /**
  40093. * @hidden
  40094. * Gets a component from the scene.
  40095. * @param name defines the name of the component to retrieve
  40096. * @returns the component or null if not present
  40097. */
  40098. _getComponent(name: string): Nullable<ISceneComponent>;
  40099. /**
  40100. * @hidden
  40101. * Defines the actions happening before camera updates.
  40102. */
  40103. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40104. /**
  40105. * @hidden
  40106. * Defines the actions happening before clear the canvas.
  40107. */
  40108. _beforeClearStage: Stage<SimpleStageAction>;
  40109. /**
  40110. * @hidden
  40111. * Defines the actions when collecting render targets for the frame.
  40112. */
  40113. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40114. /**
  40115. * @hidden
  40116. * Defines the actions happening for one camera in the frame.
  40117. */
  40118. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40119. /**
  40120. * @hidden
  40121. * Defines the actions happening during the per mesh ready checks.
  40122. */
  40123. _isReadyForMeshStage: Stage<MeshStageAction>;
  40124. /**
  40125. * @hidden
  40126. * Defines the actions happening before evaluate active mesh checks.
  40127. */
  40128. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40129. /**
  40130. * @hidden
  40131. * Defines the actions happening during the evaluate sub mesh checks.
  40132. */
  40133. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40134. /**
  40135. * @hidden
  40136. * Defines the actions happening during the active mesh stage.
  40137. */
  40138. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40139. /**
  40140. * @hidden
  40141. * Defines the actions happening during the per camera render target step.
  40142. */
  40143. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40144. /**
  40145. * @hidden
  40146. * Defines the actions happening just before the active camera is drawing.
  40147. */
  40148. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40149. /**
  40150. * @hidden
  40151. * Defines the actions happening just before a render target is drawing.
  40152. */
  40153. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40154. /**
  40155. * @hidden
  40156. * Defines the actions happening just before a rendering group is drawing.
  40157. */
  40158. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40159. /**
  40160. * @hidden
  40161. * Defines the actions happening just before a mesh is drawing.
  40162. */
  40163. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40164. /**
  40165. * @hidden
  40166. * Defines the actions happening just after a mesh has been drawn.
  40167. */
  40168. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40169. /**
  40170. * @hidden
  40171. * Defines the actions happening just after a rendering group has been drawn.
  40172. */
  40173. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40174. /**
  40175. * @hidden
  40176. * Defines the actions happening just after the active camera has been drawn.
  40177. */
  40178. _afterCameraDrawStage: Stage<CameraStageAction>;
  40179. /**
  40180. * @hidden
  40181. * Defines the actions happening just after a render target has been drawn.
  40182. */
  40183. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40184. /**
  40185. * @hidden
  40186. * Defines the actions happening just after rendering all cameras and computing intersections.
  40187. */
  40188. _afterRenderStage: Stage<SimpleStageAction>;
  40189. /**
  40190. * @hidden
  40191. * Defines the actions happening when a pointer move event happens.
  40192. */
  40193. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40194. /**
  40195. * @hidden
  40196. * Defines the actions happening when a pointer down event happens.
  40197. */
  40198. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40199. /**
  40200. * @hidden
  40201. * Defines the actions happening when a pointer up event happens.
  40202. */
  40203. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40204. /**
  40205. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40206. */
  40207. private geometriesByUniqueId;
  40208. /**
  40209. * Creates a new Scene
  40210. * @param engine defines the engine to use to render this scene
  40211. * @param options defines the scene options
  40212. */
  40213. constructor(engine: Engine, options?: SceneOptions);
  40214. /**
  40215. * Gets a string idenfifying the name of the class
  40216. * @returns "Scene" string
  40217. */
  40218. getClassName(): string;
  40219. private _defaultMeshCandidates;
  40220. /**
  40221. * @hidden
  40222. */
  40223. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40224. private _defaultSubMeshCandidates;
  40225. /**
  40226. * @hidden
  40227. */
  40228. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40229. /**
  40230. * Sets the default candidate providers for the scene.
  40231. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40232. * and getCollidingSubMeshCandidates to their default function
  40233. */
  40234. setDefaultCandidateProviders(): void;
  40235. /**
  40236. * Gets the mesh that is currently under the pointer
  40237. */
  40238. get meshUnderPointer(): Nullable<AbstractMesh>;
  40239. /**
  40240. * Gets or sets the current on-screen X position of the pointer
  40241. */
  40242. get pointerX(): number;
  40243. set pointerX(value: number);
  40244. /**
  40245. * Gets or sets the current on-screen Y position of the pointer
  40246. */
  40247. get pointerY(): number;
  40248. set pointerY(value: number);
  40249. /**
  40250. * Gets the cached material (ie. the latest rendered one)
  40251. * @returns the cached material
  40252. */
  40253. getCachedMaterial(): Nullable<Material>;
  40254. /**
  40255. * Gets the cached effect (ie. the latest rendered one)
  40256. * @returns the cached effect
  40257. */
  40258. getCachedEffect(): Nullable<Effect>;
  40259. /**
  40260. * Gets the cached visibility state (ie. the latest rendered one)
  40261. * @returns the cached visibility state
  40262. */
  40263. getCachedVisibility(): Nullable<number>;
  40264. /**
  40265. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40266. * @param material defines the current material
  40267. * @param effect defines the current effect
  40268. * @param visibility defines the current visibility state
  40269. * @returns true if one parameter is not cached
  40270. */
  40271. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40272. /**
  40273. * Gets the engine associated with the scene
  40274. * @returns an Engine
  40275. */
  40276. getEngine(): Engine;
  40277. /**
  40278. * Gets the total number of vertices rendered per frame
  40279. * @returns the total number of vertices rendered per frame
  40280. */
  40281. getTotalVertices(): number;
  40282. /**
  40283. * Gets the performance counter for total vertices
  40284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40285. */
  40286. get totalVerticesPerfCounter(): PerfCounter;
  40287. /**
  40288. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40289. * @returns the total number of active indices rendered per frame
  40290. */
  40291. getActiveIndices(): number;
  40292. /**
  40293. * Gets the performance counter for active indices
  40294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40295. */
  40296. get totalActiveIndicesPerfCounter(): PerfCounter;
  40297. /**
  40298. * Gets the total number of active particles rendered per frame
  40299. * @returns the total number of active particles rendered per frame
  40300. */
  40301. getActiveParticles(): number;
  40302. /**
  40303. * Gets the performance counter for active particles
  40304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40305. */
  40306. get activeParticlesPerfCounter(): PerfCounter;
  40307. /**
  40308. * Gets the total number of active bones rendered per frame
  40309. * @returns the total number of active bones rendered per frame
  40310. */
  40311. getActiveBones(): number;
  40312. /**
  40313. * Gets the performance counter for active bones
  40314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40315. */
  40316. get activeBonesPerfCounter(): PerfCounter;
  40317. /**
  40318. * Gets the array of active meshes
  40319. * @returns an array of AbstractMesh
  40320. */
  40321. getActiveMeshes(): SmartArray<AbstractMesh>;
  40322. /**
  40323. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40324. * @returns a number
  40325. */
  40326. getAnimationRatio(): number;
  40327. /**
  40328. * Gets an unique Id for the current render phase
  40329. * @returns a number
  40330. */
  40331. getRenderId(): number;
  40332. /**
  40333. * Gets an unique Id for the current frame
  40334. * @returns a number
  40335. */
  40336. getFrameId(): number;
  40337. /** Call this function if you want to manually increment the render Id*/
  40338. incrementRenderId(): void;
  40339. private _createUbo;
  40340. /**
  40341. * Use this method to simulate a pointer move on a mesh
  40342. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40343. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40344. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40345. * @returns the current scene
  40346. */
  40347. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40348. /**
  40349. * Use this method to simulate a pointer down on a mesh
  40350. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40351. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40352. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40353. * @returns the current scene
  40354. */
  40355. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40356. /**
  40357. * Use this method to simulate a pointer up on a mesh
  40358. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40359. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40360. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40361. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40362. * @returns the current scene
  40363. */
  40364. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40365. /**
  40366. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40367. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40368. * @returns true if the pointer was captured
  40369. */
  40370. isPointerCaptured(pointerId?: number): boolean;
  40371. /**
  40372. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40373. * @param attachUp defines if you want to attach events to pointerup
  40374. * @param attachDown defines if you want to attach events to pointerdown
  40375. * @param attachMove defines if you want to attach events to pointermove
  40376. */
  40377. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40378. /** Detaches all event handlers*/
  40379. detachControl(): void;
  40380. /**
  40381. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40382. * Delay loaded resources are not taking in account
  40383. * @return true if all required resources are ready
  40384. */
  40385. isReady(): boolean;
  40386. /** Resets all cached information relative to material (including effect and visibility) */
  40387. resetCachedMaterial(): void;
  40388. /**
  40389. * Registers a function to be called before every frame render
  40390. * @param func defines the function to register
  40391. */
  40392. registerBeforeRender(func: () => void): void;
  40393. /**
  40394. * Unregisters a function called before every frame render
  40395. * @param func defines the function to unregister
  40396. */
  40397. unregisterBeforeRender(func: () => void): void;
  40398. /**
  40399. * Registers a function to be called after every frame render
  40400. * @param func defines the function to register
  40401. */
  40402. registerAfterRender(func: () => void): void;
  40403. /**
  40404. * Unregisters a function called after every frame render
  40405. * @param func defines the function to unregister
  40406. */
  40407. unregisterAfterRender(func: () => void): void;
  40408. private _executeOnceBeforeRender;
  40409. /**
  40410. * The provided function will run before render once and will be disposed afterwards.
  40411. * A timeout delay can be provided so that the function will be executed in N ms.
  40412. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40413. * @param func The function to be executed.
  40414. * @param timeout optional delay in ms
  40415. */
  40416. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40417. /** @hidden */
  40418. _addPendingData(data: any): void;
  40419. /** @hidden */
  40420. _removePendingData(data: any): void;
  40421. /**
  40422. * Returns the number of items waiting to be loaded
  40423. * @returns the number of items waiting to be loaded
  40424. */
  40425. getWaitingItemsCount(): number;
  40426. /**
  40427. * Returns a boolean indicating if the scene is still loading data
  40428. */
  40429. get isLoading(): boolean;
  40430. /**
  40431. * Registers a function to be executed when the scene is ready
  40432. * @param {Function} func - the function to be executed
  40433. */
  40434. executeWhenReady(func: () => void): void;
  40435. /**
  40436. * Returns a promise that resolves when the scene is ready
  40437. * @returns A promise that resolves when the scene is ready
  40438. */
  40439. whenReadyAsync(): Promise<void>;
  40440. /** @hidden */
  40441. _checkIsReady(): void;
  40442. /**
  40443. * Gets all animatable attached to the scene
  40444. */
  40445. get animatables(): Animatable[];
  40446. /**
  40447. * Resets the last animation time frame.
  40448. * Useful to override when animations start running when loading a scene for the first time.
  40449. */
  40450. resetLastAnimationTimeFrame(): void;
  40451. /**
  40452. * Gets the current view matrix
  40453. * @returns a Matrix
  40454. */
  40455. getViewMatrix(): Matrix;
  40456. /**
  40457. * Gets the current projection matrix
  40458. * @returns a Matrix
  40459. */
  40460. getProjectionMatrix(): Matrix;
  40461. /**
  40462. * Gets the current transform matrix
  40463. * @returns a Matrix made of View * Projection
  40464. */
  40465. getTransformMatrix(): Matrix;
  40466. /**
  40467. * Sets the current transform matrix
  40468. * @param viewL defines the View matrix to use
  40469. * @param projectionL defines the Projection matrix to use
  40470. * @param viewR defines the right View matrix to use (if provided)
  40471. * @param projectionR defines the right Projection matrix to use (if provided)
  40472. */
  40473. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40474. /**
  40475. * Gets the uniform buffer used to store scene data
  40476. * @returns a UniformBuffer
  40477. */
  40478. getSceneUniformBuffer(): UniformBuffer;
  40479. /**
  40480. * Gets an unique (relatively to the current scene) Id
  40481. * @returns an unique number for the scene
  40482. */
  40483. getUniqueId(): number;
  40484. /**
  40485. * Add a mesh to the list of scene's meshes
  40486. * @param newMesh defines the mesh to add
  40487. * @param recursive if all child meshes should also be added to the scene
  40488. */
  40489. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40490. /**
  40491. * Remove a mesh for the list of scene's meshes
  40492. * @param toRemove defines the mesh to remove
  40493. * @param recursive if all child meshes should also be removed from the scene
  40494. * @returns the index where the mesh was in the mesh list
  40495. */
  40496. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40497. /**
  40498. * Add a transform node to the list of scene's transform nodes
  40499. * @param newTransformNode defines the transform node to add
  40500. */
  40501. addTransformNode(newTransformNode: TransformNode): void;
  40502. /**
  40503. * Remove a transform node for the list of scene's transform nodes
  40504. * @param toRemove defines the transform node to remove
  40505. * @returns the index where the transform node was in the transform node list
  40506. */
  40507. removeTransformNode(toRemove: TransformNode): number;
  40508. /**
  40509. * Remove a skeleton for the list of scene's skeletons
  40510. * @param toRemove defines the skeleton to remove
  40511. * @returns the index where the skeleton was in the skeleton list
  40512. */
  40513. removeSkeleton(toRemove: Skeleton): number;
  40514. /**
  40515. * Remove a morph target for the list of scene's morph targets
  40516. * @param toRemove defines the morph target to remove
  40517. * @returns the index where the morph target was in the morph target list
  40518. */
  40519. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40520. /**
  40521. * Remove a light for the list of scene's lights
  40522. * @param toRemove defines the light to remove
  40523. * @returns the index where the light was in the light list
  40524. */
  40525. removeLight(toRemove: Light): number;
  40526. /**
  40527. * Remove a camera for the list of scene's cameras
  40528. * @param toRemove defines the camera to remove
  40529. * @returns the index where the camera was in the camera list
  40530. */
  40531. removeCamera(toRemove: Camera): number;
  40532. /**
  40533. * Remove a particle system for the list of scene's particle systems
  40534. * @param toRemove defines the particle system to remove
  40535. * @returns the index where the particle system was in the particle system list
  40536. */
  40537. removeParticleSystem(toRemove: IParticleSystem): number;
  40538. /**
  40539. * Remove a animation for the list of scene's animations
  40540. * @param toRemove defines the animation to remove
  40541. * @returns the index where the animation was in the animation list
  40542. */
  40543. removeAnimation(toRemove: Animation): number;
  40544. /**
  40545. * Will stop the animation of the given target
  40546. * @param target - the target
  40547. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40548. * @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)
  40549. */
  40550. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40551. /**
  40552. * Removes the given animation group from this scene.
  40553. * @param toRemove The animation group to remove
  40554. * @returns The index of the removed animation group
  40555. */
  40556. removeAnimationGroup(toRemove: AnimationGroup): number;
  40557. /**
  40558. * Removes the given multi-material from this scene.
  40559. * @param toRemove The multi-material to remove
  40560. * @returns The index of the removed multi-material
  40561. */
  40562. removeMultiMaterial(toRemove: MultiMaterial): number;
  40563. /**
  40564. * Removes the given material from this scene.
  40565. * @param toRemove The material to remove
  40566. * @returns The index of the removed material
  40567. */
  40568. removeMaterial(toRemove: Material): number;
  40569. /**
  40570. * Removes the given action manager from this scene.
  40571. * @param toRemove The action manager to remove
  40572. * @returns The index of the removed action manager
  40573. */
  40574. removeActionManager(toRemove: AbstractActionManager): number;
  40575. /**
  40576. * Removes the given texture from this scene.
  40577. * @param toRemove The texture to remove
  40578. * @returns The index of the removed texture
  40579. */
  40580. removeTexture(toRemove: BaseTexture): number;
  40581. /**
  40582. * Adds the given light to this scene
  40583. * @param newLight The light to add
  40584. */
  40585. addLight(newLight: Light): void;
  40586. /**
  40587. * Sorts the list list based on light priorities
  40588. */
  40589. sortLightsByPriority(): void;
  40590. /**
  40591. * Adds the given camera to this scene
  40592. * @param newCamera The camera to add
  40593. */
  40594. addCamera(newCamera: Camera): void;
  40595. /**
  40596. * Adds the given skeleton to this scene
  40597. * @param newSkeleton The skeleton to add
  40598. */
  40599. addSkeleton(newSkeleton: Skeleton): void;
  40600. /**
  40601. * Adds the given particle system to this scene
  40602. * @param newParticleSystem The particle system to add
  40603. */
  40604. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40605. /**
  40606. * Adds the given animation to this scene
  40607. * @param newAnimation The animation to add
  40608. */
  40609. addAnimation(newAnimation: Animation): void;
  40610. /**
  40611. * Adds the given animation group to this scene.
  40612. * @param newAnimationGroup The animation group to add
  40613. */
  40614. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40615. /**
  40616. * Adds the given multi-material to this scene
  40617. * @param newMultiMaterial The multi-material to add
  40618. */
  40619. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40620. /**
  40621. * Adds the given material to this scene
  40622. * @param newMaterial The material to add
  40623. */
  40624. addMaterial(newMaterial: Material): void;
  40625. /**
  40626. * Adds the given morph target to this scene
  40627. * @param newMorphTargetManager The morph target to add
  40628. */
  40629. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40630. /**
  40631. * Adds the given geometry to this scene
  40632. * @param newGeometry The geometry to add
  40633. */
  40634. addGeometry(newGeometry: Geometry): void;
  40635. /**
  40636. * Adds the given action manager to this scene
  40637. * @param newActionManager The action manager to add
  40638. */
  40639. addActionManager(newActionManager: AbstractActionManager): void;
  40640. /**
  40641. * Adds the given texture to this scene.
  40642. * @param newTexture The texture to add
  40643. */
  40644. addTexture(newTexture: BaseTexture): void;
  40645. /**
  40646. * Switch active camera
  40647. * @param newCamera defines the new active camera
  40648. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40649. */
  40650. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40651. /**
  40652. * sets the active camera of the scene using its ID
  40653. * @param id defines the camera's ID
  40654. * @return the new active camera or null if none found.
  40655. */
  40656. setActiveCameraByID(id: string): Nullable<Camera>;
  40657. /**
  40658. * sets the active camera of the scene using its name
  40659. * @param name defines the camera's name
  40660. * @returns the new active camera or null if none found.
  40661. */
  40662. setActiveCameraByName(name: string): Nullable<Camera>;
  40663. /**
  40664. * get an animation group using its name
  40665. * @param name defines the material's name
  40666. * @return the animation group or null if none found.
  40667. */
  40668. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40669. /**
  40670. * Get a material using its unique id
  40671. * @param uniqueId defines the material's unique id
  40672. * @return the material or null if none found.
  40673. */
  40674. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40675. /**
  40676. * get a material using its id
  40677. * @param id defines the material's ID
  40678. * @return the material or null if none found.
  40679. */
  40680. getMaterialByID(id: string): Nullable<Material>;
  40681. /**
  40682. * Gets a the last added material using a given id
  40683. * @param id defines the material's ID
  40684. * @return the last material with the given id or null if none found.
  40685. */
  40686. getLastMaterialByID(id: string): Nullable<Material>;
  40687. /**
  40688. * Gets a material using its name
  40689. * @param name defines the material's name
  40690. * @return the material or null if none found.
  40691. */
  40692. getMaterialByName(name: string): Nullable<Material>;
  40693. /**
  40694. * Get a texture using its unique id
  40695. * @param uniqueId defines the texture's unique id
  40696. * @return the texture or null if none found.
  40697. */
  40698. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40699. /**
  40700. * Gets a camera using its id
  40701. * @param id defines the id to look for
  40702. * @returns the camera or null if not found
  40703. */
  40704. getCameraByID(id: string): Nullable<Camera>;
  40705. /**
  40706. * Gets a camera using its unique id
  40707. * @param uniqueId defines the unique id to look for
  40708. * @returns the camera or null if not found
  40709. */
  40710. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40711. /**
  40712. * Gets a camera using its name
  40713. * @param name defines the camera's name
  40714. * @return the camera or null if none found.
  40715. */
  40716. getCameraByName(name: string): Nullable<Camera>;
  40717. /**
  40718. * Gets a bone using its id
  40719. * @param id defines the bone's id
  40720. * @return the bone or null if not found
  40721. */
  40722. getBoneByID(id: string): Nullable<Bone>;
  40723. /**
  40724. * Gets a bone using its id
  40725. * @param name defines the bone's name
  40726. * @return the bone or null if not found
  40727. */
  40728. getBoneByName(name: string): Nullable<Bone>;
  40729. /**
  40730. * Gets a light node using its name
  40731. * @param name defines the the light's name
  40732. * @return the light or null if none found.
  40733. */
  40734. getLightByName(name: string): Nullable<Light>;
  40735. /**
  40736. * Gets a light node using its id
  40737. * @param id defines the light's id
  40738. * @return the light or null if none found.
  40739. */
  40740. getLightByID(id: string): Nullable<Light>;
  40741. /**
  40742. * Gets a light node using its scene-generated unique ID
  40743. * @param uniqueId defines the light's unique id
  40744. * @return the light or null if none found.
  40745. */
  40746. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40747. /**
  40748. * Gets a particle system by id
  40749. * @param id defines the particle system id
  40750. * @return the corresponding system or null if none found
  40751. */
  40752. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40753. /**
  40754. * Gets a geometry using its ID
  40755. * @param id defines the geometry's id
  40756. * @return the geometry or null if none found.
  40757. */
  40758. getGeometryByID(id: string): Nullable<Geometry>;
  40759. private _getGeometryByUniqueID;
  40760. /**
  40761. * Add a new geometry to this scene
  40762. * @param geometry defines the geometry to be added to the scene.
  40763. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40764. * @return a boolean defining if the geometry was added or not
  40765. */
  40766. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40767. /**
  40768. * Removes an existing geometry
  40769. * @param geometry defines the geometry to be removed from the scene
  40770. * @return a boolean defining if the geometry was removed or not
  40771. */
  40772. removeGeometry(geometry: Geometry): boolean;
  40773. /**
  40774. * Gets the list of geometries attached to the scene
  40775. * @returns an array of Geometry
  40776. */
  40777. getGeometries(): Geometry[];
  40778. /**
  40779. * Gets the first added mesh found of a given ID
  40780. * @param id defines the id to search for
  40781. * @return the mesh found or null if not found at all
  40782. */
  40783. getMeshByID(id: string): Nullable<AbstractMesh>;
  40784. /**
  40785. * Gets a list of meshes using their id
  40786. * @param id defines the id to search for
  40787. * @returns a list of meshes
  40788. */
  40789. getMeshesByID(id: string): Array<AbstractMesh>;
  40790. /**
  40791. * Gets the first added transform node found of a given ID
  40792. * @param id defines the id to search for
  40793. * @return the found transform node or null if not found at all.
  40794. */
  40795. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40796. /**
  40797. * Gets a transform node with its auto-generated unique id
  40798. * @param uniqueId efines the unique id to search for
  40799. * @return the found transform node or null if not found at all.
  40800. */
  40801. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40802. /**
  40803. * Gets a list of transform nodes using their id
  40804. * @param id defines the id to search for
  40805. * @returns a list of transform nodes
  40806. */
  40807. getTransformNodesByID(id: string): Array<TransformNode>;
  40808. /**
  40809. * Gets a mesh with its auto-generated unique id
  40810. * @param uniqueId defines the unique id to search for
  40811. * @return the found mesh or null if not found at all.
  40812. */
  40813. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40814. /**
  40815. * Gets a the last added mesh using a given id
  40816. * @param id defines the id to search for
  40817. * @return the found mesh or null if not found at all.
  40818. */
  40819. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40820. /**
  40821. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40822. * @param id defines the id to search for
  40823. * @return the found node or null if not found at all
  40824. */
  40825. getLastEntryByID(id: string): Nullable<Node>;
  40826. /**
  40827. * Gets a node (Mesh, Camera, Light) using a given id
  40828. * @param id defines the id to search for
  40829. * @return the found node or null if not found at all
  40830. */
  40831. getNodeByID(id: string): Nullable<Node>;
  40832. /**
  40833. * Gets a node (Mesh, Camera, Light) using a given name
  40834. * @param name defines the name to search for
  40835. * @return the found node or null if not found at all.
  40836. */
  40837. getNodeByName(name: string): Nullable<Node>;
  40838. /**
  40839. * Gets a mesh using a given name
  40840. * @param name defines the name to search for
  40841. * @return the found mesh or null if not found at all.
  40842. */
  40843. getMeshByName(name: string): Nullable<AbstractMesh>;
  40844. /**
  40845. * Gets a transform node using a given name
  40846. * @param name defines the name to search for
  40847. * @return the found transform node or null if not found at all.
  40848. */
  40849. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40850. /**
  40851. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40852. * @param id defines the id to search for
  40853. * @return the found skeleton or null if not found at all.
  40854. */
  40855. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40856. /**
  40857. * Gets a skeleton using a given auto generated unique id
  40858. * @param uniqueId defines the unique id to search for
  40859. * @return the found skeleton or null if not found at all.
  40860. */
  40861. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40862. /**
  40863. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40864. * @param id defines the id to search for
  40865. * @return the found skeleton or null if not found at all.
  40866. */
  40867. getSkeletonById(id: string): Nullable<Skeleton>;
  40868. /**
  40869. * Gets a skeleton using a given name
  40870. * @param name defines the name to search for
  40871. * @return the found skeleton or null if not found at all.
  40872. */
  40873. getSkeletonByName(name: string): Nullable<Skeleton>;
  40874. /**
  40875. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40876. * @param id defines the id to search for
  40877. * @return the found morph target manager or null if not found at all.
  40878. */
  40879. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40880. /**
  40881. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40882. * @param id defines the id to search for
  40883. * @return the found morph target or null if not found at all.
  40884. */
  40885. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40886. /**
  40887. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40888. * @param name defines the name to search for
  40889. * @return the found morph target or null if not found at all.
  40890. */
  40891. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40892. /**
  40893. * Gets a boolean indicating if the given mesh is active
  40894. * @param mesh defines the mesh to look for
  40895. * @returns true if the mesh is in the active list
  40896. */
  40897. isActiveMesh(mesh: AbstractMesh): boolean;
  40898. /**
  40899. * Return a unique id as a string which can serve as an identifier for the scene
  40900. */
  40901. get uid(): string;
  40902. /**
  40903. * Add an externaly attached data from its key.
  40904. * This method call will fail and return false, if such key already exists.
  40905. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40906. * @param key the unique key that identifies the data
  40907. * @param data the data object to associate to the key for this Engine instance
  40908. * @return true if no such key were already present and the data was added successfully, false otherwise
  40909. */
  40910. addExternalData<T>(key: string, data: T): boolean;
  40911. /**
  40912. * Get an externaly attached data from its key
  40913. * @param key the unique key that identifies the data
  40914. * @return the associated data, if present (can be null), or undefined if not present
  40915. */
  40916. getExternalData<T>(key: string): Nullable<T>;
  40917. /**
  40918. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40919. * @param key the unique key that identifies the data
  40920. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40921. * @return the associated data, can be null if the factory returned null.
  40922. */
  40923. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40924. /**
  40925. * Remove an externaly attached data from the Engine instance
  40926. * @param key the unique key that identifies the data
  40927. * @return true if the data was successfully removed, false if it doesn't exist
  40928. */
  40929. removeExternalData(key: string): boolean;
  40930. private _evaluateSubMesh;
  40931. /**
  40932. * Clear the processed materials smart array preventing retention point in material dispose.
  40933. */
  40934. freeProcessedMaterials(): void;
  40935. private _preventFreeActiveMeshesAndRenderingGroups;
  40936. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40937. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40938. * when disposing several meshes in a row or a hierarchy of meshes.
  40939. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40940. */
  40941. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40942. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40943. /**
  40944. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40945. */
  40946. freeActiveMeshes(): void;
  40947. /**
  40948. * Clear the info related to rendering groups preventing retention points during dispose.
  40949. */
  40950. freeRenderingGroups(): void;
  40951. /** @hidden */
  40952. _isInIntermediateRendering(): boolean;
  40953. /**
  40954. * Lambda returning the list of potentially active meshes.
  40955. */
  40956. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40957. /**
  40958. * Lambda returning the list of potentially active sub meshes.
  40959. */
  40960. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40961. /**
  40962. * Lambda returning the list of potentially intersecting sub meshes.
  40963. */
  40964. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40965. /**
  40966. * Lambda returning the list of potentially colliding sub meshes.
  40967. */
  40968. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40969. private _activeMeshesFrozen;
  40970. private _skipEvaluateActiveMeshesCompletely;
  40971. /**
  40972. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40973. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40974. * @returns the current scene
  40975. */
  40976. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40977. /**
  40978. * Use this function to restart evaluating active meshes on every frame
  40979. * @returns the current scene
  40980. */
  40981. unfreezeActiveMeshes(): Scene;
  40982. private _evaluateActiveMeshes;
  40983. private _activeMesh;
  40984. /**
  40985. * Update the transform matrix to update from the current active camera
  40986. * @param force defines a boolean used to force the update even if cache is up to date
  40987. */
  40988. updateTransformMatrix(force?: boolean): void;
  40989. private _bindFrameBuffer;
  40990. /** @hidden */
  40991. _allowPostProcessClearColor: boolean;
  40992. /** @hidden */
  40993. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40994. private _processSubCameras;
  40995. private _checkIntersections;
  40996. /** @hidden */
  40997. _advancePhysicsEngineStep(step: number): void;
  40998. /**
  40999. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41000. */
  41001. getDeterministicFrameTime: () => number;
  41002. /** @hidden */
  41003. _animate(): void;
  41004. /** Execute all animations (for a frame) */
  41005. animate(): void;
  41006. /**
  41007. * Render the scene
  41008. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41009. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41010. */
  41011. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41012. /**
  41013. * Freeze all materials
  41014. * A frozen material will not be updatable but should be faster to render
  41015. */
  41016. freezeMaterials(): void;
  41017. /**
  41018. * Unfreeze all materials
  41019. * A frozen material will not be updatable but should be faster to render
  41020. */
  41021. unfreezeMaterials(): void;
  41022. /**
  41023. * Releases all held ressources
  41024. */
  41025. dispose(): void;
  41026. /**
  41027. * Gets if the scene is already disposed
  41028. */
  41029. get isDisposed(): boolean;
  41030. /**
  41031. * Call this function to reduce memory footprint of the scene.
  41032. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41033. */
  41034. clearCachedVertexData(): void;
  41035. /**
  41036. * This function will remove the local cached buffer data from texture.
  41037. * It will save memory but will prevent the texture from being rebuilt
  41038. */
  41039. cleanCachedTextureBuffer(): void;
  41040. /**
  41041. * Get the world extend vectors with an optional filter
  41042. *
  41043. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41044. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41045. */
  41046. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41047. min: Vector3;
  41048. max: Vector3;
  41049. };
  41050. /**
  41051. * Creates a ray that can be used to pick in the scene
  41052. * @param x defines the x coordinate of the origin (on-screen)
  41053. * @param y defines the y coordinate of the origin (on-screen)
  41054. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41055. * @param camera defines the camera to use for the picking
  41056. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41057. * @returns a Ray
  41058. */
  41059. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41060. /**
  41061. * Creates a ray that can be used to pick in the scene
  41062. * @param x defines the x coordinate of the origin (on-screen)
  41063. * @param y defines the y coordinate of the origin (on-screen)
  41064. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41065. * @param result defines the ray where to store the picking ray
  41066. * @param camera defines the camera to use for the picking
  41067. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41068. * @returns the current scene
  41069. */
  41070. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41071. /**
  41072. * Creates a ray that can be used to pick in the scene
  41073. * @param x defines the x coordinate of the origin (on-screen)
  41074. * @param y defines the y coordinate of the origin (on-screen)
  41075. * @param camera defines the camera to use for the picking
  41076. * @returns a Ray
  41077. */
  41078. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41079. /**
  41080. * Creates a ray that can be used to pick in the scene
  41081. * @param x defines the x coordinate of the origin (on-screen)
  41082. * @param y defines the y coordinate of the origin (on-screen)
  41083. * @param result defines the ray where to store the picking ray
  41084. * @param camera defines the camera to use for the picking
  41085. * @returns the current scene
  41086. */
  41087. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41088. /** Launch a ray to try to pick a mesh in the scene
  41089. * @param x position on screen
  41090. * @param y position on screen
  41091. * @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
  41092. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41093. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41095. * @returns a PickingInfo
  41096. */
  41097. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41098. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41099. * @param x position on screen
  41100. * @param y position on screen
  41101. * @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
  41102. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41103. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41104. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  41105. */
  41106. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41107. /** Use the given ray to pick a mesh in the scene
  41108. * @param ray The ray to use to pick meshes
  41109. * @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
  41110. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41111. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41112. * @returns a PickingInfo
  41113. */
  41114. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41115. /**
  41116. * Launch a ray to try to pick a mesh in the scene
  41117. * @param x X position on screen
  41118. * @param y Y position on screen
  41119. * @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
  41120. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41121. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41122. * @returns an array of PickingInfo
  41123. */
  41124. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41125. /**
  41126. * Launch a ray to try to pick a mesh in the scene
  41127. * @param ray Ray to use
  41128. * @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
  41129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41130. * @returns an array of PickingInfo
  41131. */
  41132. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41133. /**
  41134. * Force the value of meshUnderPointer
  41135. * @param mesh defines the mesh to use
  41136. */
  41137. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41138. /**
  41139. * Gets the mesh under the pointer
  41140. * @returns a Mesh or null if no mesh is under the pointer
  41141. */
  41142. getPointerOverMesh(): Nullable<AbstractMesh>;
  41143. /** @hidden */
  41144. _rebuildGeometries(): void;
  41145. /** @hidden */
  41146. _rebuildTextures(): void;
  41147. private _getByTags;
  41148. /**
  41149. * Get a list of meshes by tags
  41150. * @param tagsQuery defines the tags query to use
  41151. * @param forEach defines a predicate used to filter results
  41152. * @returns an array of Mesh
  41153. */
  41154. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41155. /**
  41156. * Get a list of cameras by tags
  41157. * @param tagsQuery defines the tags query to use
  41158. * @param forEach defines a predicate used to filter results
  41159. * @returns an array of Camera
  41160. */
  41161. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41162. /**
  41163. * Get a list of lights by tags
  41164. * @param tagsQuery defines the tags query to use
  41165. * @param forEach defines a predicate used to filter results
  41166. * @returns an array of Light
  41167. */
  41168. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41169. /**
  41170. * Get a list of materials by tags
  41171. * @param tagsQuery defines the tags query to use
  41172. * @param forEach defines a predicate used to filter results
  41173. * @returns an array of Material
  41174. */
  41175. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41176. /**
  41177. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41178. * This allowed control for front to back rendering or reversly depending of the special needs.
  41179. *
  41180. * @param renderingGroupId The rendering group id corresponding to its index
  41181. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41182. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41183. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41184. */
  41185. 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;
  41186. /**
  41187. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41188. *
  41189. * @param renderingGroupId The rendering group id corresponding to its index
  41190. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41191. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41192. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41193. */
  41194. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41195. /**
  41196. * Gets the current auto clear configuration for one rendering group of the rendering
  41197. * manager.
  41198. * @param index the rendering group index to get the information for
  41199. * @returns The auto clear setup for the requested rendering group
  41200. */
  41201. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41202. private _blockMaterialDirtyMechanism;
  41203. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41204. get blockMaterialDirtyMechanism(): boolean;
  41205. set blockMaterialDirtyMechanism(value: boolean);
  41206. /**
  41207. * Will flag all materials as dirty to trigger new shader compilation
  41208. * @param flag defines the flag used to specify which material part must be marked as dirty
  41209. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41210. */
  41211. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41212. /** @hidden */
  41213. _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;
  41214. /** @hidden */
  41215. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41216. /** @hidden */
  41217. _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;
  41218. /** @hidden */
  41219. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41220. /** @hidden */
  41221. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41222. /** @hidden */
  41223. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41224. }
  41225. }
  41226. declare module "babylonjs/assetContainer" {
  41227. import { AbstractScene } from "babylonjs/abstractScene";
  41228. import { Scene } from "babylonjs/scene";
  41229. import { Mesh } from "babylonjs/Meshes/mesh";
  41230. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41231. import { Skeleton } from "babylonjs/Bones/skeleton";
  41232. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41233. import { Animatable } from "babylonjs/Animations/animatable";
  41234. import { Nullable } from "babylonjs/types";
  41235. import { Node } from "babylonjs/node";
  41236. /**
  41237. * Set of assets to keep when moving a scene into an asset container.
  41238. */
  41239. export class KeepAssets extends AbstractScene {
  41240. }
  41241. /**
  41242. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41243. */
  41244. export class InstantiatedEntries {
  41245. /**
  41246. * List of new root nodes (eg. nodes with no parent)
  41247. */
  41248. rootNodes: TransformNode[];
  41249. /**
  41250. * List of new skeletons
  41251. */
  41252. skeletons: Skeleton[];
  41253. /**
  41254. * List of new animation groups
  41255. */
  41256. animationGroups: AnimationGroup[];
  41257. }
  41258. /**
  41259. * Container with a set of assets that can be added or removed from a scene.
  41260. */
  41261. export class AssetContainer extends AbstractScene {
  41262. private _wasAddedToScene;
  41263. /**
  41264. * The scene the AssetContainer belongs to.
  41265. */
  41266. scene: Scene;
  41267. /**
  41268. * Instantiates an AssetContainer.
  41269. * @param scene The scene the AssetContainer belongs to.
  41270. */
  41271. constructor(scene: Scene);
  41272. /**
  41273. * Instantiate or clone all meshes and add the new ones to the scene.
  41274. * Skeletons and animation groups will all be cloned
  41275. * @param nameFunction defines an optional function used to get new names for clones
  41276. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41277. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41278. */
  41279. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41280. /**
  41281. * Adds all the assets from the container to the scene.
  41282. */
  41283. addAllToScene(): void;
  41284. /**
  41285. * Removes all the assets in the container from the scene
  41286. */
  41287. removeAllFromScene(): void;
  41288. /**
  41289. * Disposes all the assets in the container
  41290. */
  41291. dispose(): void;
  41292. private _moveAssets;
  41293. /**
  41294. * Removes all the assets contained in the scene and adds them to the container.
  41295. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41296. */
  41297. moveAllFromScene(keepAssets?: KeepAssets): void;
  41298. /**
  41299. * 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.
  41300. * @returns the root mesh
  41301. */
  41302. createRootMesh(): Mesh;
  41303. /**
  41304. * Merge animations (direct and animation groups) from this asset container into a scene
  41305. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41306. * @param animatables set of animatables to retarget to a node from the scene
  41307. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41308. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41309. */
  41310. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41311. }
  41312. }
  41313. declare module "babylonjs/abstractScene" {
  41314. import { Scene } from "babylonjs/scene";
  41315. import { Nullable } from "babylonjs/types";
  41316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41317. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41318. import { Geometry } from "babylonjs/Meshes/geometry";
  41319. import { Skeleton } from "babylonjs/Bones/skeleton";
  41320. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41321. import { AssetContainer } from "babylonjs/assetContainer";
  41322. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41323. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41325. import { Material } from "babylonjs/Materials/material";
  41326. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41327. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41328. import { Camera } from "babylonjs/Cameras/camera";
  41329. import { Light } from "babylonjs/Lights/light";
  41330. import { Node } from "babylonjs/node";
  41331. import { Animation } from "babylonjs/Animations/animation";
  41332. /**
  41333. * Defines how the parser contract is defined.
  41334. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41335. */
  41336. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41337. /**
  41338. * Defines how the individual parser contract is defined.
  41339. * These parser can parse an individual asset
  41340. */
  41341. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41342. /**
  41343. * Base class of the scene acting as a container for the different elements composing a scene.
  41344. * This class is dynamically extended by the different components of the scene increasing
  41345. * flexibility and reducing coupling
  41346. */
  41347. export abstract class AbstractScene {
  41348. /**
  41349. * Stores the list of available parsers in the application.
  41350. */
  41351. private static _BabylonFileParsers;
  41352. /**
  41353. * Stores the list of available individual parsers in the application.
  41354. */
  41355. private static _IndividualBabylonFileParsers;
  41356. /**
  41357. * Adds a parser in the list of available ones
  41358. * @param name Defines the name of the parser
  41359. * @param parser Defines the parser to add
  41360. */
  41361. static AddParser(name: string, parser: BabylonFileParser): void;
  41362. /**
  41363. * Gets a general parser from the list of avaialble ones
  41364. * @param name Defines the name of the parser
  41365. * @returns the requested parser or null
  41366. */
  41367. static GetParser(name: string): Nullable<BabylonFileParser>;
  41368. /**
  41369. * Adds n individual parser in the list of available ones
  41370. * @param name Defines the name of the parser
  41371. * @param parser Defines the parser to add
  41372. */
  41373. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41374. /**
  41375. * Gets an individual parser from the list of avaialble ones
  41376. * @param name Defines the name of the parser
  41377. * @returns the requested parser or null
  41378. */
  41379. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41380. /**
  41381. * Parser json data and populate both a scene and its associated container object
  41382. * @param jsonData Defines the data to parse
  41383. * @param scene Defines the scene to parse the data for
  41384. * @param container Defines the container attached to the parsing sequence
  41385. * @param rootUrl Defines the root url of the data
  41386. */
  41387. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41388. /**
  41389. * Gets the list of root nodes (ie. nodes with no parent)
  41390. */
  41391. rootNodes: Node[];
  41392. /** All of the cameras added to this scene
  41393. * @see http://doc.babylonjs.com/babylon101/cameras
  41394. */
  41395. cameras: Camera[];
  41396. /**
  41397. * All of the lights added to this scene
  41398. * @see http://doc.babylonjs.com/babylon101/lights
  41399. */
  41400. lights: Light[];
  41401. /**
  41402. * All of the (abstract) meshes added to this scene
  41403. */
  41404. meshes: AbstractMesh[];
  41405. /**
  41406. * The list of skeletons added to the scene
  41407. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41408. */
  41409. skeletons: Skeleton[];
  41410. /**
  41411. * All of the particle systems added to this scene
  41412. * @see http://doc.babylonjs.com/babylon101/particles
  41413. */
  41414. particleSystems: IParticleSystem[];
  41415. /**
  41416. * Gets a list of Animations associated with the scene
  41417. */
  41418. animations: Animation[];
  41419. /**
  41420. * All of the animation groups added to this scene
  41421. * @see http://doc.babylonjs.com/how_to/group
  41422. */
  41423. animationGroups: AnimationGroup[];
  41424. /**
  41425. * All of the multi-materials added to this scene
  41426. * @see http://doc.babylonjs.com/how_to/multi_materials
  41427. */
  41428. multiMaterials: MultiMaterial[];
  41429. /**
  41430. * All of the materials added to this scene
  41431. * In the context of a Scene, it is not supposed to be modified manually.
  41432. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41433. * Note also that the order of the Material within the array is not significant and might change.
  41434. * @see http://doc.babylonjs.com/babylon101/materials
  41435. */
  41436. materials: Material[];
  41437. /**
  41438. * The list of morph target managers added to the scene
  41439. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41440. */
  41441. morphTargetManagers: MorphTargetManager[];
  41442. /**
  41443. * The list of geometries used in the scene.
  41444. */
  41445. geometries: Geometry[];
  41446. /**
  41447. * All of the tranform nodes added to this scene
  41448. * In the context of a Scene, it is not supposed to be modified manually.
  41449. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41450. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41451. * @see http://doc.babylonjs.com/how_to/transformnode
  41452. */
  41453. transformNodes: TransformNode[];
  41454. /**
  41455. * ActionManagers available on the scene.
  41456. */
  41457. actionManagers: AbstractActionManager[];
  41458. /**
  41459. * Textures to keep.
  41460. */
  41461. textures: BaseTexture[];
  41462. /**
  41463. * Environment texture for the scene
  41464. */
  41465. environmentTexture: Nullable<BaseTexture>;
  41466. /**
  41467. * @returns all meshes, lights, cameras, transformNodes and bones
  41468. */
  41469. getNodes(): Array<Node>;
  41470. }
  41471. }
  41472. declare module "babylonjs/Audio/sound" {
  41473. import { Observable } from "babylonjs/Misc/observable";
  41474. import { Vector3 } from "babylonjs/Maths/math.vector";
  41475. import { Nullable } from "babylonjs/types";
  41476. import { Scene } from "babylonjs/scene";
  41477. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41478. /**
  41479. * Interface used to define options for Sound class
  41480. */
  41481. export interface ISoundOptions {
  41482. /**
  41483. * Does the sound autoplay once loaded.
  41484. */
  41485. autoplay?: boolean;
  41486. /**
  41487. * Does the sound loop after it finishes playing once.
  41488. */
  41489. loop?: boolean;
  41490. /**
  41491. * Sound's volume
  41492. */
  41493. volume?: number;
  41494. /**
  41495. * Is it a spatial sound?
  41496. */
  41497. spatialSound?: boolean;
  41498. /**
  41499. * Maximum distance to hear that sound
  41500. */
  41501. maxDistance?: number;
  41502. /**
  41503. * Uses user defined attenuation function
  41504. */
  41505. useCustomAttenuation?: boolean;
  41506. /**
  41507. * Define the roll off factor of spatial sounds.
  41508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41509. */
  41510. rolloffFactor?: number;
  41511. /**
  41512. * Define the reference distance the sound should be heard perfectly.
  41513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41514. */
  41515. refDistance?: number;
  41516. /**
  41517. * Define the distance attenuation model the sound will follow.
  41518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41519. */
  41520. distanceModel?: string;
  41521. /**
  41522. * Defines the playback speed (1 by default)
  41523. */
  41524. playbackRate?: number;
  41525. /**
  41526. * Defines if the sound is from a streaming source
  41527. */
  41528. streaming?: boolean;
  41529. /**
  41530. * Defines an optional length (in seconds) inside the sound file
  41531. */
  41532. length?: number;
  41533. /**
  41534. * Defines an optional offset (in seconds) inside the sound file
  41535. */
  41536. offset?: number;
  41537. /**
  41538. * If true, URLs will not be required to state the audio file codec to use.
  41539. */
  41540. skipCodecCheck?: boolean;
  41541. }
  41542. /**
  41543. * Defines a sound that can be played in the application.
  41544. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41546. */
  41547. export class Sound {
  41548. /**
  41549. * The name of the sound in the scene.
  41550. */
  41551. name: string;
  41552. /**
  41553. * Does the sound autoplay once loaded.
  41554. */
  41555. autoplay: boolean;
  41556. /**
  41557. * Does the sound loop after it finishes playing once.
  41558. */
  41559. loop: boolean;
  41560. /**
  41561. * Does the sound use a custom attenuation curve to simulate the falloff
  41562. * happening when the source gets further away from the camera.
  41563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41564. */
  41565. useCustomAttenuation: boolean;
  41566. /**
  41567. * The sound track id this sound belongs to.
  41568. */
  41569. soundTrackId: number;
  41570. /**
  41571. * Is this sound currently played.
  41572. */
  41573. isPlaying: boolean;
  41574. /**
  41575. * Is this sound currently paused.
  41576. */
  41577. isPaused: boolean;
  41578. /**
  41579. * Does this sound enables spatial sound.
  41580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41581. */
  41582. spatialSound: boolean;
  41583. /**
  41584. * Define the reference distance the sound should be heard perfectly.
  41585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41586. */
  41587. refDistance: number;
  41588. /**
  41589. * Define the roll off factor of spatial sounds.
  41590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41591. */
  41592. rolloffFactor: number;
  41593. /**
  41594. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41596. */
  41597. maxDistance: number;
  41598. /**
  41599. * Define the distance attenuation model the sound will follow.
  41600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41601. */
  41602. distanceModel: string;
  41603. /**
  41604. * @hidden
  41605. * Back Compat
  41606. **/
  41607. onended: () => any;
  41608. /**
  41609. * Gets or sets an object used to store user defined information for the sound.
  41610. */
  41611. metadata: any;
  41612. /**
  41613. * Observable event when the current playing sound finishes.
  41614. */
  41615. onEndedObservable: Observable<Sound>;
  41616. private _panningModel;
  41617. private _playbackRate;
  41618. private _streaming;
  41619. private _startTime;
  41620. private _startOffset;
  41621. private _position;
  41622. /** @hidden */
  41623. _positionInEmitterSpace: boolean;
  41624. private _localDirection;
  41625. private _volume;
  41626. private _isReadyToPlay;
  41627. private _isDirectional;
  41628. private _readyToPlayCallback;
  41629. private _audioBuffer;
  41630. private _soundSource;
  41631. private _streamingSource;
  41632. private _soundPanner;
  41633. private _soundGain;
  41634. private _inputAudioNode;
  41635. private _outputAudioNode;
  41636. private _coneInnerAngle;
  41637. private _coneOuterAngle;
  41638. private _coneOuterGain;
  41639. private _scene;
  41640. private _connectedTransformNode;
  41641. private _customAttenuationFunction;
  41642. private _registerFunc;
  41643. private _isOutputConnected;
  41644. private _htmlAudioElement;
  41645. private _urlType;
  41646. private _length?;
  41647. private _offset?;
  41648. /** @hidden */
  41649. static _SceneComponentInitialization: (scene: Scene) => void;
  41650. /**
  41651. * Create a sound and attach it to a scene
  41652. * @param name Name of your sound
  41653. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41654. * @param scene defines the scene the sound belongs to
  41655. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41656. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41657. */
  41658. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41659. /**
  41660. * Release the sound and its associated resources
  41661. */
  41662. dispose(): void;
  41663. /**
  41664. * Gets if the sounds is ready to be played or not.
  41665. * @returns true if ready, otherwise false
  41666. */
  41667. isReady(): boolean;
  41668. private _soundLoaded;
  41669. /**
  41670. * Sets the data of the sound from an audiobuffer
  41671. * @param audioBuffer The audioBuffer containing the data
  41672. */
  41673. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41674. /**
  41675. * Updates the current sounds options such as maxdistance, loop...
  41676. * @param options A JSON object containing values named as the object properties
  41677. */
  41678. updateOptions(options: ISoundOptions): void;
  41679. private _createSpatialParameters;
  41680. private _updateSpatialParameters;
  41681. /**
  41682. * Switch the panning model to HRTF:
  41683. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41685. */
  41686. switchPanningModelToHRTF(): void;
  41687. /**
  41688. * Switch the panning model to Equal Power:
  41689. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41691. */
  41692. switchPanningModelToEqualPower(): void;
  41693. private _switchPanningModel;
  41694. /**
  41695. * Connect this sound to a sound track audio node like gain...
  41696. * @param soundTrackAudioNode the sound track audio node to connect to
  41697. */
  41698. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41699. /**
  41700. * Transform this sound into a directional source
  41701. * @param coneInnerAngle Size of the inner cone in degree
  41702. * @param coneOuterAngle Size of the outer cone in degree
  41703. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41704. */
  41705. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41706. /**
  41707. * Gets or sets the inner angle for the directional cone.
  41708. */
  41709. get directionalConeInnerAngle(): number;
  41710. /**
  41711. * Gets or sets the inner angle for the directional cone.
  41712. */
  41713. set directionalConeInnerAngle(value: number);
  41714. /**
  41715. * Gets or sets the outer angle for the directional cone.
  41716. */
  41717. get directionalConeOuterAngle(): number;
  41718. /**
  41719. * Gets or sets the outer angle for the directional cone.
  41720. */
  41721. set directionalConeOuterAngle(value: number);
  41722. /**
  41723. * Sets the position of the emitter if spatial sound is enabled
  41724. * @param newPosition Defines the new posisiton
  41725. */
  41726. setPosition(newPosition: Vector3): void;
  41727. /**
  41728. * Sets the local direction of the emitter if spatial sound is enabled
  41729. * @param newLocalDirection Defines the new local direction
  41730. */
  41731. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41732. private _updateDirection;
  41733. /** @hidden */
  41734. updateDistanceFromListener(): void;
  41735. /**
  41736. * Sets a new custom attenuation function for the sound.
  41737. * @param callback Defines the function used for the attenuation
  41738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41739. */
  41740. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41741. /**
  41742. * Play the sound
  41743. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41744. * @param offset (optional) Start the sound at a specific time in seconds
  41745. * @param length (optional) Sound duration (in seconds)
  41746. */
  41747. play(time?: number, offset?: number, length?: number): void;
  41748. private _onended;
  41749. /**
  41750. * Stop the sound
  41751. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41752. */
  41753. stop(time?: number): void;
  41754. /**
  41755. * Put the sound in pause
  41756. */
  41757. pause(): void;
  41758. /**
  41759. * Sets a dedicated volume for this sounds
  41760. * @param newVolume Define the new volume of the sound
  41761. * @param time Define time for gradual change to new volume
  41762. */
  41763. setVolume(newVolume: number, time?: number): void;
  41764. /**
  41765. * Set the sound play back rate
  41766. * @param newPlaybackRate Define the playback rate the sound should be played at
  41767. */
  41768. setPlaybackRate(newPlaybackRate: number): void;
  41769. /**
  41770. * Gets the volume of the sound.
  41771. * @returns the volume of the sound
  41772. */
  41773. getVolume(): number;
  41774. /**
  41775. * Attach the sound to a dedicated mesh
  41776. * @param transformNode The transform node to connect the sound with
  41777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41778. */
  41779. attachToMesh(transformNode: TransformNode): void;
  41780. /**
  41781. * Detach the sound from the previously attached mesh
  41782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41783. */
  41784. detachFromMesh(): void;
  41785. private _onRegisterAfterWorldMatrixUpdate;
  41786. /**
  41787. * Clone the current sound in the scene.
  41788. * @returns the new sound clone
  41789. */
  41790. clone(): Nullable<Sound>;
  41791. /**
  41792. * Gets the current underlying audio buffer containing the data
  41793. * @returns the audio buffer
  41794. */
  41795. getAudioBuffer(): Nullable<AudioBuffer>;
  41796. /**
  41797. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41798. * @returns the source node
  41799. */
  41800. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41801. /**
  41802. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41803. * @returns the gain node
  41804. */
  41805. getSoundGain(): Nullable<GainNode>;
  41806. /**
  41807. * Serializes the Sound in a JSON representation
  41808. * @returns the JSON representation of the sound
  41809. */
  41810. serialize(): any;
  41811. /**
  41812. * Parse a JSON representation of a sound to innstantiate in a given scene
  41813. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41814. * @param scene Define the scene the new parsed sound should be created in
  41815. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41816. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41817. * @returns the newly parsed sound
  41818. */
  41819. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41820. }
  41821. }
  41822. declare module "babylonjs/Actions/directAudioActions" {
  41823. import { Action } from "babylonjs/Actions/action";
  41824. import { Condition } from "babylonjs/Actions/condition";
  41825. import { Sound } from "babylonjs/Audio/sound";
  41826. /**
  41827. * This defines an action helpful to play a defined sound on a triggered action.
  41828. */
  41829. export class PlaySoundAction extends Action {
  41830. private _sound;
  41831. /**
  41832. * Instantiate the action
  41833. * @param triggerOptions defines the trigger options
  41834. * @param sound defines the sound to play
  41835. * @param condition defines the trigger related conditions
  41836. */
  41837. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41838. /** @hidden */
  41839. _prepare(): void;
  41840. /**
  41841. * Execute the action and play the sound.
  41842. */
  41843. execute(): void;
  41844. /**
  41845. * Serializes the actions and its related information.
  41846. * @param parent defines the object to serialize in
  41847. * @returns the serialized object
  41848. */
  41849. serialize(parent: any): any;
  41850. }
  41851. /**
  41852. * This defines an action helpful to stop a defined sound on a triggered action.
  41853. */
  41854. export class StopSoundAction extends Action {
  41855. private _sound;
  41856. /**
  41857. * Instantiate the action
  41858. * @param triggerOptions defines the trigger options
  41859. * @param sound defines the sound to stop
  41860. * @param condition defines the trigger related conditions
  41861. */
  41862. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41863. /** @hidden */
  41864. _prepare(): void;
  41865. /**
  41866. * Execute the action and stop the sound.
  41867. */
  41868. execute(): void;
  41869. /**
  41870. * Serializes the actions and its related information.
  41871. * @param parent defines the object to serialize in
  41872. * @returns the serialized object
  41873. */
  41874. serialize(parent: any): any;
  41875. }
  41876. }
  41877. declare module "babylonjs/Actions/interpolateValueAction" {
  41878. import { Action } from "babylonjs/Actions/action";
  41879. import { Condition } from "babylonjs/Actions/condition";
  41880. import { Observable } from "babylonjs/Misc/observable";
  41881. /**
  41882. * This defines an action responsible to change the value of a property
  41883. * by interpolating between its current value and the newly set one once triggered.
  41884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  41885. */
  41886. export class InterpolateValueAction extends Action {
  41887. /**
  41888. * Defines the path of the property where the value should be interpolated
  41889. */
  41890. propertyPath: string;
  41891. /**
  41892. * Defines the target value at the end of the interpolation.
  41893. */
  41894. value: any;
  41895. /**
  41896. * Defines the time it will take for the property to interpolate to the value.
  41897. */
  41898. duration: number;
  41899. /**
  41900. * Defines if the other scene animations should be stopped when the action has been triggered
  41901. */
  41902. stopOtherAnimations?: boolean;
  41903. /**
  41904. * Defines a callback raised once the interpolation animation has been done.
  41905. */
  41906. onInterpolationDone?: () => void;
  41907. /**
  41908. * Observable triggered once the interpolation animation has been done.
  41909. */
  41910. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41911. private _target;
  41912. private _effectiveTarget;
  41913. private _property;
  41914. /**
  41915. * Instantiate the action
  41916. * @param triggerOptions defines the trigger options
  41917. * @param target defines the object containing the value to interpolate
  41918. * @param propertyPath defines the path to the property in the target object
  41919. * @param value defines the target value at the end of the interpolation
  41920. * @param duration deines the time it will take for the property to interpolate to the value.
  41921. * @param condition defines the trigger related conditions
  41922. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41923. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41924. */
  41925. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41926. /** @hidden */
  41927. _prepare(): void;
  41928. /**
  41929. * Execute the action starts the value interpolation.
  41930. */
  41931. execute(): void;
  41932. /**
  41933. * Serializes the actions and its related information.
  41934. * @param parent defines the object to serialize in
  41935. * @returns the serialized object
  41936. */
  41937. serialize(parent: any): any;
  41938. }
  41939. }
  41940. declare module "babylonjs/Actions/index" {
  41941. export * from "babylonjs/Actions/abstractActionManager";
  41942. export * from "babylonjs/Actions/action";
  41943. export * from "babylonjs/Actions/actionEvent";
  41944. export * from "babylonjs/Actions/actionManager";
  41945. export * from "babylonjs/Actions/condition";
  41946. export * from "babylonjs/Actions/directActions";
  41947. export * from "babylonjs/Actions/directAudioActions";
  41948. export * from "babylonjs/Actions/interpolateValueAction";
  41949. }
  41950. declare module "babylonjs/Animations/index" {
  41951. export * from "babylonjs/Animations/animatable";
  41952. export * from "babylonjs/Animations/animation";
  41953. export * from "babylonjs/Animations/animationGroup";
  41954. export * from "babylonjs/Animations/animationPropertiesOverride";
  41955. export * from "babylonjs/Animations/easing";
  41956. export * from "babylonjs/Animations/runtimeAnimation";
  41957. export * from "babylonjs/Animations/animationEvent";
  41958. export * from "babylonjs/Animations/animationGroup";
  41959. export * from "babylonjs/Animations/animationKey";
  41960. export * from "babylonjs/Animations/animationRange";
  41961. export * from "babylonjs/Animations/animatable.interface";
  41962. }
  41963. declare module "babylonjs/Audio/soundTrack" {
  41964. import { Sound } from "babylonjs/Audio/sound";
  41965. import { Analyser } from "babylonjs/Audio/analyser";
  41966. import { Scene } from "babylonjs/scene";
  41967. /**
  41968. * Options allowed during the creation of a sound track.
  41969. */
  41970. export interface ISoundTrackOptions {
  41971. /**
  41972. * The volume the sound track should take during creation
  41973. */
  41974. volume?: number;
  41975. /**
  41976. * Define if the sound track is the main sound track of the scene
  41977. */
  41978. mainTrack?: boolean;
  41979. }
  41980. /**
  41981. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41982. * It will be also used in a future release to apply effects on a specific track.
  41983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41984. */
  41985. export class SoundTrack {
  41986. /**
  41987. * The unique identifier of the sound track in the scene.
  41988. */
  41989. id: number;
  41990. /**
  41991. * The list of sounds included in the sound track.
  41992. */
  41993. soundCollection: Array<Sound>;
  41994. private _outputAudioNode;
  41995. private _scene;
  41996. private _connectedAnalyser;
  41997. private _options;
  41998. private _isInitialized;
  41999. /**
  42000. * Creates a new sound track.
  42001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42002. * @param scene Define the scene the sound track belongs to
  42003. * @param options
  42004. */
  42005. constructor(scene: Scene, options?: ISoundTrackOptions);
  42006. private _initializeSoundTrackAudioGraph;
  42007. /**
  42008. * Release the sound track and its associated resources
  42009. */
  42010. dispose(): void;
  42011. /**
  42012. * Adds a sound to this sound track
  42013. * @param sound define the cound to add
  42014. * @ignoreNaming
  42015. */
  42016. AddSound(sound: Sound): void;
  42017. /**
  42018. * Removes a sound to this sound track
  42019. * @param sound define the cound to remove
  42020. * @ignoreNaming
  42021. */
  42022. RemoveSound(sound: Sound): void;
  42023. /**
  42024. * Set a global volume for the full sound track.
  42025. * @param newVolume Define the new volume of the sound track
  42026. */
  42027. setVolume(newVolume: number): void;
  42028. /**
  42029. * Switch the panning model to HRTF:
  42030. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42032. */
  42033. switchPanningModelToHRTF(): void;
  42034. /**
  42035. * Switch the panning model to Equal Power:
  42036. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42038. */
  42039. switchPanningModelToEqualPower(): void;
  42040. /**
  42041. * Connect the sound track to an audio analyser allowing some amazing
  42042. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42044. * @param analyser The analyser to connect to the engine
  42045. */
  42046. connectToAnalyser(analyser: Analyser): void;
  42047. }
  42048. }
  42049. declare module "babylonjs/Audio/audioSceneComponent" {
  42050. import { Sound } from "babylonjs/Audio/sound";
  42051. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42052. import { Nullable } from "babylonjs/types";
  42053. import { Vector3 } from "babylonjs/Maths/math.vector";
  42054. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42055. import { Scene } from "babylonjs/scene";
  42056. import { AbstractScene } from "babylonjs/abstractScene";
  42057. import "babylonjs/Audio/audioEngine";
  42058. module "babylonjs/abstractScene" {
  42059. interface AbstractScene {
  42060. /**
  42061. * The list of sounds used in the scene.
  42062. */
  42063. sounds: Nullable<Array<Sound>>;
  42064. }
  42065. }
  42066. module "babylonjs/scene" {
  42067. interface Scene {
  42068. /**
  42069. * @hidden
  42070. * Backing field
  42071. */
  42072. _mainSoundTrack: SoundTrack;
  42073. /**
  42074. * The main sound track played by the scene.
  42075. * It cotains your primary collection of sounds.
  42076. */
  42077. mainSoundTrack: SoundTrack;
  42078. /**
  42079. * The list of sound tracks added to the scene
  42080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42081. */
  42082. soundTracks: Nullable<Array<SoundTrack>>;
  42083. /**
  42084. * Gets a sound using a given name
  42085. * @param name defines the name to search for
  42086. * @return the found sound or null if not found at all.
  42087. */
  42088. getSoundByName(name: string): Nullable<Sound>;
  42089. /**
  42090. * Gets or sets if audio support is enabled
  42091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42092. */
  42093. audioEnabled: boolean;
  42094. /**
  42095. * Gets or sets if audio will be output to headphones
  42096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42097. */
  42098. headphone: boolean;
  42099. /**
  42100. * Gets or sets custom audio listener position provider
  42101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42102. */
  42103. audioListenerPositionProvider: Nullable<() => Vector3>;
  42104. /**
  42105. * Gets or sets a refresh rate when using 3D audio positioning
  42106. */
  42107. audioPositioningRefreshRate: number;
  42108. }
  42109. }
  42110. /**
  42111. * Defines the sound scene component responsible to manage any sounds
  42112. * in a given scene.
  42113. */
  42114. export class AudioSceneComponent implements ISceneSerializableComponent {
  42115. /**
  42116. * The component name helpfull to identify the component in the list of scene components.
  42117. */
  42118. readonly name: string;
  42119. /**
  42120. * The scene the component belongs to.
  42121. */
  42122. scene: Scene;
  42123. private _audioEnabled;
  42124. /**
  42125. * Gets whether audio is enabled or not.
  42126. * Please use related enable/disable method to switch state.
  42127. */
  42128. get audioEnabled(): boolean;
  42129. private _headphone;
  42130. /**
  42131. * Gets whether audio is outputing to headphone or not.
  42132. * Please use the according Switch methods to change output.
  42133. */
  42134. get headphone(): boolean;
  42135. /**
  42136. * Gets or sets a refresh rate when using 3D audio positioning
  42137. */
  42138. audioPositioningRefreshRate: number;
  42139. private _audioListenerPositionProvider;
  42140. /**
  42141. * Gets the current audio listener position provider
  42142. */
  42143. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42144. /**
  42145. * Sets a custom listener position for all sounds in the scene
  42146. * By default, this is the position of the first active camera
  42147. */
  42148. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42149. /**
  42150. * Creates a new instance of the component for the given scene
  42151. * @param scene Defines the scene to register the component in
  42152. */
  42153. constructor(scene: Scene);
  42154. /**
  42155. * Registers the component in a given scene
  42156. */
  42157. register(): void;
  42158. /**
  42159. * Rebuilds the elements related to this component in case of
  42160. * context lost for instance.
  42161. */
  42162. rebuild(): void;
  42163. /**
  42164. * Serializes the component data to the specified json object
  42165. * @param serializationObject The object to serialize to
  42166. */
  42167. serialize(serializationObject: any): void;
  42168. /**
  42169. * Adds all the elements from the container to the scene
  42170. * @param container the container holding the elements
  42171. */
  42172. addFromContainer(container: AbstractScene): void;
  42173. /**
  42174. * Removes all the elements in the container from the scene
  42175. * @param container contains the elements to remove
  42176. * @param dispose if the removed element should be disposed (default: false)
  42177. */
  42178. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42179. /**
  42180. * Disposes the component and the associated ressources.
  42181. */
  42182. dispose(): void;
  42183. /**
  42184. * Disables audio in the associated scene.
  42185. */
  42186. disableAudio(): void;
  42187. /**
  42188. * Enables audio in the associated scene.
  42189. */
  42190. enableAudio(): void;
  42191. /**
  42192. * Switch audio to headphone output.
  42193. */
  42194. switchAudioModeForHeadphones(): void;
  42195. /**
  42196. * Switch audio to normal speakers.
  42197. */
  42198. switchAudioModeForNormalSpeakers(): void;
  42199. private _cachedCameraDirection;
  42200. private _cachedCameraPosition;
  42201. private _lastCheck;
  42202. private _afterRender;
  42203. }
  42204. }
  42205. declare module "babylonjs/Audio/weightedsound" {
  42206. import { Sound } from "babylonjs/Audio/sound";
  42207. /**
  42208. * Wraps one or more Sound objects and selects one with random weight for playback.
  42209. */
  42210. export class WeightedSound {
  42211. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42212. loop: boolean;
  42213. private _coneInnerAngle;
  42214. private _coneOuterAngle;
  42215. private _volume;
  42216. /** A Sound is currently playing. */
  42217. isPlaying: boolean;
  42218. /** A Sound is currently paused. */
  42219. isPaused: boolean;
  42220. private _sounds;
  42221. private _weights;
  42222. private _currentIndex?;
  42223. /**
  42224. * Creates a new WeightedSound from the list of sounds given.
  42225. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42226. * @param sounds Array of Sounds that will be selected from.
  42227. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42228. */
  42229. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42230. /**
  42231. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42232. */
  42233. get directionalConeInnerAngle(): number;
  42234. /**
  42235. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42236. */
  42237. set directionalConeInnerAngle(value: number);
  42238. /**
  42239. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42240. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42241. */
  42242. get directionalConeOuterAngle(): number;
  42243. /**
  42244. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42245. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42246. */
  42247. set directionalConeOuterAngle(value: number);
  42248. /**
  42249. * Playback volume.
  42250. */
  42251. get volume(): number;
  42252. /**
  42253. * Playback volume.
  42254. */
  42255. set volume(value: number);
  42256. private _onended;
  42257. /**
  42258. * Suspend playback
  42259. */
  42260. pause(): void;
  42261. /**
  42262. * Stop playback
  42263. */
  42264. stop(): void;
  42265. /**
  42266. * Start playback.
  42267. * @param startOffset Position the clip head at a specific time in seconds.
  42268. */
  42269. play(startOffset?: number): void;
  42270. }
  42271. }
  42272. declare module "babylonjs/Audio/index" {
  42273. export * from "babylonjs/Audio/analyser";
  42274. export * from "babylonjs/Audio/audioEngine";
  42275. export * from "babylonjs/Audio/audioSceneComponent";
  42276. export * from "babylonjs/Audio/sound";
  42277. export * from "babylonjs/Audio/soundTrack";
  42278. export * from "babylonjs/Audio/weightedsound";
  42279. }
  42280. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42281. import { Behavior } from "babylonjs/Behaviors/behavior";
  42282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42283. import { BackEase } from "babylonjs/Animations/easing";
  42284. /**
  42285. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42287. */
  42288. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42289. /**
  42290. * Gets the name of the behavior.
  42291. */
  42292. get name(): string;
  42293. /**
  42294. * The easing function used by animations
  42295. */
  42296. static EasingFunction: BackEase;
  42297. /**
  42298. * The easing mode used by animations
  42299. */
  42300. static EasingMode: number;
  42301. /**
  42302. * The duration of the animation, in milliseconds
  42303. */
  42304. transitionDuration: number;
  42305. /**
  42306. * Length of the distance animated by the transition when lower radius is reached
  42307. */
  42308. lowerRadiusTransitionRange: number;
  42309. /**
  42310. * Length of the distance animated by the transition when upper radius is reached
  42311. */
  42312. upperRadiusTransitionRange: number;
  42313. private _autoTransitionRange;
  42314. /**
  42315. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42316. */
  42317. get autoTransitionRange(): boolean;
  42318. /**
  42319. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42320. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42321. */
  42322. set autoTransitionRange(value: boolean);
  42323. private _attachedCamera;
  42324. private _onAfterCheckInputsObserver;
  42325. private _onMeshTargetChangedObserver;
  42326. /**
  42327. * Initializes the behavior.
  42328. */
  42329. init(): void;
  42330. /**
  42331. * Attaches the behavior to its arc rotate camera.
  42332. * @param camera Defines the camera to attach the behavior to
  42333. */
  42334. attach(camera: ArcRotateCamera): void;
  42335. /**
  42336. * Detaches the behavior from its current arc rotate camera.
  42337. */
  42338. detach(): void;
  42339. private _radiusIsAnimating;
  42340. private _radiusBounceTransition;
  42341. private _animatables;
  42342. private _cachedWheelPrecision;
  42343. /**
  42344. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42345. * @param radiusLimit The limit to check against.
  42346. * @return Bool to indicate if at limit.
  42347. */
  42348. private _isRadiusAtLimit;
  42349. /**
  42350. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42351. * @param radiusDelta The delta by which to animate to. Can be negative.
  42352. */
  42353. private _applyBoundRadiusAnimation;
  42354. /**
  42355. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42356. */
  42357. protected _clearAnimationLocks(): void;
  42358. /**
  42359. * Stops and removes all animations that have been applied to the camera
  42360. */
  42361. stopAllAnimations(): void;
  42362. }
  42363. }
  42364. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42365. import { Behavior } from "babylonjs/Behaviors/behavior";
  42366. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42367. import { ExponentialEase } from "babylonjs/Animations/easing";
  42368. import { Nullable } from "babylonjs/types";
  42369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42370. import { Vector3 } from "babylonjs/Maths/math.vector";
  42371. /**
  42372. * 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.
  42373. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42374. */
  42375. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42376. /**
  42377. * Gets the name of the behavior.
  42378. */
  42379. get name(): string;
  42380. private _mode;
  42381. private _radiusScale;
  42382. private _positionScale;
  42383. private _defaultElevation;
  42384. private _elevationReturnTime;
  42385. private _elevationReturnWaitTime;
  42386. private _zoomStopsAnimation;
  42387. private _framingTime;
  42388. /**
  42389. * The easing function used by animations
  42390. */
  42391. static EasingFunction: ExponentialEase;
  42392. /**
  42393. * The easing mode used by animations
  42394. */
  42395. static EasingMode: number;
  42396. /**
  42397. * Sets the current mode used by the behavior
  42398. */
  42399. set mode(mode: number);
  42400. /**
  42401. * Gets current mode used by the behavior.
  42402. */
  42403. get mode(): number;
  42404. /**
  42405. * Sets the scale applied to the radius (1 by default)
  42406. */
  42407. set radiusScale(radius: number);
  42408. /**
  42409. * Gets the scale applied to the radius
  42410. */
  42411. get radiusScale(): number;
  42412. /**
  42413. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42414. */
  42415. set positionScale(scale: number);
  42416. /**
  42417. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42418. */
  42419. get positionScale(): number;
  42420. /**
  42421. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42422. * behaviour is triggered, in radians.
  42423. */
  42424. set defaultElevation(elevation: number);
  42425. /**
  42426. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42427. * behaviour is triggered, in radians.
  42428. */
  42429. get defaultElevation(): number;
  42430. /**
  42431. * Sets the time (in milliseconds) taken to return to the default beta position.
  42432. * Negative value indicates camera should not return to default.
  42433. */
  42434. set elevationReturnTime(speed: number);
  42435. /**
  42436. * Gets the time (in milliseconds) taken to return to the default beta position.
  42437. * Negative value indicates camera should not return to default.
  42438. */
  42439. get elevationReturnTime(): number;
  42440. /**
  42441. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42442. */
  42443. set elevationReturnWaitTime(time: number);
  42444. /**
  42445. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42446. */
  42447. get elevationReturnWaitTime(): number;
  42448. /**
  42449. * Sets the flag that indicates if user zooming should stop animation.
  42450. */
  42451. set zoomStopsAnimation(flag: boolean);
  42452. /**
  42453. * Gets the flag that indicates if user zooming should stop animation.
  42454. */
  42455. get zoomStopsAnimation(): boolean;
  42456. /**
  42457. * Sets the transition time when framing the mesh, in milliseconds
  42458. */
  42459. set framingTime(time: number);
  42460. /**
  42461. * Gets the transition time when framing the mesh, in milliseconds
  42462. */
  42463. get framingTime(): number;
  42464. /**
  42465. * Define if the behavior should automatically change the configured
  42466. * camera limits and sensibilities.
  42467. */
  42468. autoCorrectCameraLimitsAndSensibility: boolean;
  42469. private _onPrePointerObservableObserver;
  42470. private _onAfterCheckInputsObserver;
  42471. private _onMeshTargetChangedObserver;
  42472. private _attachedCamera;
  42473. private _isPointerDown;
  42474. private _lastInteractionTime;
  42475. /**
  42476. * Initializes the behavior.
  42477. */
  42478. init(): void;
  42479. /**
  42480. * Attaches the behavior to its arc rotate camera.
  42481. * @param camera Defines the camera to attach the behavior to
  42482. */
  42483. attach(camera: ArcRotateCamera): void;
  42484. /**
  42485. * Detaches the behavior from its current arc rotate camera.
  42486. */
  42487. detach(): void;
  42488. private _animatables;
  42489. private _betaIsAnimating;
  42490. private _betaTransition;
  42491. private _radiusTransition;
  42492. private _vectorTransition;
  42493. /**
  42494. * Targets the given mesh and updates zoom level accordingly.
  42495. * @param mesh The mesh to target.
  42496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42498. */
  42499. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42500. /**
  42501. * Targets the given mesh with its children and updates zoom level accordingly.
  42502. * @param mesh The mesh to target.
  42503. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42504. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42505. */
  42506. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42507. /**
  42508. * Targets the given meshes with their children and updates zoom level accordingly.
  42509. * @param meshes The mesh to target.
  42510. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42511. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42512. */
  42513. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42514. /**
  42515. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42516. * @param minimumWorld Determines the smaller position of the bounding box extend
  42517. * @param maximumWorld Determines the bigger position of the bounding box extend
  42518. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42519. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42520. */
  42521. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42522. /**
  42523. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42524. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42525. * frustum width.
  42526. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42527. * to fully enclose the mesh in the viewing frustum.
  42528. */
  42529. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42530. /**
  42531. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42532. * is automatically returned to its default position (expected to be above ground plane).
  42533. */
  42534. private _maintainCameraAboveGround;
  42535. /**
  42536. * Returns the frustum slope based on the canvas ratio and camera FOV
  42537. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42538. */
  42539. private _getFrustumSlope;
  42540. /**
  42541. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42542. */
  42543. private _clearAnimationLocks;
  42544. /**
  42545. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42546. */
  42547. private _applyUserInteraction;
  42548. /**
  42549. * Stops and removes all animations that have been applied to the camera
  42550. */
  42551. stopAllAnimations(): void;
  42552. /**
  42553. * Gets a value indicating if the user is moving the camera
  42554. */
  42555. get isUserIsMoving(): boolean;
  42556. /**
  42557. * The camera can move all the way towards the mesh.
  42558. */
  42559. static IgnoreBoundsSizeMode: number;
  42560. /**
  42561. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42562. */
  42563. static FitFrustumSidesMode: number;
  42564. }
  42565. }
  42566. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42567. import { Nullable } from "babylonjs/types";
  42568. import { Camera } from "babylonjs/Cameras/camera";
  42569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42570. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42571. /**
  42572. * Base class for Camera Pointer Inputs.
  42573. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42574. * for example usage.
  42575. */
  42576. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42577. /**
  42578. * Defines the camera the input is attached to.
  42579. */
  42580. abstract camera: Camera;
  42581. /**
  42582. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42583. */
  42584. protected _altKey: boolean;
  42585. protected _ctrlKey: boolean;
  42586. protected _metaKey: boolean;
  42587. protected _shiftKey: boolean;
  42588. /**
  42589. * Which mouse buttons were pressed at time of last mouse event.
  42590. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42591. */
  42592. protected _buttonsPressed: number;
  42593. /**
  42594. * Defines the buttons associated with the input to handle camera move.
  42595. */
  42596. buttons: number[];
  42597. /**
  42598. * Attach the input controls to a specific dom element to get the input from.
  42599. * @param element Defines the element the controls should be listened from
  42600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42601. */
  42602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42603. /**
  42604. * Detach the current controls from the specified dom element.
  42605. * @param element Defines the element to stop listening the inputs from
  42606. */
  42607. detachControl(element: Nullable<HTMLElement>): void;
  42608. /**
  42609. * Gets the class name of the current input.
  42610. * @returns the class name
  42611. */
  42612. getClassName(): string;
  42613. /**
  42614. * Get the friendly name associated with the input class.
  42615. * @returns the input friendly name
  42616. */
  42617. getSimpleName(): string;
  42618. /**
  42619. * Called on pointer POINTERDOUBLETAP event.
  42620. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42621. */
  42622. protected onDoubleTap(type: string): void;
  42623. /**
  42624. * Called on pointer POINTERMOVE event if only a single touch is active.
  42625. * Override this method to provide functionality.
  42626. */
  42627. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42628. /**
  42629. * Called on pointer POINTERMOVE event if multiple touches are active.
  42630. * Override this method to provide functionality.
  42631. */
  42632. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42633. /**
  42634. * Called on JS contextmenu event.
  42635. * Override this method to provide functionality.
  42636. */
  42637. protected onContextMenu(evt: PointerEvent): void;
  42638. /**
  42639. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42640. * press.
  42641. * Override this method to provide functionality.
  42642. */
  42643. protected onButtonDown(evt: PointerEvent): void;
  42644. /**
  42645. * Called each time a new POINTERUP event occurs. Ie, for each button
  42646. * release.
  42647. * Override this method to provide functionality.
  42648. */
  42649. protected onButtonUp(evt: PointerEvent): void;
  42650. /**
  42651. * Called when window becomes inactive.
  42652. * Override this method to provide functionality.
  42653. */
  42654. protected onLostFocus(): void;
  42655. private _pointerInput;
  42656. private _observer;
  42657. private _onLostFocus;
  42658. private pointA;
  42659. private pointB;
  42660. }
  42661. }
  42662. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42663. import { Nullable } from "babylonjs/types";
  42664. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42665. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42666. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42667. /**
  42668. * Manage the pointers inputs to control an arc rotate camera.
  42669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42670. */
  42671. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42672. /**
  42673. * Defines the camera the input is attached to.
  42674. */
  42675. camera: ArcRotateCamera;
  42676. /**
  42677. * Gets the class name of the current input.
  42678. * @returns the class name
  42679. */
  42680. getClassName(): string;
  42681. /**
  42682. * Defines the buttons associated with the input to handle camera move.
  42683. */
  42684. buttons: number[];
  42685. /**
  42686. * Defines the pointer angular sensibility along the X axis or how fast is
  42687. * the camera rotating.
  42688. */
  42689. angularSensibilityX: number;
  42690. /**
  42691. * Defines the pointer angular sensibility along the Y axis or how fast is
  42692. * the camera rotating.
  42693. */
  42694. angularSensibilityY: number;
  42695. /**
  42696. * Defines the pointer pinch precision or how fast is the camera zooming.
  42697. */
  42698. pinchPrecision: number;
  42699. /**
  42700. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42701. * from 0.
  42702. * It defines the percentage of current camera.radius to use as delta when
  42703. * pinch zoom is used.
  42704. */
  42705. pinchDeltaPercentage: number;
  42706. /**
  42707. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42708. * that any object in the plane at the camera's target point will scale
  42709. * perfectly with finger motion.
  42710. * Overrides pinchDeltaPercentage and pinchPrecision.
  42711. */
  42712. useNaturalPinchZoom: boolean;
  42713. /**
  42714. * Defines the pointer panning sensibility or how fast is the camera moving.
  42715. */
  42716. panningSensibility: number;
  42717. /**
  42718. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42719. */
  42720. multiTouchPanning: boolean;
  42721. /**
  42722. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42723. * zoom (pinch) through multitouch.
  42724. */
  42725. multiTouchPanAndZoom: boolean;
  42726. /**
  42727. * Revers pinch action direction.
  42728. */
  42729. pinchInwards: boolean;
  42730. private _isPanClick;
  42731. private _twoFingerActivityCount;
  42732. private _isPinching;
  42733. /**
  42734. * Called on pointer POINTERMOVE event if only a single touch is active.
  42735. */
  42736. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42737. /**
  42738. * Called on pointer POINTERDOUBLETAP event.
  42739. */
  42740. protected onDoubleTap(type: string): void;
  42741. /**
  42742. * Called on pointer POINTERMOVE event if multiple touches are active.
  42743. */
  42744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42745. /**
  42746. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42747. * press.
  42748. */
  42749. protected onButtonDown(evt: PointerEvent): void;
  42750. /**
  42751. * Called each time a new POINTERUP event occurs. Ie, for each button
  42752. * release.
  42753. */
  42754. protected onButtonUp(evt: PointerEvent): void;
  42755. /**
  42756. * Called when window becomes inactive.
  42757. */
  42758. protected onLostFocus(): void;
  42759. }
  42760. }
  42761. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42762. import { Nullable } from "babylonjs/types";
  42763. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42765. /**
  42766. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42768. */
  42769. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42770. /**
  42771. * Defines the camera the input is attached to.
  42772. */
  42773. camera: ArcRotateCamera;
  42774. /**
  42775. * Defines the list of key codes associated with the up action (increase alpha)
  42776. */
  42777. keysUp: number[];
  42778. /**
  42779. * Defines the list of key codes associated with the down action (decrease alpha)
  42780. */
  42781. keysDown: number[];
  42782. /**
  42783. * Defines the list of key codes associated with the left action (increase beta)
  42784. */
  42785. keysLeft: number[];
  42786. /**
  42787. * Defines the list of key codes associated with the right action (decrease beta)
  42788. */
  42789. keysRight: number[];
  42790. /**
  42791. * Defines the list of key codes associated with the reset action.
  42792. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42793. */
  42794. keysReset: number[];
  42795. /**
  42796. * Defines the panning sensibility of the inputs.
  42797. * (How fast is the camera panning)
  42798. */
  42799. panningSensibility: number;
  42800. /**
  42801. * Defines the zooming sensibility of the inputs.
  42802. * (How fast is the camera zooming)
  42803. */
  42804. zoomingSensibility: number;
  42805. /**
  42806. * Defines whether maintaining the alt key down switch the movement mode from
  42807. * orientation to zoom.
  42808. */
  42809. useAltToZoom: boolean;
  42810. /**
  42811. * Rotation speed of the camera
  42812. */
  42813. angularSpeed: number;
  42814. private _keys;
  42815. private _ctrlPressed;
  42816. private _altPressed;
  42817. private _onCanvasBlurObserver;
  42818. private _onKeyboardObserver;
  42819. private _engine;
  42820. private _scene;
  42821. /**
  42822. * Attach the input controls to a specific dom element to get the input from.
  42823. * @param element Defines the element the controls should be listened from
  42824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42825. */
  42826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42827. /**
  42828. * Detach the current controls from the specified dom element.
  42829. * @param element Defines the element to stop listening the inputs from
  42830. */
  42831. detachControl(element: Nullable<HTMLElement>): void;
  42832. /**
  42833. * Update the current camera state depending on the inputs that have been used this frame.
  42834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42835. */
  42836. checkInputs(): void;
  42837. /**
  42838. * Gets the class name of the current intput.
  42839. * @returns the class name
  42840. */
  42841. getClassName(): string;
  42842. /**
  42843. * Get the friendly name associated with the input class.
  42844. * @returns the input friendly name
  42845. */
  42846. getSimpleName(): string;
  42847. }
  42848. }
  42849. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  42850. import { Nullable } from "babylonjs/types";
  42851. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42852. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42853. /**
  42854. * Manage the mouse wheel inputs to control an arc rotate camera.
  42855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42856. */
  42857. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42858. /**
  42859. * Defines the camera the input is attached to.
  42860. */
  42861. camera: ArcRotateCamera;
  42862. /**
  42863. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42864. */
  42865. wheelPrecision: number;
  42866. /**
  42867. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42868. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42869. */
  42870. wheelDeltaPercentage: number;
  42871. private _wheel;
  42872. private _observer;
  42873. private computeDeltaFromMouseWheelLegacyEvent;
  42874. /**
  42875. * Attach the input controls to a specific dom element to get the input from.
  42876. * @param element Defines the element the controls should be listened from
  42877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42878. */
  42879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42880. /**
  42881. * Detach the current controls from the specified dom element.
  42882. * @param element Defines the element to stop listening the inputs from
  42883. */
  42884. detachControl(element: Nullable<HTMLElement>): void;
  42885. /**
  42886. * Gets the class name of the current intput.
  42887. * @returns the class name
  42888. */
  42889. getClassName(): string;
  42890. /**
  42891. * Get the friendly name associated with the input class.
  42892. * @returns the input friendly name
  42893. */
  42894. getSimpleName(): string;
  42895. }
  42896. }
  42897. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42898. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42899. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42900. /**
  42901. * Default Inputs manager for the ArcRotateCamera.
  42902. * It groups all the default supported inputs for ease of use.
  42903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42904. */
  42905. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42906. /**
  42907. * Instantiates a new ArcRotateCameraInputsManager.
  42908. * @param camera Defines the camera the inputs belong to
  42909. */
  42910. constructor(camera: ArcRotateCamera);
  42911. /**
  42912. * Add mouse wheel input support to the input manager.
  42913. * @returns the current input manager
  42914. */
  42915. addMouseWheel(): ArcRotateCameraInputsManager;
  42916. /**
  42917. * Add pointers input support to the input manager.
  42918. * @returns the current input manager
  42919. */
  42920. addPointers(): ArcRotateCameraInputsManager;
  42921. /**
  42922. * Add keyboard input support to the input manager.
  42923. * @returns the current input manager
  42924. */
  42925. addKeyboard(): ArcRotateCameraInputsManager;
  42926. }
  42927. }
  42928. declare module "babylonjs/Cameras/arcRotateCamera" {
  42929. import { Observable } from "babylonjs/Misc/observable";
  42930. import { Nullable } from "babylonjs/types";
  42931. import { Scene } from "babylonjs/scene";
  42932. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  42933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42934. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  42935. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  42936. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  42937. import { Camera } from "babylonjs/Cameras/camera";
  42938. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42939. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42940. import { Collider } from "babylonjs/Collisions/collider";
  42941. /**
  42942. * This represents an orbital type of camera.
  42943. *
  42944. * 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.
  42945. * 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.
  42946. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42947. */
  42948. export class ArcRotateCamera extends TargetCamera {
  42949. /**
  42950. * Defines the rotation angle of the camera along the longitudinal axis.
  42951. */
  42952. alpha: number;
  42953. /**
  42954. * Defines the rotation angle of the camera along the latitudinal axis.
  42955. */
  42956. beta: number;
  42957. /**
  42958. * Defines the radius of the camera from it s target point.
  42959. */
  42960. radius: number;
  42961. protected _target: Vector3;
  42962. protected _targetHost: Nullable<AbstractMesh>;
  42963. /**
  42964. * Defines the target point of the camera.
  42965. * The camera looks towards it form the radius distance.
  42966. */
  42967. get target(): Vector3;
  42968. set target(value: Vector3);
  42969. /**
  42970. * Define the current local position of the camera in the scene
  42971. */
  42972. get position(): Vector3;
  42973. set position(newPosition: Vector3);
  42974. protected _upVector: Vector3;
  42975. protected _upToYMatrix: Matrix;
  42976. protected _YToUpMatrix: Matrix;
  42977. /**
  42978. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42979. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42980. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42981. */
  42982. set upVector(vec: Vector3);
  42983. get upVector(): Vector3;
  42984. /**
  42985. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42986. */
  42987. setMatUp(): void;
  42988. /**
  42989. * Current inertia value on the longitudinal axis.
  42990. * The bigger this number the longer it will take for the camera to stop.
  42991. */
  42992. inertialAlphaOffset: number;
  42993. /**
  42994. * Current inertia value on the latitudinal axis.
  42995. * The bigger this number the longer it will take for the camera to stop.
  42996. */
  42997. inertialBetaOffset: number;
  42998. /**
  42999. * Current inertia value on the radius axis.
  43000. * The bigger this number the longer it will take for the camera to stop.
  43001. */
  43002. inertialRadiusOffset: number;
  43003. /**
  43004. * Minimum allowed angle on the longitudinal axis.
  43005. * This can help limiting how the Camera is able to move in the scene.
  43006. */
  43007. lowerAlphaLimit: Nullable<number>;
  43008. /**
  43009. * Maximum allowed angle on the longitudinal axis.
  43010. * This can help limiting how the Camera is able to move in the scene.
  43011. */
  43012. upperAlphaLimit: Nullable<number>;
  43013. /**
  43014. * Minimum allowed angle on the latitudinal axis.
  43015. * This can help limiting how the Camera is able to move in the scene.
  43016. */
  43017. lowerBetaLimit: number;
  43018. /**
  43019. * Maximum allowed angle on the latitudinal axis.
  43020. * This can help limiting how the Camera is able to move in the scene.
  43021. */
  43022. upperBetaLimit: number;
  43023. /**
  43024. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43025. * This can help limiting how the Camera is able to move in the scene.
  43026. */
  43027. lowerRadiusLimit: Nullable<number>;
  43028. /**
  43029. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43030. * This can help limiting how the Camera is able to move in the scene.
  43031. */
  43032. upperRadiusLimit: Nullable<number>;
  43033. /**
  43034. * Defines the current inertia value used during panning of the camera along the X axis.
  43035. */
  43036. inertialPanningX: number;
  43037. /**
  43038. * Defines the current inertia value used during panning of the camera along the Y axis.
  43039. */
  43040. inertialPanningY: number;
  43041. /**
  43042. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43043. * Basically if your fingers moves away from more than this distance you will be considered
  43044. * in pinch mode.
  43045. */
  43046. pinchToPanMaxDistance: number;
  43047. /**
  43048. * Defines the maximum distance the camera can pan.
  43049. * This could help keeping the cammera always in your scene.
  43050. */
  43051. panningDistanceLimit: Nullable<number>;
  43052. /**
  43053. * Defines the target of the camera before paning.
  43054. */
  43055. panningOriginTarget: Vector3;
  43056. /**
  43057. * Defines the value of the inertia used during panning.
  43058. * 0 would mean stop inertia and one would mean no decelleration at all.
  43059. */
  43060. panningInertia: number;
  43061. /**
  43062. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43063. */
  43064. get angularSensibilityX(): number;
  43065. set angularSensibilityX(value: number);
  43066. /**
  43067. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43068. */
  43069. get angularSensibilityY(): number;
  43070. set angularSensibilityY(value: number);
  43071. /**
  43072. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43073. */
  43074. get pinchPrecision(): number;
  43075. set pinchPrecision(value: number);
  43076. /**
  43077. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43078. * It will be used instead of pinchDeltaPrecision if different from 0.
  43079. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43080. */
  43081. get pinchDeltaPercentage(): number;
  43082. set pinchDeltaPercentage(value: number);
  43083. /**
  43084. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43085. * and pinch delta percentage.
  43086. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43087. * that any object in the plane at the camera's target point will scale
  43088. * perfectly with finger motion.
  43089. */
  43090. get useNaturalPinchZoom(): boolean;
  43091. set useNaturalPinchZoom(value: boolean);
  43092. /**
  43093. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43094. */
  43095. get panningSensibility(): number;
  43096. set panningSensibility(value: number);
  43097. /**
  43098. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43099. */
  43100. get keysUp(): number[];
  43101. set keysUp(value: number[]);
  43102. /**
  43103. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43104. */
  43105. get keysDown(): number[];
  43106. set keysDown(value: number[]);
  43107. /**
  43108. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43109. */
  43110. get keysLeft(): number[];
  43111. set keysLeft(value: number[]);
  43112. /**
  43113. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43114. */
  43115. get keysRight(): number[];
  43116. set keysRight(value: number[]);
  43117. /**
  43118. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43119. */
  43120. get wheelPrecision(): number;
  43121. set wheelPrecision(value: number);
  43122. /**
  43123. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43124. * It will be used instead of pinchDeltaPrecision if different from 0.
  43125. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43126. */
  43127. get wheelDeltaPercentage(): number;
  43128. set wheelDeltaPercentage(value: number);
  43129. /**
  43130. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43131. */
  43132. zoomOnFactor: number;
  43133. /**
  43134. * Defines a screen offset for the camera position.
  43135. */
  43136. targetScreenOffset: Vector2;
  43137. /**
  43138. * Allows the camera to be completely reversed.
  43139. * If false the camera can not arrive upside down.
  43140. */
  43141. allowUpsideDown: boolean;
  43142. /**
  43143. * Define if double tap/click is used to restore the previously saved state of the camera.
  43144. */
  43145. useInputToRestoreState: boolean;
  43146. /** @hidden */
  43147. _viewMatrix: Matrix;
  43148. /** @hidden */
  43149. _useCtrlForPanning: boolean;
  43150. /** @hidden */
  43151. _panningMouseButton: number;
  43152. /**
  43153. * Defines the input associated to the camera.
  43154. */
  43155. inputs: ArcRotateCameraInputsManager;
  43156. /** @hidden */
  43157. _reset: () => void;
  43158. /**
  43159. * Defines the allowed panning axis.
  43160. */
  43161. panningAxis: Vector3;
  43162. protected _localDirection: Vector3;
  43163. protected _transformedDirection: Vector3;
  43164. private _bouncingBehavior;
  43165. /**
  43166. * Gets the bouncing behavior of the camera if it has been enabled.
  43167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43168. */
  43169. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43170. /**
  43171. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43173. */
  43174. get useBouncingBehavior(): boolean;
  43175. set useBouncingBehavior(value: boolean);
  43176. private _framingBehavior;
  43177. /**
  43178. * Gets the framing behavior of the camera if it has been enabled.
  43179. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43180. */
  43181. get framingBehavior(): Nullable<FramingBehavior>;
  43182. /**
  43183. * Defines if the framing behavior of the camera is enabled on the camera.
  43184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43185. */
  43186. get useFramingBehavior(): boolean;
  43187. set useFramingBehavior(value: boolean);
  43188. private _autoRotationBehavior;
  43189. /**
  43190. * Gets the auto rotation behavior of the camera if it has been enabled.
  43191. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43192. */
  43193. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43194. /**
  43195. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43196. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43197. */
  43198. get useAutoRotationBehavior(): boolean;
  43199. set useAutoRotationBehavior(value: boolean);
  43200. /**
  43201. * Observable triggered when the mesh target has been changed on the camera.
  43202. */
  43203. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43204. /**
  43205. * Event raised when the camera is colliding with a mesh.
  43206. */
  43207. onCollide: (collidedMesh: AbstractMesh) => void;
  43208. /**
  43209. * Defines whether the camera should check collision with the objects oh the scene.
  43210. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43211. */
  43212. checkCollisions: boolean;
  43213. /**
  43214. * Defines the collision radius of the camera.
  43215. * This simulates a sphere around the camera.
  43216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43217. */
  43218. collisionRadius: Vector3;
  43219. protected _collider: Collider;
  43220. protected _previousPosition: Vector3;
  43221. protected _collisionVelocity: Vector3;
  43222. protected _newPosition: Vector3;
  43223. protected _previousAlpha: number;
  43224. protected _previousBeta: number;
  43225. protected _previousRadius: number;
  43226. protected _collisionTriggered: boolean;
  43227. protected _targetBoundingCenter: Nullable<Vector3>;
  43228. private _computationVector;
  43229. /**
  43230. * Instantiates a new ArcRotateCamera in a given scene
  43231. * @param name Defines the name of the camera
  43232. * @param alpha Defines the camera rotation along the logitudinal axis
  43233. * @param beta Defines the camera rotation along the latitudinal axis
  43234. * @param radius Defines the camera distance from its target
  43235. * @param target Defines the camera target
  43236. * @param scene Defines the scene the camera belongs to
  43237. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43238. */
  43239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43240. /** @hidden */
  43241. _initCache(): void;
  43242. /** @hidden */
  43243. _updateCache(ignoreParentClass?: boolean): void;
  43244. protected _getTargetPosition(): Vector3;
  43245. private _storedAlpha;
  43246. private _storedBeta;
  43247. private _storedRadius;
  43248. private _storedTarget;
  43249. private _storedTargetScreenOffset;
  43250. /**
  43251. * Stores the current state of the camera (alpha, beta, radius and target)
  43252. * @returns the camera itself
  43253. */
  43254. storeState(): Camera;
  43255. /**
  43256. * @hidden
  43257. * Restored camera state. You must call storeState() first
  43258. */
  43259. _restoreStateValues(): boolean;
  43260. /** @hidden */
  43261. _isSynchronizedViewMatrix(): boolean;
  43262. /**
  43263. * Attached controls to the current camera.
  43264. * @param element Defines the element the controls should be listened from
  43265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43266. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43267. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43268. */
  43269. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43270. /**
  43271. * Detach the current controls from the camera.
  43272. * The camera will stop reacting to inputs.
  43273. * @param element Defines the element to stop listening the inputs from
  43274. */
  43275. detachControl(element: HTMLElement): void;
  43276. /** @hidden */
  43277. _checkInputs(): void;
  43278. protected _checkLimits(): void;
  43279. /**
  43280. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43281. */
  43282. rebuildAnglesAndRadius(): void;
  43283. /**
  43284. * Use a position to define the current camera related information like alpha, beta and radius
  43285. * @param position Defines the position to set the camera at
  43286. */
  43287. setPosition(position: Vector3): void;
  43288. /**
  43289. * Defines the target the camera should look at.
  43290. * This will automatically adapt alpha beta and radius to fit within the new target.
  43291. * @param target Defines the new target as a Vector or a mesh
  43292. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43293. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43294. */
  43295. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43296. /** @hidden */
  43297. _getViewMatrix(): Matrix;
  43298. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43299. /**
  43300. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43301. * @param meshes Defines the mesh to zoom on
  43302. * @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)
  43303. */
  43304. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43305. /**
  43306. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43307. * The target will be changed but the radius
  43308. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43309. * @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)
  43310. */
  43311. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43312. min: Vector3;
  43313. max: Vector3;
  43314. distance: number;
  43315. }, doNotUpdateMaxZ?: boolean): void;
  43316. /**
  43317. * @override
  43318. * Override Camera.createRigCamera
  43319. */
  43320. createRigCamera(name: string, cameraIndex: number): Camera;
  43321. /**
  43322. * @hidden
  43323. * @override
  43324. * Override Camera._updateRigCameras
  43325. */
  43326. _updateRigCameras(): void;
  43327. /**
  43328. * Destroy the camera and release the current resources hold by it.
  43329. */
  43330. dispose(): void;
  43331. /**
  43332. * Gets the current object class name.
  43333. * @return the class name
  43334. */
  43335. getClassName(): string;
  43336. }
  43337. }
  43338. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43339. import { Behavior } from "babylonjs/Behaviors/behavior";
  43340. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43341. /**
  43342. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43343. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43344. */
  43345. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43346. /**
  43347. * Gets the name of the behavior.
  43348. */
  43349. get name(): string;
  43350. private _zoomStopsAnimation;
  43351. private _idleRotationSpeed;
  43352. private _idleRotationWaitTime;
  43353. private _idleRotationSpinupTime;
  43354. /**
  43355. * Sets the flag that indicates if user zooming should stop animation.
  43356. */
  43357. set zoomStopsAnimation(flag: boolean);
  43358. /**
  43359. * Gets the flag that indicates if user zooming should stop animation.
  43360. */
  43361. get zoomStopsAnimation(): boolean;
  43362. /**
  43363. * Sets the default speed at which the camera rotates around the model.
  43364. */
  43365. set idleRotationSpeed(speed: number);
  43366. /**
  43367. * Gets the default speed at which the camera rotates around the model.
  43368. */
  43369. get idleRotationSpeed(): number;
  43370. /**
  43371. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43372. */
  43373. set idleRotationWaitTime(time: number);
  43374. /**
  43375. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43376. */
  43377. get idleRotationWaitTime(): number;
  43378. /**
  43379. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43380. */
  43381. set idleRotationSpinupTime(time: number);
  43382. /**
  43383. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43384. */
  43385. get idleRotationSpinupTime(): number;
  43386. /**
  43387. * Gets a value indicating if the camera is currently rotating because of this behavior
  43388. */
  43389. get rotationInProgress(): boolean;
  43390. private _onPrePointerObservableObserver;
  43391. private _onAfterCheckInputsObserver;
  43392. private _attachedCamera;
  43393. private _isPointerDown;
  43394. private _lastFrameTime;
  43395. private _lastInteractionTime;
  43396. private _cameraRotationSpeed;
  43397. /**
  43398. * Initializes the behavior.
  43399. */
  43400. init(): void;
  43401. /**
  43402. * Attaches the behavior to its arc rotate camera.
  43403. * @param camera Defines the camera to attach the behavior to
  43404. */
  43405. attach(camera: ArcRotateCamera): void;
  43406. /**
  43407. * Detaches the behavior from its current arc rotate camera.
  43408. */
  43409. detach(): void;
  43410. /**
  43411. * Returns true if user is scrolling.
  43412. * @return true if user is scrolling.
  43413. */
  43414. private _userIsZooming;
  43415. private _lastFrameRadius;
  43416. private _shouldAnimationStopForInteraction;
  43417. /**
  43418. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43419. */
  43420. private _applyUserInteraction;
  43421. private _userIsMoving;
  43422. }
  43423. }
  43424. declare module "babylonjs/Behaviors/Cameras/index" {
  43425. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43426. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43427. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43428. }
  43429. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43430. import { Mesh } from "babylonjs/Meshes/mesh";
  43431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43432. import { Behavior } from "babylonjs/Behaviors/behavior";
  43433. /**
  43434. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43435. */
  43436. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43437. private ui;
  43438. /**
  43439. * The name of the behavior
  43440. */
  43441. name: string;
  43442. /**
  43443. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43444. */
  43445. distanceAwayFromFace: number;
  43446. /**
  43447. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43448. */
  43449. distanceAwayFromBottomOfFace: number;
  43450. private _faceVectors;
  43451. private _target;
  43452. private _scene;
  43453. private _onRenderObserver;
  43454. private _tmpMatrix;
  43455. private _tmpVector;
  43456. /**
  43457. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43458. * @param ui The transform node that should be attched to the mesh
  43459. */
  43460. constructor(ui: TransformNode);
  43461. /**
  43462. * Initializes the behavior
  43463. */
  43464. init(): void;
  43465. private _closestFace;
  43466. private _zeroVector;
  43467. private _lookAtTmpMatrix;
  43468. private _lookAtToRef;
  43469. /**
  43470. * Attaches the AttachToBoxBehavior to the passed in mesh
  43471. * @param target The mesh that the specified node will be attached to
  43472. */
  43473. attach(target: Mesh): void;
  43474. /**
  43475. * Detaches the behavior from the mesh
  43476. */
  43477. detach(): void;
  43478. }
  43479. }
  43480. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43481. import { Behavior } from "babylonjs/Behaviors/behavior";
  43482. import { Mesh } from "babylonjs/Meshes/mesh";
  43483. /**
  43484. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43485. */
  43486. export class FadeInOutBehavior implements Behavior<Mesh> {
  43487. /**
  43488. * Time in milliseconds to delay before fading in (Default: 0)
  43489. */
  43490. delay: number;
  43491. /**
  43492. * Time in milliseconds for the mesh to fade in (Default: 300)
  43493. */
  43494. fadeInTime: number;
  43495. private _millisecondsPerFrame;
  43496. private _hovered;
  43497. private _hoverValue;
  43498. private _ownerNode;
  43499. /**
  43500. * Instatiates the FadeInOutBehavior
  43501. */
  43502. constructor();
  43503. /**
  43504. * The name of the behavior
  43505. */
  43506. get name(): string;
  43507. /**
  43508. * Initializes the behavior
  43509. */
  43510. init(): void;
  43511. /**
  43512. * Attaches the fade behavior on the passed in mesh
  43513. * @param ownerNode The mesh that will be faded in/out once attached
  43514. */
  43515. attach(ownerNode: Mesh): void;
  43516. /**
  43517. * Detaches the behavior from the mesh
  43518. */
  43519. detach(): void;
  43520. /**
  43521. * Triggers the mesh to begin fading in or out
  43522. * @param value if the object should fade in or out (true to fade in)
  43523. */
  43524. fadeIn(value: boolean): void;
  43525. private _update;
  43526. private _setAllVisibility;
  43527. }
  43528. }
  43529. declare module "babylonjs/Misc/pivotTools" {
  43530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43531. /**
  43532. * Class containing a set of static utilities functions for managing Pivots
  43533. * @hidden
  43534. */
  43535. export class PivotTools {
  43536. private static _PivotCached;
  43537. private static _OldPivotPoint;
  43538. private static _PivotTranslation;
  43539. private static _PivotTmpVector;
  43540. /** @hidden */
  43541. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43542. /** @hidden */
  43543. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43544. }
  43545. }
  43546. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43547. import { Scene } from "babylonjs/scene";
  43548. import { Vector4 } from "babylonjs/Maths/math.vector";
  43549. import { Mesh } from "babylonjs/Meshes/mesh";
  43550. import { Nullable } from "babylonjs/types";
  43551. import { Plane } from "babylonjs/Maths/math.plane";
  43552. /**
  43553. * Class containing static functions to help procedurally build meshes
  43554. */
  43555. export class PlaneBuilder {
  43556. /**
  43557. * Creates a plane mesh
  43558. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43559. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43560. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43564. * @param name defines the name of the mesh
  43565. * @param options defines the options used to create the mesh
  43566. * @param scene defines the hosting scene
  43567. * @returns the plane mesh
  43568. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43569. */
  43570. static CreatePlane(name: string, options: {
  43571. size?: number;
  43572. width?: number;
  43573. height?: number;
  43574. sideOrientation?: number;
  43575. frontUVs?: Vector4;
  43576. backUVs?: Vector4;
  43577. updatable?: boolean;
  43578. sourcePlane?: Plane;
  43579. }, scene?: Nullable<Scene>): Mesh;
  43580. }
  43581. }
  43582. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43583. import { Behavior } from "babylonjs/Behaviors/behavior";
  43584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43585. import { Observable } from "babylonjs/Misc/observable";
  43586. import { Vector3 } from "babylonjs/Maths/math.vector";
  43587. import { Ray } from "babylonjs/Culling/ray";
  43588. import "babylonjs/Meshes/Builders/planeBuilder";
  43589. /**
  43590. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43591. */
  43592. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43593. private static _AnyMouseID;
  43594. /**
  43595. * Abstract mesh the behavior is set on
  43596. */
  43597. attachedNode: AbstractMesh;
  43598. private _dragPlane;
  43599. private _scene;
  43600. private _pointerObserver;
  43601. private _beforeRenderObserver;
  43602. private static _planeScene;
  43603. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43604. /**
  43605. * 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)
  43606. */
  43607. maxDragAngle: number;
  43608. /**
  43609. * @hidden
  43610. */
  43611. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43612. /**
  43613. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43614. */
  43615. currentDraggingPointerID: number;
  43616. /**
  43617. * The last position where the pointer hit the drag plane in world space
  43618. */
  43619. lastDragPosition: Vector3;
  43620. /**
  43621. * If the behavior is currently in a dragging state
  43622. */
  43623. dragging: boolean;
  43624. /**
  43625. * 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)
  43626. */
  43627. dragDeltaRatio: number;
  43628. /**
  43629. * If the drag plane orientation should be updated during the dragging (Default: true)
  43630. */
  43631. updateDragPlane: boolean;
  43632. private _debugMode;
  43633. private _moving;
  43634. /**
  43635. * Fires each time the attached mesh is dragged with the pointer
  43636. * * delta between last drag position and current drag position in world space
  43637. * * dragDistance along the drag axis
  43638. * * dragPlaneNormal normal of the current drag plane used during the drag
  43639. * * dragPlanePoint in world space where the drag intersects the drag plane
  43640. */
  43641. onDragObservable: Observable<{
  43642. delta: Vector3;
  43643. dragPlanePoint: Vector3;
  43644. dragPlaneNormal: Vector3;
  43645. dragDistance: number;
  43646. pointerId: number;
  43647. }>;
  43648. /**
  43649. * Fires each time a drag begins (eg. mouse down on mesh)
  43650. */
  43651. onDragStartObservable: Observable<{
  43652. dragPlanePoint: Vector3;
  43653. pointerId: number;
  43654. }>;
  43655. /**
  43656. * Fires each time a drag ends (eg. mouse release after drag)
  43657. */
  43658. onDragEndObservable: Observable<{
  43659. dragPlanePoint: Vector3;
  43660. pointerId: number;
  43661. }>;
  43662. /**
  43663. * If the attached mesh should be moved when dragged
  43664. */
  43665. moveAttached: boolean;
  43666. /**
  43667. * If the drag behavior will react to drag events (Default: true)
  43668. */
  43669. enabled: boolean;
  43670. /**
  43671. * If pointer events should start and release the drag (Default: true)
  43672. */
  43673. startAndReleaseDragOnPointerEvents: boolean;
  43674. /**
  43675. * If camera controls should be detached during the drag
  43676. */
  43677. detachCameraControls: boolean;
  43678. /**
  43679. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43680. */
  43681. useObjectOrientationForDragging: boolean;
  43682. private _options;
  43683. /**
  43684. * Gets the options used by the behavior
  43685. */
  43686. get options(): {
  43687. dragAxis?: Vector3;
  43688. dragPlaneNormal?: Vector3;
  43689. };
  43690. /**
  43691. * Sets the options used by the behavior
  43692. */
  43693. set options(options: {
  43694. dragAxis?: Vector3;
  43695. dragPlaneNormal?: Vector3;
  43696. });
  43697. /**
  43698. * Creates a pointer drag behavior that can be attached to a mesh
  43699. * @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)
  43700. */
  43701. constructor(options?: {
  43702. dragAxis?: Vector3;
  43703. dragPlaneNormal?: Vector3;
  43704. });
  43705. /**
  43706. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43707. */
  43708. validateDrag: (targetPosition: Vector3) => boolean;
  43709. /**
  43710. * The name of the behavior
  43711. */
  43712. get name(): string;
  43713. /**
  43714. * Initializes the behavior
  43715. */
  43716. init(): void;
  43717. private _tmpVector;
  43718. private _alternatePickedPoint;
  43719. private _worldDragAxis;
  43720. private _targetPosition;
  43721. private _attachedElement;
  43722. /**
  43723. * Attaches the drag behavior the passed in mesh
  43724. * @param ownerNode The mesh that will be dragged around once attached
  43725. * @param predicate Predicate to use for pick filtering
  43726. */
  43727. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43728. /**
  43729. * Force relase the drag action by code.
  43730. */
  43731. releaseDrag(): void;
  43732. private _startDragRay;
  43733. private _lastPointerRay;
  43734. /**
  43735. * Simulates the start of a pointer drag event on the behavior
  43736. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43737. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43738. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43739. */
  43740. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43741. private _startDrag;
  43742. private _dragDelta;
  43743. private _moveDrag;
  43744. private _pickWithRayOnDragPlane;
  43745. private _pointA;
  43746. private _pointB;
  43747. private _pointC;
  43748. private _lineA;
  43749. private _lineB;
  43750. private _localAxis;
  43751. private _lookAt;
  43752. private _updateDragPlanePosition;
  43753. /**
  43754. * Detaches the behavior from the mesh
  43755. */
  43756. detach(): void;
  43757. }
  43758. }
  43759. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43760. import { Mesh } from "babylonjs/Meshes/mesh";
  43761. import { Behavior } from "babylonjs/Behaviors/behavior";
  43762. /**
  43763. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43764. */
  43765. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43766. private _dragBehaviorA;
  43767. private _dragBehaviorB;
  43768. private _startDistance;
  43769. private _initialScale;
  43770. private _targetScale;
  43771. private _ownerNode;
  43772. private _sceneRenderObserver;
  43773. /**
  43774. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43775. */
  43776. constructor();
  43777. /**
  43778. * The name of the behavior
  43779. */
  43780. get name(): string;
  43781. /**
  43782. * Initializes the behavior
  43783. */
  43784. init(): void;
  43785. private _getCurrentDistance;
  43786. /**
  43787. * Attaches the scale behavior the passed in mesh
  43788. * @param ownerNode The mesh that will be scaled around once attached
  43789. */
  43790. attach(ownerNode: Mesh): void;
  43791. /**
  43792. * Detaches the behavior from the mesh
  43793. */
  43794. detach(): void;
  43795. }
  43796. }
  43797. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43798. import { Behavior } from "babylonjs/Behaviors/behavior";
  43799. import { Mesh } from "babylonjs/Meshes/mesh";
  43800. import { Observable } from "babylonjs/Misc/observable";
  43801. /**
  43802. * 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
  43803. */
  43804. export class SixDofDragBehavior implements Behavior<Mesh> {
  43805. private static _virtualScene;
  43806. private _ownerNode;
  43807. private _sceneRenderObserver;
  43808. private _scene;
  43809. private _targetPosition;
  43810. private _virtualOriginMesh;
  43811. private _virtualDragMesh;
  43812. private _pointerObserver;
  43813. private _moving;
  43814. private _startingOrientation;
  43815. private _attachedElement;
  43816. /**
  43817. * 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)
  43818. */
  43819. private zDragFactor;
  43820. /**
  43821. * If the object should rotate to face the drag origin
  43822. */
  43823. rotateDraggedObject: boolean;
  43824. /**
  43825. * If the behavior is currently in a dragging state
  43826. */
  43827. dragging: boolean;
  43828. /**
  43829. * 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)
  43830. */
  43831. dragDeltaRatio: number;
  43832. /**
  43833. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43834. */
  43835. currentDraggingPointerID: number;
  43836. /**
  43837. * If camera controls should be detached during the drag
  43838. */
  43839. detachCameraControls: boolean;
  43840. /**
  43841. * Fires each time a drag starts
  43842. */
  43843. onDragStartObservable: Observable<{}>;
  43844. /**
  43845. * Fires each time a drag ends (eg. mouse release after drag)
  43846. */
  43847. onDragEndObservable: Observable<{}>;
  43848. /**
  43849. * 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
  43850. */
  43851. constructor();
  43852. /**
  43853. * The name of the behavior
  43854. */
  43855. get name(): string;
  43856. /**
  43857. * Initializes the behavior
  43858. */
  43859. init(): void;
  43860. /**
  43861. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43862. */
  43863. private get _pointerCamera();
  43864. /**
  43865. * Attaches the scale behavior the passed in mesh
  43866. * @param ownerNode The mesh that will be scaled around once attached
  43867. */
  43868. attach(ownerNode: Mesh): void;
  43869. /**
  43870. * Detaches the behavior from the mesh
  43871. */
  43872. detach(): void;
  43873. }
  43874. }
  43875. declare module "babylonjs/Behaviors/Meshes/index" {
  43876. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  43877. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  43878. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  43879. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43880. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43881. }
  43882. declare module "babylonjs/Behaviors/index" {
  43883. export * from "babylonjs/Behaviors/behavior";
  43884. export * from "babylonjs/Behaviors/Cameras/index";
  43885. export * from "babylonjs/Behaviors/Meshes/index";
  43886. }
  43887. declare module "babylonjs/Bones/boneIKController" {
  43888. import { Bone } from "babylonjs/Bones/bone";
  43889. import { Vector3 } from "babylonjs/Maths/math.vector";
  43890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43891. import { Nullable } from "babylonjs/types";
  43892. /**
  43893. * Class used to apply inverse kinematics to bones
  43894. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43895. */
  43896. export class BoneIKController {
  43897. private static _tmpVecs;
  43898. private static _tmpQuat;
  43899. private static _tmpMats;
  43900. /**
  43901. * Gets or sets the target mesh
  43902. */
  43903. targetMesh: AbstractMesh;
  43904. /** Gets or sets the mesh used as pole */
  43905. poleTargetMesh: AbstractMesh;
  43906. /**
  43907. * Gets or sets the bone used as pole
  43908. */
  43909. poleTargetBone: Nullable<Bone>;
  43910. /**
  43911. * Gets or sets the target position
  43912. */
  43913. targetPosition: Vector3;
  43914. /**
  43915. * Gets or sets the pole target position
  43916. */
  43917. poleTargetPosition: Vector3;
  43918. /**
  43919. * Gets or sets the pole target local offset
  43920. */
  43921. poleTargetLocalOffset: Vector3;
  43922. /**
  43923. * Gets or sets the pole angle
  43924. */
  43925. poleAngle: number;
  43926. /**
  43927. * Gets or sets the mesh associated with the controller
  43928. */
  43929. mesh: AbstractMesh;
  43930. /**
  43931. * 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)
  43932. */
  43933. slerpAmount: number;
  43934. private _bone1Quat;
  43935. private _bone1Mat;
  43936. private _bone2Ang;
  43937. private _bone1;
  43938. private _bone2;
  43939. private _bone1Length;
  43940. private _bone2Length;
  43941. private _maxAngle;
  43942. private _maxReach;
  43943. private _rightHandedSystem;
  43944. private _bendAxis;
  43945. private _slerping;
  43946. private _adjustRoll;
  43947. /**
  43948. * Gets or sets maximum allowed angle
  43949. */
  43950. get maxAngle(): number;
  43951. set maxAngle(value: number);
  43952. /**
  43953. * Creates a new BoneIKController
  43954. * @param mesh defines the mesh to control
  43955. * @param bone defines the bone to control
  43956. * @param options defines options to set up the controller
  43957. */
  43958. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43959. targetMesh?: AbstractMesh;
  43960. poleTargetMesh?: AbstractMesh;
  43961. poleTargetBone?: Bone;
  43962. poleTargetLocalOffset?: Vector3;
  43963. poleAngle?: number;
  43964. bendAxis?: Vector3;
  43965. maxAngle?: number;
  43966. slerpAmount?: number;
  43967. });
  43968. private _setMaxAngle;
  43969. /**
  43970. * Force the controller to update the bones
  43971. */
  43972. update(): void;
  43973. }
  43974. }
  43975. declare module "babylonjs/Bones/boneLookController" {
  43976. import { Vector3 } from "babylonjs/Maths/math.vector";
  43977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43978. import { Bone } from "babylonjs/Bones/bone";
  43979. import { Space } from "babylonjs/Maths/math.axis";
  43980. /**
  43981. * Class used to make a bone look toward a point in space
  43982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43983. */
  43984. export class BoneLookController {
  43985. private static _tmpVecs;
  43986. private static _tmpQuat;
  43987. private static _tmpMats;
  43988. /**
  43989. * The target Vector3 that the bone will look at
  43990. */
  43991. target: Vector3;
  43992. /**
  43993. * The mesh that the bone is attached to
  43994. */
  43995. mesh: AbstractMesh;
  43996. /**
  43997. * The bone that will be looking to the target
  43998. */
  43999. bone: Bone;
  44000. /**
  44001. * The up axis of the coordinate system that is used when the bone is rotated
  44002. */
  44003. upAxis: Vector3;
  44004. /**
  44005. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44006. */
  44007. upAxisSpace: Space;
  44008. /**
  44009. * Used to make an adjustment to the yaw of the bone
  44010. */
  44011. adjustYaw: number;
  44012. /**
  44013. * Used to make an adjustment to the pitch of the bone
  44014. */
  44015. adjustPitch: number;
  44016. /**
  44017. * Used to make an adjustment to the roll of the bone
  44018. */
  44019. adjustRoll: number;
  44020. /**
  44021. * 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)
  44022. */
  44023. slerpAmount: number;
  44024. private _minYaw;
  44025. private _maxYaw;
  44026. private _minPitch;
  44027. private _maxPitch;
  44028. private _minYawSin;
  44029. private _minYawCos;
  44030. private _maxYawSin;
  44031. private _maxYawCos;
  44032. private _midYawConstraint;
  44033. private _minPitchTan;
  44034. private _maxPitchTan;
  44035. private _boneQuat;
  44036. private _slerping;
  44037. private _transformYawPitch;
  44038. private _transformYawPitchInv;
  44039. private _firstFrameSkipped;
  44040. private _yawRange;
  44041. private _fowardAxis;
  44042. /**
  44043. * Gets or sets the minimum yaw angle that the bone can look to
  44044. */
  44045. get minYaw(): number;
  44046. set minYaw(value: number);
  44047. /**
  44048. * Gets or sets the maximum yaw angle that the bone can look to
  44049. */
  44050. get maxYaw(): number;
  44051. set maxYaw(value: number);
  44052. /**
  44053. * Gets or sets the minimum pitch angle that the bone can look to
  44054. */
  44055. get minPitch(): number;
  44056. set minPitch(value: number);
  44057. /**
  44058. * Gets or sets the maximum pitch angle that the bone can look to
  44059. */
  44060. get maxPitch(): number;
  44061. set maxPitch(value: number);
  44062. /**
  44063. * Create a BoneLookController
  44064. * @param mesh the mesh that the bone belongs to
  44065. * @param bone the bone that will be looking to the target
  44066. * @param target the target Vector3 to look at
  44067. * @param options optional settings:
  44068. * * maxYaw: the maximum angle the bone will yaw to
  44069. * * minYaw: the minimum angle the bone will yaw to
  44070. * * maxPitch: the maximum angle the bone will pitch to
  44071. * * minPitch: the minimum angle the bone will yaw to
  44072. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44073. * * upAxis: the up axis of the coordinate system
  44074. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44075. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44076. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44077. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44078. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44079. * * adjustRoll: used to make an adjustment to the roll of the bone
  44080. **/
  44081. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44082. maxYaw?: number;
  44083. minYaw?: number;
  44084. maxPitch?: number;
  44085. minPitch?: number;
  44086. slerpAmount?: number;
  44087. upAxis?: Vector3;
  44088. upAxisSpace?: Space;
  44089. yawAxis?: Vector3;
  44090. pitchAxis?: Vector3;
  44091. adjustYaw?: number;
  44092. adjustPitch?: number;
  44093. adjustRoll?: number;
  44094. });
  44095. /**
  44096. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44097. */
  44098. update(): void;
  44099. private _getAngleDiff;
  44100. private _getAngleBetween;
  44101. private _isAngleBetween;
  44102. }
  44103. }
  44104. declare module "babylonjs/Bones/index" {
  44105. export * from "babylonjs/Bones/bone";
  44106. export * from "babylonjs/Bones/boneIKController";
  44107. export * from "babylonjs/Bones/boneLookController";
  44108. export * from "babylonjs/Bones/skeleton";
  44109. }
  44110. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44111. import { Nullable } from "babylonjs/types";
  44112. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44114. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44115. /**
  44116. * Manage the gamepad inputs to control an arc rotate camera.
  44117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44118. */
  44119. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44120. /**
  44121. * Defines the camera the input is attached to.
  44122. */
  44123. camera: ArcRotateCamera;
  44124. /**
  44125. * Defines the gamepad the input is gathering event from.
  44126. */
  44127. gamepad: Nullable<Gamepad>;
  44128. /**
  44129. * Defines the gamepad rotation sensiblity.
  44130. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44131. */
  44132. gamepadRotationSensibility: number;
  44133. /**
  44134. * Defines the gamepad move sensiblity.
  44135. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44136. */
  44137. gamepadMoveSensibility: number;
  44138. private _yAxisScale;
  44139. /**
  44140. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44141. */
  44142. get invertYAxis(): boolean;
  44143. set invertYAxis(value: boolean);
  44144. private _onGamepadConnectedObserver;
  44145. private _onGamepadDisconnectedObserver;
  44146. /**
  44147. * Attach the input controls to a specific dom element to get the input from.
  44148. * @param element Defines the element the controls should be listened from
  44149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44150. */
  44151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44152. /**
  44153. * Detach the current controls from the specified dom element.
  44154. * @param element Defines the element to stop listening the inputs from
  44155. */
  44156. detachControl(element: Nullable<HTMLElement>): void;
  44157. /**
  44158. * Update the current camera state depending on the inputs that have been used this frame.
  44159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44160. */
  44161. checkInputs(): void;
  44162. /**
  44163. * Gets the class name of the current intput.
  44164. * @returns the class name
  44165. */
  44166. getClassName(): string;
  44167. /**
  44168. * Get the friendly name associated with the input class.
  44169. * @returns the input friendly name
  44170. */
  44171. getSimpleName(): string;
  44172. }
  44173. }
  44174. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44175. import { Nullable } from "babylonjs/types";
  44176. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44177. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44178. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44179. interface ArcRotateCameraInputsManager {
  44180. /**
  44181. * Add orientation input support to the input manager.
  44182. * @returns the current input manager
  44183. */
  44184. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44185. }
  44186. }
  44187. /**
  44188. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44190. */
  44191. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44192. /**
  44193. * Defines the camera the input is attached to.
  44194. */
  44195. camera: ArcRotateCamera;
  44196. /**
  44197. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44198. */
  44199. alphaCorrection: number;
  44200. /**
  44201. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44202. */
  44203. gammaCorrection: number;
  44204. private _alpha;
  44205. private _gamma;
  44206. private _dirty;
  44207. private _deviceOrientationHandler;
  44208. /**
  44209. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44210. */
  44211. constructor();
  44212. /**
  44213. * Attach the input controls to a specific dom element to get the input from.
  44214. * @param element Defines the element the controls should be listened from
  44215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44216. */
  44217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44218. /** @hidden */
  44219. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44220. /**
  44221. * Update the current camera state depending on the inputs that have been used this frame.
  44222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44223. */
  44224. checkInputs(): void;
  44225. /**
  44226. * Detach the current controls from the specified dom element.
  44227. * @param element Defines the element to stop listening the inputs from
  44228. */
  44229. detachControl(element: Nullable<HTMLElement>): void;
  44230. /**
  44231. * Gets the class name of the current intput.
  44232. * @returns the class name
  44233. */
  44234. getClassName(): string;
  44235. /**
  44236. * Get the friendly name associated with the input class.
  44237. * @returns the input friendly name
  44238. */
  44239. getSimpleName(): string;
  44240. }
  44241. }
  44242. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44243. import { Nullable } from "babylonjs/types";
  44244. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44245. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44246. /**
  44247. * Listen to mouse events to control the camera.
  44248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44249. */
  44250. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44251. /**
  44252. * Defines the camera the input is attached to.
  44253. */
  44254. camera: FlyCamera;
  44255. /**
  44256. * Defines if touch is enabled. (Default is true.)
  44257. */
  44258. touchEnabled: boolean;
  44259. /**
  44260. * Defines the buttons associated with the input to handle camera rotation.
  44261. */
  44262. buttons: number[];
  44263. /**
  44264. * Assign buttons for Yaw control.
  44265. */
  44266. buttonsYaw: number[];
  44267. /**
  44268. * Assign buttons for Pitch control.
  44269. */
  44270. buttonsPitch: number[];
  44271. /**
  44272. * Assign buttons for Roll control.
  44273. */
  44274. buttonsRoll: number[];
  44275. /**
  44276. * Detect if any button is being pressed while mouse is moved.
  44277. * -1 = Mouse locked.
  44278. * 0 = Left button.
  44279. * 1 = Middle Button.
  44280. * 2 = Right Button.
  44281. */
  44282. activeButton: number;
  44283. /**
  44284. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44285. * Higher values reduce its sensitivity.
  44286. */
  44287. angularSensibility: number;
  44288. private _mousemoveCallback;
  44289. private _observer;
  44290. private _rollObserver;
  44291. private previousPosition;
  44292. private noPreventDefault;
  44293. private element;
  44294. /**
  44295. * Listen to mouse events to control the camera.
  44296. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44298. */
  44299. constructor(touchEnabled?: boolean);
  44300. /**
  44301. * Attach the mouse control to the HTML DOM element.
  44302. * @param element Defines the element that listens to the input events.
  44303. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44304. */
  44305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44306. /**
  44307. * Detach the current controls from the specified dom element.
  44308. * @param element Defines the element to stop listening the inputs from
  44309. */
  44310. detachControl(element: Nullable<HTMLElement>): void;
  44311. /**
  44312. * Gets the class name of the current input.
  44313. * @returns the class name.
  44314. */
  44315. getClassName(): string;
  44316. /**
  44317. * Get the friendly name associated with the input class.
  44318. * @returns the input's friendly name.
  44319. */
  44320. getSimpleName(): string;
  44321. private _pointerInput;
  44322. private _onMouseMove;
  44323. /**
  44324. * Rotate camera by mouse offset.
  44325. */
  44326. private rotateCamera;
  44327. }
  44328. }
  44329. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44330. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44331. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44332. /**
  44333. * Default Inputs manager for the FlyCamera.
  44334. * It groups all the default supported inputs for ease of use.
  44335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44336. */
  44337. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44338. /**
  44339. * Instantiates a new FlyCameraInputsManager.
  44340. * @param camera Defines the camera the inputs belong to.
  44341. */
  44342. constructor(camera: FlyCamera);
  44343. /**
  44344. * Add keyboard input support to the input manager.
  44345. * @returns the new FlyCameraKeyboardMoveInput().
  44346. */
  44347. addKeyboard(): FlyCameraInputsManager;
  44348. /**
  44349. * Add mouse input support to the input manager.
  44350. * @param touchEnabled Enable touch screen support.
  44351. * @returns the new FlyCameraMouseInput().
  44352. */
  44353. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44354. }
  44355. }
  44356. declare module "babylonjs/Cameras/flyCamera" {
  44357. import { Scene } from "babylonjs/scene";
  44358. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44360. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44361. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44362. /**
  44363. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44364. * such as in a 3D Space Shooter or a Flight Simulator.
  44365. */
  44366. export class FlyCamera extends TargetCamera {
  44367. /**
  44368. * Define the collision ellipsoid of the camera.
  44369. * This is helpful for simulating a camera body, like a player's body.
  44370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44371. */
  44372. ellipsoid: Vector3;
  44373. /**
  44374. * Define an offset for the position of the ellipsoid around the camera.
  44375. * This can be helpful if the camera is attached away from the player's body center,
  44376. * such as at its head.
  44377. */
  44378. ellipsoidOffset: Vector3;
  44379. /**
  44380. * Enable or disable collisions of the camera with the rest of the scene objects.
  44381. */
  44382. checkCollisions: boolean;
  44383. /**
  44384. * Enable or disable gravity on the camera.
  44385. */
  44386. applyGravity: boolean;
  44387. /**
  44388. * Define the current direction the camera is moving to.
  44389. */
  44390. cameraDirection: Vector3;
  44391. /**
  44392. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44393. * This overrides and empties cameraRotation.
  44394. */
  44395. rotationQuaternion: Quaternion;
  44396. /**
  44397. * Track Roll to maintain the wanted Rolling when looking around.
  44398. */
  44399. _trackRoll: number;
  44400. /**
  44401. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44402. */
  44403. rollCorrect: number;
  44404. /**
  44405. * Mimic a banked turn, Rolling the camera when Yawing.
  44406. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44407. */
  44408. bankedTurn: boolean;
  44409. /**
  44410. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44411. */
  44412. bankedTurnLimit: number;
  44413. /**
  44414. * Value of 0 disables the banked Roll.
  44415. * Value of 1 is equal to the Yaw angle in radians.
  44416. */
  44417. bankedTurnMultiplier: number;
  44418. /**
  44419. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44420. */
  44421. inputs: FlyCameraInputsManager;
  44422. /**
  44423. * Gets the input sensibility for mouse input.
  44424. * Higher values reduce sensitivity.
  44425. */
  44426. get angularSensibility(): number;
  44427. /**
  44428. * Sets the input sensibility for a mouse input.
  44429. * Higher values reduce sensitivity.
  44430. */
  44431. set angularSensibility(value: number);
  44432. /**
  44433. * Get the keys for camera movement forward.
  44434. */
  44435. get keysForward(): number[];
  44436. /**
  44437. * Set the keys for camera movement forward.
  44438. */
  44439. set keysForward(value: number[]);
  44440. /**
  44441. * Get the keys for camera movement backward.
  44442. */
  44443. get keysBackward(): number[];
  44444. set keysBackward(value: number[]);
  44445. /**
  44446. * Get the keys for camera movement up.
  44447. */
  44448. get keysUp(): number[];
  44449. /**
  44450. * Set the keys for camera movement up.
  44451. */
  44452. set keysUp(value: number[]);
  44453. /**
  44454. * Get the keys for camera movement down.
  44455. */
  44456. get keysDown(): number[];
  44457. /**
  44458. * Set the keys for camera movement down.
  44459. */
  44460. set keysDown(value: number[]);
  44461. /**
  44462. * Get the keys for camera movement left.
  44463. */
  44464. get keysLeft(): number[];
  44465. /**
  44466. * Set the keys for camera movement left.
  44467. */
  44468. set keysLeft(value: number[]);
  44469. /**
  44470. * Set the keys for camera movement right.
  44471. */
  44472. get keysRight(): number[];
  44473. /**
  44474. * Set the keys for camera movement right.
  44475. */
  44476. set keysRight(value: number[]);
  44477. /**
  44478. * Event raised when the camera collides with a mesh in the scene.
  44479. */
  44480. onCollide: (collidedMesh: AbstractMesh) => void;
  44481. private _collider;
  44482. private _needMoveForGravity;
  44483. private _oldPosition;
  44484. private _diffPosition;
  44485. private _newPosition;
  44486. /** @hidden */
  44487. _localDirection: Vector3;
  44488. /** @hidden */
  44489. _transformedDirection: Vector3;
  44490. /**
  44491. * Instantiates a FlyCamera.
  44492. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44493. * such as in a 3D Space Shooter or a Flight Simulator.
  44494. * @param name Define the name of the camera in the scene.
  44495. * @param position Define the starting position of the camera in the scene.
  44496. * @param scene Define the scene the camera belongs to.
  44497. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44498. */
  44499. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44500. /**
  44501. * Attach a control to the HTML DOM element.
  44502. * @param element Defines the element that listens to the input events.
  44503. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44504. */
  44505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44506. /**
  44507. * Detach a control from the HTML DOM element.
  44508. * The camera will stop reacting to that input.
  44509. * @param element Defines the element that listens to the input events.
  44510. */
  44511. detachControl(element: HTMLElement): void;
  44512. private _collisionMask;
  44513. /**
  44514. * Get the mask that the camera ignores in collision events.
  44515. */
  44516. get collisionMask(): number;
  44517. /**
  44518. * Set the mask that the camera ignores in collision events.
  44519. */
  44520. set collisionMask(mask: number);
  44521. /** @hidden */
  44522. _collideWithWorld(displacement: Vector3): void;
  44523. /** @hidden */
  44524. private _onCollisionPositionChange;
  44525. /** @hidden */
  44526. _checkInputs(): void;
  44527. /** @hidden */
  44528. _decideIfNeedsToMove(): boolean;
  44529. /** @hidden */
  44530. _updatePosition(): void;
  44531. /**
  44532. * Restore the Roll to its target value at the rate specified.
  44533. * @param rate - Higher means slower restoring.
  44534. * @hidden
  44535. */
  44536. restoreRoll(rate: number): void;
  44537. /**
  44538. * Destroy the camera and release the current resources held by it.
  44539. */
  44540. dispose(): void;
  44541. /**
  44542. * Get the current object class name.
  44543. * @returns the class name.
  44544. */
  44545. getClassName(): string;
  44546. }
  44547. }
  44548. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44549. import { Nullable } from "babylonjs/types";
  44550. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44551. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44552. /**
  44553. * Listen to keyboard events to control the camera.
  44554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44555. */
  44556. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44557. /**
  44558. * Defines the camera the input is attached to.
  44559. */
  44560. camera: FlyCamera;
  44561. /**
  44562. * The list of keyboard keys used to control the forward move of the camera.
  44563. */
  44564. keysForward: number[];
  44565. /**
  44566. * The list of keyboard keys used to control the backward move of the camera.
  44567. */
  44568. keysBackward: number[];
  44569. /**
  44570. * The list of keyboard keys used to control the forward move of the camera.
  44571. */
  44572. keysUp: number[];
  44573. /**
  44574. * The list of keyboard keys used to control the backward move of the camera.
  44575. */
  44576. keysDown: number[];
  44577. /**
  44578. * The list of keyboard keys used to control the right strafe move of the camera.
  44579. */
  44580. keysRight: number[];
  44581. /**
  44582. * The list of keyboard keys used to control the left strafe move of the camera.
  44583. */
  44584. keysLeft: number[];
  44585. private _keys;
  44586. private _onCanvasBlurObserver;
  44587. private _onKeyboardObserver;
  44588. private _engine;
  44589. private _scene;
  44590. /**
  44591. * Attach the input controls to a specific dom element to get the input from.
  44592. * @param element Defines the element the controls should be listened from
  44593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44594. */
  44595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44596. /**
  44597. * Detach the current controls from the specified dom element.
  44598. * @param element Defines the element to stop listening the inputs from
  44599. */
  44600. detachControl(element: Nullable<HTMLElement>): void;
  44601. /**
  44602. * Gets the class name of the current intput.
  44603. * @returns the class name
  44604. */
  44605. getClassName(): string;
  44606. /** @hidden */
  44607. _onLostFocus(e: FocusEvent): void;
  44608. /**
  44609. * Get the friendly name associated with the input class.
  44610. * @returns the input friendly name
  44611. */
  44612. getSimpleName(): string;
  44613. /**
  44614. * Update the current camera state depending on the inputs that have been used this frame.
  44615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44616. */
  44617. checkInputs(): void;
  44618. }
  44619. }
  44620. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44621. import { Nullable } from "babylonjs/types";
  44622. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44624. /**
  44625. * Manage the mouse wheel inputs to control a follow camera.
  44626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44627. */
  44628. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44629. /**
  44630. * Defines the camera the input is attached to.
  44631. */
  44632. camera: FollowCamera;
  44633. /**
  44634. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44635. */
  44636. axisControlRadius: boolean;
  44637. /**
  44638. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44639. */
  44640. axisControlHeight: boolean;
  44641. /**
  44642. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44643. */
  44644. axisControlRotation: boolean;
  44645. /**
  44646. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44647. * relation to mouseWheel events.
  44648. */
  44649. wheelPrecision: number;
  44650. /**
  44651. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44652. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44653. */
  44654. wheelDeltaPercentage: number;
  44655. private _wheel;
  44656. private _observer;
  44657. /**
  44658. * Attach the input controls to a specific dom element to get the input from.
  44659. * @param element Defines the element the controls should be listened from
  44660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44661. */
  44662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44663. /**
  44664. * Detach the current controls from the specified dom element.
  44665. * @param element Defines the element to stop listening the inputs from
  44666. */
  44667. detachControl(element: Nullable<HTMLElement>): void;
  44668. /**
  44669. * Gets the class name of the current intput.
  44670. * @returns the class name
  44671. */
  44672. getClassName(): string;
  44673. /**
  44674. * Get the friendly name associated with the input class.
  44675. * @returns the input friendly name
  44676. */
  44677. getSimpleName(): string;
  44678. }
  44679. }
  44680. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44681. import { Nullable } from "babylonjs/types";
  44682. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44683. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44684. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44685. /**
  44686. * Manage the pointers inputs to control an follow camera.
  44687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44688. */
  44689. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44690. /**
  44691. * Defines the camera the input is attached to.
  44692. */
  44693. camera: FollowCamera;
  44694. /**
  44695. * Gets the class name of the current input.
  44696. * @returns the class name
  44697. */
  44698. getClassName(): string;
  44699. /**
  44700. * Defines the pointer angular sensibility along the X axis or how fast is
  44701. * the camera rotating.
  44702. * A negative number will reverse the axis direction.
  44703. */
  44704. angularSensibilityX: number;
  44705. /**
  44706. * Defines the pointer angular sensibility along the Y axis or how fast is
  44707. * the camera rotating.
  44708. * A negative number will reverse the axis direction.
  44709. */
  44710. angularSensibilityY: number;
  44711. /**
  44712. * Defines the pointer pinch precision or how fast is the camera zooming.
  44713. * A negative number will reverse the axis direction.
  44714. */
  44715. pinchPrecision: number;
  44716. /**
  44717. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44718. * from 0.
  44719. * It defines the percentage of current camera.radius to use as delta when
  44720. * pinch zoom is used.
  44721. */
  44722. pinchDeltaPercentage: number;
  44723. /**
  44724. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44725. */
  44726. axisXControlRadius: boolean;
  44727. /**
  44728. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44729. */
  44730. axisXControlHeight: boolean;
  44731. /**
  44732. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44733. */
  44734. axisXControlRotation: boolean;
  44735. /**
  44736. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44737. */
  44738. axisYControlRadius: boolean;
  44739. /**
  44740. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44741. */
  44742. axisYControlHeight: boolean;
  44743. /**
  44744. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44745. */
  44746. axisYControlRotation: boolean;
  44747. /**
  44748. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44749. */
  44750. axisPinchControlRadius: boolean;
  44751. /**
  44752. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44753. */
  44754. axisPinchControlHeight: boolean;
  44755. /**
  44756. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44757. */
  44758. axisPinchControlRotation: boolean;
  44759. /**
  44760. * Log error messages if basic misconfiguration has occurred.
  44761. */
  44762. warningEnable: boolean;
  44763. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44764. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44765. private _warningCounter;
  44766. private _warning;
  44767. }
  44768. }
  44769. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44770. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44771. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44772. /**
  44773. * Default Inputs manager for the FollowCamera.
  44774. * It groups all the default supported inputs for ease of use.
  44775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44776. */
  44777. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44778. /**
  44779. * Instantiates a new FollowCameraInputsManager.
  44780. * @param camera Defines the camera the inputs belong to
  44781. */
  44782. constructor(camera: FollowCamera);
  44783. /**
  44784. * Add keyboard input support to the input manager.
  44785. * @returns the current input manager
  44786. */
  44787. addKeyboard(): FollowCameraInputsManager;
  44788. /**
  44789. * Add mouse wheel input support to the input manager.
  44790. * @returns the current input manager
  44791. */
  44792. addMouseWheel(): FollowCameraInputsManager;
  44793. /**
  44794. * Add pointers input support to the input manager.
  44795. * @returns the current input manager
  44796. */
  44797. addPointers(): FollowCameraInputsManager;
  44798. /**
  44799. * Add orientation input support to the input manager.
  44800. * @returns the current input manager
  44801. */
  44802. addVRDeviceOrientation(): FollowCameraInputsManager;
  44803. }
  44804. }
  44805. declare module "babylonjs/Cameras/followCamera" {
  44806. import { Nullable } from "babylonjs/types";
  44807. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44808. import { Scene } from "babylonjs/scene";
  44809. import { Vector3 } from "babylonjs/Maths/math.vector";
  44810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44811. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44812. /**
  44813. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44814. * an arc rotate version arcFollowCamera are available.
  44815. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44816. */
  44817. export class FollowCamera extends TargetCamera {
  44818. /**
  44819. * Distance the follow camera should follow an object at
  44820. */
  44821. radius: number;
  44822. /**
  44823. * Minimum allowed distance of the camera to the axis of rotation
  44824. * (The camera can not get closer).
  44825. * This can help limiting how the Camera is able to move in the scene.
  44826. */
  44827. lowerRadiusLimit: Nullable<number>;
  44828. /**
  44829. * Maximum allowed distance of the camera to the axis of rotation
  44830. * (The camera can not get further).
  44831. * This can help limiting how the Camera is able to move in the scene.
  44832. */
  44833. upperRadiusLimit: Nullable<number>;
  44834. /**
  44835. * Define a rotation offset between the camera and the object it follows
  44836. */
  44837. rotationOffset: number;
  44838. /**
  44839. * Minimum allowed angle to camera position relative to target object.
  44840. * This can help limiting how the Camera is able to move in the scene.
  44841. */
  44842. lowerRotationOffsetLimit: Nullable<number>;
  44843. /**
  44844. * Maximum allowed angle to camera position relative to target object.
  44845. * This can help limiting how the Camera is able to move in the scene.
  44846. */
  44847. upperRotationOffsetLimit: Nullable<number>;
  44848. /**
  44849. * Define a height offset between the camera and the object it follows.
  44850. * It can help following an object from the top (like a car chaing a plane)
  44851. */
  44852. heightOffset: number;
  44853. /**
  44854. * Minimum allowed height of camera position relative to target object.
  44855. * This can help limiting how the Camera is able to move in the scene.
  44856. */
  44857. lowerHeightOffsetLimit: Nullable<number>;
  44858. /**
  44859. * Maximum allowed height of camera position relative to target object.
  44860. * This can help limiting how the Camera is able to move in the scene.
  44861. */
  44862. upperHeightOffsetLimit: Nullable<number>;
  44863. /**
  44864. * Define how fast the camera can accelerate to follow it s target.
  44865. */
  44866. cameraAcceleration: number;
  44867. /**
  44868. * Define the speed limit of the camera following an object.
  44869. */
  44870. maxCameraSpeed: number;
  44871. /**
  44872. * Define the target of the camera.
  44873. */
  44874. lockedTarget: Nullable<AbstractMesh>;
  44875. /**
  44876. * Defines the input associated with the camera.
  44877. */
  44878. inputs: FollowCameraInputsManager;
  44879. /**
  44880. * Instantiates the follow camera.
  44881. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44882. * @param name Define the name of the camera in the scene
  44883. * @param position Define the position of the camera
  44884. * @param scene Define the scene the camera belong to
  44885. * @param lockedTarget Define the target of the camera
  44886. */
  44887. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44888. private _follow;
  44889. /**
  44890. * Attached controls to the current camera.
  44891. * @param element Defines the element the controls should be listened from
  44892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44893. */
  44894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44895. /**
  44896. * Detach the current controls from the camera.
  44897. * The camera will stop reacting to inputs.
  44898. * @param element Defines the element to stop listening the inputs from
  44899. */
  44900. detachControl(element: HTMLElement): void;
  44901. /** @hidden */
  44902. _checkInputs(): void;
  44903. private _checkLimits;
  44904. /**
  44905. * Gets the camera class name.
  44906. * @returns the class name
  44907. */
  44908. getClassName(): string;
  44909. }
  44910. /**
  44911. * Arc Rotate version of the follow camera.
  44912. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44913. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44914. */
  44915. export class ArcFollowCamera extends TargetCamera {
  44916. /** The longitudinal angle of the camera */
  44917. alpha: number;
  44918. /** The latitudinal angle of the camera */
  44919. beta: number;
  44920. /** The radius of the camera from its target */
  44921. radius: number;
  44922. /** Define the camera target (the messh it should follow) */
  44923. target: Nullable<AbstractMesh>;
  44924. private _cartesianCoordinates;
  44925. /**
  44926. * Instantiates a new ArcFollowCamera
  44927. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44928. * @param name Define the name of the camera
  44929. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44930. * @param beta Define the rotation angle of the camera around the elevation axis
  44931. * @param radius Define the radius of the camera from its target point
  44932. * @param target Define the target of the camera
  44933. * @param scene Define the scene the camera belongs to
  44934. */
  44935. constructor(name: string,
  44936. /** The longitudinal angle of the camera */
  44937. alpha: number,
  44938. /** The latitudinal angle of the camera */
  44939. beta: number,
  44940. /** The radius of the camera from its target */
  44941. radius: number,
  44942. /** Define the camera target (the messh it should follow) */
  44943. target: Nullable<AbstractMesh>, scene: Scene);
  44944. private _follow;
  44945. /** @hidden */
  44946. _checkInputs(): void;
  44947. /**
  44948. * Returns the class name of the object.
  44949. * It is mostly used internally for serialization purposes.
  44950. */
  44951. getClassName(): string;
  44952. }
  44953. }
  44954. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  44955. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44956. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44957. import { Nullable } from "babylonjs/types";
  44958. /**
  44959. * Manage the keyboard inputs to control the movement of a follow camera.
  44960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44961. */
  44962. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44963. /**
  44964. * Defines the camera the input is attached to.
  44965. */
  44966. camera: FollowCamera;
  44967. /**
  44968. * Defines the list of key codes associated with the up action (increase heightOffset)
  44969. */
  44970. keysHeightOffsetIncr: number[];
  44971. /**
  44972. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44973. */
  44974. keysHeightOffsetDecr: number[];
  44975. /**
  44976. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44977. */
  44978. keysHeightOffsetModifierAlt: boolean;
  44979. /**
  44980. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44981. */
  44982. keysHeightOffsetModifierCtrl: boolean;
  44983. /**
  44984. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44985. */
  44986. keysHeightOffsetModifierShift: boolean;
  44987. /**
  44988. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44989. */
  44990. keysRotationOffsetIncr: number[];
  44991. /**
  44992. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44993. */
  44994. keysRotationOffsetDecr: number[];
  44995. /**
  44996. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44997. */
  44998. keysRotationOffsetModifierAlt: boolean;
  44999. /**
  45000. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45001. */
  45002. keysRotationOffsetModifierCtrl: boolean;
  45003. /**
  45004. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45005. */
  45006. keysRotationOffsetModifierShift: boolean;
  45007. /**
  45008. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45009. */
  45010. keysRadiusIncr: number[];
  45011. /**
  45012. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45013. */
  45014. keysRadiusDecr: number[];
  45015. /**
  45016. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45017. */
  45018. keysRadiusModifierAlt: boolean;
  45019. /**
  45020. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45021. */
  45022. keysRadiusModifierCtrl: boolean;
  45023. /**
  45024. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45025. */
  45026. keysRadiusModifierShift: boolean;
  45027. /**
  45028. * Defines the rate of change of heightOffset.
  45029. */
  45030. heightSensibility: number;
  45031. /**
  45032. * Defines the rate of change of rotationOffset.
  45033. */
  45034. rotationSensibility: number;
  45035. /**
  45036. * Defines the rate of change of radius.
  45037. */
  45038. radiusSensibility: number;
  45039. private _keys;
  45040. private _ctrlPressed;
  45041. private _altPressed;
  45042. private _shiftPressed;
  45043. private _onCanvasBlurObserver;
  45044. private _onKeyboardObserver;
  45045. private _engine;
  45046. private _scene;
  45047. /**
  45048. * Attach the input controls to a specific dom element to get the input from.
  45049. * @param element Defines the element the controls should be listened from
  45050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45051. */
  45052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45053. /**
  45054. * Detach the current controls from the specified dom element.
  45055. * @param element Defines the element to stop listening the inputs from
  45056. */
  45057. detachControl(element: Nullable<HTMLElement>): void;
  45058. /**
  45059. * Update the current camera state depending on the inputs that have been used this frame.
  45060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45061. */
  45062. checkInputs(): void;
  45063. /**
  45064. * Gets the class name of the current input.
  45065. * @returns the class name
  45066. */
  45067. getClassName(): string;
  45068. /**
  45069. * Get the friendly name associated with the input class.
  45070. * @returns the input friendly name
  45071. */
  45072. getSimpleName(): string;
  45073. /**
  45074. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45075. * allow modification of the heightOffset value.
  45076. */
  45077. private _modifierHeightOffset;
  45078. /**
  45079. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45080. * allow modification of the rotationOffset value.
  45081. */
  45082. private _modifierRotationOffset;
  45083. /**
  45084. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45085. * allow modification of the radius value.
  45086. */
  45087. private _modifierRadius;
  45088. }
  45089. }
  45090. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45091. import { Nullable } from "babylonjs/types";
  45092. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45093. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45094. import { Observable } from "babylonjs/Misc/observable";
  45095. module "babylonjs/Cameras/freeCameraInputsManager" {
  45096. interface FreeCameraInputsManager {
  45097. /**
  45098. * @hidden
  45099. */
  45100. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45101. /**
  45102. * Add orientation input support to the input manager.
  45103. * @returns the current input manager
  45104. */
  45105. addDeviceOrientation(): FreeCameraInputsManager;
  45106. }
  45107. }
  45108. /**
  45109. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45110. * Screen rotation is taken into account.
  45111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45112. */
  45113. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45114. private _camera;
  45115. private _screenOrientationAngle;
  45116. private _constantTranform;
  45117. private _screenQuaternion;
  45118. private _alpha;
  45119. private _beta;
  45120. private _gamma;
  45121. /**
  45122. * Can be used to detect if a device orientation sensor is available on a device
  45123. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45124. * @returns a promise that will resolve on orientation change
  45125. */
  45126. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45127. /**
  45128. * @hidden
  45129. */
  45130. _onDeviceOrientationChangedObservable: Observable<void>;
  45131. /**
  45132. * Instantiates a new input
  45133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45134. */
  45135. constructor();
  45136. /**
  45137. * Define the camera controlled by the input.
  45138. */
  45139. get camera(): FreeCamera;
  45140. set camera(camera: FreeCamera);
  45141. /**
  45142. * Attach the input controls to a specific dom element to get the input from.
  45143. * @param element Defines the element the controls should be listened from
  45144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45145. */
  45146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45147. private _orientationChanged;
  45148. private _deviceOrientation;
  45149. /**
  45150. * Detach the current controls from the specified dom element.
  45151. * @param element Defines the element to stop listening the inputs from
  45152. */
  45153. detachControl(element: Nullable<HTMLElement>): void;
  45154. /**
  45155. * Update the current camera state depending on the inputs that have been used this frame.
  45156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45157. */
  45158. checkInputs(): void;
  45159. /**
  45160. * Gets the class name of the current intput.
  45161. * @returns the class name
  45162. */
  45163. getClassName(): string;
  45164. /**
  45165. * Get the friendly name associated with the input class.
  45166. * @returns the input friendly name
  45167. */
  45168. getSimpleName(): string;
  45169. }
  45170. }
  45171. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45172. import { Nullable } from "babylonjs/types";
  45173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45174. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45175. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45176. /**
  45177. * Manage the gamepad inputs to control a free camera.
  45178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45179. */
  45180. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45181. /**
  45182. * Define the camera the input is attached to.
  45183. */
  45184. camera: FreeCamera;
  45185. /**
  45186. * Define the Gamepad controlling the input
  45187. */
  45188. gamepad: Nullable<Gamepad>;
  45189. /**
  45190. * Defines the gamepad rotation sensiblity.
  45191. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45192. */
  45193. gamepadAngularSensibility: number;
  45194. /**
  45195. * Defines the gamepad move sensiblity.
  45196. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45197. */
  45198. gamepadMoveSensibility: number;
  45199. private _yAxisScale;
  45200. /**
  45201. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45202. */
  45203. get invertYAxis(): boolean;
  45204. set invertYAxis(value: boolean);
  45205. private _onGamepadConnectedObserver;
  45206. private _onGamepadDisconnectedObserver;
  45207. private _cameraTransform;
  45208. private _deltaTransform;
  45209. private _vector3;
  45210. private _vector2;
  45211. /**
  45212. * Attach the input controls to a specific dom element to get the input from.
  45213. * @param element Defines the element the controls should be listened from
  45214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45215. */
  45216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45217. /**
  45218. * Detach the current controls from the specified dom element.
  45219. * @param element Defines the element to stop listening the inputs from
  45220. */
  45221. detachControl(element: Nullable<HTMLElement>): void;
  45222. /**
  45223. * Update the current camera state depending on the inputs that have been used this frame.
  45224. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45225. */
  45226. checkInputs(): void;
  45227. /**
  45228. * Gets the class name of the current intput.
  45229. * @returns the class name
  45230. */
  45231. getClassName(): string;
  45232. /**
  45233. * Get the friendly name associated with the input class.
  45234. * @returns the input friendly name
  45235. */
  45236. getSimpleName(): string;
  45237. }
  45238. }
  45239. declare module "babylonjs/Misc/virtualJoystick" {
  45240. import { Nullable } from "babylonjs/types";
  45241. import { Vector3 } from "babylonjs/Maths/math.vector";
  45242. /**
  45243. * Defines the potential axis of a Joystick
  45244. */
  45245. export enum JoystickAxis {
  45246. /** X axis */
  45247. X = 0,
  45248. /** Y axis */
  45249. Y = 1,
  45250. /** Z axis */
  45251. Z = 2
  45252. }
  45253. /**
  45254. * Class used to define virtual joystick (used in touch mode)
  45255. */
  45256. export class VirtualJoystick {
  45257. /**
  45258. * Gets or sets a boolean indicating that left and right values must be inverted
  45259. */
  45260. reverseLeftRight: boolean;
  45261. /**
  45262. * Gets or sets a boolean indicating that up and down values must be inverted
  45263. */
  45264. reverseUpDown: boolean;
  45265. /**
  45266. * Gets the offset value for the position (ie. the change of the position value)
  45267. */
  45268. deltaPosition: Vector3;
  45269. /**
  45270. * Gets a boolean indicating if the virtual joystick was pressed
  45271. */
  45272. pressed: boolean;
  45273. /**
  45274. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45275. */
  45276. static Canvas: Nullable<HTMLCanvasElement>;
  45277. private static _globalJoystickIndex;
  45278. private static vjCanvasContext;
  45279. private static vjCanvasWidth;
  45280. private static vjCanvasHeight;
  45281. private static halfWidth;
  45282. private _action;
  45283. private _axisTargetedByLeftAndRight;
  45284. private _axisTargetedByUpAndDown;
  45285. private _joystickSensibility;
  45286. private _inversedSensibility;
  45287. private _joystickPointerID;
  45288. private _joystickColor;
  45289. private _joystickPointerPos;
  45290. private _joystickPreviousPointerPos;
  45291. private _joystickPointerStartPos;
  45292. private _deltaJoystickVector;
  45293. private _leftJoystick;
  45294. private _touches;
  45295. private _onPointerDownHandlerRef;
  45296. private _onPointerMoveHandlerRef;
  45297. private _onPointerUpHandlerRef;
  45298. private _onResize;
  45299. /**
  45300. * Creates a new virtual joystick
  45301. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45302. */
  45303. constructor(leftJoystick?: boolean);
  45304. /**
  45305. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45306. * @param newJoystickSensibility defines the new sensibility
  45307. */
  45308. setJoystickSensibility(newJoystickSensibility: number): void;
  45309. private _onPointerDown;
  45310. private _onPointerMove;
  45311. private _onPointerUp;
  45312. /**
  45313. * Change the color of the virtual joystick
  45314. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45315. */
  45316. setJoystickColor(newColor: string): void;
  45317. /**
  45318. * Defines a callback to call when the joystick is touched
  45319. * @param action defines the callback
  45320. */
  45321. setActionOnTouch(action: () => any): void;
  45322. /**
  45323. * Defines which axis you'd like to control for left & right
  45324. * @param axis defines the axis to use
  45325. */
  45326. setAxisForLeftRight(axis: JoystickAxis): void;
  45327. /**
  45328. * Defines which axis you'd like to control for up & down
  45329. * @param axis defines the axis to use
  45330. */
  45331. setAxisForUpDown(axis: JoystickAxis): void;
  45332. private _drawVirtualJoystick;
  45333. /**
  45334. * Release internal HTML canvas
  45335. */
  45336. releaseCanvas(): void;
  45337. }
  45338. }
  45339. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45340. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45341. import { Nullable } from "babylonjs/types";
  45342. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45343. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45344. module "babylonjs/Cameras/freeCameraInputsManager" {
  45345. interface FreeCameraInputsManager {
  45346. /**
  45347. * Add virtual joystick input support to the input manager.
  45348. * @returns the current input manager
  45349. */
  45350. addVirtualJoystick(): FreeCameraInputsManager;
  45351. }
  45352. }
  45353. /**
  45354. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45356. */
  45357. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45358. /**
  45359. * Defines the camera the input is attached to.
  45360. */
  45361. camera: FreeCamera;
  45362. private _leftjoystick;
  45363. private _rightjoystick;
  45364. /**
  45365. * Gets the left stick of the virtual joystick.
  45366. * @returns The virtual Joystick
  45367. */
  45368. getLeftJoystick(): VirtualJoystick;
  45369. /**
  45370. * Gets the right stick of the virtual joystick.
  45371. * @returns The virtual Joystick
  45372. */
  45373. getRightJoystick(): VirtualJoystick;
  45374. /**
  45375. * Update the current camera state depending on the inputs that have been used this frame.
  45376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45377. */
  45378. checkInputs(): void;
  45379. /**
  45380. * Attach the input controls to a specific dom element to get the input from.
  45381. * @param element Defines the element the controls should be listened from
  45382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45383. */
  45384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45385. /**
  45386. * Detach the current controls from the specified dom element.
  45387. * @param element Defines the element to stop listening the inputs from
  45388. */
  45389. detachControl(element: Nullable<HTMLElement>): void;
  45390. /**
  45391. * Gets the class name of the current intput.
  45392. * @returns the class name
  45393. */
  45394. getClassName(): string;
  45395. /**
  45396. * Get the friendly name associated with the input class.
  45397. * @returns the input friendly name
  45398. */
  45399. getSimpleName(): string;
  45400. }
  45401. }
  45402. declare module "babylonjs/Cameras/Inputs/index" {
  45403. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45404. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45405. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45406. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45407. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45408. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45409. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45410. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45411. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45412. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45413. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45414. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45415. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45416. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45417. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45418. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45419. }
  45420. declare module "babylonjs/Cameras/touchCamera" {
  45421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45422. import { Scene } from "babylonjs/scene";
  45423. import { Vector3 } from "babylonjs/Maths/math.vector";
  45424. /**
  45425. * This represents a FPS type of camera controlled by touch.
  45426. * This is like a universal camera minus the Gamepad controls.
  45427. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45428. */
  45429. export class TouchCamera extends FreeCamera {
  45430. /**
  45431. * Defines the touch sensibility for rotation.
  45432. * The higher the faster.
  45433. */
  45434. get touchAngularSensibility(): number;
  45435. set touchAngularSensibility(value: number);
  45436. /**
  45437. * Defines the touch sensibility for move.
  45438. * The higher the faster.
  45439. */
  45440. get touchMoveSensibility(): number;
  45441. set touchMoveSensibility(value: number);
  45442. /**
  45443. * Instantiates a new touch camera.
  45444. * This represents a FPS type of camera controlled by touch.
  45445. * This is like a universal camera minus the Gamepad controls.
  45446. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45447. * @param name Define the name of the camera in the scene
  45448. * @param position Define the start position of the camera in the scene
  45449. * @param scene Define the scene the camera belongs to
  45450. */
  45451. constructor(name: string, position: Vector3, scene: Scene);
  45452. /**
  45453. * Gets the current object class name.
  45454. * @return the class name
  45455. */
  45456. getClassName(): string;
  45457. /** @hidden */
  45458. _setupInputs(): void;
  45459. }
  45460. }
  45461. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45462. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45463. import { Scene } from "babylonjs/scene";
  45464. import { Vector3 } from "babylonjs/Maths/math.vector";
  45465. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45466. import { Axis } from "babylonjs/Maths/math.axis";
  45467. /**
  45468. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45469. * being tilted forward or back and left or right.
  45470. */
  45471. export class DeviceOrientationCamera extends FreeCamera {
  45472. private _initialQuaternion;
  45473. private _quaternionCache;
  45474. private _tmpDragQuaternion;
  45475. private _disablePointerInputWhenUsingDeviceOrientation;
  45476. /**
  45477. * Creates a new device orientation camera
  45478. * @param name The name of the camera
  45479. * @param position The start position camera
  45480. * @param scene The scene the camera belongs to
  45481. */
  45482. constructor(name: string, position: Vector3, scene: Scene);
  45483. /**
  45484. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45485. */
  45486. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45487. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45488. private _dragFactor;
  45489. /**
  45490. * Enabled turning on the y axis when the orientation sensor is active
  45491. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45492. */
  45493. enableHorizontalDragging(dragFactor?: number): void;
  45494. /**
  45495. * Gets the current instance class name ("DeviceOrientationCamera").
  45496. * This helps avoiding instanceof at run time.
  45497. * @returns the class name
  45498. */
  45499. getClassName(): string;
  45500. /**
  45501. * @hidden
  45502. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45503. */
  45504. _checkInputs(): void;
  45505. /**
  45506. * Reset the camera to its default orientation on the specified axis only.
  45507. * @param axis The axis to reset
  45508. */
  45509. resetToCurrentRotation(axis?: Axis): void;
  45510. }
  45511. }
  45512. declare module "babylonjs/Gamepads/xboxGamepad" {
  45513. import { Observable } from "babylonjs/Misc/observable";
  45514. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45515. /**
  45516. * Defines supported buttons for XBox360 compatible gamepads
  45517. */
  45518. export enum Xbox360Button {
  45519. /** A */
  45520. A = 0,
  45521. /** B */
  45522. B = 1,
  45523. /** X */
  45524. X = 2,
  45525. /** Y */
  45526. Y = 3,
  45527. /** Left button */
  45528. LB = 4,
  45529. /** Right button */
  45530. RB = 5,
  45531. /** Back */
  45532. Back = 8,
  45533. /** Start */
  45534. Start = 9,
  45535. /** Left stick */
  45536. LeftStick = 10,
  45537. /** Right stick */
  45538. RightStick = 11
  45539. }
  45540. /** Defines values for XBox360 DPad */
  45541. export enum Xbox360Dpad {
  45542. /** Up */
  45543. Up = 12,
  45544. /** Down */
  45545. Down = 13,
  45546. /** Left */
  45547. Left = 14,
  45548. /** Right */
  45549. Right = 15
  45550. }
  45551. /**
  45552. * Defines a XBox360 gamepad
  45553. */
  45554. export class Xbox360Pad extends Gamepad {
  45555. private _leftTrigger;
  45556. private _rightTrigger;
  45557. private _onlefttriggerchanged;
  45558. private _onrighttriggerchanged;
  45559. private _onbuttondown;
  45560. private _onbuttonup;
  45561. private _ondpaddown;
  45562. private _ondpadup;
  45563. /** Observable raised when a button is pressed */
  45564. onButtonDownObservable: Observable<Xbox360Button>;
  45565. /** Observable raised when a button is released */
  45566. onButtonUpObservable: Observable<Xbox360Button>;
  45567. /** Observable raised when a pad is pressed */
  45568. onPadDownObservable: Observable<Xbox360Dpad>;
  45569. /** Observable raised when a pad is released */
  45570. onPadUpObservable: Observable<Xbox360Dpad>;
  45571. private _buttonA;
  45572. private _buttonB;
  45573. private _buttonX;
  45574. private _buttonY;
  45575. private _buttonBack;
  45576. private _buttonStart;
  45577. private _buttonLB;
  45578. private _buttonRB;
  45579. private _buttonLeftStick;
  45580. private _buttonRightStick;
  45581. private _dPadUp;
  45582. private _dPadDown;
  45583. private _dPadLeft;
  45584. private _dPadRight;
  45585. private _isXboxOnePad;
  45586. /**
  45587. * Creates a new XBox360 gamepad object
  45588. * @param id defines the id of this gamepad
  45589. * @param index defines its index
  45590. * @param gamepad defines the internal HTML gamepad object
  45591. * @param xboxOne defines if it is a XBox One gamepad
  45592. */
  45593. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45594. /**
  45595. * Defines the callback to call when left trigger is pressed
  45596. * @param callback defines the callback to use
  45597. */
  45598. onlefttriggerchanged(callback: (value: number) => void): void;
  45599. /**
  45600. * Defines the callback to call when right trigger is pressed
  45601. * @param callback defines the callback to use
  45602. */
  45603. onrighttriggerchanged(callback: (value: number) => void): void;
  45604. /**
  45605. * Gets the left trigger value
  45606. */
  45607. get leftTrigger(): number;
  45608. /**
  45609. * Sets the left trigger value
  45610. */
  45611. set leftTrigger(newValue: number);
  45612. /**
  45613. * Gets the right trigger value
  45614. */
  45615. get rightTrigger(): number;
  45616. /**
  45617. * Sets the right trigger value
  45618. */
  45619. set rightTrigger(newValue: number);
  45620. /**
  45621. * Defines the callback to call when a button is pressed
  45622. * @param callback defines the callback to use
  45623. */
  45624. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45625. /**
  45626. * Defines the callback to call when a button is released
  45627. * @param callback defines the callback to use
  45628. */
  45629. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45630. /**
  45631. * Defines the callback to call when a pad is pressed
  45632. * @param callback defines the callback to use
  45633. */
  45634. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45635. /**
  45636. * Defines the callback to call when a pad is released
  45637. * @param callback defines the callback to use
  45638. */
  45639. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45640. private _setButtonValue;
  45641. private _setDPadValue;
  45642. /**
  45643. * Gets the value of the `A` button
  45644. */
  45645. get buttonA(): number;
  45646. /**
  45647. * Sets the value of the `A` button
  45648. */
  45649. set buttonA(value: number);
  45650. /**
  45651. * Gets the value of the `B` button
  45652. */
  45653. get buttonB(): number;
  45654. /**
  45655. * Sets the value of the `B` button
  45656. */
  45657. set buttonB(value: number);
  45658. /**
  45659. * Gets the value of the `X` button
  45660. */
  45661. get buttonX(): number;
  45662. /**
  45663. * Sets the value of the `X` button
  45664. */
  45665. set buttonX(value: number);
  45666. /**
  45667. * Gets the value of the `Y` button
  45668. */
  45669. get buttonY(): number;
  45670. /**
  45671. * Sets the value of the `Y` button
  45672. */
  45673. set buttonY(value: number);
  45674. /**
  45675. * Gets the value of the `Start` button
  45676. */
  45677. get buttonStart(): number;
  45678. /**
  45679. * Sets the value of the `Start` button
  45680. */
  45681. set buttonStart(value: number);
  45682. /**
  45683. * Gets the value of the `Back` button
  45684. */
  45685. get buttonBack(): number;
  45686. /**
  45687. * Sets the value of the `Back` button
  45688. */
  45689. set buttonBack(value: number);
  45690. /**
  45691. * Gets the value of the `Left` button
  45692. */
  45693. get buttonLB(): number;
  45694. /**
  45695. * Sets the value of the `Left` button
  45696. */
  45697. set buttonLB(value: number);
  45698. /**
  45699. * Gets the value of the `Right` button
  45700. */
  45701. get buttonRB(): number;
  45702. /**
  45703. * Sets the value of the `Right` button
  45704. */
  45705. set buttonRB(value: number);
  45706. /**
  45707. * Gets the value of the Left joystick
  45708. */
  45709. get buttonLeftStick(): number;
  45710. /**
  45711. * Sets the value of the Left joystick
  45712. */
  45713. set buttonLeftStick(value: number);
  45714. /**
  45715. * Gets the value of the Right joystick
  45716. */
  45717. get buttonRightStick(): number;
  45718. /**
  45719. * Sets the value of the Right joystick
  45720. */
  45721. set buttonRightStick(value: number);
  45722. /**
  45723. * Gets the value of D-pad up
  45724. */
  45725. get dPadUp(): number;
  45726. /**
  45727. * Sets the value of D-pad up
  45728. */
  45729. set dPadUp(value: number);
  45730. /**
  45731. * Gets the value of D-pad down
  45732. */
  45733. get dPadDown(): number;
  45734. /**
  45735. * Sets the value of D-pad down
  45736. */
  45737. set dPadDown(value: number);
  45738. /**
  45739. * Gets the value of D-pad left
  45740. */
  45741. get dPadLeft(): number;
  45742. /**
  45743. * Sets the value of D-pad left
  45744. */
  45745. set dPadLeft(value: number);
  45746. /**
  45747. * Gets the value of D-pad right
  45748. */
  45749. get dPadRight(): number;
  45750. /**
  45751. * Sets the value of D-pad right
  45752. */
  45753. set dPadRight(value: number);
  45754. /**
  45755. * Force the gamepad to synchronize with device values
  45756. */
  45757. update(): void;
  45758. /**
  45759. * Disposes the gamepad
  45760. */
  45761. dispose(): void;
  45762. }
  45763. }
  45764. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45765. import { Observable } from "babylonjs/Misc/observable";
  45766. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45767. /**
  45768. * Defines supported buttons for DualShock compatible gamepads
  45769. */
  45770. export enum DualShockButton {
  45771. /** Cross */
  45772. Cross = 0,
  45773. /** Circle */
  45774. Circle = 1,
  45775. /** Square */
  45776. Square = 2,
  45777. /** Triangle */
  45778. Triangle = 3,
  45779. /** L1 */
  45780. L1 = 4,
  45781. /** R1 */
  45782. R1 = 5,
  45783. /** Share */
  45784. Share = 8,
  45785. /** Options */
  45786. Options = 9,
  45787. /** Left stick */
  45788. LeftStick = 10,
  45789. /** Right stick */
  45790. RightStick = 11
  45791. }
  45792. /** Defines values for DualShock DPad */
  45793. export enum DualShockDpad {
  45794. /** Up */
  45795. Up = 12,
  45796. /** Down */
  45797. Down = 13,
  45798. /** Left */
  45799. Left = 14,
  45800. /** Right */
  45801. Right = 15
  45802. }
  45803. /**
  45804. * Defines a DualShock gamepad
  45805. */
  45806. export class DualShockPad extends Gamepad {
  45807. private _leftTrigger;
  45808. private _rightTrigger;
  45809. private _onlefttriggerchanged;
  45810. private _onrighttriggerchanged;
  45811. private _onbuttondown;
  45812. private _onbuttonup;
  45813. private _ondpaddown;
  45814. private _ondpadup;
  45815. /** Observable raised when a button is pressed */
  45816. onButtonDownObservable: Observable<DualShockButton>;
  45817. /** Observable raised when a button is released */
  45818. onButtonUpObservable: Observable<DualShockButton>;
  45819. /** Observable raised when a pad is pressed */
  45820. onPadDownObservable: Observable<DualShockDpad>;
  45821. /** Observable raised when a pad is released */
  45822. onPadUpObservable: Observable<DualShockDpad>;
  45823. private _buttonCross;
  45824. private _buttonCircle;
  45825. private _buttonSquare;
  45826. private _buttonTriangle;
  45827. private _buttonShare;
  45828. private _buttonOptions;
  45829. private _buttonL1;
  45830. private _buttonR1;
  45831. private _buttonLeftStick;
  45832. private _buttonRightStick;
  45833. private _dPadUp;
  45834. private _dPadDown;
  45835. private _dPadLeft;
  45836. private _dPadRight;
  45837. /**
  45838. * Creates a new DualShock gamepad object
  45839. * @param id defines the id of this gamepad
  45840. * @param index defines its index
  45841. * @param gamepad defines the internal HTML gamepad object
  45842. */
  45843. constructor(id: string, index: number, gamepad: any);
  45844. /**
  45845. * Defines the callback to call when left trigger is pressed
  45846. * @param callback defines the callback to use
  45847. */
  45848. onlefttriggerchanged(callback: (value: number) => void): void;
  45849. /**
  45850. * Defines the callback to call when right trigger is pressed
  45851. * @param callback defines the callback to use
  45852. */
  45853. onrighttriggerchanged(callback: (value: number) => void): void;
  45854. /**
  45855. * Gets the left trigger value
  45856. */
  45857. get leftTrigger(): number;
  45858. /**
  45859. * Sets the left trigger value
  45860. */
  45861. set leftTrigger(newValue: number);
  45862. /**
  45863. * Gets the right trigger value
  45864. */
  45865. get rightTrigger(): number;
  45866. /**
  45867. * Sets the right trigger value
  45868. */
  45869. set rightTrigger(newValue: number);
  45870. /**
  45871. * Defines the callback to call when a button is pressed
  45872. * @param callback defines the callback to use
  45873. */
  45874. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45875. /**
  45876. * Defines the callback to call when a button is released
  45877. * @param callback defines the callback to use
  45878. */
  45879. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45880. /**
  45881. * Defines the callback to call when a pad is pressed
  45882. * @param callback defines the callback to use
  45883. */
  45884. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45885. /**
  45886. * Defines the callback to call when a pad is released
  45887. * @param callback defines the callback to use
  45888. */
  45889. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45890. private _setButtonValue;
  45891. private _setDPadValue;
  45892. /**
  45893. * Gets the value of the `Cross` button
  45894. */
  45895. get buttonCross(): number;
  45896. /**
  45897. * Sets the value of the `Cross` button
  45898. */
  45899. set buttonCross(value: number);
  45900. /**
  45901. * Gets the value of the `Circle` button
  45902. */
  45903. get buttonCircle(): number;
  45904. /**
  45905. * Sets the value of the `Circle` button
  45906. */
  45907. set buttonCircle(value: number);
  45908. /**
  45909. * Gets the value of the `Square` button
  45910. */
  45911. get buttonSquare(): number;
  45912. /**
  45913. * Sets the value of the `Square` button
  45914. */
  45915. set buttonSquare(value: number);
  45916. /**
  45917. * Gets the value of the `Triangle` button
  45918. */
  45919. get buttonTriangle(): number;
  45920. /**
  45921. * Sets the value of the `Triangle` button
  45922. */
  45923. set buttonTriangle(value: number);
  45924. /**
  45925. * Gets the value of the `Options` button
  45926. */
  45927. get buttonOptions(): number;
  45928. /**
  45929. * Sets the value of the `Options` button
  45930. */
  45931. set buttonOptions(value: number);
  45932. /**
  45933. * Gets the value of the `Share` button
  45934. */
  45935. get buttonShare(): number;
  45936. /**
  45937. * Sets the value of the `Share` button
  45938. */
  45939. set buttonShare(value: number);
  45940. /**
  45941. * Gets the value of the `L1` button
  45942. */
  45943. get buttonL1(): number;
  45944. /**
  45945. * Sets the value of the `L1` button
  45946. */
  45947. set buttonL1(value: number);
  45948. /**
  45949. * Gets the value of the `R1` button
  45950. */
  45951. get buttonR1(): number;
  45952. /**
  45953. * Sets the value of the `R1` button
  45954. */
  45955. set buttonR1(value: number);
  45956. /**
  45957. * Gets the value of the Left joystick
  45958. */
  45959. get buttonLeftStick(): number;
  45960. /**
  45961. * Sets the value of the Left joystick
  45962. */
  45963. set buttonLeftStick(value: number);
  45964. /**
  45965. * Gets the value of the Right joystick
  45966. */
  45967. get buttonRightStick(): number;
  45968. /**
  45969. * Sets the value of the Right joystick
  45970. */
  45971. set buttonRightStick(value: number);
  45972. /**
  45973. * Gets the value of D-pad up
  45974. */
  45975. get dPadUp(): number;
  45976. /**
  45977. * Sets the value of D-pad up
  45978. */
  45979. set dPadUp(value: number);
  45980. /**
  45981. * Gets the value of D-pad down
  45982. */
  45983. get dPadDown(): number;
  45984. /**
  45985. * Sets the value of D-pad down
  45986. */
  45987. set dPadDown(value: number);
  45988. /**
  45989. * Gets the value of D-pad left
  45990. */
  45991. get dPadLeft(): number;
  45992. /**
  45993. * Sets the value of D-pad left
  45994. */
  45995. set dPadLeft(value: number);
  45996. /**
  45997. * Gets the value of D-pad right
  45998. */
  45999. get dPadRight(): number;
  46000. /**
  46001. * Sets the value of D-pad right
  46002. */
  46003. set dPadRight(value: number);
  46004. /**
  46005. * Force the gamepad to synchronize with device values
  46006. */
  46007. update(): void;
  46008. /**
  46009. * Disposes the gamepad
  46010. */
  46011. dispose(): void;
  46012. }
  46013. }
  46014. declare module "babylonjs/Gamepads/gamepadManager" {
  46015. import { Observable } from "babylonjs/Misc/observable";
  46016. import { Nullable } from "babylonjs/types";
  46017. import { Scene } from "babylonjs/scene";
  46018. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46019. /**
  46020. * Manager for handling gamepads
  46021. */
  46022. export class GamepadManager {
  46023. private _scene?;
  46024. private _babylonGamepads;
  46025. private _oneGamepadConnected;
  46026. /** @hidden */
  46027. _isMonitoring: boolean;
  46028. private _gamepadEventSupported;
  46029. private _gamepadSupport?;
  46030. /**
  46031. * observable to be triggered when the gamepad controller has been connected
  46032. */
  46033. onGamepadConnectedObservable: Observable<Gamepad>;
  46034. /**
  46035. * observable to be triggered when the gamepad controller has been disconnected
  46036. */
  46037. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46038. private _onGamepadConnectedEvent;
  46039. private _onGamepadDisconnectedEvent;
  46040. /**
  46041. * Initializes the gamepad manager
  46042. * @param _scene BabylonJS scene
  46043. */
  46044. constructor(_scene?: Scene | undefined);
  46045. /**
  46046. * The gamepads in the game pad manager
  46047. */
  46048. get gamepads(): Gamepad[];
  46049. /**
  46050. * Get the gamepad controllers based on type
  46051. * @param type The type of gamepad controller
  46052. * @returns Nullable gamepad
  46053. */
  46054. getGamepadByType(type?: number): Nullable<Gamepad>;
  46055. /**
  46056. * Disposes the gamepad manager
  46057. */
  46058. dispose(): void;
  46059. private _addNewGamepad;
  46060. private _startMonitoringGamepads;
  46061. private _stopMonitoringGamepads;
  46062. /** @hidden */
  46063. _checkGamepadsStatus(): void;
  46064. private _updateGamepadObjects;
  46065. }
  46066. }
  46067. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46068. import { Nullable } from "babylonjs/types";
  46069. import { Scene } from "babylonjs/scene";
  46070. import { ISceneComponent } from "babylonjs/sceneComponent";
  46071. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46072. module "babylonjs/scene" {
  46073. interface Scene {
  46074. /** @hidden */
  46075. _gamepadManager: Nullable<GamepadManager>;
  46076. /**
  46077. * Gets the gamepad manager associated with the scene
  46078. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46079. */
  46080. gamepadManager: GamepadManager;
  46081. }
  46082. }
  46083. module "babylonjs/Cameras/freeCameraInputsManager" {
  46084. /**
  46085. * Interface representing a free camera inputs manager
  46086. */
  46087. interface FreeCameraInputsManager {
  46088. /**
  46089. * Adds gamepad input support to the FreeCameraInputsManager.
  46090. * @returns the FreeCameraInputsManager
  46091. */
  46092. addGamepad(): FreeCameraInputsManager;
  46093. }
  46094. }
  46095. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46096. /**
  46097. * Interface representing an arc rotate camera inputs manager
  46098. */
  46099. interface ArcRotateCameraInputsManager {
  46100. /**
  46101. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46102. * @returns the camera inputs manager
  46103. */
  46104. addGamepad(): ArcRotateCameraInputsManager;
  46105. }
  46106. }
  46107. /**
  46108. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46109. */
  46110. export class GamepadSystemSceneComponent implements ISceneComponent {
  46111. /**
  46112. * The component name helpfull to identify the component in the list of scene components.
  46113. */
  46114. readonly name: string;
  46115. /**
  46116. * The scene the component belongs to.
  46117. */
  46118. scene: Scene;
  46119. /**
  46120. * Creates a new instance of the component for the given scene
  46121. * @param scene Defines the scene to register the component in
  46122. */
  46123. constructor(scene: Scene);
  46124. /**
  46125. * Registers the component in a given scene
  46126. */
  46127. register(): void;
  46128. /**
  46129. * Rebuilds the elements related to this component in case of
  46130. * context lost for instance.
  46131. */
  46132. rebuild(): void;
  46133. /**
  46134. * Disposes the component and the associated ressources
  46135. */
  46136. dispose(): void;
  46137. private _beforeCameraUpdate;
  46138. }
  46139. }
  46140. declare module "babylonjs/Cameras/universalCamera" {
  46141. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46142. import { Scene } from "babylonjs/scene";
  46143. import { Vector3 } from "babylonjs/Maths/math.vector";
  46144. import "babylonjs/Gamepads/gamepadSceneComponent";
  46145. /**
  46146. * 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,
  46147. * which still works and will still be found in many Playgrounds.
  46148. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46149. */
  46150. export class UniversalCamera extends TouchCamera {
  46151. /**
  46152. * Defines the gamepad rotation sensiblity.
  46153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46154. */
  46155. get gamepadAngularSensibility(): number;
  46156. set gamepadAngularSensibility(value: number);
  46157. /**
  46158. * Defines the gamepad move sensiblity.
  46159. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46160. */
  46161. get gamepadMoveSensibility(): number;
  46162. set gamepadMoveSensibility(value: number);
  46163. /**
  46164. * 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,
  46165. * which still works and will still be found in many Playgrounds.
  46166. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46167. * @param name Define the name of the camera in the scene
  46168. * @param position Define the start position of the camera in the scene
  46169. * @param scene Define the scene the camera belongs to
  46170. */
  46171. constructor(name: string, position: Vector3, scene: Scene);
  46172. /**
  46173. * Gets the current object class name.
  46174. * @return the class name
  46175. */
  46176. getClassName(): string;
  46177. }
  46178. }
  46179. declare module "babylonjs/Cameras/gamepadCamera" {
  46180. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46181. import { Scene } from "babylonjs/scene";
  46182. import { Vector3 } from "babylonjs/Maths/math.vector";
  46183. /**
  46184. * This represents a FPS type of camera. This is only here for back compat purpose.
  46185. * Please use the UniversalCamera instead as both are identical.
  46186. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46187. */
  46188. export class GamepadCamera extends UniversalCamera {
  46189. /**
  46190. * Instantiates a new Gamepad Camera
  46191. * This represents a FPS type of camera. This is only here for back compat purpose.
  46192. * Please use the UniversalCamera instead as both are identical.
  46193. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46194. * @param name Define the name of the camera in the scene
  46195. * @param position Define the start position of the camera in the scene
  46196. * @param scene Define the scene the camera belongs to
  46197. */
  46198. constructor(name: string, position: Vector3, scene: Scene);
  46199. /**
  46200. * Gets the current object class name.
  46201. * @return the class name
  46202. */
  46203. getClassName(): string;
  46204. }
  46205. }
  46206. declare module "babylonjs/Shaders/pass.fragment" {
  46207. /** @hidden */
  46208. export var passPixelShader: {
  46209. name: string;
  46210. shader: string;
  46211. };
  46212. }
  46213. declare module "babylonjs/Shaders/passCube.fragment" {
  46214. /** @hidden */
  46215. export var passCubePixelShader: {
  46216. name: string;
  46217. shader: string;
  46218. };
  46219. }
  46220. declare module "babylonjs/PostProcesses/passPostProcess" {
  46221. import { Nullable } from "babylonjs/types";
  46222. import { Camera } from "babylonjs/Cameras/camera";
  46223. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46224. import { Engine } from "babylonjs/Engines/engine";
  46225. import "babylonjs/Shaders/pass.fragment";
  46226. import "babylonjs/Shaders/passCube.fragment";
  46227. /**
  46228. * PassPostProcess which produces an output the same as it's input
  46229. */
  46230. export class PassPostProcess extends PostProcess {
  46231. /**
  46232. * Creates the PassPostProcess
  46233. * @param name The name of the effect.
  46234. * @param options The required width/height ratio to downsize to before computing the render pass.
  46235. * @param camera The camera to apply the render pass to.
  46236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46237. * @param engine The engine which the post process will be applied. (default: current engine)
  46238. * @param reusable If the post process can be reused on the same frame. (default: false)
  46239. * @param textureType The type of texture to be used when performing the post processing.
  46240. * @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)
  46241. */
  46242. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46243. }
  46244. /**
  46245. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46246. */
  46247. export class PassCubePostProcess extends PostProcess {
  46248. private _face;
  46249. /**
  46250. * Gets or sets the cube face to display.
  46251. * * 0 is +X
  46252. * * 1 is -X
  46253. * * 2 is +Y
  46254. * * 3 is -Y
  46255. * * 4 is +Z
  46256. * * 5 is -Z
  46257. */
  46258. get face(): number;
  46259. set face(value: number);
  46260. /**
  46261. * Creates the PassCubePostProcess
  46262. * @param name The name of the effect.
  46263. * @param options The required width/height ratio to downsize to before computing the render pass.
  46264. * @param camera The camera to apply the render pass to.
  46265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46266. * @param engine The engine which the post process will be applied. (default: current engine)
  46267. * @param reusable If the post process can be reused on the same frame. (default: false)
  46268. * @param textureType The type of texture to be used when performing the post processing.
  46269. * @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)
  46270. */
  46271. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46272. }
  46273. }
  46274. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46275. /** @hidden */
  46276. export var anaglyphPixelShader: {
  46277. name: string;
  46278. shader: string;
  46279. };
  46280. }
  46281. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46282. import { Engine } from "babylonjs/Engines/engine";
  46283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46284. import { Camera } from "babylonjs/Cameras/camera";
  46285. import "babylonjs/Shaders/anaglyph.fragment";
  46286. /**
  46287. * Postprocess used to generate anaglyphic rendering
  46288. */
  46289. export class AnaglyphPostProcess extends PostProcess {
  46290. private _passedProcess;
  46291. /**
  46292. * Creates a new AnaglyphPostProcess
  46293. * @param name defines postprocess name
  46294. * @param options defines creation options or target ratio scale
  46295. * @param rigCameras defines cameras using this postprocess
  46296. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46297. * @param engine defines hosting engine
  46298. * @param reusable defines if the postprocess will be reused multiple times per frame
  46299. */
  46300. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46301. }
  46302. }
  46303. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46304. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46305. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46306. import { Scene } from "babylonjs/scene";
  46307. import { Vector3 } from "babylonjs/Maths/math.vector";
  46308. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46309. /**
  46310. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46311. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46312. */
  46313. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46314. /**
  46315. * Creates a new AnaglyphArcRotateCamera
  46316. * @param name defines camera name
  46317. * @param alpha defines alpha angle (in radians)
  46318. * @param beta defines beta angle (in radians)
  46319. * @param radius defines radius
  46320. * @param target defines camera target
  46321. * @param interaxialDistance defines distance between each color axis
  46322. * @param scene defines the hosting scene
  46323. */
  46324. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46325. /**
  46326. * Gets camera class name
  46327. * @returns AnaglyphArcRotateCamera
  46328. */
  46329. getClassName(): string;
  46330. }
  46331. }
  46332. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46333. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46334. import { Scene } from "babylonjs/scene";
  46335. import { Vector3 } from "babylonjs/Maths/math.vector";
  46336. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46337. /**
  46338. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46340. */
  46341. export class AnaglyphFreeCamera extends FreeCamera {
  46342. /**
  46343. * Creates a new AnaglyphFreeCamera
  46344. * @param name defines camera name
  46345. * @param position defines initial position
  46346. * @param interaxialDistance defines distance between each color axis
  46347. * @param scene defines the hosting scene
  46348. */
  46349. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46350. /**
  46351. * Gets camera class name
  46352. * @returns AnaglyphFreeCamera
  46353. */
  46354. getClassName(): string;
  46355. }
  46356. }
  46357. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46358. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46359. import { Scene } from "babylonjs/scene";
  46360. import { Vector3 } from "babylonjs/Maths/math.vector";
  46361. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46362. /**
  46363. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46364. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46365. */
  46366. export class AnaglyphGamepadCamera extends GamepadCamera {
  46367. /**
  46368. * Creates a new AnaglyphGamepadCamera
  46369. * @param name defines camera name
  46370. * @param position defines initial position
  46371. * @param interaxialDistance defines distance between each color axis
  46372. * @param scene defines the hosting scene
  46373. */
  46374. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46375. /**
  46376. * Gets camera class name
  46377. * @returns AnaglyphGamepadCamera
  46378. */
  46379. getClassName(): string;
  46380. }
  46381. }
  46382. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46383. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46384. import { Scene } from "babylonjs/scene";
  46385. import { Vector3 } from "babylonjs/Maths/math.vector";
  46386. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46387. /**
  46388. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46390. */
  46391. export class AnaglyphUniversalCamera extends UniversalCamera {
  46392. /**
  46393. * Creates a new AnaglyphUniversalCamera
  46394. * @param name defines camera name
  46395. * @param position defines initial position
  46396. * @param interaxialDistance defines distance between each color axis
  46397. * @param scene defines the hosting scene
  46398. */
  46399. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46400. /**
  46401. * Gets camera class name
  46402. * @returns AnaglyphUniversalCamera
  46403. */
  46404. getClassName(): string;
  46405. }
  46406. }
  46407. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46408. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46409. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46410. import { Scene } from "babylonjs/scene";
  46411. import { Vector3 } from "babylonjs/Maths/math.vector";
  46412. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46413. /**
  46414. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46415. * @see http://doc.babylonjs.com/features/cameras
  46416. */
  46417. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46418. /**
  46419. * Creates a new StereoscopicArcRotateCamera
  46420. * @param name defines camera name
  46421. * @param alpha defines alpha angle (in radians)
  46422. * @param beta defines beta angle (in radians)
  46423. * @param radius defines radius
  46424. * @param target defines camera target
  46425. * @param interaxialDistance defines distance between each color axis
  46426. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46427. * @param scene defines the hosting scene
  46428. */
  46429. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46430. /**
  46431. * Gets camera class name
  46432. * @returns StereoscopicArcRotateCamera
  46433. */
  46434. getClassName(): string;
  46435. }
  46436. }
  46437. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46439. import { Scene } from "babylonjs/scene";
  46440. import { Vector3 } from "babylonjs/Maths/math.vector";
  46441. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46442. /**
  46443. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46444. * @see http://doc.babylonjs.com/features/cameras
  46445. */
  46446. export class StereoscopicFreeCamera extends FreeCamera {
  46447. /**
  46448. * Creates a new StereoscopicFreeCamera
  46449. * @param name defines camera name
  46450. * @param position defines initial position
  46451. * @param interaxialDistance defines distance between each color axis
  46452. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46453. * @param scene defines the hosting scene
  46454. */
  46455. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46456. /**
  46457. * Gets camera class name
  46458. * @returns StereoscopicFreeCamera
  46459. */
  46460. getClassName(): string;
  46461. }
  46462. }
  46463. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46464. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46465. import { Scene } from "babylonjs/scene";
  46466. import { Vector3 } from "babylonjs/Maths/math.vector";
  46467. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46468. /**
  46469. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46470. * @see http://doc.babylonjs.com/features/cameras
  46471. */
  46472. export class StereoscopicGamepadCamera extends GamepadCamera {
  46473. /**
  46474. * Creates a new StereoscopicGamepadCamera
  46475. * @param name defines camera name
  46476. * @param position defines initial position
  46477. * @param interaxialDistance defines distance between each color axis
  46478. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46479. * @param scene defines the hosting scene
  46480. */
  46481. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46482. /**
  46483. * Gets camera class name
  46484. * @returns StereoscopicGamepadCamera
  46485. */
  46486. getClassName(): string;
  46487. }
  46488. }
  46489. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46490. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46491. import { Scene } from "babylonjs/scene";
  46492. import { Vector3 } from "babylonjs/Maths/math.vector";
  46493. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46494. /**
  46495. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46496. * @see http://doc.babylonjs.com/features/cameras
  46497. */
  46498. export class StereoscopicUniversalCamera extends UniversalCamera {
  46499. /**
  46500. * Creates a new StereoscopicUniversalCamera
  46501. * @param name defines camera name
  46502. * @param position defines initial position
  46503. * @param interaxialDistance defines distance between each color axis
  46504. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46505. * @param scene defines the hosting scene
  46506. */
  46507. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46508. /**
  46509. * Gets camera class name
  46510. * @returns StereoscopicUniversalCamera
  46511. */
  46512. getClassName(): string;
  46513. }
  46514. }
  46515. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46516. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46517. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46518. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46519. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46520. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46521. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46522. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46523. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46524. }
  46525. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46526. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46527. import { Scene } from "babylonjs/scene";
  46528. import { Vector3 } from "babylonjs/Maths/math.vector";
  46529. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46530. /**
  46531. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46532. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46533. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46534. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46535. */
  46536. export class VirtualJoysticksCamera extends FreeCamera {
  46537. /**
  46538. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46539. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46540. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46541. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46542. * @param name Define the name of the camera in the scene
  46543. * @param position Define the start position of the camera in the scene
  46544. * @param scene Define the scene the camera belongs to
  46545. */
  46546. constructor(name: string, position: Vector3, scene: Scene);
  46547. /**
  46548. * Gets the current object class name.
  46549. * @return the class name
  46550. */
  46551. getClassName(): string;
  46552. }
  46553. }
  46554. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46555. import { Matrix } from "babylonjs/Maths/math.vector";
  46556. /**
  46557. * This represents all the required metrics to create a VR camera.
  46558. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46559. */
  46560. export class VRCameraMetrics {
  46561. /**
  46562. * Define the horizontal resolution off the screen.
  46563. */
  46564. hResolution: number;
  46565. /**
  46566. * Define the vertical resolution off the screen.
  46567. */
  46568. vResolution: number;
  46569. /**
  46570. * Define the horizontal screen size.
  46571. */
  46572. hScreenSize: number;
  46573. /**
  46574. * Define the vertical screen size.
  46575. */
  46576. vScreenSize: number;
  46577. /**
  46578. * Define the vertical screen center position.
  46579. */
  46580. vScreenCenter: number;
  46581. /**
  46582. * Define the distance of the eyes to the screen.
  46583. */
  46584. eyeToScreenDistance: number;
  46585. /**
  46586. * Define the distance between both lenses
  46587. */
  46588. lensSeparationDistance: number;
  46589. /**
  46590. * Define the distance between both viewer's eyes.
  46591. */
  46592. interpupillaryDistance: number;
  46593. /**
  46594. * Define the distortion factor of the VR postprocess.
  46595. * Please, touch with care.
  46596. */
  46597. distortionK: number[];
  46598. /**
  46599. * Define the chromatic aberration correction factors for the VR post process.
  46600. */
  46601. chromaAbCorrection: number[];
  46602. /**
  46603. * Define the scale factor of the post process.
  46604. * The smaller the better but the slower.
  46605. */
  46606. postProcessScaleFactor: number;
  46607. /**
  46608. * Define an offset for the lens center.
  46609. */
  46610. lensCenterOffset: number;
  46611. /**
  46612. * Define if the current vr camera should compensate the distortion of the lense or not.
  46613. */
  46614. compensateDistortion: boolean;
  46615. /**
  46616. * Defines if multiview should be enabled when rendering (Default: false)
  46617. */
  46618. multiviewEnabled: boolean;
  46619. /**
  46620. * Gets the rendering aspect ratio based on the provided resolutions.
  46621. */
  46622. get aspectRatio(): number;
  46623. /**
  46624. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46625. */
  46626. get aspectRatioFov(): number;
  46627. /**
  46628. * @hidden
  46629. */
  46630. get leftHMatrix(): Matrix;
  46631. /**
  46632. * @hidden
  46633. */
  46634. get rightHMatrix(): Matrix;
  46635. /**
  46636. * @hidden
  46637. */
  46638. get leftPreViewMatrix(): Matrix;
  46639. /**
  46640. * @hidden
  46641. */
  46642. get rightPreViewMatrix(): Matrix;
  46643. /**
  46644. * Get the default VRMetrics based on the most generic setup.
  46645. * @returns the default vr metrics
  46646. */
  46647. static GetDefault(): VRCameraMetrics;
  46648. }
  46649. }
  46650. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46651. /** @hidden */
  46652. export var vrDistortionCorrectionPixelShader: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46658. import { Camera } from "babylonjs/Cameras/camera";
  46659. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46660. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46661. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46662. /**
  46663. * VRDistortionCorrectionPostProcess used for mobile VR
  46664. */
  46665. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46666. private _isRightEye;
  46667. private _distortionFactors;
  46668. private _postProcessScaleFactor;
  46669. private _lensCenterOffset;
  46670. private _scaleIn;
  46671. private _scaleFactor;
  46672. private _lensCenter;
  46673. /**
  46674. * Initializes the VRDistortionCorrectionPostProcess
  46675. * @param name The name of the effect.
  46676. * @param camera The camera to apply the render pass to.
  46677. * @param isRightEye If this is for the right eye distortion
  46678. * @param vrMetrics All the required metrics for the VR camera
  46679. */
  46680. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46681. }
  46682. }
  46683. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46684. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46685. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46686. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46687. import { Scene } from "babylonjs/scene";
  46688. import { Vector3 } from "babylonjs/Maths/math.vector";
  46689. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46690. import "babylonjs/Cameras/RigModes/vrRigMode";
  46691. /**
  46692. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46693. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46694. */
  46695. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46696. /**
  46697. * Creates a new VRDeviceOrientationArcRotateCamera
  46698. * @param name defines camera name
  46699. * @param alpha defines the camera rotation along the logitudinal axis
  46700. * @param beta defines the camera rotation along the latitudinal axis
  46701. * @param radius defines the camera distance from its target
  46702. * @param target defines the camera target
  46703. * @param scene defines the scene the camera belongs to
  46704. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46705. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46706. */
  46707. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46708. /**
  46709. * Gets camera class name
  46710. * @returns VRDeviceOrientationArcRotateCamera
  46711. */
  46712. getClassName(): string;
  46713. }
  46714. }
  46715. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46716. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46717. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46718. import { Scene } from "babylonjs/scene";
  46719. import { Vector3 } from "babylonjs/Maths/math.vector";
  46720. import "babylonjs/Cameras/RigModes/vrRigMode";
  46721. /**
  46722. * Camera used to simulate VR rendering (based on FreeCamera)
  46723. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46724. */
  46725. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46726. /**
  46727. * Creates a new VRDeviceOrientationFreeCamera
  46728. * @param name defines camera name
  46729. * @param position defines the start position of the camera
  46730. * @param scene defines the scene the camera belongs to
  46731. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46732. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46733. */
  46734. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46735. /**
  46736. * Gets camera class name
  46737. * @returns VRDeviceOrientationFreeCamera
  46738. */
  46739. getClassName(): string;
  46740. }
  46741. }
  46742. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46743. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46744. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46745. import { Scene } from "babylonjs/scene";
  46746. import { Vector3 } from "babylonjs/Maths/math.vector";
  46747. import "babylonjs/Gamepads/gamepadSceneComponent";
  46748. /**
  46749. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46750. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46751. */
  46752. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46753. /**
  46754. * Creates a new VRDeviceOrientationGamepadCamera
  46755. * @param name defines camera name
  46756. * @param position defines the start position of the camera
  46757. * @param scene defines the scene the camera belongs to
  46758. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46759. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46760. */
  46761. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46762. /**
  46763. * Gets camera class name
  46764. * @returns VRDeviceOrientationGamepadCamera
  46765. */
  46766. getClassName(): string;
  46767. }
  46768. }
  46769. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46770. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46771. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46772. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46773. /** @hidden */
  46774. export var imageProcessingPixelShader: {
  46775. name: string;
  46776. shader: string;
  46777. };
  46778. }
  46779. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46780. import { Nullable } from "babylonjs/types";
  46781. import { Color4 } from "babylonjs/Maths/math.color";
  46782. import { Camera } from "babylonjs/Cameras/camera";
  46783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46784. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46785. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46786. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46787. import { Engine } from "babylonjs/Engines/engine";
  46788. import "babylonjs/Shaders/imageProcessing.fragment";
  46789. import "babylonjs/Shaders/postprocess.vertex";
  46790. /**
  46791. * ImageProcessingPostProcess
  46792. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46793. */
  46794. export class ImageProcessingPostProcess extends PostProcess {
  46795. /**
  46796. * Default configuration related to image processing available in the PBR Material.
  46797. */
  46798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46799. /**
  46800. * Gets the image processing configuration used either in this material.
  46801. */
  46802. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46803. /**
  46804. * Sets the Default image processing configuration used either in the this material.
  46805. *
  46806. * If sets to null, the scene one is in use.
  46807. */
  46808. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46809. /**
  46810. * Keep track of the image processing observer to allow dispose and replace.
  46811. */
  46812. private _imageProcessingObserver;
  46813. /**
  46814. * Attaches a new image processing configuration to the PBR Material.
  46815. * @param configuration
  46816. */
  46817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  46818. /**
  46819. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46820. */
  46821. get colorCurves(): Nullable<ColorCurves>;
  46822. /**
  46823. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46824. */
  46825. set colorCurves(value: Nullable<ColorCurves>);
  46826. /**
  46827. * Gets wether the color curves effect is enabled.
  46828. */
  46829. get colorCurvesEnabled(): boolean;
  46830. /**
  46831. * Sets wether the color curves effect is enabled.
  46832. */
  46833. set colorCurvesEnabled(value: boolean);
  46834. /**
  46835. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46836. */
  46837. get colorGradingTexture(): Nullable<BaseTexture>;
  46838. /**
  46839. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46840. */
  46841. set colorGradingTexture(value: Nullable<BaseTexture>);
  46842. /**
  46843. * Gets wether the color grading effect is enabled.
  46844. */
  46845. get colorGradingEnabled(): boolean;
  46846. /**
  46847. * Gets wether the color grading effect is enabled.
  46848. */
  46849. set colorGradingEnabled(value: boolean);
  46850. /**
  46851. * Gets exposure used in the effect.
  46852. */
  46853. get exposure(): number;
  46854. /**
  46855. * Sets exposure used in the effect.
  46856. */
  46857. set exposure(value: number);
  46858. /**
  46859. * Gets wether tonemapping is enabled or not.
  46860. */
  46861. get toneMappingEnabled(): boolean;
  46862. /**
  46863. * Sets wether tonemapping is enabled or not
  46864. */
  46865. set toneMappingEnabled(value: boolean);
  46866. /**
  46867. * Gets the type of tone mapping effect.
  46868. */
  46869. get toneMappingType(): number;
  46870. /**
  46871. * Sets the type of tone mapping effect.
  46872. */
  46873. set toneMappingType(value: number);
  46874. /**
  46875. * Gets contrast used in the effect.
  46876. */
  46877. get contrast(): number;
  46878. /**
  46879. * Sets contrast used in the effect.
  46880. */
  46881. set contrast(value: number);
  46882. /**
  46883. * Gets Vignette stretch size.
  46884. */
  46885. get vignetteStretch(): number;
  46886. /**
  46887. * Sets Vignette stretch size.
  46888. */
  46889. set vignetteStretch(value: number);
  46890. /**
  46891. * Gets Vignette centre X Offset.
  46892. */
  46893. get vignetteCentreX(): number;
  46894. /**
  46895. * Sets Vignette centre X Offset.
  46896. */
  46897. set vignetteCentreX(value: number);
  46898. /**
  46899. * Gets Vignette centre Y Offset.
  46900. */
  46901. get vignetteCentreY(): number;
  46902. /**
  46903. * Sets Vignette centre Y Offset.
  46904. */
  46905. set vignetteCentreY(value: number);
  46906. /**
  46907. * Gets Vignette weight or intensity of the vignette effect.
  46908. */
  46909. get vignetteWeight(): number;
  46910. /**
  46911. * Sets Vignette weight or intensity of the vignette effect.
  46912. */
  46913. set vignetteWeight(value: number);
  46914. /**
  46915. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  46916. * if vignetteEnabled is set to true.
  46917. */
  46918. get vignetteColor(): Color4;
  46919. /**
  46920. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  46921. * if vignetteEnabled is set to true.
  46922. */
  46923. set vignetteColor(value: Color4);
  46924. /**
  46925. * Gets Camera field of view used by the Vignette effect.
  46926. */
  46927. get vignetteCameraFov(): number;
  46928. /**
  46929. * Sets Camera field of view used by the Vignette effect.
  46930. */
  46931. set vignetteCameraFov(value: number);
  46932. /**
  46933. * Gets the vignette blend mode allowing different kind of effect.
  46934. */
  46935. get vignetteBlendMode(): number;
  46936. /**
  46937. * Sets the vignette blend mode allowing different kind of effect.
  46938. */
  46939. set vignetteBlendMode(value: number);
  46940. /**
  46941. * Gets wether the vignette effect is enabled.
  46942. */
  46943. get vignetteEnabled(): boolean;
  46944. /**
  46945. * Sets wether the vignette effect is enabled.
  46946. */
  46947. set vignetteEnabled(value: boolean);
  46948. private _fromLinearSpace;
  46949. /**
  46950. * Gets wether the input of the processing is in Gamma or Linear Space.
  46951. */
  46952. get fromLinearSpace(): boolean;
  46953. /**
  46954. * Sets wether the input of the processing is in Gamma or Linear Space.
  46955. */
  46956. set fromLinearSpace(value: boolean);
  46957. /**
  46958. * Defines cache preventing GC.
  46959. */
  46960. private _defines;
  46961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  46962. /**
  46963. * "ImageProcessingPostProcess"
  46964. * @returns "ImageProcessingPostProcess"
  46965. */
  46966. getClassName(): string;
  46967. protected _updateParameters(): void;
  46968. dispose(camera?: Camera): void;
  46969. }
  46970. }
  46971. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  46972. import { Scene } from "babylonjs/scene";
  46973. import { Color3 } from "babylonjs/Maths/math.color";
  46974. import { Mesh } from "babylonjs/Meshes/mesh";
  46975. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  46976. import { Nullable } from "babylonjs/types";
  46977. /**
  46978. * Class containing static functions to help procedurally build meshes
  46979. */
  46980. export class GroundBuilder {
  46981. /**
  46982. * Creates a ground mesh
  46983. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46984. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46986. * @param name defines the name of the mesh
  46987. * @param options defines the options used to create the mesh
  46988. * @param scene defines the hosting scene
  46989. * @returns the ground mesh
  46990. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46991. */
  46992. static CreateGround(name: string, options: {
  46993. width?: number;
  46994. height?: number;
  46995. subdivisions?: number;
  46996. subdivisionsX?: number;
  46997. subdivisionsY?: number;
  46998. updatable?: boolean;
  46999. }, scene: any): Mesh;
  47000. /**
  47001. * Creates a tiled ground mesh
  47002. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47003. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47004. * * 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
  47005. * * 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
  47006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47007. * @param name defines the name of the mesh
  47008. * @param options defines the options used to create the mesh
  47009. * @param scene defines the hosting scene
  47010. * @returns the tiled ground mesh
  47011. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47012. */
  47013. static CreateTiledGround(name: string, options: {
  47014. xmin: number;
  47015. zmin: number;
  47016. xmax: number;
  47017. zmax: number;
  47018. subdivisions?: {
  47019. w: number;
  47020. h: number;
  47021. };
  47022. precision?: {
  47023. w: number;
  47024. h: number;
  47025. };
  47026. updatable?: boolean;
  47027. }, scene?: Nullable<Scene>): Mesh;
  47028. /**
  47029. * Creates a ground mesh from a height map
  47030. * * The parameter `url` sets the URL of the height map image resource.
  47031. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47032. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47033. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47034. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47035. * * 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.
  47036. * * 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).
  47037. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47039. * @param name defines the name of the mesh
  47040. * @param url defines the url to the height map
  47041. * @param options defines the options used to create the mesh
  47042. * @param scene defines the hosting scene
  47043. * @returns the ground mesh
  47044. * @see https://doc.babylonjs.com/babylon101/height_map
  47045. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47046. */
  47047. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47048. width?: number;
  47049. height?: number;
  47050. subdivisions?: number;
  47051. minHeight?: number;
  47052. maxHeight?: number;
  47053. colorFilter?: Color3;
  47054. alphaFilter?: number;
  47055. updatable?: boolean;
  47056. onReady?: (mesh: GroundMesh) => void;
  47057. }, scene?: Nullable<Scene>): GroundMesh;
  47058. }
  47059. }
  47060. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47061. import { Vector4 } from "babylonjs/Maths/math.vector";
  47062. import { Mesh } from "babylonjs/Meshes/mesh";
  47063. /**
  47064. * Class containing static functions to help procedurally build meshes
  47065. */
  47066. export class TorusBuilder {
  47067. /**
  47068. * Creates a torus mesh
  47069. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47070. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47071. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47075. * @param name defines the name of the mesh
  47076. * @param options defines the options used to create the mesh
  47077. * @param scene defines the hosting scene
  47078. * @returns the torus mesh
  47079. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47080. */
  47081. static CreateTorus(name: string, options: {
  47082. diameter?: number;
  47083. thickness?: number;
  47084. tessellation?: number;
  47085. updatable?: boolean;
  47086. sideOrientation?: number;
  47087. frontUVs?: Vector4;
  47088. backUVs?: Vector4;
  47089. }, scene: any): Mesh;
  47090. }
  47091. }
  47092. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47093. import { Vector4 } from "babylonjs/Maths/math.vector";
  47094. import { Color4 } from "babylonjs/Maths/math.color";
  47095. import { Mesh } from "babylonjs/Meshes/mesh";
  47096. /**
  47097. * Class containing static functions to help procedurally build meshes
  47098. */
  47099. export class CylinderBuilder {
  47100. /**
  47101. * Creates a cylinder or a cone mesh
  47102. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47103. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47104. * * 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.
  47105. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47106. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47107. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47108. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47109. * * 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).
  47110. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47111. * * 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).
  47112. * * 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
  47113. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47114. * * 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
  47115. * * 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.
  47116. * * If `enclose` is false, a ring surface is one element.
  47117. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47118. * * 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
  47119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47122. * @param name defines the name of the mesh
  47123. * @param options defines the options used to create the mesh
  47124. * @param scene defines the hosting scene
  47125. * @returns the cylinder mesh
  47126. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47127. */
  47128. static CreateCylinder(name: string, options: {
  47129. height?: number;
  47130. diameterTop?: number;
  47131. diameterBottom?: number;
  47132. diameter?: number;
  47133. tessellation?: number;
  47134. subdivisions?: number;
  47135. arc?: number;
  47136. faceColors?: Color4[];
  47137. faceUV?: Vector4[];
  47138. updatable?: boolean;
  47139. hasRings?: boolean;
  47140. enclose?: boolean;
  47141. cap?: number;
  47142. sideOrientation?: number;
  47143. frontUVs?: Vector4;
  47144. backUVs?: Vector4;
  47145. }, scene: any): Mesh;
  47146. }
  47147. }
  47148. declare module "babylonjs/XR/webXRTypes" {
  47149. import { Nullable } from "babylonjs/types";
  47150. import { IDisposable } from "babylonjs/scene";
  47151. /**
  47152. * States of the webXR experience
  47153. */
  47154. export enum WebXRState {
  47155. /**
  47156. * Transitioning to being in XR mode
  47157. */
  47158. ENTERING_XR = 0,
  47159. /**
  47160. * Transitioning to non XR mode
  47161. */
  47162. EXITING_XR = 1,
  47163. /**
  47164. * In XR mode and presenting
  47165. */
  47166. IN_XR = 2,
  47167. /**
  47168. * Not entered XR mode
  47169. */
  47170. NOT_IN_XR = 3
  47171. }
  47172. /**
  47173. * Abstraction of the XR render target
  47174. */
  47175. export interface WebXRRenderTarget extends IDisposable {
  47176. /**
  47177. * xrpresent context of the canvas which can be used to display/mirror xr content
  47178. */
  47179. canvasContext: WebGLRenderingContext;
  47180. /**
  47181. * xr layer for the canvas
  47182. */
  47183. xrLayer: Nullable<XRWebGLLayer>;
  47184. /**
  47185. * Initializes the xr layer for the session
  47186. * @param xrSession xr session
  47187. * @returns a promise that will resolve once the XR Layer has been created
  47188. */
  47189. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47190. }
  47191. }
  47192. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47193. import { Nullable } from "babylonjs/types";
  47194. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47195. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47196. /**
  47197. * COnfiguration object for WebXR output canvas
  47198. */
  47199. export class WebXRManagedOutputCanvasOptions {
  47200. /**
  47201. * An optional canvas in case you wish to create it yourself and provide it here.
  47202. * If not provided, a new canvas will be created
  47203. */
  47204. canvasElement?: HTMLCanvasElement;
  47205. /**
  47206. * Options for this XR Layer output
  47207. */
  47208. canvasOptions?: XRWebGLLayerOptions;
  47209. /**
  47210. * CSS styling for a newly created canvas (if not provided)
  47211. */
  47212. newCanvasCssStyle?: string;
  47213. /**
  47214. * Get the default values of the configuration object
  47215. * @returns default values of this configuration object
  47216. */
  47217. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47218. }
  47219. /**
  47220. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47221. */
  47222. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47223. private _options;
  47224. private _canvas;
  47225. private _engine;
  47226. /**
  47227. * Rendering context of the canvas which can be used to display/mirror xr content
  47228. */
  47229. canvasContext: WebGLRenderingContext;
  47230. /**
  47231. * xr layer for the canvas
  47232. */
  47233. xrLayer: Nullable<XRWebGLLayer>;
  47234. /**
  47235. * Initializes the canvas to be added/removed upon entering/exiting xr
  47236. * @param _xrSessionManager The XR Session manager
  47237. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47238. */
  47239. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47240. /**
  47241. * Disposes of the object
  47242. */
  47243. dispose(): void;
  47244. /**
  47245. * Initializes the xr layer for the session
  47246. * @param xrSession xr session
  47247. * @returns a promise that will resolve once the XR Layer has been created
  47248. */
  47249. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47250. private _addCanvas;
  47251. private _removeCanvas;
  47252. private _setManagedOutputCanvas;
  47253. }
  47254. }
  47255. declare module "babylonjs/XR/webXRSessionManager" {
  47256. import { Observable } from "babylonjs/Misc/observable";
  47257. import { Nullable } from "babylonjs/types";
  47258. import { IDisposable, Scene } from "babylonjs/scene";
  47259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47260. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47261. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47262. /**
  47263. * Manages an XRSession to work with Babylon's engine
  47264. * @see https://doc.babylonjs.com/how_to/webxr
  47265. */
  47266. export class WebXRSessionManager implements IDisposable {
  47267. /** The scene which the session should be created for */
  47268. scene: Scene;
  47269. private _referenceSpace;
  47270. private _rttProvider;
  47271. private _sessionEnded;
  47272. private _xrNavigator;
  47273. private baseLayer;
  47274. /**
  47275. * The base reference space from which the session started. good if you want to reset your
  47276. * reference space
  47277. */
  47278. baseReferenceSpace: XRReferenceSpace;
  47279. /**
  47280. * Current XR frame
  47281. */
  47282. currentFrame: Nullable<XRFrame>;
  47283. /** WebXR timestamp updated every frame */
  47284. currentTimestamp: number;
  47285. /**
  47286. * Used just in case of a failure to initialize an immersive session.
  47287. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47288. */
  47289. defaultHeightCompensation: number;
  47290. /**
  47291. * Fires every time a new xrFrame arrives which can be used to update the camera
  47292. */
  47293. onXRFrameObservable: Observable<XRFrame>;
  47294. /**
  47295. * Fires when the reference space changed
  47296. */
  47297. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47298. /**
  47299. * Fires when the xr session is ended either by the device or manually done
  47300. */
  47301. onXRSessionEnded: Observable<any>;
  47302. /**
  47303. * Fires when the xr session is ended either by the device or manually done
  47304. */
  47305. onXRSessionInit: Observable<XRSession>;
  47306. /**
  47307. * Underlying xr session
  47308. */
  47309. session: XRSession;
  47310. /**
  47311. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47312. * or get the offset the player is currently at.
  47313. */
  47314. viewerReferenceSpace: XRReferenceSpace;
  47315. /**
  47316. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47317. * @param scene The scene which the session should be created for
  47318. */
  47319. constructor(
  47320. /** The scene which the session should be created for */
  47321. scene: Scene);
  47322. /**
  47323. * The current reference space used in this session. This reference space can constantly change!
  47324. * It is mainly used to offset the camera's position.
  47325. */
  47326. get referenceSpace(): XRReferenceSpace;
  47327. /**
  47328. * Set a new reference space and triggers the observable
  47329. */
  47330. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47331. /**
  47332. * Disposes of the session manager
  47333. */
  47334. dispose(): void;
  47335. /**
  47336. * Stops the xrSession and restores the render loop
  47337. * @returns Promise which resolves after it exits XR
  47338. */
  47339. exitXRAsync(): Promise<void>;
  47340. /**
  47341. * Gets the correct render target texture to be rendered this frame for this eye
  47342. * @param eye the eye for which to get the render target
  47343. * @returns the render target for the specified eye
  47344. */
  47345. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47346. /**
  47347. * Creates a WebXRRenderTarget object for the XR session
  47348. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47349. * @param options optional options to provide when creating a new render target
  47350. * @returns a WebXR render target to which the session can render
  47351. */
  47352. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47353. /**
  47354. * Initializes the manager
  47355. * After initialization enterXR can be called to start an XR session
  47356. * @returns Promise which resolves after it is initialized
  47357. */
  47358. initializeAsync(): Promise<void>;
  47359. /**
  47360. * Initializes an xr session
  47361. * @param xrSessionMode mode to initialize
  47362. * @param xrSessionInit defines optional and required values to pass to the session builder
  47363. * @returns a promise which will resolve once the session has been initialized
  47364. */
  47365. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47366. /**
  47367. * Checks if a session would be supported for the creation options specified
  47368. * @param sessionMode session mode to check if supported eg. immersive-vr
  47369. * @returns A Promise that resolves to true if supported and false if not
  47370. */
  47371. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47372. /**
  47373. * Resets the reference space to the one started the session
  47374. */
  47375. resetReferenceSpace(): void;
  47376. /**
  47377. * Starts rendering to the xr layer
  47378. */
  47379. runXRRenderLoop(): void;
  47380. /**
  47381. * Sets the reference space on the xr session
  47382. * @param referenceSpaceType space to set
  47383. * @returns a promise that will resolve once the reference space has been set
  47384. */
  47385. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47386. /**
  47387. * Updates the render state of the session
  47388. * @param state state to set
  47389. * @returns a promise that resolves once the render state has been updated
  47390. */
  47391. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47392. /**
  47393. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47394. * @param sessionMode defines the session to test
  47395. * @returns a promise with boolean as final value
  47396. */
  47397. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47398. private _createRenderTargetTexture;
  47399. }
  47400. }
  47401. declare module "babylonjs/XR/webXRCamera" {
  47402. import { Matrix } from "babylonjs/Maths/math.vector";
  47403. import { Scene } from "babylonjs/scene";
  47404. import { Camera } from "babylonjs/Cameras/camera";
  47405. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47406. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47407. /**
  47408. * WebXR Camera which holds the views for the xrSession
  47409. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47410. */
  47411. export class WebXRCamera extends FreeCamera {
  47412. private _xrSessionManager;
  47413. private _firstFrame;
  47414. private _referenceQuaternion;
  47415. private _referencedPosition;
  47416. private _xrInvPositionCache;
  47417. private _xrInvQuaternionCache;
  47418. /**
  47419. * Should position compensation execute on first frame.
  47420. * This is used when copying the position from a native (non XR) camera
  47421. */
  47422. compensateOnFirstFrame: boolean;
  47423. /**
  47424. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47425. * @param name the name of the camera
  47426. * @param scene the scene to add the camera to
  47427. * @param _xrSessionManager a constructed xr session manager
  47428. */
  47429. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47430. /**
  47431. * Return the user's height, unrelated to the current ground.
  47432. * This will be the y position of this camera, when ground level is 0.
  47433. */
  47434. get realWorldHeight(): number;
  47435. /** @hidden */
  47436. _updateForDualEyeDebugging(): void;
  47437. /**
  47438. * Sets this camera's transformation based on a non-vr camera
  47439. * @param otherCamera the non-vr camera to copy the transformation from
  47440. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47441. */
  47442. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47443. /**
  47444. * Gets the current instance class name ("WebXRCamera").
  47445. * @returns the class name
  47446. */
  47447. getClassName(): string;
  47448. /**
  47449. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47450. */
  47451. _getViewMatrix(): Matrix;
  47452. private _updateFromXRSession;
  47453. private _updateNumberOfRigCameras;
  47454. private _updateReferenceSpace;
  47455. private _updateReferenceSpaceOffset;
  47456. }
  47457. }
  47458. declare module "babylonjs/XR/webXRFeaturesManager" {
  47459. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47460. import { IDisposable } from "babylonjs/scene";
  47461. /**
  47462. * Defining the interface required for a (webxr) feature
  47463. */
  47464. export interface IWebXRFeature extends IDisposable {
  47465. /**
  47466. * Is this feature attached
  47467. */
  47468. attached: boolean;
  47469. /**
  47470. * Should auto-attach be disabled?
  47471. */
  47472. disableAutoAttach: boolean;
  47473. /**
  47474. * Attach the feature to the session
  47475. * Will usually be called by the features manager
  47476. *
  47477. * @param force should attachment be forced (even when already attached)
  47478. * @returns true if successful.
  47479. */
  47480. attach(force?: boolean): boolean;
  47481. /**
  47482. * Detach the feature from the session
  47483. * Will usually be called by the features manager
  47484. *
  47485. * @returns true if successful.
  47486. */
  47487. detach(): boolean;
  47488. }
  47489. /**
  47490. * A list of the currently available features without referencing them
  47491. */
  47492. export class WebXRFeatureName {
  47493. /**
  47494. * The name of the anchor system feature
  47495. */
  47496. static ANCHOR_SYSTEM: string;
  47497. /**
  47498. * The name of the background remover feature
  47499. */
  47500. static BACKGROUND_REMOVER: string;
  47501. /**
  47502. * The name of the hit test feature
  47503. */
  47504. static HIT_TEST: string;
  47505. /**
  47506. * physics impostors for xr controllers feature
  47507. */
  47508. static PHYSICS_CONTROLLERS: string;
  47509. /**
  47510. * The name of the plane detection feature
  47511. */
  47512. static PLANE_DETECTION: string;
  47513. /**
  47514. * The name of the pointer selection feature
  47515. */
  47516. static POINTER_SELECTION: string;
  47517. /**
  47518. * The name of the teleportation feature
  47519. */
  47520. static TELEPORTATION: string;
  47521. }
  47522. /**
  47523. * Defining the constructor of a feature. Used to register the modules.
  47524. */
  47525. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47526. /**
  47527. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47528. * It is mainly used in AR sessions.
  47529. *
  47530. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47531. */
  47532. export class WebXRFeaturesManager implements IDisposable {
  47533. private _xrSessionManager;
  47534. private static readonly _AvailableFeatures;
  47535. private _features;
  47536. /**
  47537. * constructs a new features manages.
  47538. *
  47539. * @param _xrSessionManager an instance of WebXRSessionManager
  47540. */
  47541. constructor(_xrSessionManager: WebXRSessionManager);
  47542. /**
  47543. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47544. * Mainly used internally.
  47545. *
  47546. * @param featureName the name of the feature to register
  47547. * @param constructorFunction the function used to construct the module
  47548. * @param version the (babylon) version of the module
  47549. * @param stable is that a stable version of this module
  47550. */
  47551. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47552. /**
  47553. * Returns a constructor of a specific feature.
  47554. *
  47555. * @param featureName the name of the feature to construct
  47556. * @param version the version of the feature to load
  47557. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47558. * @param options optional options provided to the module.
  47559. * @returns a function that, when called, will return a new instance of this feature
  47560. */
  47561. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47562. /**
  47563. * Can be used to return the list of features currently registered
  47564. *
  47565. * @returns an Array of available features
  47566. */
  47567. static GetAvailableFeatures(): string[];
  47568. /**
  47569. * Gets the versions available for a specific feature
  47570. * @param featureName the name of the feature
  47571. * @returns an array with the available versions
  47572. */
  47573. static GetAvailableVersions(featureName: string): string[];
  47574. /**
  47575. * Return the latest unstable version of this feature
  47576. * @param featureName the name of the feature to search
  47577. * @returns the version number. if not found will return -1
  47578. */
  47579. static GetLatestVersionOfFeature(featureName: string): number;
  47580. /**
  47581. * Return the latest stable version of this feature
  47582. * @param featureName the name of the feature to search
  47583. * @returns the version number. if not found will return -1
  47584. */
  47585. static GetStableVersionOfFeature(featureName: string): number;
  47586. /**
  47587. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47588. * Can be used during a session to start a feature
  47589. * @param featureName the name of feature to attach
  47590. */
  47591. attachFeature(featureName: string): void;
  47592. /**
  47593. * Can be used inside a session or when the session ends to detach a specific feature
  47594. * @param featureName the name of the feature to detach
  47595. */
  47596. detachFeature(featureName: string): void;
  47597. /**
  47598. * Used to disable an already-enabled feature
  47599. * The feature will be disposed and will be recreated once enabled.
  47600. * @param featureName the feature to disable
  47601. * @returns true if disable was successful
  47602. */
  47603. disableFeature(featureName: string | {
  47604. Name: string;
  47605. }): boolean;
  47606. /**
  47607. * dispose this features manager
  47608. */
  47609. dispose(): void;
  47610. /**
  47611. * 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.
  47612. * 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.
  47613. *
  47614. * @param featureName the name of the feature to load or the class of the feature
  47615. * @param version optional version to load. if not provided the latest version will be enabled
  47616. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47617. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47618. * @returns a new constructed feature or throws an error if feature not found.
  47619. */
  47620. enableFeature(featureName: string | {
  47621. Name: string;
  47622. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47623. /**
  47624. * get the implementation of an enabled feature.
  47625. * @param featureName the name of the feature to load
  47626. * @returns the feature class, if found
  47627. */
  47628. getEnabledFeature(featureName: string): IWebXRFeature;
  47629. /**
  47630. * Get the list of enabled features
  47631. * @returns an array of enabled features
  47632. */
  47633. getEnabledFeatures(): string[];
  47634. }
  47635. }
  47636. declare module "babylonjs/XR/webXRExperienceHelper" {
  47637. import { Observable } from "babylonjs/Misc/observable";
  47638. import { IDisposable, Scene } from "babylonjs/scene";
  47639. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47640. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47641. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47642. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47643. /**
  47644. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47645. * @see https://doc.babylonjs.com/how_to/webxr
  47646. */
  47647. export class WebXRExperienceHelper implements IDisposable {
  47648. private scene;
  47649. private _nonVRCamera;
  47650. private _originalSceneAutoClear;
  47651. private _supported;
  47652. /**
  47653. * Camera used to render xr content
  47654. */
  47655. camera: WebXRCamera;
  47656. /** A features manager for this xr session */
  47657. featuresManager: WebXRFeaturesManager;
  47658. /**
  47659. * Observers registered here will be triggered after the camera's initial transformation is set
  47660. * This can be used to set a different ground level or an extra rotation.
  47661. *
  47662. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47663. * to the position set after this observable is done executing.
  47664. */
  47665. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47666. /**
  47667. * Fires when the state of the experience helper has changed
  47668. */
  47669. onStateChangedObservable: Observable<WebXRState>;
  47670. /** Session manager used to keep track of xr session */
  47671. sessionManager: WebXRSessionManager;
  47672. /**
  47673. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47674. */
  47675. state: WebXRState;
  47676. /**
  47677. * Creates a WebXRExperienceHelper
  47678. * @param scene The scene the helper should be created in
  47679. */
  47680. private constructor();
  47681. /**
  47682. * Creates the experience helper
  47683. * @param scene the scene to attach the experience helper to
  47684. * @returns a promise for the experience helper
  47685. */
  47686. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47687. /**
  47688. * Disposes of the experience helper
  47689. */
  47690. dispose(): void;
  47691. /**
  47692. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47693. * @param sessionMode options for the XR session
  47694. * @param referenceSpaceType frame of reference of the XR session
  47695. * @param renderTarget the output canvas that will be used to enter XR mode
  47696. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47697. * @returns promise that resolves after xr mode has entered
  47698. */
  47699. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47700. /**
  47701. * Exits XR mode and returns the scene to its original state
  47702. * @returns promise that resolves after xr mode has exited
  47703. */
  47704. exitXRAsync(): Promise<void>;
  47705. private _nonXRToXRCamera;
  47706. private _setState;
  47707. }
  47708. }
  47709. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47710. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47711. import { Observable } from "babylonjs/Misc/observable";
  47712. import { IDisposable } from "babylonjs/scene";
  47713. /**
  47714. * X-Y values for axes in WebXR
  47715. */
  47716. export interface IWebXRMotionControllerAxesValue {
  47717. /**
  47718. * The value of the x axis
  47719. */
  47720. x: number;
  47721. /**
  47722. * The value of the y-axis
  47723. */
  47724. y: number;
  47725. }
  47726. /**
  47727. * changed / previous values for the values of this component
  47728. */
  47729. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47730. /**
  47731. * current (this frame) value
  47732. */
  47733. current: T;
  47734. /**
  47735. * previous (last change) value
  47736. */
  47737. previous: T;
  47738. }
  47739. /**
  47740. * Represents changes in the component between current frame and last values recorded
  47741. */
  47742. export interface IWebXRMotionControllerComponentChanges {
  47743. /**
  47744. * will be populated with previous and current values if axes changed
  47745. */
  47746. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47747. /**
  47748. * will be populated with previous and current values if pressed changed
  47749. */
  47750. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47751. /**
  47752. * will be populated with previous and current values if touched changed
  47753. */
  47754. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47755. /**
  47756. * will be populated with previous and current values if value changed
  47757. */
  47758. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47759. }
  47760. /**
  47761. * This class represents a single component (for example button or thumbstick) of a motion controller
  47762. */
  47763. export class WebXRControllerComponent implements IDisposable {
  47764. /**
  47765. * the id of this component
  47766. */
  47767. id: string;
  47768. /**
  47769. * the type of the component
  47770. */
  47771. type: MotionControllerComponentType;
  47772. private _buttonIndex;
  47773. private _axesIndices;
  47774. private _axes;
  47775. private _changes;
  47776. private _currentValue;
  47777. private _hasChanges;
  47778. private _pressed;
  47779. private _touched;
  47780. /**
  47781. * button component type
  47782. */
  47783. static BUTTON_TYPE: MotionControllerComponentType;
  47784. /**
  47785. * squeeze component type
  47786. */
  47787. static SQUEEZE_TYPE: MotionControllerComponentType;
  47788. /**
  47789. * Thumbstick component type
  47790. */
  47791. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47792. /**
  47793. * Touchpad component type
  47794. */
  47795. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47796. /**
  47797. * trigger component type
  47798. */
  47799. static TRIGGER_TYPE: MotionControllerComponentType;
  47800. /**
  47801. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47802. * the axes data changes
  47803. */
  47804. onAxisValueChangedObservable: Observable<{
  47805. x: number;
  47806. y: number;
  47807. }>;
  47808. /**
  47809. * Observers registered here will be triggered when the state of a button changes
  47810. * State change is either pressed / touched / value
  47811. */
  47812. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47813. /**
  47814. * Creates a new component for a motion controller.
  47815. * It is created by the motion controller itself
  47816. *
  47817. * @param id the id of this component
  47818. * @param type the type of the component
  47819. * @param _buttonIndex index in the buttons array of the gamepad
  47820. * @param _axesIndices indices of the values in the axes array of the gamepad
  47821. */
  47822. constructor(
  47823. /**
  47824. * the id of this component
  47825. */
  47826. id: string,
  47827. /**
  47828. * the type of the component
  47829. */
  47830. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47831. /**
  47832. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47833. */
  47834. get axes(): IWebXRMotionControllerAxesValue;
  47835. /**
  47836. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47837. */
  47838. get changes(): IWebXRMotionControllerComponentChanges;
  47839. /**
  47840. * Return whether or not the component changed the last frame
  47841. */
  47842. get hasChanges(): boolean;
  47843. /**
  47844. * is the button currently pressed
  47845. */
  47846. get pressed(): boolean;
  47847. /**
  47848. * is the button currently touched
  47849. */
  47850. get touched(): boolean;
  47851. /**
  47852. * Get the current value of this component
  47853. */
  47854. get value(): number;
  47855. /**
  47856. * Dispose this component
  47857. */
  47858. dispose(): void;
  47859. /**
  47860. * Are there axes correlating to this component
  47861. * @return true is axes data is available
  47862. */
  47863. isAxes(): boolean;
  47864. /**
  47865. * Is this component a button (hence - pressable)
  47866. * @returns true if can be pressed
  47867. */
  47868. isButton(): boolean;
  47869. /**
  47870. * update this component using the gamepad object it is in. Called on every frame
  47871. * @param nativeController the native gamepad controller object
  47872. */
  47873. update(nativeController: IMinimalMotionControllerObject): void;
  47874. }
  47875. }
  47876. declare module "babylonjs/Loading/sceneLoader" {
  47877. import { Observable } from "babylonjs/Misc/observable";
  47878. import { Nullable } from "babylonjs/types";
  47879. import { Scene } from "babylonjs/scene";
  47880. import { Engine } from "babylonjs/Engines/engine";
  47881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47882. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47883. import { AssetContainer } from "babylonjs/assetContainer";
  47884. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47885. import { Skeleton } from "babylonjs/Bones/skeleton";
  47886. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47887. import { WebRequest } from "babylonjs/Misc/webRequest";
  47888. /**
  47889. * Class used to represent data loading progression
  47890. */
  47891. export class SceneLoaderProgressEvent {
  47892. /** defines if data length to load can be evaluated */
  47893. readonly lengthComputable: boolean;
  47894. /** defines the loaded data length */
  47895. readonly loaded: number;
  47896. /** defines the data length to load */
  47897. readonly total: number;
  47898. /**
  47899. * Create a new progress event
  47900. * @param lengthComputable defines if data length to load can be evaluated
  47901. * @param loaded defines the loaded data length
  47902. * @param total defines the data length to load
  47903. */
  47904. constructor(
  47905. /** defines if data length to load can be evaluated */
  47906. lengthComputable: boolean,
  47907. /** defines the loaded data length */
  47908. loaded: number,
  47909. /** defines the data length to load */
  47910. total: number);
  47911. /**
  47912. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  47913. * @param event defines the source event
  47914. * @returns a new SceneLoaderProgressEvent
  47915. */
  47916. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  47917. }
  47918. /**
  47919. * Interface used by SceneLoader plugins to define supported file extensions
  47920. */
  47921. export interface ISceneLoaderPluginExtensions {
  47922. /**
  47923. * Defines the list of supported extensions
  47924. */
  47925. [extension: string]: {
  47926. isBinary: boolean;
  47927. };
  47928. }
  47929. /**
  47930. * Interface used by SceneLoader plugin factory
  47931. */
  47932. export interface ISceneLoaderPluginFactory {
  47933. /**
  47934. * Defines the name of the factory
  47935. */
  47936. name: string;
  47937. /**
  47938. * Function called to create a new plugin
  47939. * @return the new plugin
  47940. */
  47941. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47942. /**
  47943. * The callback that returns true if the data can be directly loaded.
  47944. * @param data string containing the file data
  47945. * @returns if the data can be loaded directly
  47946. */
  47947. canDirectLoad?(data: string): boolean;
  47948. }
  47949. /**
  47950. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47951. */
  47952. export interface ISceneLoaderPluginBase {
  47953. /**
  47954. * The friendly name of this plugin.
  47955. */
  47956. name: string;
  47957. /**
  47958. * The file extensions supported by this plugin.
  47959. */
  47960. extensions: string | ISceneLoaderPluginExtensions;
  47961. /**
  47962. * The callback called when loading from a url.
  47963. * @param scene scene loading this url
  47964. * @param url url to load
  47965. * @param onSuccess callback called when the file successfully loads
  47966. * @param onProgress callback called while file is loading (if the server supports this mode)
  47967. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47968. * @param onError callback called when the file fails to load
  47969. * @returns a file request object
  47970. */
  47971. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47972. /**
  47973. * The callback called when loading from a file object.
  47974. * @param scene scene loading this file
  47975. * @param file defines the file to load
  47976. * @param onSuccess defines the callback to call when data is loaded
  47977. * @param onProgress defines the callback to call during loading process
  47978. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47979. * @param onError defines the callback to call when an error occurs
  47980. * @returns a file request object
  47981. */
  47982. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47983. /**
  47984. * The callback that returns true if the data can be directly loaded.
  47985. * @param data string containing the file data
  47986. * @returns if the data can be loaded directly
  47987. */
  47988. canDirectLoad?(data: string): boolean;
  47989. /**
  47990. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47991. * @param scene scene loading this data
  47992. * @param data string containing the data
  47993. * @returns data to pass to the plugin
  47994. */
  47995. directLoad?(scene: Scene, data: string): any;
  47996. /**
  47997. * The callback that allows custom handling of the root url based on the response url.
  47998. * @param rootUrl the original root url
  47999. * @param responseURL the response url if available
  48000. * @returns the new root url
  48001. */
  48002. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48003. }
  48004. /**
  48005. * Interface used to define a SceneLoader plugin
  48006. */
  48007. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48008. /**
  48009. * Import meshes into a scene.
  48010. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48011. * @param scene The scene to import into
  48012. * @param data The data to import
  48013. * @param rootUrl The root url for scene and resources
  48014. * @param meshes The meshes array to import into
  48015. * @param particleSystems The particle systems array to import into
  48016. * @param skeletons The skeletons array to import into
  48017. * @param onError The callback when import fails
  48018. * @returns True if successful or false otherwise
  48019. */
  48020. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48021. /**
  48022. * Load into a scene.
  48023. * @param scene The scene to load into
  48024. * @param data The data to import
  48025. * @param rootUrl The root url for scene and resources
  48026. * @param onError The callback when import fails
  48027. * @returns True if successful or false otherwise
  48028. */
  48029. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48030. /**
  48031. * Load into an asset container.
  48032. * @param scene The scene to load into
  48033. * @param data The data to import
  48034. * @param rootUrl The root url for scene and resources
  48035. * @param onError The callback when import fails
  48036. * @returns The loaded asset container
  48037. */
  48038. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48039. }
  48040. /**
  48041. * Interface used to define an async SceneLoader plugin
  48042. */
  48043. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48044. /**
  48045. * Import meshes into a scene.
  48046. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48047. * @param scene The scene to import into
  48048. * @param data The data to import
  48049. * @param rootUrl The root url for scene and resources
  48050. * @param onProgress The callback when the load progresses
  48051. * @param fileName Defines the name of the file to load
  48052. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48053. */
  48054. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48055. meshes: AbstractMesh[];
  48056. particleSystems: IParticleSystem[];
  48057. skeletons: Skeleton[];
  48058. animationGroups: AnimationGroup[];
  48059. }>;
  48060. /**
  48061. * Load into a scene.
  48062. * @param scene The scene to load into
  48063. * @param data The data to import
  48064. * @param rootUrl The root url for scene and resources
  48065. * @param onProgress The callback when the load progresses
  48066. * @param fileName Defines the name of the file to load
  48067. * @returns Nothing
  48068. */
  48069. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48070. /**
  48071. * Load into an asset container.
  48072. * @param scene The scene to load into
  48073. * @param data The data to import
  48074. * @param rootUrl The root url for scene and resources
  48075. * @param onProgress The callback when the load progresses
  48076. * @param fileName Defines the name of the file to load
  48077. * @returns The loaded asset container
  48078. */
  48079. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48080. }
  48081. /**
  48082. * Mode that determines how to handle old animation groups before loading new ones.
  48083. */
  48084. export enum SceneLoaderAnimationGroupLoadingMode {
  48085. /**
  48086. * Reset all old animations to initial state then dispose them.
  48087. */
  48088. Clean = 0,
  48089. /**
  48090. * Stop all old animations.
  48091. */
  48092. Stop = 1,
  48093. /**
  48094. * Restart old animations from first frame.
  48095. */
  48096. Sync = 2,
  48097. /**
  48098. * Old animations remains untouched.
  48099. */
  48100. NoSync = 3
  48101. }
  48102. /**
  48103. * Class used to load scene from various file formats using registered plugins
  48104. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48105. */
  48106. export class SceneLoader {
  48107. /**
  48108. * No logging while loading
  48109. */
  48110. static readonly NO_LOGGING: number;
  48111. /**
  48112. * Minimal logging while loading
  48113. */
  48114. static readonly MINIMAL_LOGGING: number;
  48115. /**
  48116. * Summary logging while loading
  48117. */
  48118. static readonly SUMMARY_LOGGING: number;
  48119. /**
  48120. * Detailled logging while loading
  48121. */
  48122. static readonly DETAILED_LOGGING: number;
  48123. /**
  48124. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48125. */
  48126. static get ForceFullSceneLoadingForIncremental(): boolean;
  48127. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48128. /**
  48129. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48130. */
  48131. static get ShowLoadingScreen(): boolean;
  48132. static set ShowLoadingScreen(value: boolean);
  48133. /**
  48134. * Defines the current logging level (while loading the scene)
  48135. * @ignorenaming
  48136. */
  48137. static get loggingLevel(): number;
  48138. static set loggingLevel(value: number);
  48139. /**
  48140. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48141. */
  48142. static get CleanBoneMatrixWeights(): boolean;
  48143. static set CleanBoneMatrixWeights(value: boolean);
  48144. /**
  48145. * Event raised when a plugin is used to load a scene
  48146. */
  48147. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48148. private static _registeredPlugins;
  48149. private static _getDefaultPlugin;
  48150. private static _getPluginForExtension;
  48151. private static _getPluginForDirectLoad;
  48152. private static _getPluginForFilename;
  48153. private static _getDirectLoad;
  48154. private static _loadData;
  48155. private static _getFileInfo;
  48156. /**
  48157. * Gets a plugin that can load the given extension
  48158. * @param extension defines the extension to load
  48159. * @returns a plugin or null if none works
  48160. */
  48161. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48162. /**
  48163. * Gets a boolean indicating that the given extension can be loaded
  48164. * @param extension defines the extension to load
  48165. * @returns true if the extension is supported
  48166. */
  48167. static IsPluginForExtensionAvailable(extension: string): boolean;
  48168. /**
  48169. * Adds a new plugin to the list of registered plugins
  48170. * @param plugin defines the plugin to add
  48171. */
  48172. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48173. /**
  48174. * Import meshes into a scene
  48175. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48176. * @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)
  48177. * @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)
  48178. * @param scene the instance of BABYLON.Scene to append to
  48179. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48180. * @param onProgress a callback with a progress event for each file being loaded
  48181. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48182. * @param pluginExtension the extension used to determine the plugin
  48183. * @returns The loaded plugin
  48184. */
  48185. 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>;
  48186. /**
  48187. * Import meshes into a scene
  48188. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48189. * @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)
  48190. * @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)
  48191. * @param scene the instance of BABYLON.Scene to append to
  48192. * @param onProgress a callback with a progress event for each file being loaded
  48193. * @param pluginExtension the extension used to determine the plugin
  48194. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48195. */
  48196. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48197. meshes: AbstractMesh[];
  48198. particleSystems: IParticleSystem[];
  48199. skeletons: Skeleton[];
  48200. animationGroups: AnimationGroup[];
  48201. }>;
  48202. /**
  48203. * Load a scene
  48204. * @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)
  48205. * @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)
  48206. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48207. * @param onSuccess a callback with the scene when import succeeds
  48208. * @param onProgress a callback with a progress event for each file being loaded
  48209. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48210. * @param pluginExtension the extension used to determine the plugin
  48211. * @returns The loaded plugin
  48212. */
  48213. 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>;
  48214. /**
  48215. * Load a scene
  48216. * @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)
  48217. * @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)
  48218. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48219. * @param onProgress a callback with a progress event for each file being loaded
  48220. * @param pluginExtension the extension used to determine the plugin
  48221. * @returns The loaded scene
  48222. */
  48223. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48224. /**
  48225. * Append a scene
  48226. * @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)
  48227. * @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)
  48228. * @param scene is the instance of BABYLON.Scene to append to
  48229. * @param onSuccess a callback with the scene when import succeeds
  48230. * @param onProgress a callback with a progress event for each file being loaded
  48231. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48232. * @param pluginExtension the extension used to determine the plugin
  48233. * @returns The loaded plugin
  48234. */
  48235. 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>;
  48236. /**
  48237. * Append a scene
  48238. * @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)
  48239. * @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)
  48240. * @param scene is the instance of BABYLON.Scene to append to
  48241. * @param onProgress a callback with a progress event for each file being loaded
  48242. * @param pluginExtension the extension used to determine the plugin
  48243. * @returns The given scene
  48244. */
  48245. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48246. /**
  48247. * Load a scene into an asset container
  48248. * @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)
  48249. * @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)
  48250. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48251. * @param onSuccess a callback with the scene when import succeeds
  48252. * @param onProgress a callback with a progress event for each file being loaded
  48253. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48254. * @param pluginExtension the extension used to determine the plugin
  48255. * @returns The loaded plugin
  48256. */
  48257. 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>;
  48258. /**
  48259. * Load a scene into an asset container
  48260. * @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)
  48261. * @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)
  48262. * @param scene is the instance of Scene to append to
  48263. * @param onProgress a callback with a progress event for each file being loaded
  48264. * @param pluginExtension the extension used to determine the plugin
  48265. * @returns The loaded asset container
  48266. */
  48267. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48268. /**
  48269. * Import animations from a file into a scene
  48270. * @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)
  48271. * @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)
  48272. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48273. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48274. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48275. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48276. * @param onSuccess a callback with the scene when import succeeds
  48277. * @param onProgress a callback with a progress event for each file being loaded
  48278. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48279. */
  48280. 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;
  48281. /**
  48282. * Import animations from a file into a scene
  48283. * @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)
  48284. * @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)
  48285. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48286. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48287. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48288. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48289. * @param onSuccess a callback with the scene when import succeeds
  48290. * @param onProgress a callback with a progress event for each file being loaded
  48291. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48292. * @returns the updated scene with imported animations
  48293. */
  48294. 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>;
  48295. }
  48296. }
  48297. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48298. import { IDisposable, Scene } from "babylonjs/scene";
  48299. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48300. import { Observable } from "babylonjs/Misc/observable";
  48301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48302. import { Nullable } from "babylonjs/types";
  48303. /**
  48304. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48305. */
  48306. export type MotionControllerHandedness = "none" | "left" | "right";
  48307. /**
  48308. * The type of components available in motion controllers.
  48309. * This is not the name of the component.
  48310. */
  48311. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48312. /**
  48313. * The state of a controller component
  48314. */
  48315. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48316. /**
  48317. * The schema of motion controller layout.
  48318. * No object will be initialized using this interface
  48319. * This is used just to define the profile.
  48320. */
  48321. export interface IMotionControllerLayout {
  48322. /**
  48323. * Path to load the assets. Usually relative to the base path
  48324. */
  48325. assetPath: string;
  48326. /**
  48327. * Available components (unsorted)
  48328. */
  48329. components: {
  48330. /**
  48331. * A map of component Ids
  48332. */
  48333. [componentId: string]: {
  48334. /**
  48335. * The type of input the component outputs
  48336. */
  48337. type: MotionControllerComponentType;
  48338. /**
  48339. * The indices of this component in the gamepad object
  48340. */
  48341. gamepadIndices: {
  48342. /**
  48343. * Index of button
  48344. */
  48345. button?: number;
  48346. /**
  48347. * If available, index of x-axis
  48348. */
  48349. xAxis?: number;
  48350. /**
  48351. * If available, index of y-axis
  48352. */
  48353. yAxis?: number;
  48354. };
  48355. /**
  48356. * The mesh's root node name
  48357. */
  48358. rootNodeName: string;
  48359. /**
  48360. * Animation definitions for this model
  48361. */
  48362. visualResponses: {
  48363. [stateKey: string]: {
  48364. /**
  48365. * What property will be animated
  48366. */
  48367. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48368. /**
  48369. * What states influence this visual response
  48370. */
  48371. states: MotionControllerComponentStateType[];
  48372. /**
  48373. * Type of animation - movement or visibility
  48374. */
  48375. valueNodeProperty: "transform" | "visibility";
  48376. /**
  48377. * Base node name to move. Its position will be calculated according to the min and max nodes
  48378. */
  48379. valueNodeName?: string;
  48380. /**
  48381. * Minimum movement node
  48382. */
  48383. minNodeName?: string;
  48384. /**
  48385. * Max movement node
  48386. */
  48387. maxNodeName?: string;
  48388. };
  48389. };
  48390. /**
  48391. * If touch enabled, what is the name of node to display user feedback
  48392. */
  48393. touchPointNodeName?: string;
  48394. };
  48395. };
  48396. /**
  48397. * Is it xr standard mapping or not
  48398. */
  48399. gamepadMapping: "" | "xr-standard";
  48400. /**
  48401. * Base root node of this entire model
  48402. */
  48403. rootNodeName: string;
  48404. /**
  48405. * Defines the main button component id
  48406. */
  48407. selectComponentId: string;
  48408. }
  48409. /**
  48410. * A definition for the layout map in the input profile
  48411. */
  48412. export interface IMotionControllerLayoutMap {
  48413. /**
  48414. * Layouts with handedness type as a key
  48415. */
  48416. [handedness: string]: IMotionControllerLayout;
  48417. }
  48418. /**
  48419. * The XR Input profile schema
  48420. * Profiles can be found here:
  48421. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48422. */
  48423. export interface IMotionControllerProfile {
  48424. /**
  48425. * fallback profiles for this profileId
  48426. */
  48427. fallbackProfileIds: string[];
  48428. /**
  48429. * The layout map, with handedness as key
  48430. */
  48431. layouts: IMotionControllerLayoutMap;
  48432. /**
  48433. * The id of this profile
  48434. * correlates to the profile(s) in the xrInput.profiles array
  48435. */
  48436. profileId: string;
  48437. }
  48438. /**
  48439. * A helper-interface for the 3 meshes needed for controller button animation
  48440. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48441. */
  48442. export interface IMotionControllerButtonMeshMap {
  48443. /**
  48444. * the mesh that defines the pressed value mesh position.
  48445. * This is used to find the max-position of this button
  48446. */
  48447. pressedMesh: AbstractMesh;
  48448. /**
  48449. * the mesh that defines the unpressed value mesh position.
  48450. * This is used to find the min (or initial) position of this button
  48451. */
  48452. unpressedMesh: AbstractMesh;
  48453. /**
  48454. * The mesh that will be changed when value changes
  48455. */
  48456. valueMesh: AbstractMesh;
  48457. }
  48458. /**
  48459. * A helper-interface for the 3 meshes needed for controller axis animation.
  48460. * This will be expanded when touchpad animations are fully supported
  48461. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48462. */
  48463. export interface IMotionControllerMeshMap {
  48464. /**
  48465. * the mesh that defines the maximum value mesh position.
  48466. */
  48467. maxMesh?: AbstractMesh;
  48468. /**
  48469. * the mesh that defines the minimum value mesh position.
  48470. */
  48471. minMesh?: AbstractMesh;
  48472. /**
  48473. * The mesh that will be changed when axis value changes
  48474. */
  48475. valueMesh: AbstractMesh;
  48476. }
  48477. /**
  48478. * The elements needed for change-detection of the gamepad objects in motion controllers
  48479. */
  48480. export interface IMinimalMotionControllerObject {
  48481. /**
  48482. * Available axes of this controller
  48483. */
  48484. axes: number[];
  48485. /**
  48486. * An array of available buttons
  48487. */
  48488. buttons: Array<{
  48489. /**
  48490. * Value of the button/trigger
  48491. */
  48492. value: number;
  48493. /**
  48494. * If the button/trigger is currently touched
  48495. */
  48496. touched: boolean;
  48497. /**
  48498. * If the button/trigger is currently pressed
  48499. */
  48500. pressed: boolean;
  48501. }>;
  48502. /**
  48503. * EXPERIMENTAL haptic support.
  48504. */
  48505. hapticActuators?: Array<{
  48506. pulse: (value: number, duration: number) => Promise<boolean>;
  48507. }>;
  48508. }
  48509. /**
  48510. * An Abstract Motion controller
  48511. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48512. * Each component has an observable to check for changes in value and state
  48513. */
  48514. export abstract class WebXRAbstractMotionController implements IDisposable {
  48515. protected scene: Scene;
  48516. protected layout: IMotionControllerLayout;
  48517. /**
  48518. * The gamepad object correlating to this controller
  48519. */
  48520. gamepadObject: IMinimalMotionControllerObject;
  48521. /**
  48522. * handedness (left/right/none) of this controller
  48523. */
  48524. handedness: MotionControllerHandedness;
  48525. private _initComponent;
  48526. private _modelReady;
  48527. /**
  48528. * A map of components (WebXRControllerComponent) in this motion controller
  48529. * Components have a ComponentType and can also have both button and axis definitions
  48530. */
  48531. readonly components: {
  48532. [id: string]: WebXRControllerComponent;
  48533. };
  48534. /**
  48535. * Disable the model's animation. Can be set at any time.
  48536. */
  48537. disableAnimation: boolean;
  48538. /**
  48539. * Observers registered here will be triggered when the model of this controller is done loading
  48540. */
  48541. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48542. /**
  48543. * The profile id of this motion controller
  48544. */
  48545. abstract profileId: string;
  48546. /**
  48547. * The root mesh of the model. It is null if the model was not yet initialized
  48548. */
  48549. rootMesh: Nullable<AbstractMesh>;
  48550. /**
  48551. * constructs a new abstract motion controller
  48552. * @param scene the scene to which the model of the controller will be added
  48553. * @param layout The profile layout to load
  48554. * @param gamepadObject The gamepad object correlating to this controller
  48555. * @param handedness handedness (left/right/none) of this controller
  48556. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48557. */
  48558. constructor(scene: Scene, layout: IMotionControllerLayout,
  48559. /**
  48560. * The gamepad object correlating to this controller
  48561. */
  48562. gamepadObject: IMinimalMotionControllerObject,
  48563. /**
  48564. * handedness (left/right/none) of this controller
  48565. */
  48566. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48567. /**
  48568. * Dispose this controller, the model mesh and all its components
  48569. */
  48570. dispose(): void;
  48571. /**
  48572. * Returns all components of specific type
  48573. * @param type the type to search for
  48574. * @return an array of components with this type
  48575. */
  48576. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48577. /**
  48578. * get a component based an its component id as defined in layout.components
  48579. * @param id the id of the component
  48580. * @returns the component correlates to the id or undefined if not found
  48581. */
  48582. getComponent(id: string): WebXRControllerComponent;
  48583. /**
  48584. * Get the list of components available in this motion controller
  48585. * @returns an array of strings correlating to available components
  48586. */
  48587. getComponentIds(): string[];
  48588. /**
  48589. * Get the first component of specific type
  48590. * @param type type of component to find
  48591. * @return a controller component or null if not found
  48592. */
  48593. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48594. /**
  48595. * Get the main (Select) component of this controller as defined in the layout
  48596. * @returns the main component of this controller
  48597. */
  48598. getMainComponent(): WebXRControllerComponent;
  48599. /**
  48600. * Loads the model correlating to this controller
  48601. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48602. * @returns A promise fulfilled with the result of the model loading
  48603. */
  48604. loadModel(): Promise<boolean>;
  48605. /**
  48606. * Update this model using the current XRFrame
  48607. * @param xrFrame the current xr frame to use and update the model
  48608. */
  48609. updateFromXRFrame(xrFrame: XRFrame): void;
  48610. /**
  48611. * Backwards compatibility due to a deeply-integrated typo
  48612. */
  48613. get handness(): XREye;
  48614. /**
  48615. * Pulse (vibrate) this controller
  48616. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48617. * Consecutive calls to this function will cancel the last pulse call
  48618. *
  48619. * @param value the strength of the pulse in 0.0...1.0 range
  48620. * @param duration Duration of the pulse in milliseconds
  48621. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48622. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  48623. */
  48624. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48625. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48626. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48627. /**
  48628. * Moves the axis on the controller mesh based on its current state
  48629. * @param axis the index of the axis
  48630. * @param axisValue the value of the axis which determines the meshes new position
  48631. * @hidden
  48632. */
  48633. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48634. /**
  48635. * Update the model itself with the current frame data
  48636. * @param xrFrame the frame to use for updating the model mesh
  48637. */
  48638. protected updateModel(xrFrame: XRFrame): void;
  48639. /**
  48640. * Get the filename and path for this controller's model
  48641. * @returns a map of filename and path
  48642. */
  48643. protected abstract _getFilenameAndPath(): {
  48644. filename: string;
  48645. path: string;
  48646. };
  48647. /**
  48648. * This function is called before the mesh is loaded. It checks for loading constraints.
  48649. * For example, this function can check if the GLB loader is available
  48650. * If this function returns false, the generic controller will be loaded instead
  48651. * @returns Is the client ready to load the mesh
  48652. */
  48653. protected abstract _getModelLoadingConstraints(): boolean;
  48654. /**
  48655. * This function will be called after the model was successfully loaded and can be used
  48656. * for mesh transformations before it is available for the user
  48657. * @param meshes the loaded meshes
  48658. */
  48659. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48660. /**
  48661. * Set the root mesh for this controller. Important for the WebXR controller class
  48662. * @param meshes the loaded meshes
  48663. */
  48664. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48665. /**
  48666. * A function executed each frame that updates the mesh (if needed)
  48667. * @param xrFrame the current xrFrame
  48668. */
  48669. protected abstract _updateModel(xrFrame: XRFrame): void;
  48670. private _getGenericFilenameAndPath;
  48671. private _getGenericParentMesh;
  48672. }
  48673. }
  48674. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48675. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48677. import { Scene } from "babylonjs/scene";
  48678. /**
  48679. * A generic trigger-only motion controller for WebXR
  48680. */
  48681. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48682. /**
  48683. * Static version of the profile id of this controller
  48684. */
  48685. static ProfileId: string;
  48686. profileId: string;
  48687. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48688. protected _getFilenameAndPath(): {
  48689. filename: string;
  48690. path: string;
  48691. };
  48692. protected _getModelLoadingConstraints(): boolean;
  48693. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48694. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48695. protected _updateModel(): void;
  48696. }
  48697. }
  48698. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48699. import { Vector4 } from "babylonjs/Maths/math.vector";
  48700. import { Mesh } from "babylonjs/Meshes/mesh";
  48701. import { Scene } from "babylonjs/scene";
  48702. import { Nullable } from "babylonjs/types";
  48703. /**
  48704. * Class containing static functions to help procedurally build meshes
  48705. */
  48706. export class SphereBuilder {
  48707. /**
  48708. * Creates a sphere mesh
  48709. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48710. * * 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`)
  48711. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48712. * * 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
  48713. * * 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)
  48714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48717. * @param name defines the name of the mesh
  48718. * @param options defines the options used to create the mesh
  48719. * @param scene defines the hosting scene
  48720. * @returns the sphere mesh
  48721. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48722. */
  48723. static CreateSphere(name: string, options: {
  48724. segments?: number;
  48725. diameter?: number;
  48726. diameterX?: number;
  48727. diameterY?: number;
  48728. diameterZ?: number;
  48729. arc?: number;
  48730. slice?: number;
  48731. sideOrientation?: number;
  48732. frontUVs?: Vector4;
  48733. backUVs?: Vector4;
  48734. updatable?: boolean;
  48735. }, scene?: Nullable<Scene>): Mesh;
  48736. }
  48737. }
  48738. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48740. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48741. import { Scene } from "babylonjs/scene";
  48742. /**
  48743. * A profiled motion controller has its profile loaded from an online repository.
  48744. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48745. */
  48746. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48747. private _repositoryUrl;
  48748. private _buttonMeshMapping;
  48749. private _touchDots;
  48750. /**
  48751. * The profile ID of this controller. Will be populated when the controller initializes.
  48752. */
  48753. profileId: string;
  48754. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48755. dispose(): void;
  48756. protected _getFilenameAndPath(): {
  48757. filename: string;
  48758. path: string;
  48759. };
  48760. protected _getModelLoadingConstraints(): boolean;
  48761. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48762. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48763. protected _updateModel(_xrFrame: XRFrame): void;
  48764. }
  48765. }
  48766. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48767. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48768. import { Scene } from "babylonjs/scene";
  48769. /**
  48770. * A construction function type to create a new controller based on an xrInput object
  48771. */
  48772. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48773. /**
  48774. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48775. *
  48776. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48777. * it should be replaced with auto-loaded controllers.
  48778. *
  48779. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48780. */
  48781. export class WebXRMotionControllerManager {
  48782. private static _AvailableControllers;
  48783. private static _Fallbacks;
  48784. private static _ProfileLoadingPromises;
  48785. private static _ProfilesList;
  48786. /**
  48787. * The base URL of the online controller repository. Can be changed at any time.
  48788. */
  48789. static BaseRepositoryUrl: string;
  48790. /**
  48791. * Which repository gets priority - local or online
  48792. */
  48793. static PrioritizeOnlineRepository: boolean;
  48794. /**
  48795. * Use the online repository, or use only locally-defined controllers
  48796. */
  48797. static UseOnlineRepository: boolean;
  48798. /**
  48799. * Clear the cache used for profile loading and reload when requested again
  48800. */
  48801. static ClearProfilesCache(): void;
  48802. /**
  48803. * Register the default fallbacks.
  48804. * This function is called automatically when this file is imported.
  48805. */
  48806. static DefaultFallbacks(): void;
  48807. /**
  48808. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48809. * @param profileId the profile to which a fallback needs to be found
  48810. * @return an array with corresponding fallback profiles
  48811. */
  48812. static FindFallbackWithProfileId(profileId: string): string[];
  48813. /**
  48814. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48815. * The order of search:
  48816. *
  48817. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48818. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48819. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48820. * 4) return the generic trigger controller if none were found
  48821. *
  48822. * @param xrInput the xrInput to which a new controller is initialized
  48823. * @param scene the scene to which the model will be added
  48824. * @param forceProfile force a certain profile for this controller
  48825. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48826. */
  48827. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48828. /**
  48829. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48830. *
  48831. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48832. *
  48833. * @param type the profile type to register
  48834. * @param constructFunction the function to be called when loading this profile
  48835. */
  48836. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48837. /**
  48838. * Register a fallback to a specific profile.
  48839. * @param profileId the profileId that will receive the fallbacks
  48840. * @param fallbacks A list of fallback profiles
  48841. */
  48842. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48843. /**
  48844. * Will update the list of profiles available in the repository
  48845. * @return a promise that resolves to a map of profiles available online
  48846. */
  48847. static UpdateProfilesList(): Promise<{
  48848. [profile: string]: string;
  48849. }>;
  48850. private static _LoadProfileFromRepository;
  48851. private static _LoadProfilesFromAvailableControllers;
  48852. }
  48853. }
  48854. declare module "babylonjs/XR/webXRInputSource" {
  48855. import { Observable } from "babylonjs/Misc/observable";
  48856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48857. import { Ray } from "babylonjs/Culling/ray";
  48858. import { Scene } from "babylonjs/scene";
  48859. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48860. /**
  48861. * Configuration options for the WebXR controller creation
  48862. */
  48863. export interface IWebXRControllerOptions {
  48864. /**
  48865. * Should the controller mesh be animated when a user interacts with it
  48866. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48867. */
  48868. disableMotionControllerAnimation?: boolean;
  48869. /**
  48870. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48871. */
  48872. doNotLoadControllerMesh?: boolean;
  48873. /**
  48874. * Force a specific controller type for this controller.
  48875. * This can be used when creating your own profile or when testing different controllers
  48876. */
  48877. forceControllerProfile?: string;
  48878. /**
  48879. * Defines a rendering group ID for meshes that will be loaded.
  48880. * This is for the default controllers only.
  48881. */
  48882. renderingGroupId?: number;
  48883. }
  48884. /**
  48885. * Represents an XR controller
  48886. */
  48887. export class WebXRInputSource {
  48888. private _scene;
  48889. /** The underlying input source for the controller */
  48890. inputSource: XRInputSource;
  48891. private _options;
  48892. private _tmpVector;
  48893. private _uniqueId;
  48894. /**
  48895. * 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
  48896. */
  48897. grip?: AbstractMesh;
  48898. /**
  48899. * If available, this is the gamepad object related to this controller.
  48900. * Using this object it is possible to get click events and trackpad changes of the
  48901. * webxr controller that is currently being used.
  48902. */
  48903. motionController?: WebXRAbstractMotionController;
  48904. /**
  48905. * Event that fires when the controller is removed/disposed.
  48906. * The object provided as event data is this controller, after associated assets were disposed.
  48907. * uniqueId is still available.
  48908. */
  48909. onDisposeObservable: Observable<WebXRInputSource>;
  48910. /**
  48911. * Will be triggered when the mesh associated with the motion controller is done loading.
  48912. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48913. * A shortened version of controller -> motion controller -> on mesh loaded.
  48914. */
  48915. onMeshLoadedObservable: Observable<AbstractMesh>;
  48916. /**
  48917. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48918. */
  48919. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48920. /**
  48921. * Pointer which can be used to select objects or attach a visible laser to
  48922. */
  48923. pointer: AbstractMesh;
  48924. /**
  48925. * Creates the controller
  48926. * @see https://doc.babylonjs.com/how_to/webxr
  48927. * @param _scene the scene which the controller should be associated to
  48928. * @param inputSource the underlying input source for the controller
  48929. * @param _options options for this controller creation
  48930. */
  48931. constructor(_scene: Scene,
  48932. /** The underlying input source for the controller */
  48933. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48934. /**
  48935. * Get this controllers unique id
  48936. */
  48937. get uniqueId(): string;
  48938. /**
  48939. * Disposes of the object
  48940. */
  48941. dispose(): void;
  48942. /**
  48943. * Gets a world space ray coming from the pointer or grip
  48944. * @param result the resulting ray
  48945. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48946. */
  48947. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48948. /**
  48949. * Updates the controller pose based on the given XRFrame
  48950. * @param xrFrame xr frame to update the pose with
  48951. * @param referenceSpace reference space to use
  48952. */
  48953. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48954. }
  48955. }
  48956. declare module "babylonjs/XR/webXRInput" {
  48957. import { Observable } from "babylonjs/Misc/observable";
  48958. import { IDisposable } from "babylonjs/scene";
  48959. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  48960. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48961. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48962. /**
  48963. * The schema for initialization options of the XR Input class
  48964. */
  48965. export interface IWebXRInputOptions {
  48966. /**
  48967. * If set to true no model will be automatically loaded
  48968. */
  48969. doNotLoadControllerMeshes?: boolean;
  48970. /**
  48971. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48972. * If not found, the xr input profile data will be used.
  48973. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48974. */
  48975. forceInputProfile?: string;
  48976. /**
  48977. * Do not send a request to the controller repository to load the profile.
  48978. *
  48979. * Instead, use the controllers available in babylon itself.
  48980. */
  48981. disableOnlineControllerRepository?: boolean;
  48982. /**
  48983. * A custom URL for the controllers repository
  48984. */
  48985. customControllersRepositoryURL?: string;
  48986. /**
  48987. * Should the controller model's components not move according to the user input
  48988. */
  48989. disableControllerAnimation?: boolean;
  48990. /**
  48991. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48992. */
  48993. controllerOptions?: IWebXRControllerOptions;
  48994. }
  48995. /**
  48996. * XR input used to track XR inputs such as controllers/rays
  48997. */
  48998. export class WebXRInput implements IDisposable {
  48999. /**
  49000. * the xr session manager for this session
  49001. */
  49002. xrSessionManager: WebXRSessionManager;
  49003. /**
  49004. * the WebXR camera for this session. Mainly used for teleportation
  49005. */
  49006. xrCamera: WebXRCamera;
  49007. private readonly options;
  49008. /**
  49009. * XR controllers being tracked
  49010. */
  49011. controllers: Array<WebXRInputSource>;
  49012. private _frameObserver;
  49013. private _sessionEndedObserver;
  49014. private _sessionInitObserver;
  49015. /**
  49016. * Event when a controller has been connected/added
  49017. */
  49018. onControllerAddedObservable: Observable<WebXRInputSource>;
  49019. /**
  49020. * Event when a controller has been removed/disconnected
  49021. */
  49022. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49023. /**
  49024. * Initializes the WebXRInput
  49025. * @param xrSessionManager the xr session manager for this session
  49026. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49027. * @param options = initialization options for this xr input
  49028. */
  49029. constructor(
  49030. /**
  49031. * the xr session manager for this session
  49032. */
  49033. xrSessionManager: WebXRSessionManager,
  49034. /**
  49035. * the WebXR camera for this session. Mainly used for teleportation
  49036. */
  49037. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49038. private _onInputSourcesChange;
  49039. private _addAndRemoveControllers;
  49040. /**
  49041. * Disposes of the object
  49042. */
  49043. dispose(): void;
  49044. }
  49045. }
  49046. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49047. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49048. import { Observable, EventState } from "babylonjs/Misc/observable";
  49049. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49050. /**
  49051. * This is the base class for all WebXR features.
  49052. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49053. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49054. */
  49055. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49056. protected _xrSessionManager: WebXRSessionManager;
  49057. private _attached;
  49058. private _removeOnDetach;
  49059. /**
  49060. * Should auto-attach be disabled?
  49061. */
  49062. disableAutoAttach: boolean;
  49063. /**
  49064. * Construct a new (abstract) WebXR feature
  49065. * @param _xrSessionManager the xr session manager for this feature
  49066. */
  49067. constructor(_xrSessionManager: WebXRSessionManager);
  49068. /**
  49069. * Is this feature attached
  49070. */
  49071. get attached(): boolean;
  49072. /**
  49073. * attach this feature
  49074. *
  49075. * @param force should attachment be forced (even when already attached)
  49076. * @returns true if successful, false is failed or already attached
  49077. */
  49078. attach(force?: boolean): boolean;
  49079. /**
  49080. * detach this feature.
  49081. *
  49082. * @returns true if successful, false if failed or already detached
  49083. */
  49084. detach(): boolean;
  49085. /**
  49086. * Dispose this feature and all of the resources attached
  49087. */
  49088. dispose(): void;
  49089. /**
  49090. * This is used to register callbacks that will automatically be removed when detach is called.
  49091. * @param observable the observable to which the observer will be attached
  49092. * @param callback the callback to register
  49093. */
  49094. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49095. /**
  49096. * Code in this function will be executed on each xrFrame received from the browser.
  49097. * This function will not execute after the feature is detached.
  49098. * @param _xrFrame the current frame
  49099. */
  49100. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49101. }
  49102. }
  49103. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49104. import { IDisposable, Scene } from "babylonjs/scene";
  49105. import { Nullable } from "babylonjs/types";
  49106. import { Observable } from "babylonjs/Misc/observable";
  49107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49108. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49109. import { Camera } from "babylonjs/Cameras/camera";
  49110. /**
  49111. * Renders a layer on top of an existing scene
  49112. */
  49113. export class UtilityLayerRenderer implements IDisposable {
  49114. /** the original scene that will be rendered on top of */
  49115. originalScene: Scene;
  49116. private _pointerCaptures;
  49117. private _lastPointerEvents;
  49118. private static _DefaultUtilityLayer;
  49119. private static _DefaultKeepDepthUtilityLayer;
  49120. private _sharedGizmoLight;
  49121. private _renderCamera;
  49122. /**
  49123. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49124. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49125. * @returns the camera that is used when rendering the utility layer
  49126. */
  49127. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49128. /**
  49129. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49130. * @param cam the camera that should be used when rendering the utility layer
  49131. */
  49132. setRenderCamera(cam: Nullable<Camera>): void;
  49133. /**
  49134. * @hidden
  49135. * Light which used by gizmos to get light shading
  49136. */
  49137. _getSharedGizmoLight(): HemisphericLight;
  49138. /**
  49139. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49140. */
  49141. pickUtilitySceneFirst: boolean;
  49142. /**
  49143. * 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)
  49144. */
  49145. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49146. /**
  49147. * 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)
  49148. */
  49149. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49150. /**
  49151. * The scene that is rendered on top of the original scene
  49152. */
  49153. utilityLayerScene: Scene;
  49154. /**
  49155. * If the utility layer should automatically be rendered on top of existing scene
  49156. */
  49157. shouldRender: boolean;
  49158. /**
  49159. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49160. */
  49161. onlyCheckPointerDownEvents: boolean;
  49162. /**
  49163. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49164. */
  49165. processAllEvents: boolean;
  49166. /**
  49167. * Observable raised when the pointer move from the utility layer scene to the main scene
  49168. */
  49169. onPointerOutObservable: Observable<number>;
  49170. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49171. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49172. private _afterRenderObserver;
  49173. private _sceneDisposeObserver;
  49174. private _originalPointerObserver;
  49175. /**
  49176. * Instantiates a UtilityLayerRenderer
  49177. * @param originalScene the original scene that will be rendered on top of
  49178. * @param handleEvents boolean indicating if the utility layer should handle events
  49179. */
  49180. constructor(
  49181. /** the original scene that will be rendered on top of */
  49182. originalScene: Scene, handleEvents?: boolean);
  49183. private _notifyObservers;
  49184. /**
  49185. * Renders the utility layers scene on top of the original scene
  49186. */
  49187. render(): void;
  49188. /**
  49189. * Disposes of the renderer
  49190. */
  49191. dispose(): void;
  49192. private _updateCamera;
  49193. }
  49194. }
  49195. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49196. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49198. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49199. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49200. import { Scene } from "babylonjs/scene";
  49201. import { Nullable } from "babylonjs/types";
  49202. import { Color3 } from "babylonjs/Maths/math.color";
  49203. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49204. /**
  49205. * Options interface for the pointer selection module
  49206. */
  49207. export interface IWebXRControllerPointerSelectionOptions {
  49208. /**
  49209. * if provided, this scene will be used to render meshes.
  49210. */
  49211. customUtilityLayerScene?: Scene;
  49212. /**
  49213. * 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)
  49214. * If not disabled, the last picked point will be used to execute a pointer up event
  49215. * If disabled, pointer up event will be triggered right after the pointer down event.
  49216. * Used in screen and gaze target ray mode only
  49217. */
  49218. disablePointerUpOnTouchOut: boolean;
  49219. /**
  49220. * For gaze mode (time to select instead of press)
  49221. */
  49222. forceGazeMode: boolean;
  49223. /**
  49224. * 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
  49225. * to start a new countdown to the pointer down event.
  49226. * Defaults to 1.
  49227. */
  49228. gazeModePointerMovedFactor?: number;
  49229. /**
  49230. * Different button type to use instead of the main component
  49231. */
  49232. overrideButtonId?: string;
  49233. /**
  49234. * use this rendering group id for the meshes (optional)
  49235. */
  49236. renderingGroupId?: number;
  49237. /**
  49238. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49239. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49240. * 3000 means 3 seconds between pointing at something and selecting it
  49241. */
  49242. timeToSelect?: number;
  49243. /**
  49244. * Should meshes created here be added to a utility layer or the main scene
  49245. */
  49246. useUtilityLayer?: boolean;
  49247. /**
  49248. * the xr input to use with this pointer selection
  49249. */
  49250. xrInput: WebXRInput;
  49251. }
  49252. /**
  49253. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49254. */
  49255. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49256. private readonly _options;
  49257. private static _idCounter;
  49258. private _attachController;
  49259. private _controllers;
  49260. private _scene;
  49261. private _tmpVectorForPickCompare;
  49262. /**
  49263. * The module's name
  49264. */
  49265. static readonly Name: string;
  49266. /**
  49267. * The (Babylon) version of this module.
  49268. * This is an integer representing the implementation version.
  49269. * This number does not correspond to the WebXR specs version
  49270. */
  49271. static readonly Version: number;
  49272. /**
  49273. * Disable lighting on the laser pointer (so it will always be visible)
  49274. */
  49275. disablePointerLighting: boolean;
  49276. /**
  49277. * Disable lighting on the selection mesh (so it will always be visible)
  49278. */
  49279. disableSelectionMeshLighting: boolean;
  49280. /**
  49281. * Should the laser pointer be displayed
  49282. */
  49283. displayLaserPointer: boolean;
  49284. /**
  49285. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49286. */
  49287. displaySelectionMesh: boolean;
  49288. /**
  49289. * This color will be set to the laser pointer when selection is triggered
  49290. */
  49291. laserPointerPickedColor: Color3;
  49292. /**
  49293. * Default color of the laser pointer
  49294. */
  49295. lasterPointerDefaultColor: Color3;
  49296. /**
  49297. * default color of the selection ring
  49298. */
  49299. selectionMeshDefaultColor: Color3;
  49300. /**
  49301. * This color will be applied to the selection ring when selection is triggered
  49302. */
  49303. selectionMeshPickedColor: Color3;
  49304. /**
  49305. * Optional filter to be used for ray selection. This predicate shares behavior with
  49306. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49307. */
  49308. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49309. /**
  49310. * constructs a new background remover module
  49311. * @param _xrSessionManager the session manager for this module
  49312. * @param _options read-only options to be used in this module
  49313. */
  49314. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49315. /**
  49316. * attach this feature
  49317. * Will usually be called by the features manager
  49318. *
  49319. * @returns true if successful.
  49320. */
  49321. attach(): boolean;
  49322. /**
  49323. * detach this feature.
  49324. * Will usually be called by the features manager
  49325. *
  49326. * @returns true if successful.
  49327. */
  49328. detach(): boolean;
  49329. /**
  49330. * Will get the mesh under a specific pointer.
  49331. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49332. * @param controllerId the controllerId to check
  49333. * @returns The mesh under pointer or null if no mesh is under the pointer
  49334. */
  49335. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49336. /**
  49337. * Get the xr controller that correlates to the pointer id in the pointer event
  49338. *
  49339. * @param id the pointer id to search for
  49340. * @returns the controller that correlates to this id or null if not found
  49341. */
  49342. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49343. protected _onXRFrame(_xrFrame: XRFrame): void;
  49344. private _attachGazeMode;
  49345. private _attachScreenRayMode;
  49346. private _attachTrackedPointerRayMode;
  49347. private _convertNormalToDirectionOfRay;
  49348. private _detachController;
  49349. private _generateNewMeshPair;
  49350. private _pickingMoved;
  49351. private _updatePointerDistance;
  49352. }
  49353. }
  49354. declare module "babylonjs/XR/webXREnterExitUI" {
  49355. import { Nullable } from "babylonjs/types";
  49356. import { Observable } from "babylonjs/Misc/observable";
  49357. import { IDisposable, Scene } from "babylonjs/scene";
  49358. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49359. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49360. /**
  49361. * Button which can be used to enter a different mode of XR
  49362. */
  49363. export class WebXREnterExitUIButton {
  49364. /** button element */
  49365. element: HTMLElement;
  49366. /** XR initialization options for the button */
  49367. sessionMode: XRSessionMode;
  49368. /** Reference space type */
  49369. referenceSpaceType: XRReferenceSpaceType;
  49370. /**
  49371. * Creates a WebXREnterExitUIButton
  49372. * @param element button element
  49373. * @param sessionMode XR initialization session mode
  49374. * @param referenceSpaceType the type of reference space to be used
  49375. */
  49376. constructor(
  49377. /** button element */
  49378. element: HTMLElement,
  49379. /** XR initialization options for the button */
  49380. sessionMode: XRSessionMode,
  49381. /** Reference space type */
  49382. referenceSpaceType: XRReferenceSpaceType);
  49383. /**
  49384. * Extendable function which can be used to update the button's visuals when the state changes
  49385. * @param activeButton the current active button in the UI
  49386. */
  49387. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49388. }
  49389. /**
  49390. * Options to create the webXR UI
  49391. */
  49392. export class WebXREnterExitUIOptions {
  49393. /**
  49394. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49395. */
  49396. customButtons?: Array<WebXREnterExitUIButton>;
  49397. /**
  49398. * A reference space type to use when creating the default button.
  49399. * Default is local-floor
  49400. */
  49401. referenceSpaceType?: XRReferenceSpaceType;
  49402. /**
  49403. * Context to enter xr with
  49404. */
  49405. renderTarget?: Nullable<WebXRRenderTarget>;
  49406. /**
  49407. * A session mode to use when creating the default button.
  49408. * Default is immersive-vr
  49409. */
  49410. sessionMode?: XRSessionMode;
  49411. /**
  49412. * A list of optional features to init the session with
  49413. */
  49414. optionalFeatures?: string[];
  49415. }
  49416. /**
  49417. * UI to allow the user to enter/exit XR mode
  49418. */
  49419. export class WebXREnterExitUI implements IDisposable {
  49420. private scene;
  49421. /** version of the options passed to this UI */
  49422. options: WebXREnterExitUIOptions;
  49423. private _activeButton;
  49424. private _buttons;
  49425. private _overlay;
  49426. /**
  49427. * Fired every time the active button is changed.
  49428. *
  49429. * When xr is entered via a button that launches xr that button will be the callback parameter
  49430. *
  49431. * When exiting xr the callback parameter will be null)
  49432. */
  49433. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49434. /**
  49435. *
  49436. * @param scene babylon scene object to use
  49437. * @param options (read-only) version of the options passed to this UI
  49438. */
  49439. private constructor();
  49440. /**
  49441. * Creates UI to allow the user to enter/exit XR mode
  49442. * @param scene the scene to add the ui to
  49443. * @param helper the xr experience helper to enter/exit xr with
  49444. * @param options options to configure the UI
  49445. * @returns the created ui
  49446. */
  49447. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49448. /**
  49449. * Disposes of the XR UI component
  49450. */
  49451. dispose(): void;
  49452. private _updateButtons;
  49453. }
  49454. }
  49455. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49456. import { Vector3 } from "babylonjs/Maths/math.vector";
  49457. import { Color4 } from "babylonjs/Maths/math.color";
  49458. import { Nullable } from "babylonjs/types";
  49459. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49460. import { Scene } from "babylonjs/scene";
  49461. /**
  49462. * Class containing static functions to help procedurally build meshes
  49463. */
  49464. export class LinesBuilder {
  49465. /**
  49466. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49467. * * 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
  49468. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49469. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49470. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49471. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49472. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49473. * * 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
  49474. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49477. * @param name defines the name of the new line system
  49478. * @param options defines the options used to create the line system
  49479. * @param scene defines the hosting scene
  49480. * @returns a new line system mesh
  49481. */
  49482. static CreateLineSystem(name: string, options: {
  49483. lines: Vector3[][];
  49484. updatable?: boolean;
  49485. instance?: Nullable<LinesMesh>;
  49486. colors?: Nullable<Color4[][]>;
  49487. useVertexAlpha?: boolean;
  49488. }, scene: Nullable<Scene>): LinesMesh;
  49489. /**
  49490. * Creates a line mesh
  49491. * 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
  49492. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49493. * * The parameter `points` is an array successive Vector3
  49494. * * 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
  49495. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49496. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49497. * * When updating an instance, remember that only point positions can change, not the number of points
  49498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49500. * @param name defines the name of the new line system
  49501. * @param options defines the options used to create the line system
  49502. * @param scene defines the hosting scene
  49503. * @returns a new line mesh
  49504. */
  49505. static CreateLines(name: string, options: {
  49506. points: Vector3[];
  49507. updatable?: boolean;
  49508. instance?: Nullable<LinesMesh>;
  49509. colors?: Color4[];
  49510. useVertexAlpha?: boolean;
  49511. }, scene?: Nullable<Scene>): LinesMesh;
  49512. /**
  49513. * Creates a dashed line mesh
  49514. * * 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
  49515. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49516. * * The parameter `points` is an array successive Vector3
  49517. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49518. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49519. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49520. * * 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
  49521. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49522. * * When updating an instance, remember that only point positions can change, not the number of points
  49523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49524. * @param name defines the name of the mesh
  49525. * @param options defines the options used to create the mesh
  49526. * @param scene defines the hosting scene
  49527. * @returns the dashed line mesh
  49528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49529. */
  49530. static CreateDashedLines(name: string, options: {
  49531. points: Vector3[];
  49532. dashSize?: number;
  49533. gapSize?: number;
  49534. dashNb?: number;
  49535. updatable?: boolean;
  49536. instance?: LinesMesh;
  49537. useVertexAlpha?: boolean;
  49538. }, scene?: Nullable<Scene>): LinesMesh;
  49539. }
  49540. }
  49541. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49542. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49543. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49544. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49546. import { Vector3 } from "babylonjs/Maths/math.vector";
  49547. import { Material } from "babylonjs/Materials/material";
  49548. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49549. import { Scene } from "babylonjs/scene";
  49550. /**
  49551. * The options container for the teleportation module
  49552. */
  49553. export interface IWebXRTeleportationOptions {
  49554. /**
  49555. * if provided, this scene will be used to render meshes.
  49556. */
  49557. customUtilityLayerScene?: Scene;
  49558. /**
  49559. * Values to configure the default target mesh
  49560. */
  49561. defaultTargetMeshOptions?: {
  49562. /**
  49563. * Fill color of the teleportation area
  49564. */
  49565. teleportationFillColor?: string;
  49566. /**
  49567. * Border color for the teleportation area
  49568. */
  49569. teleportationBorderColor?: string;
  49570. /**
  49571. * Disable the mesh's animation sequence
  49572. */
  49573. disableAnimation?: boolean;
  49574. /**
  49575. * Disable lighting on the material or the ring and arrow
  49576. */
  49577. disableLighting?: boolean;
  49578. /**
  49579. * Override the default material of the torus and arrow
  49580. */
  49581. torusArrowMaterial?: Material;
  49582. };
  49583. /**
  49584. * A list of meshes to use as floor meshes.
  49585. * Meshes can be added and removed after initializing the feature using the
  49586. * addFloorMesh and removeFloorMesh functions
  49587. * If empty, rotation will still work
  49588. */
  49589. floorMeshes?: AbstractMesh[];
  49590. /**
  49591. * use this rendering group id for the meshes (optional)
  49592. */
  49593. renderingGroupId?: number;
  49594. /**
  49595. * Should teleportation move only to snap points
  49596. */
  49597. snapPointsOnly?: boolean;
  49598. /**
  49599. * An array of points to which the teleportation will snap to.
  49600. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49601. */
  49602. snapPositions?: Vector3[];
  49603. /**
  49604. * How close should the teleportation ray be in order to snap to position.
  49605. * Default to 0.8 units (meters)
  49606. */
  49607. snapToPositionRadius?: number;
  49608. /**
  49609. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49610. * If you want to support rotation, make sure your mesh has a direction indicator.
  49611. *
  49612. * When left untouched, the default mesh will be initialized.
  49613. */
  49614. teleportationTargetMesh?: AbstractMesh;
  49615. /**
  49616. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49617. */
  49618. timeToTeleport?: number;
  49619. /**
  49620. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49621. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49622. */
  49623. useMainComponentOnly?: boolean;
  49624. /**
  49625. * Should meshes created here be added to a utility layer or the main scene
  49626. */
  49627. useUtilityLayer?: boolean;
  49628. /**
  49629. * Babylon XR Input class for controller
  49630. */
  49631. xrInput: WebXRInput;
  49632. }
  49633. /**
  49634. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49635. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49636. * the input of the attached controllers.
  49637. */
  49638. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49639. private _options;
  49640. private _controllers;
  49641. private _currentTeleportationControllerId;
  49642. private _floorMeshes;
  49643. private _quadraticBezierCurve;
  49644. private _selectionFeature;
  49645. private _snapToPositions;
  49646. private _snappedToPoint;
  49647. private _teleportationRingMaterial?;
  49648. private _tmpRay;
  49649. private _tmpVector;
  49650. /**
  49651. * The module's name
  49652. */
  49653. static readonly Name: string;
  49654. /**
  49655. * The (Babylon) version of this module.
  49656. * This is an integer representing the implementation version.
  49657. * This number does not correspond to the webxr specs version
  49658. */
  49659. static readonly Version: number;
  49660. /**
  49661. * Is movement backwards enabled
  49662. */
  49663. backwardsMovementEnabled: boolean;
  49664. /**
  49665. * Distance to travel when moving backwards
  49666. */
  49667. backwardsTeleportationDistance: number;
  49668. /**
  49669. * The distance from the user to the inspection point in the direction of the controller
  49670. * A higher number will allow the user to move further
  49671. * defaults to 5 (meters, in xr units)
  49672. */
  49673. parabolicCheckRadius: number;
  49674. /**
  49675. * Should the module support parabolic ray on top of direct ray
  49676. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49677. * Very helpful when moving between floors / different heights
  49678. */
  49679. parabolicRayEnabled: boolean;
  49680. /**
  49681. * How much rotation should be applied when rotating right and left
  49682. */
  49683. rotationAngle: number;
  49684. /**
  49685. * Is rotation enabled when moving forward?
  49686. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49687. */
  49688. rotationEnabled: boolean;
  49689. /**
  49690. * constructs a new anchor system
  49691. * @param _xrSessionManager an instance of WebXRSessionManager
  49692. * @param _options configuration object for this feature
  49693. */
  49694. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49695. /**
  49696. * Get the snapPointsOnly flag
  49697. */
  49698. get snapPointsOnly(): boolean;
  49699. /**
  49700. * Sets the snapPointsOnly flag
  49701. * @param snapToPoints should teleportation be exclusively to snap points
  49702. */
  49703. set snapPointsOnly(snapToPoints: boolean);
  49704. /**
  49705. * Add a new mesh to the floor meshes array
  49706. * @param mesh the mesh to use as floor mesh
  49707. */
  49708. addFloorMesh(mesh: AbstractMesh): void;
  49709. /**
  49710. * Add a new snap-to point to fix teleportation to this position
  49711. * @param newSnapPoint The new Snap-To point
  49712. */
  49713. addSnapPoint(newSnapPoint: Vector3): void;
  49714. attach(): boolean;
  49715. detach(): boolean;
  49716. dispose(): void;
  49717. /**
  49718. * Remove a mesh from the floor meshes array
  49719. * @param mesh the mesh to remove
  49720. */
  49721. removeFloorMesh(mesh: AbstractMesh): void;
  49722. /**
  49723. * Remove a mesh from the floor meshes array using its name
  49724. * @param name the mesh name to remove
  49725. */
  49726. removeFloorMeshByName(name: string): void;
  49727. /**
  49728. * 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
  49729. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49730. * @returns was the point found and removed or not
  49731. */
  49732. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49733. /**
  49734. * This function sets a selection feature that will be disabled when
  49735. * the forward ray is shown and will be reattached when hidden.
  49736. * This is used to remove the selection rays when moving.
  49737. * @param selectionFeature the feature to disable when forward movement is enabled
  49738. */
  49739. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49740. protected _onXRFrame(_xrFrame: XRFrame): void;
  49741. private _attachController;
  49742. private _createDefaultTargetMesh;
  49743. private _detachController;
  49744. private _findClosestSnapPointWithRadius;
  49745. private _setTargetMeshPosition;
  49746. private _setTargetMeshVisibility;
  49747. private _showParabolicPath;
  49748. private _teleportForward;
  49749. }
  49750. }
  49751. declare module "babylonjs/XR/webXRDefaultExperience" {
  49752. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49753. import { Scene } from "babylonjs/scene";
  49754. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  49755. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  49756. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49757. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  49758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49759. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  49760. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  49761. /**
  49762. * Options for the default xr helper
  49763. */
  49764. export class WebXRDefaultExperienceOptions {
  49765. /**
  49766. * Enable or disable default UI to enter XR
  49767. */
  49768. disableDefaultUI?: boolean;
  49769. /**
  49770. * Should teleportation not initialize. defaults to false.
  49771. */
  49772. disableTeleportation?: boolean;
  49773. /**
  49774. * Floor meshes that will be used for teleport
  49775. */
  49776. floorMeshes?: Array<AbstractMesh>;
  49777. /**
  49778. * If set to true, the first frame will not be used to reset position
  49779. * The first frame is mainly used when copying transformation from the old camera
  49780. * Mainly used in AR
  49781. */
  49782. ignoreNativeCameraTransformation?: boolean;
  49783. /**
  49784. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49785. */
  49786. inputOptions?: IWebXRInputOptions;
  49787. /**
  49788. * optional configuration for the output canvas
  49789. */
  49790. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49791. /**
  49792. * optional UI options. This can be used among other to change session mode and reference space type
  49793. */
  49794. uiOptions?: WebXREnterExitUIOptions;
  49795. /**
  49796. * When loading teleportation and pointer select, use stable versions instead of latest.
  49797. */
  49798. useStablePlugins?: boolean;
  49799. /**
  49800. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49801. */
  49802. renderingGroupId?: number;
  49803. /**
  49804. * A list of optional features to init the session with
  49805. * If set to true, all features we support will be added
  49806. */
  49807. optionalFeatures?: boolean | string[];
  49808. }
  49809. /**
  49810. * Default experience which provides a similar setup to the previous webVRExperience
  49811. */
  49812. export class WebXRDefaultExperience {
  49813. /**
  49814. * Base experience
  49815. */
  49816. baseExperience: WebXRExperienceHelper;
  49817. /**
  49818. * Enables ui for entering/exiting xr
  49819. */
  49820. enterExitUI: WebXREnterExitUI;
  49821. /**
  49822. * Input experience extension
  49823. */
  49824. input: WebXRInput;
  49825. /**
  49826. * Enables laser pointer and selection
  49827. */
  49828. pointerSelection: WebXRControllerPointerSelection;
  49829. /**
  49830. * Default target xr should render to
  49831. */
  49832. renderTarget: WebXRRenderTarget;
  49833. /**
  49834. * Enables teleportation
  49835. */
  49836. teleportation: WebXRMotionControllerTeleportation;
  49837. private constructor();
  49838. /**
  49839. * Creates the default xr experience
  49840. * @param scene scene
  49841. * @param options options for basic configuration
  49842. * @returns resulting WebXRDefaultExperience
  49843. */
  49844. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49845. /**
  49846. * DIsposes of the experience helper
  49847. */
  49848. dispose(): void;
  49849. }
  49850. }
  49851. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  49852. import { Observable } from "babylonjs/Misc/observable";
  49853. import { Nullable } from "babylonjs/types";
  49854. import { Camera } from "babylonjs/Cameras/camera";
  49855. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  49856. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  49857. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  49858. import { Scene } from "babylonjs/scene";
  49859. import { Vector3 } from "babylonjs/Maths/math.vector";
  49860. import { Color3 } from "babylonjs/Maths/math.color";
  49861. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49863. import { Mesh } from "babylonjs/Meshes/mesh";
  49864. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  49865. import { EasingFunction } from "babylonjs/Animations/easing";
  49866. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  49867. import "babylonjs/Meshes/Builders/groundBuilder";
  49868. import "babylonjs/Meshes/Builders/torusBuilder";
  49869. import "babylonjs/Meshes/Builders/cylinderBuilder";
  49870. import "babylonjs/Gamepads/gamepadSceneComponent";
  49871. import "babylonjs/Animations/animatable";
  49872. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  49873. /**
  49874. * Options to modify the vr teleportation behavior.
  49875. */
  49876. export interface VRTeleportationOptions {
  49877. /**
  49878. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49879. */
  49880. floorMeshName?: string;
  49881. /**
  49882. * A list of meshes to be used as the teleportation floor. (default: empty)
  49883. */
  49884. floorMeshes?: Mesh[];
  49885. /**
  49886. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49887. */
  49888. teleportationMode?: number;
  49889. /**
  49890. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49891. */
  49892. teleportationTime?: number;
  49893. /**
  49894. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49895. */
  49896. teleportationSpeed?: number;
  49897. /**
  49898. * The easing function used in the animation or null for Linear. (default CircleEase)
  49899. */
  49900. easingFunction?: EasingFunction;
  49901. }
  49902. /**
  49903. * Options to modify the vr experience helper's behavior.
  49904. */
  49905. export interface VRExperienceHelperOptions extends WebVROptions {
  49906. /**
  49907. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49908. */
  49909. createDeviceOrientationCamera?: boolean;
  49910. /**
  49911. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49912. */
  49913. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49914. /**
  49915. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49916. */
  49917. laserToggle?: boolean;
  49918. /**
  49919. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49920. */
  49921. floorMeshes?: Mesh[];
  49922. /**
  49923. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49924. */
  49925. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49926. /**
  49927. * Defines if WebXR should be used instead of WebVR (if available)
  49928. */
  49929. useXR?: boolean;
  49930. }
  49931. /**
  49932. * Event containing information after VR has been entered
  49933. */
  49934. export class OnAfterEnteringVRObservableEvent {
  49935. /**
  49936. * If entering vr was successful
  49937. */
  49938. success: boolean;
  49939. }
  49940. /**
  49941. * Helps to quickly add VR support to an existing scene.
  49942. * See http://doc.babylonjs.com/how_to/webvr_helper
  49943. */
  49944. export class VRExperienceHelper {
  49945. /** Options to modify the vr experience helper's behavior. */
  49946. webVROptions: VRExperienceHelperOptions;
  49947. private _scene;
  49948. private _position;
  49949. private _btnVR;
  49950. private _btnVRDisplayed;
  49951. private _webVRsupported;
  49952. private _webVRready;
  49953. private _webVRrequesting;
  49954. private _webVRpresenting;
  49955. private _hasEnteredVR;
  49956. private _fullscreenVRpresenting;
  49957. private _inputElement;
  49958. private _webVRCamera;
  49959. private _vrDeviceOrientationCamera;
  49960. private _deviceOrientationCamera;
  49961. private _existingCamera;
  49962. private _onKeyDown;
  49963. private _onVrDisplayPresentChange;
  49964. private _onVRDisplayChanged;
  49965. private _onVRRequestPresentStart;
  49966. private _onVRRequestPresentComplete;
  49967. /**
  49968. * 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)
  49969. */
  49970. enableGazeEvenWhenNoPointerLock: boolean;
  49971. /**
  49972. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49973. */
  49974. exitVROnDoubleTap: boolean;
  49975. /**
  49976. * Observable raised right before entering VR.
  49977. */
  49978. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49979. /**
  49980. * Observable raised when entering VR has completed.
  49981. */
  49982. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49983. /**
  49984. * Observable raised when exiting VR.
  49985. */
  49986. onExitingVRObservable: Observable<VRExperienceHelper>;
  49987. /**
  49988. * Observable raised when controller mesh is loaded.
  49989. */
  49990. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49991. /** Return this.onEnteringVRObservable
  49992. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49993. */
  49994. get onEnteringVR(): Observable<VRExperienceHelper>;
  49995. /** Return this.onExitingVRObservable
  49996. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49997. */
  49998. get onExitingVR(): Observable<VRExperienceHelper>;
  49999. /** Return this.onControllerMeshLoadedObservable
  50000. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50001. */
  50002. get onControllerMeshLoaded(): Observable<WebVRController>;
  50003. private _rayLength;
  50004. private _useCustomVRButton;
  50005. private _teleportationRequested;
  50006. private _teleportActive;
  50007. private _floorMeshName;
  50008. private _floorMeshesCollection;
  50009. private _teleportationMode;
  50010. private _teleportationTime;
  50011. private _teleportationSpeed;
  50012. private _teleportationEasing;
  50013. private _rotationAllowed;
  50014. private _teleportBackwardsVector;
  50015. private _teleportationTarget;
  50016. private _isDefaultTeleportationTarget;
  50017. private _postProcessMove;
  50018. private _teleportationFillColor;
  50019. private _teleportationBorderColor;
  50020. private _rotationAngle;
  50021. private _haloCenter;
  50022. private _cameraGazer;
  50023. private _padSensibilityUp;
  50024. private _padSensibilityDown;
  50025. private _leftController;
  50026. private _rightController;
  50027. private _gazeColor;
  50028. private _laserColor;
  50029. private _pickedLaserColor;
  50030. private _pickedGazeColor;
  50031. /**
  50032. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50033. */
  50034. onNewMeshSelected: Observable<AbstractMesh>;
  50035. /**
  50036. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50037. * This observable will provide the mesh and the controller used to select the mesh
  50038. */
  50039. onMeshSelectedWithController: Observable<{
  50040. mesh: AbstractMesh;
  50041. controller: WebVRController;
  50042. }>;
  50043. /**
  50044. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50045. */
  50046. onNewMeshPicked: Observable<PickingInfo>;
  50047. private _circleEase;
  50048. /**
  50049. * Observable raised before camera teleportation
  50050. */
  50051. onBeforeCameraTeleport: Observable<Vector3>;
  50052. /**
  50053. * Observable raised after camera teleportation
  50054. */
  50055. onAfterCameraTeleport: Observable<Vector3>;
  50056. /**
  50057. * Observable raised when current selected mesh gets unselected
  50058. */
  50059. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50060. private _raySelectionPredicate;
  50061. /**
  50062. * To be optionaly changed by user to define custom ray selection
  50063. */
  50064. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50065. /**
  50066. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50067. */
  50068. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50069. /**
  50070. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50071. */
  50072. teleportationEnabled: boolean;
  50073. private _defaultHeight;
  50074. private _teleportationInitialized;
  50075. private _interactionsEnabled;
  50076. private _interactionsRequested;
  50077. private _displayGaze;
  50078. private _displayLaserPointer;
  50079. /**
  50080. * The mesh used to display where the user is going to teleport.
  50081. */
  50082. get teleportationTarget(): Mesh;
  50083. /**
  50084. * Sets the mesh to be used to display where the user is going to teleport.
  50085. */
  50086. set teleportationTarget(value: Mesh);
  50087. /**
  50088. * 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
  50089. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50090. * See http://doc.babylonjs.com/resources/baking_transformations
  50091. */
  50092. get gazeTrackerMesh(): Mesh;
  50093. set gazeTrackerMesh(value: Mesh);
  50094. /**
  50095. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50096. */
  50097. updateGazeTrackerScale: boolean;
  50098. /**
  50099. * If the gaze trackers color should be updated when selecting meshes
  50100. */
  50101. updateGazeTrackerColor: boolean;
  50102. /**
  50103. * If the controller laser color should be updated when selecting meshes
  50104. */
  50105. updateControllerLaserColor: boolean;
  50106. /**
  50107. * The gaze tracking mesh corresponding to the left controller
  50108. */
  50109. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50110. /**
  50111. * The gaze tracking mesh corresponding to the right controller
  50112. */
  50113. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50114. /**
  50115. * If the ray of the gaze should be displayed.
  50116. */
  50117. get displayGaze(): boolean;
  50118. /**
  50119. * Sets if the ray of the gaze should be displayed.
  50120. */
  50121. set displayGaze(value: boolean);
  50122. /**
  50123. * If the ray of the LaserPointer should be displayed.
  50124. */
  50125. get displayLaserPointer(): boolean;
  50126. /**
  50127. * Sets if the ray of the LaserPointer should be displayed.
  50128. */
  50129. set displayLaserPointer(value: boolean);
  50130. /**
  50131. * The deviceOrientationCamera used as the camera when not in VR.
  50132. */
  50133. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50134. /**
  50135. * Based on the current WebVR support, returns the current VR camera used.
  50136. */
  50137. get currentVRCamera(): Nullable<Camera>;
  50138. /**
  50139. * The webVRCamera which is used when in VR.
  50140. */
  50141. get webVRCamera(): WebVRFreeCamera;
  50142. /**
  50143. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50144. */
  50145. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50146. /**
  50147. * The html button that is used to trigger entering into VR.
  50148. */
  50149. get vrButton(): Nullable<HTMLButtonElement>;
  50150. private get _teleportationRequestInitiated();
  50151. /**
  50152. * Defines whether or not Pointer lock should be requested when switching to
  50153. * full screen.
  50154. */
  50155. requestPointerLockOnFullScreen: boolean;
  50156. /**
  50157. * If asking to force XR, this will be populated with the default xr experience
  50158. */
  50159. xr: WebXRDefaultExperience;
  50160. /**
  50161. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50162. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50163. */
  50164. xrTestDone: boolean;
  50165. /**
  50166. * Instantiates a VRExperienceHelper.
  50167. * Helps to quickly add VR support to an existing scene.
  50168. * @param scene The scene the VRExperienceHelper belongs to.
  50169. * @param webVROptions Options to modify the vr experience helper's behavior.
  50170. */
  50171. constructor(scene: Scene,
  50172. /** Options to modify the vr experience helper's behavior. */
  50173. webVROptions?: VRExperienceHelperOptions);
  50174. private completeVRInit;
  50175. private _onDefaultMeshLoaded;
  50176. private _onResize;
  50177. private _onFullscreenChange;
  50178. /**
  50179. * Gets a value indicating if we are currently in VR mode.
  50180. */
  50181. get isInVRMode(): boolean;
  50182. private onVrDisplayPresentChange;
  50183. private onVRDisplayChanged;
  50184. private moveButtonToBottomRight;
  50185. private displayVRButton;
  50186. private updateButtonVisibility;
  50187. private _cachedAngularSensibility;
  50188. /**
  50189. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50190. * Otherwise, will use the fullscreen API.
  50191. */
  50192. enterVR(): void;
  50193. /**
  50194. * Attempt to exit VR, or fullscreen.
  50195. */
  50196. exitVR(): void;
  50197. /**
  50198. * The position of the vr experience helper.
  50199. */
  50200. get position(): Vector3;
  50201. /**
  50202. * Sets the position of the vr experience helper.
  50203. */
  50204. set position(value: Vector3);
  50205. /**
  50206. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50207. */
  50208. enableInteractions(): void;
  50209. private get _noControllerIsActive();
  50210. private beforeRender;
  50211. private _isTeleportationFloor;
  50212. /**
  50213. * Adds a floor mesh to be used for teleportation.
  50214. * @param floorMesh the mesh to be used for teleportation.
  50215. */
  50216. addFloorMesh(floorMesh: Mesh): void;
  50217. /**
  50218. * Removes a floor mesh from being used for teleportation.
  50219. * @param floorMesh the mesh to be removed.
  50220. */
  50221. removeFloorMesh(floorMesh: Mesh): void;
  50222. /**
  50223. * Enables interactions and teleportation using the VR controllers and gaze.
  50224. * @param vrTeleportationOptions options to modify teleportation behavior.
  50225. */
  50226. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50227. private _onNewGamepadConnected;
  50228. private _tryEnableInteractionOnController;
  50229. private _onNewGamepadDisconnected;
  50230. private _enableInteractionOnController;
  50231. private _checkTeleportWithRay;
  50232. private _checkRotate;
  50233. private _checkTeleportBackwards;
  50234. private _enableTeleportationOnController;
  50235. private _createTeleportationCircles;
  50236. private _displayTeleportationTarget;
  50237. private _hideTeleportationTarget;
  50238. private _rotateCamera;
  50239. private _moveTeleportationSelectorTo;
  50240. private _workingVector;
  50241. private _workingQuaternion;
  50242. private _workingMatrix;
  50243. /**
  50244. * Time Constant Teleportation Mode
  50245. */
  50246. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50247. /**
  50248. * Speed Constant Teleportation Mode
  50249. */
  50250. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50251. /**
  50252. * Teleports the users feet to the desired location
  50253. * @param location The location where the user's feet should be placed
  50254. */
  50255. teleportCamera(location: Vector3): void;
  50256. private _convertNormalToDirectionOfRay;
  50257. private _castRayAndSelectObject;
  50258. private _notifySelectedMeshUnselected;
  50259. /**
  50260. * Permanently set new colors for the laser pointer
  50261. * @param color the new laser color
  50262. * @param pickedColor the new laser color when picked mesh detected
  50263. */
  50264. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50265. /**
  50266. * Set lighting enabled / disabled on the laser pointer of both controllers
  50267. * @param enabled should the lighting be enabled on the laser pointer
  50268. */
  50269. setLaserLightingState(enabled?: boolean): void;
  50270. /**
  50271. * Permanently set new colors for the gaze pointer
  50272. * @param color the new gaze color
  50273. * @param pickedColor the new gaze color when picked mesh detected
  50274. */
  50275. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50276. /**
  50277. * Sets the color of the laser ray from the vr controllers.
  50278. * @param color new color for the ray.
  50279. */
  50280. changeLaserColor(color: Color3): void;
  50281. /**
  50282. * Sets the color of the ray from the vr headsets gaze.
  50283. * @param color new color for the ray.
  50284. */
  50285. changeGazeColor(color: Color3): void;
  50286. /**
  50287. * Exits VR and disposes of the vr experience helper
  50288. */
  50289. dispose(): void;
  50290. /**
  50291. * Gets the name of the VRExperienceHelper class
  50292. * @returns "VRExperienceHelper"
  50293. */
  50294. getClassName(): string;
  50295. }
  50296. }
  50297. declare module "babylonjs/Cameras/VR/index" {
  50298. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50299. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50300. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50301. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50302. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50303. export * from "babylonjs/Cameras/VR/webVRCamera";
  50304. }
  50305. declare module "babylonjs/Cameras/RigModes/index" {
  50306. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50307. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50308. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50309. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50310. }
  50311. declare module "babylonjs/Cameras/index" {
  50312. export * from "babylonjs/Cameras/Inputs/index";
  50313. export * from "babylonjs/Cameras/cameraInputsManager";
  50314. export * from "babylonjs/Cameras/camera";
  50315. export * from "babylonjs/Cameras/targetCamera";
  50316. export * from "babylonjs/Cameras/freeCamera";
  50317. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50318. export * from "babylonjs/Cameras/touchCamera";
  50319. export * from "babylonjs/Cameras/arcRotateCamera";
  50320. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50321. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50322. export * from "babylonjs/Cameras/flyCamera";
  50323. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50324. export * from "babylonjs/Cameras/followCamera";
  50325. export * from "babylonjs/Cameras/followCameraInputsManager";
  50326. export * from "babylonjs/Cameras/gamepadCamera";
  50327. export * from "babylonjs/Cameras/Stereoscopic/index";
  50328. export * from "babylonjs/Cameras/universalCamera";
  50329. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50330. export * from "babylonjs/Cameras/VR/index";
  50331. export * from "babylonjs/Cameras/RigModes/index";
  50332. }
  50333. declare module "babylonjs/Collisions/index" {
  50334. export * from "babylonjs/Collisions/collider";
  50335. export * from "babylonjs/Collisions/collisionCoordinator";
  50336. export * from "babylonjs/Collisions/pickingInfo";
  50337. export * from "babylonjs/Collisions/intersectionInfo";
  50338. export * from "babylonjs/Collisions/meshCollisionData";
  50339. }
  50340. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50341. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50342. import { Vector3 } from "babylonjs/Maths/math.vector";
  50343. import { Ray } from "babylonjs/Culling/ray";
  50344. import { Plane } from "babylonjs/Maths/math.plane";
  50345. /**
  50346. * Contains an array of blocks representing the octree
  50347. */
  50348. export interface IOctreeContainer<T> {
  50349. /**
  50350. * Blocks within the octree
  50351. */
  50352. blocks: Array<OctreeBlock<T>>;
  50353. }
  50354. /**
  50355. * Class used to store a cell in an octree
  50356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50357. */
  50358. export class OctreeBlock<T> {
  50359. /**
  50360. * Gets the content of the current block
  50361. */
  50362. entries: T[];
  50363. /**
  50364. * Gets the list of block children
  50365. */
  50366. blocks: Array<OctreeBlock<T>>;
  50367. private _depth;
  50368. private _maxDepth;
  50369. private _capacity;
  50370. private _minPoint;
  50371. private _maxPoint;
  50372. private _boundingVectors;
  50373. private _creationFunc;
  50374. /**
  50375. * Creates a new block
  50376. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50377. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50378. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50379. * @param depth defines the current depth of this block in the octree
  50380. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50381. * @param creationFunc defines a callback to call when an element is added to the block
  50382. */
  50383. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50384. /**
  50385. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50386. */
  50387. get capacity(): number;
  50388. /**
  50389. * Gets the minimum vector (in world space) of the block's bounding box
  50390. */
  50391. get minPoint(): Vector3;
  50392. /**
  50393. * Gets the maximum vector (in world space) of the block's bounding box
  50394. */
  50395. get maxPoint(): Vector3;
  50396. /**
  50397. * Add a new element to this block
  50398. * @param entry defines the element to add
  50399. */
  50400. addEntry(entry: T): void;
  50401. /**
  50402. * Remove an element from this block
  50403. * @param entry defines the element to remove
  50404. */
  50405. removeEntry(entry: T): void;
  50406. /**
  50407. * Add an array of elements to this block
  50408. * @param entries defines the array of elements to add
  50409. */
  50410. addEntries(entries: T[]): void;
  50411. /**
  50412. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50413. * @param frustumPlanes defines the frustum planes to test
  50414. * @param selection defines the array to store current content if selection is positive
  50415. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50416. */
  50417. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50418. /**
  50419. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50420. * @param sphereCenter defines the bounding sphere center
  50421. * @param sphereRadius defines the bounding sphere radius
  50422. * @param selection defines the array to store current content if selection is positive
  50423. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50424. */
  50425. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50426. /**
  50427. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50428. * @param ray defines the ray to test with
  50429. * @param selection defines the array to store current content if selection is positive
  50430. */
  50431. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50432. /**
  50433. * Subdivide the content into child blocks (this block will then be empty)
  50434. */
  50435. createInnerBlocks(): void;
  50436. /**
  50437. * @hidden
  50438. */
  50439. 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;
  50440. }
  50441. }
  50442. declare module "babylonjs/Culling/Octrees/octree" {
  50443. import { SmartArray } from "babylonjs/Misc/smartArray";
  50444. import { Vector3 } from "babylonjs/Maths/math.vector";
  50445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50447. import { Ray } from "babylonjs/Culling/ray";
  50448. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50449. import { Plane } from "babylonjs/Maths/math.plane";
  50450. /**
  50451. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50452. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50453. */
  50454. export class Octree<T> {
  50455. /** 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.) */
  50456. maxDepth: number;
  50457. /**
  50458. * Blocks within the octree containing objects
  50459. */
  50460. blocks: Array<OctreeBlock<T>>;
  50461. /**
  50462. * Content stored in the octree
  50463. */
  50464. dynamicContent: T[];
  50465. private _maxBlockCapacity;
  50466. private _selectionContent;
  50467. private _creationFunc;
  50468. /**
  50469. * Creates a octree
  50470. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50471. * @param creationFunc function to be used to instatiate the octree
  50472. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50473. * @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.)
  50474. */
  50475. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50476. /** 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.) */
  50477. maxDepth?: number);
  50478. /**
  50479. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50480. * @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);
  50481. * @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);
  50482. * @param entries meshes to be added to the octree blocks
  50483. */
  50484. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50485. /**
  50486. * Adds a mesh to the octree
  50487. * @param entry Mesh to add to the octree
  50488. */
  50489. addMesh(entry: T): void;
  50490. /**
  50491. * Remove an element from the octree
  50492. * @param entry defines the element to remove
  50493. */
  50494. removeMesh(entry: T): void;
  50495. /**
  50496. * Selects an array of meshes within the frustum
  50497. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50498. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50499. * @returns array of meshes within the frustum
  50500. */
  50501. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50502. /**
  50503. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50504. * @param sphereCenter defines the bounding sphere center
  50505. * @param sphereRadius defines the bounding sphere radius
  50506. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50507. * @returns an array of objects that intersect the sphere
  50508. */
  50509. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50510. /**
  50511. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50512. * @param ray defines the ray to test with
  50513. * @returns array of intersected objects
  50514. */
  50515. intersectsRay(ray: Ray): SmartArray<T>;
  50516. /**
  50517. * Adds a mesh into the octree block if it intersects the block
  50518. */
  50519. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50520. /**
  50521. * Adds a submesh into the octree block if it intersects the block
  50522. */
  50523. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50524. }
  50525. }
  50526. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50527. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50528. import { Scene } from "babylonjs/scene";
  50529. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50531. import { Ray } from "babylonjs/Culling/ray";
  50532. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50533. import { Collider } from "babylonjs/Collisions/collider";
  50534. module "babylonjs/scene" {
  50535. interface Scene {
  50536. /**
  50537. * @hidden
  50538. * Backing Filed
  50539. */
  50540. _selectionOctree: Octree<AbstractMesh>;
  50541. /**
  50542. * Gets the octree used to boost mesh selection (picking)
  50543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50544. */
  50545. selectionOctree: Octree<AbstractMesh>;
  50546. /**
  50547. * Creates or updates the octree used to boost selection (picking)
  50548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50549. * @param maxCapacity defines the maximum capacity per leaf
  50550. * @param maxDepth defines the maximum depth of the octree
  50551. * @returns an octree of AbstractMesh
  50552. */
  50553. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50554. }
  50555. }
  50556. module "babylonjs/Meshes/abstractMesh" {
  50557. interface AbstractMesh {
  50558. /**
  50559. * @hidden
  50560. * Backing Field
  50561. */
  50562. _submeshesOctree: Octree<SubMesh>;
  50563. /**
  50564. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50565. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50566. * @param maxCapacity defines the maximum size of each block (64 by default)
  50567. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50568. * @returns the new octree
  50569. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50571. */
  50572. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50573. }
  50574. }
  50575. /**
  50576. * Defines the octree scene component responsible to manage any octrees
  50577. * in a given scene.
  50578. */
  50579. export class OctreeSceneComponent {
  50580. /**
  50581. * The component name help to identify the component in the list of scene components.
  50582. */
  50583. readonly name: string;
  50584. /**
  50585. * The scene the component belongs to.
  50586. */
  50587. scene: Scene;
  50588. /**
  50589. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50590. */
  50591. readonly checksIsEnabled: boolean;
  50592. /**
  50593. * Creates a new instance of the component for the given scene
  50594. * @param scene Defines the scene to register the component in
  50595. */
  50596. constructor(scene: Scene);
  50597. /**
  50598. * Registers the component in a given scene
  50599. */
  50600. register(): void;
  50601. /**
  50602. * Return the list of active meshes
  50603. * @returns the list of active meshes
  50604. */
  50605. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50606. /**
  50607. * Return the list of active sub meshes
  50608. * @param mesh The mesh to get the candidates sub meshes from
  50609. * @returns the list of active sub meshes
  50610. */
  50611. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50612. private _tempRay;
  50613. /**
  50614. * Return the list of sub meshes intersecting with a given local ray
  50615. * @param mesh defines the mesh to find the submesh for
  50616. * @param localRay defines the ray in local space
  50617. * @returns the list of intersecting sub meshes
  50618. */
  50619. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50620. /**
  50621. * Return the list of sub meshes colliding with a collider
  50622. * @param mesh defines the mesh to find the submesh for
  50623. * @param collider defines the collider to evaluate the collision against
  50624. * @returns the list of colliding sub meshes
  50625. */
  50626. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50627. /**
  50628. * Rebuilds the elements related to this component in case of
  50629. * context lost for instance.
  50630. */
  50631. rebuild(): void;
  50632. /**
  50633. * Disposes the component and the associated ressources.
  50634. */
  50635. dispose(): void;
  50636. }
  50637. }
  50638. declare module "babylonjs/Culling/Octrees/index" {
  50639. export * from "babylonjs/Culling/Octrees/octree";
  50640. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50641. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50642. }
  50643. declare module "babylonjs/Culling/index" {
  50644. export * from "babylonjs/Culling/boundingBox";
  50645. export * from "babylonjs/Culling/boundingInfo";
  50646. export * from "babylonjs/Culling/boundingSphere";
  50647. export * from "babylonjs/Culling/Octrees/index";
  50648. export * from "babylonjs/Culling/ray";
  50649. }
  50650. declare module "babylonjs/Gizmos/gizmo" {
  50651. import { Nullable } from "babylonjs/types";
  50652. import { IDisposable } from "babylonjs/scene";
  50653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50654. import { Mesh } from "babylonjs/Meshes/mesh";
  50655. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50656. /**
  50657. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50658. */
  50659. export class Gizmo implements IDisposable {
  50660. /** The utility layer the gizmo will be added to */
  50661. gizmoLayer: UtilityLayerRenderer;
  50662. /**
  50663. * The root mesh of the gizmo
  50664. */
  50665. _rootMesh: Mesh;
  50666. private _attachedMesh;
  50667. /**
  50668. * Ratio for the scale of the gizmo (Default: 1)
  50669. */
  50670. scaleRatio: number;
  50671. /**
  50672. * If a custom mesh has been set (Default: false)
  50673. */
  50674. protected _customMeshSet: boolean;
  50675. /**
  50676. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50677. * * When set, interactions will be enabled
  50678. */
  50679. get attachedMesh(): Nullable<AbstractMesh>;
  50680. set attachedMesh(value: Nullable<AbstractMesh>);
  50681. /**
  50682. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50683. * @param mesh The mesh to replace the default mesh of the gizmo
  50684. */
  50685. setCustomMesh(mesh: Mesh): void;
  50686. /**
  50687. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50688. */
  50689. updateGizmoRotationToMatchAttachedMesh: boolean;
  50690. /**
  50691. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50692. */
  50693. updateGizmoPositionToMatchAttachedMesh: boolean;
  50694. /**
  50695. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50696. */
  50697. updateScale: boolean;
  50698. protected _interactionsEnabled: boolean;
  50699. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50700. private _beforeRenderObserver;
  50701. private _tempVector;
  50702. /**
  50703. * Creates a gizmo
  50704. * @param gizmoLayer The utility layer the gizmo will be added to
  50705. */
  50706. constructor(
  50707. /** The utility layer the gizmo will be added to */
  50708. gizmoLayer?: UtilityLayerRenderer);
  50709. /**
  50710. * Updates the gizmo to match the attached mesh's position/rotation
  50711. */
  50712. protected _update(): void;
  50713. /**
  50714. * Disposes of the gizmo
  50715. */
  50716. dispose(): void;
  50717. }
  50718. }
  50719. declare module "babylonjs/Gizmos/planeDragGizmo" {
  50720. import { Observable } from "babylonjs/Misc/observable";
  50721. import { Nullable } from "babylonjs/types";
  50722. import { Vector3 } from "babylonjs/Maths/math.vector";
  50723. import { Color3 } from "babylonjs/Maths/math.color";
  50724. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50726. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50727. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50728. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50729. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50730. import { Scene } from "babylonjs/scene";
  50731. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50732. /**
  50733. * Single plane drag gizmo
  50734. */
  50735. export class PlaneDragGizmo extends Gizmo {
  50736. /**
  50737. * Drag behavior responsible for the gizmos dragging interactions
  50738. */
  50739. dragBehavior: PointerDragBehavior;
  50740. private _pointerObserver;
  50741. /**
  50742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50743. */
  50744. snapDistance: number;
  50745. /**
  50746. * Event that fires each time the gizmo snaps to a new location.
  50747. * * snapDistance is the the change in distance
  50748. */
  50749. onSnapObservable: Observable<{
  50750. snapDistance: number;
  50751. }>;
  50752. private _plane;
  50753. private _coloredMaterial;
  50754. private _hoverMaterial;
  50755. private _isEnabled;
  50756. private _parent;
  50757. /** @hidden */
  50758. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50759. /** @hidden */
  50760. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50761. /**
  50762. * Creates a PlaneDragGizmo
  50763. * @param gizmoLayer The utility layer the gizmo will be added to
  50764. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50765. * @param color The color of the gizmo
  50766. */
  50767. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50768. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50769. /**
  50770. * If the gizmo is enabled
  50771. */
  50772. set isEnabled(value: boolean);
  50773. get isEnabled(): boolean;
  50774. /**
  50775. * Disposes of the gizmo
  50776. */
  50777. dispose(): void;
  50778. }
  50779. }
  50780. declare module "babylonjs/Gizmos/positionGizmo" {
  50781. import { Observable } from "babylonjs/Misc/observable";
  50782. import { Nullable } from "babylonjs/types";
  50783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50784. import { Mesh } from "babylonjs/Meshes/mesh";
  50785. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50786. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  50787. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  50788. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50789. /**
  50790. * Gizmo that enables dragging a mesh along 3 axis
  50791. */
  50792. export class PositionGizmo extends Gizmo {
  50793. /**
  50794. * Internal gizmo used for interactions on the x axis
  50795. */
  50796. xGizmo: AxisDragGizmo;
  50797. /**
  50798. * Internal gizmo used for interactions on the y axis
  50799. */
  50800. yGizmo: AxisDragGizmo;
  50801. /**
  50802. * Internal gizmo used for interactions on the z axis
  50803. */
  50804. zGizmo: AxisDragGizmo;
  50805. /**
  50806. * Internal gizmo used for interactions on the yz plane
  50807. */
  50808. xPlaneGizmo: PlaneDragGizmo;
  50809. /**
  50810. * Internal gizmo used for interactions on the xz plane
  50811. */
  50812. yPlaneGizmo: PlaneDragGizmo;
  50813. /**
  50814. * Internal gizmo used for interactions on the xy plane
  50815. */
  50816. zPlaneGizmo: PlaneDragGizmo;
  50817. /**
  50818. * private variables
  50819. */
  50820. private _meshAttached;
  50821. private _updateGizmoRotationToMatchAttachedMesh;
  50822. private _snapDistance;
  50823. private _scaleRatio;
  50824. /** Fires an event when any of it's sub gizmos are dragged */
  50825. onDragStartObservable: Observable<unknown>;
  50826. /** Fires an event when any of it's sub gizmos are released from dragging */
  50827. onDragEndObservable: Observable<unknown>;
  50828. /**
  50829. * If set to true, planar drag is enabled
  50830. */
  50831. private _planarGizmoEnabled;
  50832. get attachedMesh(): Nullable<AbstractMesh>;
  50833. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50834. /**
  50835. * Creates a PositionGizmo
  50836. * @param gizmoLayer The utility layer the gizmo will be added to
  50837. */
  50838. constructor(gizmoLayer?: UtilityLayerRenderer);
  50839. /**
  50840. * If the planar drag gizmo is enabled
  50841. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50842. */
  50843. set planarGizmoEnabled(value: boolean);
  50844. get planarGizmoEnabled(): boolean;
  50845. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50846. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50847. /**
  50848. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50849. */
  50850. set snapDistance(value: number);
  50851. get snapDistance(): number;
  50852. /**
  50853. * Ratio for the scale of the gizmo (Default: 1)
  50854. */
  50855. set scaleRatio(value: number);
  50856. get scaleRatio(): number;
  50857. /**
  50858. * Disposes of the gizmo
  50859. */
  50860. dispose(): void;
  50861. /**
  50862. * CustomMeshes are not supported by this gizmo
  50863. * @param mesh The mesh to replace the default mesh of the gizmo
  50864. */
  50865. setCustomMesh(mesh: Mesh): void;
  50866. }
  50867. }
  50868. declare module "babylonjs/Gizmos/axisDragGizmo" {
  50869. import { Observable } from "babylonjs/Misc/observable";
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Vector3 } from "babylonjs/Maths/math.vector";
  50872. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50874. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50875. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50876. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50877. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50878. import { Scene } from "babylonjs/scene";
  50879. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50880. import { Color3 } from "babylonjs/Maths/math.color";
  50881. /**
  50882. * Single axis drag gizmo
  50883. */
  50884. export class AxisDragGizmo extends Gizmo {
  50885. /**
  50886. * Drag behavior responsible for the gizmos dragging interactions
  50887. */
  50888. dragBehavior: PointerDragBehavior;
  50889. private _pointerObserver;
  50890. /**
  50891. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50892. */
  50893. snapDistance: number;
  50894. /**
  50895. * Event that fires each time the gizmo snaps to a new location.
  50896. * * snapDistance is the the change in distance
  50897. */
  50898. onSnapObservable: Observable<{
  50899. snapDistance: number;
  50900. }>;
  50901. private _isEnabled;
  50902. private _parent;
  50903. private _arrow;
  50904. private _coloredMaterial;
  50905. private _hoverMaterial;
  50906. /** @hidden */
  50907. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  50908. /** @hidden */
  50909. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50910. /**
  50911. * Creates an AxisDragGizmo
  50912. * @param gizmoLayer The utility layer the gizmo will be added to
  50913. * @param dragAxis The axis which the gizmo will be able to drag on
  50914. * @param color The color of the gizmo
  50915. */
  50916. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50917. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50918. /**
  50919. * If the gizmo is enabled
  50920. */
  50921. set isEnabled(value: boolean);
  50922. get isEnabled(): boolean;
  50923. /**
  50924. * Disposes of the gizmo
  50925. */
  50926. dispose(): void;
  50927. }
  50928. }
  50929. declare module "babylonjs/Debug/axesViewer" {
  50930. import { Vector3 } from "babylonjs/Maths/math.vector";
  50931. import { Nullable } from "babylonjs/types";
  50932. import { Scene } from "babylonjs/scene";
  50933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50934. /**
  50935. * The Axes viewer will show 3 axes in a specific point in space
  50936. */
  50937. export class AxesViewer {
  50938. private _xAxis;
  50939. private _yAxis;
  50940. private _zAxis;
  50941. private _scaleLinesFactor;
  50942. private _instanced;
  50943. /**
  50944. * Gets the hosting scene
  50945. */
  50946. scene: Scene;
  50947. /**
  50948. * Gets or sets a number used to scale line length
  50949. */
  50950. scaleLines: number;
  50951. /** Gets the node hierarchy used to render x-axis */
  50952. get xAxis(): TransformNode;
  50953. /** Gets the node hierarchy used to render y-axis */
  50954. get yAxis(): TransformNode;
  50955. /** Gets the node hierarchy used to render z-axis */
  50956. get zAxis(): TransformNode;
  50957. /**
  50958. * Creates a new AxesViewer
  50959. * @param scene defines the hosting scene
  50960. * @param scaleLines defines a number used to scale line length (1 by default)
  50961. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50962. * @param xAxis defines the node hierarchy used to render the x-axis
  50963. * @param yAxis defines the node hierarchy used to render the y-axis
  50964. * @param zAxis defines the node hierarchy used to render the z-axis
  50965. */
  50966. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50967. /**
  50968. * Force the viewer to update
  50969. * @param position defines the position of the viewer
  50970. * @param xaxis defines the x axis of the viewer
  50971. * @param yaxis defines the y axis of the viewer
  50972. * @param zaxis defines the z axis of the viewer
  50973. */
  50974. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50975. /**
  50976. * Creates an instance of this axes viewer.
  50977. * @returns a new axes viewer with instanced meshes
  50978. */
  50979. createInstance(): AxesViewer;
  50980. /** Releases resources */
  50981. dispose(): void;
  50982. private static _SetRenderingGroupId;
  50983. }
  50984. }
  50985. declare module "babylonjs/Debug/boneAxesViewer" {
  50986. import { Nullable } from "babylonjs/types";
  50987. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  50988. import { Vector3 } from "babylonjs/Maths/math.vector";
  50989. import { Mesh } from "babylonjs/Meshes/mesh";
  50990. import { Bone } from "babylonjs/Bones/bone";
  50991. import { Scene } from "babylonjs/scene";
  50992. /**
  50993. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50994. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50995. */
  50996. export class BoneAxesViewer extends AxesViewer {
  50997. /**
  50998. * Gets or sets the target mesh where to display the axes viewer
  50999. */
  51000. mesh: Nullable<Mesh>;
  51001. /**
  51002. * Gets or sets the target bone where to display the axes viewer
  51003. */
  51004. bone: Nullable<Bone>;
  51005. /** Gets current position */
  51006. pos: Vector3;
  51007. /** Gets direction of X axis */
  51008. xaxis: Vector3;
  51009. /** Gets direction of Y axis */
  51010. yaxis: Vector3;
  51011. /** Gets direction of Z axis */
  51012. zaxis: Vector3;
  51013. /**
  51014. * Creates a new BoneAxesViewer
  51015. * @param scene defines the hosting scene
  51016. * @param bone defines the target bone
  51017. * @param mesh defines the target mesh
  51018. * @param scaleLines defines a scaling factor for line length (1 by default)
  51019. */
  51020. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51021. /**
  51022. * Force the viewer to update
  51023. */
  51024. update(): void;
  51025. /** Releases resources */
  51026. dispose(): void;
  51027. }
  51028. }
  51029. declare module "babylonjs/Debug/debugLayer" {
  51030. import { Scene } from "babylonjs/scene";
  51031. /**
  51032. * Interface used to define scene explorer extensibility option
  51033. */
  51034. export interface IExplorerExtensibilityOption {
  51035. /**
  51036. * Define the option label
  51037. */
  51038. label: string;
  51039. /**
  51040. * Defines the action to execute on click
  51041. */
  51042. action: (entity: any) => void;
  51043. }
  51044. /**
  51045. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51046. */
  51047. export interface IExplorerExtensibilityGroup {
  51048. /**
  51049. * Defines a predicate to test if a given type mut be extended
  51050. */
  51051. predicate: (entity: any) => boolean;
  51052. /**
  51053. * Gets the list of options added to a type
  51054. */
  51055. entries: IExplorerExtensibilityOption[];
  51056. }
  51057. /**
  51058. * Interface used to define the options to use to create the Inspector
  51059. */
  51060. export interface IInspectorOptions {
  51061. /**
  51062. * Display in overlay mode (default: false)
  51063. */
  51064. overlay?: boolean;
  51065. /**
  51066. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51067. */
  51068. globalRoot?: HTMLElement;
  51069. /**
  51070. * Display the Scene explorer
  51071. */
  51072. showExplorer?: boolean;
  51073. /**
  51074. * Display the property inspector
  51075. */
  51076. showInspector?: boolean;
  51077. /**
  51078. * Display in embed mode (both panes on the right)
  51079. */
  51080. embedMode?: boolean;
  51081. /**
  51082. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51083. */
  51084. handleResize?: boolean;
  51085. /**
  51086. * Allow the panes to popup (default: true)
  51087. */
  51088. enablePopup?: boolean;
  51089. /**
  51090. * Allow the panes to be closed by users (default: true)
  51091. */
  51092. enableClose?: boolean;
  51093. /**
  51094. * Optional list of extensibility entries
  51095. */
  51096. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51097. /**
  51098. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51099. */
  51100. inspectorURL?: string;
  51101. /**
  51102. * Optional initial tab (default to DebugLayerTab.Properties)
  51103. */
  51104. initialTab?: DebugLayerTab;
  51105. }
  51106. module "babylonjs/scene" {
  51107. interface Scene {
  51108. /**
  51109. * @hidden
  51110. * Backing field
  51111. */
  51112. _debugLayer: DebugLayer;
  51113. /**
  51114. * Gets the debug layer (aka Inspector) associated with the scene
  51115. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51116. */
  51117. debugLayer: DebugLayer;
  51118. }
  51119. }
  51120. /**
  51121. * Enum of inspector action tab
  51122. */
  51123. export enum DebugLayerTab {
  51124. /**
  51125. * Properties tag (default)
  51126. */
  51127. Properties = 0,
  51128. /**
  51129. * Debug tab
  51130. */
  51131. Debug = 1,
  51132. /**
  51133. * Statistics tab
  51134. */
  51135. Statistics = 2,
  51136. /**
  51137. * Tools tab
  51138. */
  51139. Tools = 3,
  51140. /**
  51141. * Settings tab
  51142. */
  51143. Settings = 4
  51144. }
  51145. /**
  51146. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51147. * what is happening in your scene
  51148. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51149. */
  51150. export class DebugLayer {
  51151. /**
  51152. * Define the url to get the inspector script from.
  51153. * By default it uses the babylonjs CDN.
  51154. * @ignoreNaming
  51155. */
  51156. static InspectorURL: string;
  51157. private _scene;
  51158. private BJSINSPECTOR;
  51159. private _onPropertyChangedObservable?;
  51160. /**
  51161. * Observable triggered when a property is changed through the inspector.
  51162. */
  51163. get onPropertyChangedObservable(): any;
  51164. /**
  51165. * Instantiates a new debug layer.
  51166. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51167. * what is happening in your scene
  51168. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51169. * @param scene Defines the scene to inspect
  51170. */
  51171. constructor(scene: Scene);
  51172. /** Creates the inspector window. */
  51173. private _createInspector;
  51174. /**
  51175. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51176. * @param entity defines the entity to select
  51177. * @param lineContainerTitle defines the specific block to highlight
  51178. */
  51179. select(entity: any, lineContainerTitle?: string): void;
  51180. /** Get the inspector from bundle or global */
  51181. private _getGlobalInspector;
  51182. /**
  51183. * Get if the inspector is visible or not.
  51184. * @returns true if visible otherwise, false
  51185. */
  51186. isVisible(): boolean;
  51187. /**
  51188. * Hide the inspector and close its window.
  51189. */
  51190. hide(): void;
  51191. /**
  51192. * Update the scene in the inspector
  51193. */
  51194. setAsActiveScene(): void;
  51195. /**
  51196. * Launch the debugLayer.
  51197. * @param config Define the configuration of the inspector
  51198. * @return a promise fulfilled when the debug layer is visible
  51199. */
  51200. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51201. }
  51202. }
  51203. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51204. import { Nullable } from "babylonjs/types";
  51205. import { Scene } from "babylonjs/scene";
  51206. import { Vector4 } from "babylonjs/Maths/math.vector";
  51207. import { Color4 } from "babylonjs/Maths/math.color";
  51208. import { Mesh } from "babylonjs/Meshes/mesh";
  51209. /**
  51210. * Class containing static functions to help procedurally build meshes
  51211. */
  51212. export class BoxBuilder {
  51213. /**
  51214. * Creates a box mesh
  51215. * * The parameter `size` sets the size (float) of each box side (default 1)
  51216. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51217. * * 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)
  51218. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51222. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51223. * @param name defines the name of the mesh
  51224. * @param options defines the options used to create the mesh
  51225. * @param scene defines the hosting scene
  51226. * @returns the box mesh
  51227. */
  51228. static CreateBox(name: string, options: {
  51229. size?: number;
  51230. width?: number;
  51231. height?: number;
  51232. depth?: number;
  51233. faceUV?: Vector4[];
  51234. faceColors?: Color4[];
  51235. sideOrientation?: number;
  51236. frontUVs?: Vector4;
  51237. backUVs?: Vector4;
  51238. wrap?: boolean;
  51239. topBaseAt?: number;
  51240. bottomBaseAt?: number;
  51241. updatable?: boolean;
  51242. }, scene?: Nullable<Scene>): Mesh;
  51243. }
  51244. }
  51245. declare module "babylonjs/Debug/physicsViewer" {
  51246. import { Nullable } from "babylonjs/types";
  51247. import { Scene } from "babylonjs/scene";
  51248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51249. import { Mesh } from "babylonjs/Meshes/mesh";
  51250. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51251. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51252. /**
  51253. * Used to show the physics impostor around the specific mesh
  51254. */
  51255. export class PhysicsViewer {
  51256. /** @hidden */
  51257. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51258. /** @hidden */
  51259. protected _meshes: Array<Nullable<AbstractMesh>>;
  51260. /** @hidden */
  51261. protected _scene: Nullable<Scene>;
  51262. /** @hidden */
  51263. protected _numMeshes: number;
  51264. /** @hidden */
  51265. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51266. private _renderFunction;
  51267. private _utilityLayer;
  51268. private _debugBoxMesh;
  51269. private _debugSphereMesh;
  51270. private _debugCylinderMesh;
  51271. private _debugMaterial;
  51272. private _debugMeshMeshes;
  51273. /**
  51274. * Creates a new PhysicsViewer
  51275. * @param scene defines the hosting scene
  51276. */
  51277. constructor(scene: Scene);
  51278. /** @hidden */
  51279. protected _updateDebugMeshes(): void;
  51280. /**
  51281. * Renders a specified physic impostor
  51282. * @param impostor defines the impostor to render
  51283. * @param targetMesh defines the mesh represented by the impostor
  51284. * @returns the new debug mesh used to render the impostor
  51285. */
  51286. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51287. /**
  51288. * Hides a specified physic impostor
  51289. * @param impostor defines the impostor to hide
  51290. */
  51291. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51292. private _getDebugMaterial;
  51293. private _getDebugBoxMesh;
  51294. private _getDebugSphereMesh;
  51295. private _getDebugCylinderMesh;
  51296. private _getDebugMeshMesh;
  51297. private _getDebugMesh;
  51298. /** Releases all resources */
  51299. dispose(): void;
  51300. }
  51301. }
  51302. declare module "babylonjs/Debug/rayHelper" {
  51303. import { Nullable } from "babylonjs/types";
  51304. import { Ray } from "babylonjs/Culling/ray";
  51305. import { Vector3 } from "babylonjs/Maths/math.vector";
  51306. import { Color3 } from "babylonjs/Maths/math.color";
  51307. import { Scene } from "babylonjs/scene";
  51308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51309. import "babylonjs/Meshes/Builders/linesBuilder";
  51310. /**
  51311. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51312. * in order to better appreciate the issue one might have.
  51313. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51314. */
  51315. export class RayHelper {
  51316. /**
  51317. * Defines the ray we are currently tryin to visualize.
  51318. */
  51319. ray: Nullable<Ray>;
  51320. private _renderPoints;
  51321. private _renderLine;
  51322. private _renderFunction;
  51323. private _scene;
  51324. private _updateToMeshFunction;
  51325. private _attachedToMesh;
  51326. private _meshSpaceDirection;
  51327. private _meshSpaceOrigin;
  51328. /**
  51329. * Helper function to create a colored helper in a scene in one line.
  51330. * @param ray Defines the ray we are currently tryin to visualize
  51331. * @param scene Defines the scene the ray is used in
  51332. * @param color Defines the color we want to see the ray in
  51333. * @returns The newly created ray helper.
  51334. */
  51335. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51336. /**
  51337. * Instantiate a new ray helper.
  51338. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51339. * in order to better appreciate the issue one might have.
  51340. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51341. * @param ray Defines the ray we are currently tryin to visualize
  51342. */
  51343. constructor(ray: Ray);
  51344. /**
  51345. * Shows the ray we are willing to debug.
  51346. * @param scene Defines the scene the ray needs to be rendered in
  51347. * @param color Defines the color the ray needs to be rendered in
  51348. */
  51349. show(scene: Scene, color?: Color3): void;
  51350. /**
  51351. * Hides the ray we are debugging.
  51352. */
  51353. hide(): void;
  51354. private _render;
  51355. /**
  51356. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51357. * @param mesh Defines the mesh we want the helper attached to
  51358. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51359. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51360. * @param length Defines the length of the ray
  51361. */
  51362. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51363. /**
  51364. * Detach the ray helper from the mesh it has previously been attached to.
  51365. */
  51366. detachFromMesh(): void;
  51367. private _updateToMesh;
  51368. /**
  51369. * Dispose the helper and release its associated resources.
  51370. */
  51371. dispose(): void;
  51372. }
  51373. }
  51374. declare module "babylonjs/Debug/skeletonViewer" {
  51375. import { Color3 } from "babylonjs/Maths/math.color";
  51376. import { Scene } from "babylonjs/scene";
  51377. import { Nullable } from "babylonjs/types";
  51378. import { Skeleton } from "babylonjs/Bones/skeleton";
  51379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51380. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51381. /**
  51382. * Class used to render a debug view of a given skeleton
  51383. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51384. */
  51385. export class SkeletonViewer {
  51386. /** defines the skeleton to render */
  51387. skeleton: Skeleton;
  51388. /** defines the mesh attached to the skeleton */
  51389. mesh: AbstractMesh;
  51390. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51391. autoUpdateBonesMatrices: boolean;
  51392. /** defines the rendering group id to use with the viewer */
  51393. renderingGroupId: number;
  51394. /** Gets or sets the color used to render the skeleton */
  51395. color: Color3;
  51396. private _scene;
  51397. private _debugLines;
  51398. private _debugMesh;
  51399. private _isEnabled;
  51400. private _renderFunction;
  51401. private _utilityLayer;
  51402. /**
  51403. * Returns the mesh used to render the bones
  51404. */
  51405. get debugMesh(): Nullable<LinesMesh>;
  51406. /**
  51407. * Creates a new SkeletonViewer
  51408. * @param skeleton defines the skeleton to render
  51409. * @param mesh defines the mesh attached to the skeleton
  51410. * @param scene defines the hosting scene
  51411. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51412. * @param renderingGroupId defines the rendering group id to use with the viewer
  51413. */
  51414. constructor(
  51415. /** defines the skeleton to render */
  51416. skeleton: Skeleton,
  51417. /** defines the mesh attached to the skeleton */
  51418. mesh: AbstractMesh, scene: Scene,
  51419. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51420. autoUpdateBonesMatrices?: boolean,
  51421. /** defines the rendering group id to use with the viewer */
  51422. renderingGroupId?: number);
  51423. /** Gets or sets a boolean indicating if the viewer is enabled */
  51424. set isEnabled(value: boolean);
  51425. get isEnabled(): boolean;
  51426. private _getBonePosition;
  51427. private _getLinesForBonesWithLength;
  51428. private _getLinesForBonesNoLength;
  51429. /** Update the viewer to sync with current skeleton state */
  51430. update(): void;
  51431. /** Release associated resources */
  51432. dispose(): void;
  51433. }
  51434. }
  51435. declare module "babylonjs/Debug/index" {
  51436. export * from "babylonjs/Debug/axesViewer";
  51437. export * from "babylonjs/Debug/boneAxesViewer";
  51438. export * from "babylonjs/Debug/debugLayer";
  51439. export * from "babylonjs/Debug/physicsViewer";
  51440. export * from "babylonjs/Debug/rayHelper";
  51441. export * from "babylonjs/Debug/skeletonViewer";
  51442. }
  51443. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51444. /**
  51445. * Enum for Device Types
  51446. */
  51447. export enum DeviceType {
  51448. /** Generic */
  51449. Generic = 0,
  51450. /** Keyboard */
  51451. Keyboard = 1,
  51452. /** Mouse */
  51453. Mouse = 2,
  51454. /** Touch Pointers */
  51455. Touch = 3,
  51456. /** PS4 Dual Shock */
  51457. DualShock = 4,
  51458. /** Xbox */
  51459. Xbox = 5,
  51460. /** Switch Controller */
  51461. Switch = 6
  51462. }
  51463. /**
  51464. * Enum for All Pointers (Touch/Mouse)
  51465. */
  51466. export enum PointerInput {
  51467. /** Horizontal Axis */
  51468. Horizontal = 0,
  51469. /** Vertical Axis */
  51470. Vertical = 1,
  51471. /** Left Click or Touch */
  51472. LeftClick = 2,
  51473. /** Middle Click */
  51474. MiddleClick = 3,
  51475. /** Right Click */
  51476. RightClick = 4,
  51477. /** Browser Back */
  51478. BrowserBack = 5,
  51479. /** Browser Forward */
  51480. BrowserForward = 6
  51481. }
  51482. /**
  51483. * Enum for Dual Shock Gamepad
  51484. */
  51485. export enum DualShockInput {
  51486. /** Cross */
  51487. Cross = 0,
  51488. /** Circle */
  51489. Circle = 1,
  51490. /** Square */
  51491. Square = 2,
  51492. /** Triangle */
  51493. Triangle = 3,
  51494. /** L1 */
  51495. L1 = 4,
  51496. /** R1 */
  51497. R1 = 5,
  51498. /** L2 */
  51499. L2 = 6,
  51500. /** R2 */
  51501. R2 = 7,
  51502. /** Share */
  51503. Share = 8,
  51504. /** Options */
  51505. Options = 9,
  51506. /** L3 */
  51507. L3 = 10,
  51508. /** R3 */
  51509. R3 = 11,
  51510. /** DPadUp */
  51511. DPadUp = 12,
  51512. /** DPadDown */
  51513. DPadDown = 13,
  51514. /** DPadLeft */
  51515. DPadLeft = 14,
  51516. /** DRight */
  51517. DPadRight = 15,
  51518. /** Home */
  51519. Home = 16,
  51520. /** TouchPad */
  51521. TouchPad = 17,
  51522. /** LStickXAxis */
  51523. LStickXAxis = 18,
  51524. /** LStickYAxis */
  51525. LStickYAxis = 19,
  51526. /** RStickXAxis */
  51527. RStickXAxis = 20,
  51528. /** RStickYAxis */
  51529. RStickYAxis = 21
  51530. }
  51531. /**
  51532. * Enum for Xbox Gamepad
  51533. */
  51534. export enum XboxInput {
  51535. /** A */
  51536. A = 0,
  51537. /** B */
  51538. B = 1,
  51539. /** X */
  51540. X = 2,
  51541. /** Y */
  51542. Y = 3,
  51543. /** LB */
  51544. LB = 4,
  51545. /** RB */
  51546. RB = 5,
  51547. /** LT */
  51548. LT = 6,
  51549. /** RT */
  51550. RT = 7,
  51551. /** Back */
  51552. Back = 8,
  51553. /** Start */
  51554. Start = 9,
  51555. /** LS */
  51556. LS = 10,
  51557. /** RS */
  51558. RS = 11,
  51559. /** DPadUp */
  51560. DPadUp = 12,
  51561. /** DPadDown */
  51562. DPadDown = 13,
  51563. /** DPadLeft */
  51564. DPadLeft = 14,
  51565. /** DRight */
  51566. DPadRight = 15,
  51567. /** Home */
  51568. Home = 16,
  51569. /** LStickXAxis */
  51570. LStickXAxis = 17,
  51571. /** LStickYAxis */
  51572. LStickYAxis = 18,
  51573. /** RStickXAxis */
  51574. RStickXAxis = 19,
  51575. /** RStickYAxis */
  51576. RStickYAxis = 20
  51577. }
  51578. /**
  51579. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51580. */
  51581. export enum SwitchInput {
  51582. /** B */
  51583. B = 0,
  51584. /** A */
  51585. A = 1,
  51586. /** Y */
  51587. Y = 2,
  51588. /** X */
  51589. X = 3,
  51590. /** L */
  51591. L = 4,
  51592. /** R */
  51593. R = 5,
  51594. /** ZL */
  51595. ZL = 6,
  51596. /** ZR */
  51597. ZR = 7,
  51598. /** Minus */
  51599. Minus = 8,
  51600. /** Plus */
  51601. Plus = 9,
  51602. /** LS */
  51603. LS = 10,
  51604. /** RS */
  51605. RS = 11,
  51606. /** DPadUp */
  51607. DPadUp = 12,
  51608. /** DPadDown */
  51609. DPadDown = 13,
  51610. /** DPadLeft */
  51611. DPadLeft = 14,
  51612. /** DRight */
  51613. DPadRight = 15,
  51614. /** Home */
  51615. Home = 16,
  51616. /** Capture */
  51617. Capture = 17,
  51618. /** LStickXAxis */
  51619. LStickXAxis = 18,
  51620. /** LStickYAxis */
  51621. LStickYAxis = 19,
  51622. /** RStickXAxis */
  51623. RStickXAxis = 20,
  51624. /** RStickYAxis */
  51625. RStickYAxis = 21
  51626. }
  51627. }
  51628. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51629. import { Engine } from "babylonjs/Engines/engine";
  51630. import { IDisposable } from "babylonjs/scene";
  51631. import { Nullable } from "babylonjs/types";
  51632. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51633. /**
  51634. * This class will take all inputs from Keyboard, Pointer, and
  51635. * any Gamepads and provide a polling system that all devices
  51636. * will use. This class assumes that there will only be one
  51637. * pointer device and one keyboard.
  51638. */
  51639. export class DeviceInputSystem implements IDisposable {
  51640. /**
  51641. * Callback to be triggered when a device is connected
  51642. */
  51643. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51644. /**
  51645. * Callback to be triggered when a device is disconnected
  51646. */
  51647. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51648. /**
  51649. * Callback to be triggered when event driven input is updated
  51650. */
  51651. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51652. private _inputs;
  51653. private _gamepads;
  51654. private _keyboardActive;
  51655. private _pointerActive;
  51656. private _elementToAttachTo;
  51657. private _keyboardDownEvent;
  51658. private _keyboardUpEvent;
  51659. private _pointerMoveEvent;
  51660. private _pointerDownEvent;
  51661. private _pointerUpEvent;
  51662. private _gamepadConnectedEvent;
  51663. private _gamepadDisconnectedEvent;
  51664. private static _MAX_KEYCODES;
  51665. private static _MAX_POINTER_INPUTS;
  51666. /**
  51667. * Default Constructor
  51668. * @param engine - engine to pull input element from
  51669. */
  51670. constructor(engine: Engine);
  51671. /**
  51672. * Checks for current device input value, given an id and input index
  51673. * @param deviceName Id of connected device
  51674. * @param inputIndex Index of device input
  51675. * @returns Current value of input
  51676. */
  51677. /**
  51678. * Checks for current device input value, given an id and input index
  51679. * @param deviceType Enum specifiying device type
  51680. * @param deviceSlot "Slot" or index that device is referenced in
  51681. * @param inputIndex Id of input to be checked
  51682. * @returns Current value of input
  51683. */
  51684. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51685. /**
  51686. * Dispose of all the eventlisteners
  51687. */
  51688. dispose(): void;
  51689. /**
  51690. * Add device and inputs to device array
  51691. * @param deviceType Enum specifiying device type
  51692. * @param deviceSlot "Slot" or index that device is referenced in
  51693. * @param numberOfInputs Number of input entries to create for given device
  51694. */
  51695. private _registerDevice;
  51696. /**
  51697. * Given a specific device name, remove that device from the device map
  51698. * @param deviceType Enum specifiying device type
  51699. * @param deviceSlot "Slot" or index that device is referenced in
  51700. */
  51701. private _unregisterDevice;
  51702. /**
  51703. * Handle all actions that come from keyboard interaction
  51704. */
  51705. private _handleKeyActions;
  51706. /**
  51707. * Handle all actions that come from pointer interaction
  51708. */
  51709. private _handlePointerActions;
  51710. /**
  51711. * Handle all actions that come from gamepad interaction
  51712. */
  51713. private _handleGamepadActions;
  51714. /**
  51715. * Update all non-event based devices with each frame
  51716. * @param deviceType Enum specifiying device type
  51717. * @param deviceSlot "Slot" or index that device is referenced in
  51718. * @param inputIndex Id of input to be checked
  51719. */
  51720. private _updateDevice;
  51721. /**
  51722. * Gets DeviceType from the device name
  51723. * @param deviceName Name of Device from DeviceInputSystem
  51724. * @returns DeviceType enum value
  51725. */
  51726. private _getGamepadDeviceType;
  51727. }
  51728. }
  51729. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  51730. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51731. /**
  51732. * Type to handle enforcement of inputs
  51733. */
  51734. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  51735. }
  51736. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  51737. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  51738. import { Engine } from "babylonjs/Engines/engine";
  51739. import { IDisposable } from "babylonjs/scene";
  51740. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51741. import { Nullable } from "babylonjs/types";
  51742. import { Observable } from "babylonjs/Misc/observable";
  51743. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51744. /**
  51745. * Class that handles all input for a specific device
  51746. */
  51747. export class DeviceSource<T extends DeviceType> {
  51748. /** Type of device */
  51749. readonly deviceType: DeviceType;
  51750. /** "Slot" or index that device is referenced in */
  51751. readonly deviceSlot: number;
  51752. /**
  51753. * Observable to handle device input changes per device
  51754. */
  51755. readonly onInputChangedObservable: Observable<{
  51756. inputIndex: DeviceInput<T>;
  51757. previousState: Nullable<number>;
  51758. currentState: Nullable<number>;
  51759. }>;
  51760. private readonly _deviceInputSystem;
  51761. /**
  51762. * Default Constructor
  51763. * @param deviceInputSystem Reference to DeviceInputSystem
  51764. * @param deviceType Type of device
  51765. * @param deviceSlot "Slot" or index that device is referenced in
  51766. */
  51767. constructor(deviceInputSystem: DeviceInputSystem,
  51768. /** Type of device */
  51769. deviceType: DeviceType,
  51770. /** "Slot" or index that device is referenced in */
  51771. deviceSlot?: number);
  51772. /**
  51773. * Get input for specific input
  51774. * @param inputIndex index of specific input on device
  51775. * @returns Input value from DeviceInputSystem
  51776. */
  51777. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51778. }
  51779. /**
  51780. * Class to keep track of devices
  51781. */
  51782. export class DeviceSourceManager implements IDisposable {
  51783. /**
  51784. * Observable to be triggered when before a device is connected
  51785. */
  51786. readonly onBeforeDeviceConnectedObservable: Observable<{
  51787. deviceType: DeviceType;
  51788. deviceSlot: number;
  51789. }>;
  51790. /**
  51791. * Observable to be triggered when before a device is disconnected
  51792. */
  51793. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51794. deviceType: DeviceType;
  51795. deviceSlot: number;
  51796. }>;
  51797. /**
  51798. * Observable to be triggered when after a device is connected
  51799. */
  51800. readonly onAfterDeviceConnectedObservable: Observable<{
  51801. deviceType: DeviceType;
  51802. deviceSlot: number;
  51803. }>;
  51804. /**
  51805. * Observable to be triggered when after a device is disconnected
  51806. */
  51807. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51808. deviceType: DeviceType;
  51809. deviceSlot: number;
  51810. }>;
  51811. private readonly _devices;
  51812. private readonly _firstDevice;
  51813. private readonly _deviceInputSystem;
  51814. /**
  51815. * Default Constructor
  51816. * @param engine engine to pull input element from
  51817. */
  51818. constructor(engine: Engine);
  51819. /**
  51820. * Gets a DeviceSource, given a type and slot
  51821. * @param deviceType Enum specifying device type
  51822. * @param deviceSlot "Slot" or index that device is referenced in
  51823. * @returns DeviceSource object
  51824. */
  51825. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51826. /**
  51827. * Gets an array of DeviceSource objects for a given device type
  51828. * @param deviceType Enum specifying device type
  51829. * @returns Array of DeviceSource objects
  51830. */
  51831. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51832. /**
  51833. * Dispose of DeviceInputSystem and other parts
  51834. */
  51835. dispose(): void;
  51836. /**
  51837. * Function to add device name to device list
  51838. * @param deviceType Enum specifying device type
  51839. * @param deviceSlot "Slot" or index that device is referenced in
  51840. */
  51841. private _addDevice;
  51842. /**
  51843. * Function to remove device name to device list
  51844. * @param deviceType Enum specifying device type
  51845. * @param deviceSlot "Slot" or index that device is referenced in
  51846. */
  51847. private _removeDevice;
  51848. /**
  51849. * Updates array storing first connected device of each type
  51850. * @param type Type of Device
  51851. */
  51852. private _updateFirstDevices;
  51853. }
  51854. }
  51855. declare module "babylonjs/DeviceInput/index" {
  51856. export * from "babylonjs/DeviceInput/deviceInputSystem";
  51857. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51858. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51859. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51860. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51861. }
  51862. declare module "babylonjs/Engines/nullEngine" {
  51863. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  51864. import { Engine } from "babylonjs/Engines/engine";
  51865. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  51866. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  51867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51868. import { Effect } from "babylonjs/Materials/effect";
  51869. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  51870. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  51871. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  51872. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  51873. /**
  51874. * Options to create the null engine
  51875. */
  51876. export class NullEngineOptions {
  51877. /**
  51878. * Render width (Default: 512)
  51879. */
  51880. renderWidth: number;
  51881. /**
  51882. * Render height (Default: 256)
  51883. */
  51884. renderHeight: number;
  51885. /**
  51886. * Texture size (Default: 512)
  51887. */
  51888. textureSize: number;
  51889. /**
  51890. * If delta time between frames should be constant
  51891. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51892. */
  51893. deterministicLockstep: boolean;
  51894. /**
  51895. * Maximum about of steps between frames (Default: 4)
  51896. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51897. */
  51898. lockstepMaxSteps: number;
  51899. }
  51900. /**
  51901. * The null engine class provides support for headless version of babylon.js.
  51902. * This can be used in server side scenario or for testing purposes
  51903. */
  51904. export class NullEngine extends Engine {
  51905. private _options;
  51906. /**
  51907. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51909. * @returns true if engine is in deterministic lock step mode
  51910. */
  51911. isDeterministicLockStep(): boolean;
  51912. /**
  51913. * Gets the max steps when engine is running in deterministic lock step
  51914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51915. * @returns the max steps
  51916. */
  51917. getLockstepMaxSteps(): number;
  51918. /**
  51919. * Gets the current hardware scaling level.
  51920. * By default the hardware scaling level is computed from the window device ratio.
  51921. * 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.
  51922. * @returns a number indicating the current hardware scaling level
  51923. */
  51924. getHardwareScalingLevel(): number;
  51925. constructor(options?: NullEngineOptions);
  51926. /**
  51927. * Creates a vertex buffer
  51928. * @param vertices the data for the vertex buffer
  51929. * @returns the new WebGL static buffer
  51930. */
  51931. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51932. /**
  51933. * Creates a new index buffer
  51934. * @param indices defines the content of the index buffer
  51935. * @param updatable defines if the index buffer must be updatable
  51936. * @returns a new webGL buffer
  51937. */
  51938. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51939. /**
  51940. * Clear the current render buffer or the current render target (if any is set up)
  51941. * @param color defines the color to use
  51942. * @param backBuffer defines if the back buffer must be cleared
  51943. * @param depth defines if the depth buffer must be cleared
  51944. * @param stencil defines if the stencil buffer must be cleared
  51945. */
  51946. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51947. /**
  51948. * Gets the current render width
  51949. * @param useScreen defines if screen size must be used (or the current render target if any)
  51950. * @returns a number defining the current render width
  51951. */
  51952. getRenderWidth(useScreen?: boolean): number;
  51953. /**
  51954. * Gets the current render height
  51955. * @param useScreen defines if screen size must be used (or the current render target if any)
  51956. * @returns a number defining the current render height
  51957. */
  51958. getRenderHeight(useScreen?: boolean): number;
  51959. /**
  51960. * Set the WebGL's viewport
  51961. * @param viewport defines the viewport element to be used
  51962. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51963. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51964. */
  51965. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51966. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51967. /**
  51968. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51969. * @param pipelineContext defines the pipeline context to use
  51970. * @param uniformsNames defines the list of uniform names
  51971. * @returns an array of webGL uniform locations
  51972. */
  51973. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51974. /**
  51975. * Gets the lsit of active attributes for a given webGL program
  51976. * @param pipelineContext defines the pipeline context to use
  51977. * @param attributesNames defines the list of attribute names to get
  51978. * @returns an array of indices indicating the offset of each attribute
  51979. */
  51980. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51981. /**
  51982. * Binds an effect to the webGL context
  51983. * @param effect defines the effect to bind
  51984. */
  51985. bindSamplers(effect: Effect): void;
  51986. /**
  51987. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51988. * @param effect defines the effect to activate
  51989. */
  51990. enableEffect(effect: Effect): void;
  51991. /**
  51992. * Set various states to the webGL context
  51993. * @param culling defines backface culling state
  51994. * @param zOffset defines the value to apply to zOffset (0 by default)
  51995. * @param force defines if states must be applied even if cache is up to date
  51996. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51997. */
  51998. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51999. /**
  52000. * Set the value of an uniform to an array of int32
  52001. * @param uniform defines the webGL uniform location where to store the value
  52002. * @param array defines the array of int32 to store
  52003. */
  52004. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52005. /**
  52006. * Set the value of an uniform to an array of int32 (stored as vec2)
  52007. * @param uniform defines the webGL uniform location where to store the value
  52008. * @param array defines the array of int32 to store
  52009. */
  52010. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52011. /**
  52012. * Set the value of an uniform to an array of int32 (stored as vec3)
  52013. * @param uniform defines the webGL uniform location where to store the value
  52014. * @param array defines the array of int32 to store
  52015. */
  52016. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52017. /**
  52018. * Set the value of an uniform to an array of int32 (stored as vec4)
  52019. * @param uniform defines the webGL uniform location where to store the value
  52020. * @param array defines the array of int32 to store
  52021. */
  52022. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52023. /**
  52024. * Set the value of an uniform to an array of float32
  52025. * @param uniform defines the webGL uniform location where to store the value
  52026. * @param array defines the array of float32 to store
  52027. */
  52028. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52029. /**
  52030. * Set the value of an uniform to an array of float32 (stored as vec2)
  52031. * @param uniform defines the webGL uniform location where to store the value
  52032. * @param array defines the array of float32 to store
  52033. */
  52034. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52035. /**
  52036. * Set the value of an uniform to an array of float32 (stored as vec3)
  52037. * @param uniform defines the webGL uniform location where to store the value
  52038. * @param array defines the array of float32 to store
  52039. */
  52040. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52041. /**
  52042. * Set the value of an uniform to an array of float32 (stored as vec4)
  52043. * @param uniform defines the webGL uniform location where to store the value
  52044. * @param array defines the array of float32 to store
  52045. */
  52046. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52047. /**
  52048. * Set the value of an uniform to an array of number
  52049. * @param uniform defines the webGL uniform location where to store the value
  52050. * @param array defines the array of number to store
  52051. */
  52052. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52053. /**
  52054. * Set the value of an uniform to an array of number (stored as vec2)
  52055. * @param uniform defines the webGL uniform location where to store the value
  52056. * @param array defines the array of number to store
  52057. */
  52058. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52059. /**
  52060. * Set the value of an uniform to an array of number (stored as vec3)
  52061. * @param uniform defines the webGL uniform location where to store the value
  52062. * @param array defines the array of number to store
  52063. */
  52064. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52065. /**
  52066. * Set the value of an uniform to an array of number (stored as vec4)
  52067. * @param uniform defines the webGL uniform location where to store the value
  52068. * @param array defines the array of number to store
  52069. */
  52070. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52071. /**
  52072. * Set the value of an uniform to an array of float32 (stored as matrices)
  52073. * @param uniform defines the webGL uniform location where to store the value
  52074. * @param matrices defines the array of float32 to store
  52075. */
  52076. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52077. /**
  52078. * Set the value of an uniform to a matrix (3x3)
  52079. * @param uniform defines the webGL uniform location where to store the value
  52080. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52081. */
  52082. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52083. /**
  52084. * Set the value of an uniform to a matrix (2x2)
  52085. * @param uniform defines the webGL uniform location where to store the value
  52086. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52087. */
  52088. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52089. /**
  52090. * Set the value of an uniform to a number (float)
  52091. * @param uniform defines the webGL uniform location where to store the value
  52092. * @param value defines the float number to store
  52093. */
  52094. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52095. /**
  52096. * Set the value of an uniform to a vec2
  52097. * @param uniform defines the webGL uniform location where to store the value
  52098. * @param x defines the 1st component of the value
  52099. * @param y defines the 2nd component of the value
  52100. */
  52101. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52102. /**
  52103. * Set the value of an uniform to a vec3
  52104. * @param uniform defines the webGL uniform location where to store the value
  52105. * @param x defines the 1st component of the value
  52106. * @param y defines the 2nd component of the value
  52107. * @param z defines the 3rd component of the value
  52108. */
  52109. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52110. /**
  52111. * Set the value of an uniform to a boolean
  52112. * @param uniform defines the webGL uniform location where to store the value
  52113. * @param bool defines the boolean to store
  52114. */
  52115. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52116. /**
  52117. * Set the value of an uniform to a vec4
  52118. * @param uniform defines the webGL uniform location where to store the value
  52119. * @param x defines the 1st component of the value
  52120. * @param y defines the 2nd component of the value
  52121. * @param z defines the 3rd component of the value
  52122. * @param w defines the 4th component of the value
  52123. */
  52124. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52125. /**
  52126. * Sets the current alpha mode
  52127. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52128. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52129. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52130. */
  52131. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52132. /**
  52133. * Bind webGl buffers directly to the webGL context
  52134. * @param vertexBuffers defines the vertex buffer to bind
  52135. * @param indexBuffer defines the index buffer to bind
  52136. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52137. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52138. * @param effect defines the effect associated with the vertex buffer
  52139. */
  52140. bindBuffers(vertexBuffers: {
  52141. [key: string]: VertexBuffer;
  52142. }, indexBuffer: DataBuffer, effect: Effect): void;
  52143. /**
  52144. * Force the entire cache to be cleared
  52145. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52146. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52147. */
  52148. wipeCaches(bruteForce?: boolean): void;
  52149. /**
  52150. * Send a draw order
  52151. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52152. * @param indexStart defines the starting index
  52153. * @param indexCount defines the number of index to draw
  52154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52155. */
  52156. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52157. /**
  52158. * Draw a list of indexed primitives
  52159. * @param fillMode defines the primitive to use
  52160. * @param indexStart defines the starting index
  52161. * @param indexCount defines the number of index to draw
  52162. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52163. */
  52164. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52165. /**
  52166. * Draw a list of unindexed primitives
  52167. * @param fillMode defines the primitive to use
  52168. * @param verticesStart defines the index of first vertex to draw
  52169. * @param verticesCount defines the count of vertices to draw
  52170. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52171. */
  52172. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52173. /** @hidden */
  52174. _createTexture(): WebGLTexture;
  52175. /** @hidden */
  52176. _releaseTexture(texture: InternalTexture): void;
  52177. /**
  52178. * Usually called from Texture.ts.
  52179. * Passed information to create a WebGLTexture
  52180. * @param urlArg defines a value which contains one of the following:
  52181. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52182. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52183. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52184. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52185. * @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)
  52186. * @param scene needed for loading to the correct scene
  52187. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52188. * @param onLoad optional callback to be called upon successful completion
  52189. * @param onError optional callback to be called upon failure
  52190. * @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
  52191. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52192. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52193. * @param forcedExtension defines the extension to use to pick the right loader
  52194. * @param mimeType defines an optional mime type
  52195. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52196. */
  52197. 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;
  52198. /**
  52199. * Creates a new render target texture
  52200. * @param size defines the size of the texture
  52201. * @param options defines the options used to create the texture
  52202. * @returns a new render target texture stored in an InternalTexture
  52203. */
  52204. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52205. /**
  52206. * Update the sampling mode of a given texture
  52207. * @param samplingMode defines the required sampling mode
  52208. * @param texture defines the texture to update
  52209. */
  52210. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52211. /**
  52212. * Binds the frame buffer to the specified texture.
  52213. * @param texture The texture to render to or null for the default canvas
  52214. * @param faceIndex The face of the texture to render to in case of cube texture
  52215. * @param requiredWidth The width of the target to render to
  52216. * @param requiredHeight The height of the target to render to
  52217. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52218. * @param lodLevel defines le lod level to bind to the frame buffer
  52219. */
  52220. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52221. /**
  52222. * Unbind the current render target texture from the webGL context
  52223. * @param texture defines the render target texture to unbind
  52224. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52225. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52226. */
  52227. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52228. /**
  52229. * Creates a dynamic vertex buffer
  52230. * @param vertices the data for the dynamic vertex buffer
  52231. * @returns the new WebGL dynamic buffer
  52232. */
  52233. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52234. /**
  52235. * Update the content of a dynamic texture
  52236. * @param texture defines the texture to update
  52237. * @param canvas defines the canvas containing the source
  52238. * @param invertY defines if data must be stored with Y axis inverted
  52239. * @param premulAlpha defines if alpha is stored as premultiplied
  52240. * @param format defines the format of the data
  52241. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52242. */
  52243. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52244. /**
  52245. * Gets a boolean indicating if all created effects are ready
  52246. * @returns true if all effects are ready
  52247. */
  52248. areAllEffectsReady(): boolean;
  52249. /**
  52250. * @hidden
  52251. * Get the current error code of the webGL context
  52252. * @returns the error code
  52253. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52254. */
  52255. getError(): number;
  52256. /** @hidden */
  52257. _getUnpackAlignement(): number;
  52258. /** @hidden */
  52259. _unpackFlipY(value: boolean): void;
  52260. /**
  52261. * Update a dynamic index buffer
  52262. * @param indexBuffer defines the target index buffer
  52263. * @param indices defines the data to update
  52264. * @param offset defines the offset in the target index buffer where update should start
  52265. */
  52266. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52267. /**
  52268. * Updates a dynamic vertex buffer.
  52269. * @param vertexBuffer the vertex buffer to update
  52270. * @param vertices the data used to update the vertex buffer
  52271. * @param byteOffset the byte offset of the data (optional)
  52272. * @param byteLength the byte length of the data (optional)
  52273. */
  52274. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52275. /** @hidden */
  52276. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52277. /** @hidden */
  52278. _bindTexture(channel: number, texture: InternalTexture): void;
  52279. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52280. /**
  52281. * 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
  52282. */
  52283. releaseEffects(): void;
  52284. displayLoadingUI(): void;
  52285. hideLoadingUI(): void;
  52286. /** @hidden */
  52287. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52288. /** @hidden */
  52289. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52290. /** @hidden */
  52291. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52292. /** @hidden */
  52293. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52294. }
  52295. }
  52296. declare module "babylonjs/Instrumentation/timeToken" {
  52297. import { Nullable } from "babylonjs/types";
  52298. /**
  52299. * @hidden
  52300. **/
  52301. export class _TimeToken {
  52302. _startTimeQuery: Nullable<WebGLQuery>;
  52303. _endTimeQuery: Nullable<WebGLQuery>;
  52304. _timeElapsedQuery: Nullable<WebGLQuery>;
  52305. _timeElapsedQueryEnded: boolean;
  52306. }
  52307. }
  52308. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52309. import { Nullable, int } from "babylonjs/types";
  52310. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52311. /** @hidden */
  52312. export class _OcclusionDataStorage {
  52313. /** @hidden */
  52314. occlusionInternalRetryCounter: number;
  52315. /** @hidden */
  52316. isOcclusionQueryInProgress: boolean;
  52317. /** @hidden */
  52318. isOccluded: boolean;
  52319. /** @hidden */
  52320. occlusionRetryCount: number;
  52321. /** @hidden */
  52322. occlusionType: number;
  52323. /** @hidden */
  52324. occlusionQueryAlgorithmType: number;
  52325. }
  52326. module "babylonjs/Engines/engine" {
  52327. interface Engine {
  52328. /**
  52329. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52330. * @return the new query
  52331. */
  52332. createQuery(): WebGLQuery;
  52333. /**
  52334. * Delete and release a webGL query
  52335. * @param query defines the query to delete
  52336. * @return the current engine
  52337. */
  52338. deleteQuery(query: WebGLQuery): Engine;
  52339. /**
  52340. * Check if a given query has resolved and got its value
  52341. * @param query defines the query to check
  52342. * @returns true if the query got its value
  52343. */
  52344. isQueryResultAvailable(query: WebGLQuery): boolean;
  52345. /**
  52346. * Gets the value of a given query
  52347. * @param query defines the query to check
  52348. * @returns the value of the query
  52349. */
  52350. getQueryResult(query: WebGLQuery): number;
  52351. /**
  52352. * Initiates an occlusion query
  52353. * @param algorithmType defines the algorithm to use
  52354. * @param query defines the query to use
  52355. * @returns the current engine
  52356. * @see http://doc.babylonjs.com/features/occlusionquery
  52357. */
  52358. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52359. /**
  52360. * Ends an occlusion query
  52361. * @see http://doc.babylonjs.com/features/occlusionquery
  52362. * @param algorithmType defines the algorithm to use
  52363. * @returns the current engine
  52364. */
  52365. endOcclusionQuery(algorithmType: number): Engine;
  52366. /**
  52367. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52368. * Please note that only one query can be issued at a time
  52369. * @returns a time token used to track the time span
  52370. */
  52371. startTimeQuery(): Nullable<_TimeToken>;
  52372. /**
  52373. * Ends a time query
  52374. * @param token defines the token used to measure the time span
  52375. * @returns the time spent (in ns)
  52376. */
  52377. endTimeQuery(token: _TimeToken): int;
  52378. /** @hidden */
  52379. _currentNonTimestampToken: Nullable<_TimeToken>;
  52380. /** @hidden */
  52381. _createTimeQuery(): WebGLQuery;
  52382. /** @hidden */
  52383. _deleteTimeQuery(query: WebGLQuery): void;
  52384. /** @hidden */
  52385. _getGlAlgorithmType(algorithmType: number): number;
  52386. /** @hidden */
  52387. _getTimeQueryResult(query: WebGLQuery): any;
  52388. /** @hidden */
  52389. _getTimeQueryAvailability(query: WebGLQuery): any;
  52390. }
  52391. }
  52392. module "babylonjs/Meshes/abstractMesh" {
  52393. interface AbstractMesh {
  52394. /**
  52395. * Backing filed
  52396. * @hidden
  52397. */
  52398. __occlusionDataStorage: _OcclusionDataStorage;
  52399. /**
  52400. * Access property
  52401. * @hidden
  52402. */
  52403. _occlusionDataStorage: _OcclusionDataStorage;
  52404. /**
  52405. * 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.
  52406. * The default value is -1 which means don't break the query and wait till the result
  52407. * @see http://doc.babylonjs.com/features/occlusionquery
  52408. */
  52409. occlusionRetryCount: number;
  52410. /**
  52411. * 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:
  52412. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52413. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52414. * * 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.
  52415. * @see http://doc.babylonjs.com/features/occlusionquery
  52416. */
  52417. occlusionType: number;
  52418. /**
  52419. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52420. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52421. * * 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.
  52422. * @see http://doc.babylonjs.com/features/occlusionquery
  52423. */
  52424. occlusionQueryAlgorithmType: number;
  52425. /**
  52426. * 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
  52427. * @see http://doc.babylonjs.com/features/occlusionquery
  52428. */
  52429. isOccluded: boolean;
  52430. /**
  52431. * Flag to check the progress status of the query
  52432. * @see http://doc.babylonjs.com/features/occlusionquery
  52433. */
  52434. isOcclusionQueryInProgress: boolean;
  52435. }
  52436. }
  52437. }
  52438. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52439. import { Nullable } from "babylonjs/types";
  52440. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52441. /** @hidden */
  52442. export var _forceTransformFeedbackToBundle: boolean;
  52443. module "babylonjs/Engines/engine" {
  52444. interface Engine {
  52445. /**
  52446. * Creates a webGL transform feedback object
  52447. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52448. * @returns the webGL transform feedback object
  52449. */
  52450. createTransformFeedback(): WebGLTransformFeedback;
  52451. /**
  52452. * Delete a webGL transform feedback object
  52453. * @param value defines the webGL transform feedback object to delete
  52454. */
  52455. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52456. /**
  52457. * Bind a webGL transform feedback object to the webgl context
  52458. * @param value defines the webGL transform feedback object to bind
  52459. */
  52460. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52461. /**
  52462. * Begins a transform feedback operation
  52463. * @param usePoints defines if points or triangles must be used
  52464. */
  52465. beginTransformFeedback(usePoints: boolean): void;
  52466. /**
  52467. * Ends a transform feedback operation
  52468. */
  52469. endTransformFeedback(): void;
  52470. /**
  52471. * Specify the varyings to use with transform feedback
  52472. * @param program defines the associated webGL program
  52473. * @param value defines the list of strings representing the varying names
  52474. */
  52475. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52476. /**
  52477. * Bind a webGL buffer for a transform feedback operation
  52478. * @param value defines the webGL buffer to bind
  52479. */
  52480. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52481. }
  52482. }
  52483. }
  52484. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52485. import { Scene } from "babylonjs/scene";
  52486. import { Engine } from "babylonjs/Engines/engine";
  52487. import { Texture } from "babylonjs/Materials/Textures/texture";
  52488. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52489. import "babylonjs/Engines/Extensions/engine.multiRender";
  52490. /**
  52491. * Creation options of the multi render target texture.
  52492. */
  52493. export interface IMultiRenderTargetOptions {
  52494. /**
  52495. * Define if the texture needs to create mip maps after render.
  52496. */
  52497. generateMipMaps?: boolean;
  52498. /**
  52499. * Define the types of all the draw buffers we want to create
  52500. */
  52501. types?: number[];
  52502. /**
  52503. * Define the sampling modes of all the draw buffers we want to create
  52504. */
  52505. samplingModes?: number[];
  52506. /**
  52507. * Define if a depth buffer is required
  52508. */
  52509. generateDepthBuffer?: boolean;
  52510. /**
  52511. * Define if a stencil buffer is required
  52512. */
  52513. generateStencilBuffer?: boolean;
  52514. /**
  52515. * Define if a depth texture is required instead of a depth buffer
  52516. */
  52517. generateDepthTexture?: boolean;
  52518. /**
  52519. * Define the number of desired draw buffers
  52520. */
  52521. textureCount?: number;
  52522. /**
  52523. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52524. */
  52525. doNotChangeAspectRatio?: boolean;
  52526. /**
  52527. * Define the default type of the buffers we are creating
  52528. */
  52529. defaultType?: number;
  52530. }
  52531. /**
  52532. * A multi render target, like a render target provides the ability to render to a texture.
  52533. * Unlike the render target, it can render to several draw buffers in one draw.
  52534. * This is specially interesting in deferred rendering or for any effects requiring more than
  52535. * just one color from a single pass.
  52536. */
  52537. export class MultiRenderTarget extends RenderTargetTexture {
  52538. private _internalTextures;
  52539. private _textures;
  52540. private _multiRenderTargetOptions;
  52541. /**
  52542. * Get if draw buffers are currently supported by the used hardware and browser.
  52543. */
  52544. get isSupported(): boolean;
  52545. /**
  52546. * Get the list of textures generated by the multi render target.
  52547. */
  52548. get textures(): Texture[];
  52549. /**
  52550. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52551. */
  52552. get depthTexture(): Texture;
  52553. /**
  52554. * Set the wrapping mode on U of all the textures we are rendering to.
  52555. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52556. */
  52557. set wrapU(wrap: number);
  52558. /**
  52559. * Set the wrapping mode on V of all the textures we are rendering to.
  52560. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52561. */
  52562. set wrapV(wrap: number);
  52563. /**
  52564. * Instantiate a new multi render target texture.
  52565. * A multi render target, like a render target provides the ability to render to a texture.
  52566. * Unlike the render target, it can render to several draw buffers in one draw.
  52567. * This is specially interesting in deferred rendering or for any effects requiring more than
  52568. * just one color from a single pass.
  52569. * @param name Define the name of the texture
  52570. * @param size Define the size of the buffers to render to
  52571. * @param count Define the number of target we are rendering into
  52572. * @param scene Define the scene the texture belongs to
  52573. * @param options Define the options used to create the multi render target
  52574. */
  52575. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52576. /** @hidden */
  52577. _rebuild(): void;
  52578. private _createInternalTextures;
  52579. private _createTextures;
  52580. /**
  52581. * Define the number of samples used if MSAA is enabled.
  52582. */
  52583. get samples(): number;
  52584. set samples(value: number);
  52585. /**
  52586. * Resize all the textures in the multi render target.
  52587. * Be carrefull as it will recreate all the data in the new texture.
  52588. * @param size Define the new size
  52589. */
  52590. resize(size: any): void;
  52591. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52592. /**
  52593. * Dispose the render targets and their associated resources
  52594. */
  52595. dispose(): void;
  52596. /**
  52597. * Release all the underlying texture used as draw buffers.
  52598. */
  52599. releaseInternalTextures(): void;
  52600. }
  52601. }
  52602. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52604. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52605. import { Nullable } from "babylonjs/types";
  52606. module "babylonjs/Engines/thinEngine" {
  52607. interface ThinEngine {
  52608. /**
  52609. * Unbind a list of render target textures from the webGL context
  52610. * This is used only when drawBuffer extension or webGL2 are active
  52611. * @param textures defines the render target textures to unbind
  52612. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52613. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52614. */
  52615. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52616. /**
  52617. * Create a multi render target texture
  52618. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52619. * @param size defines the size of the texture
  52620. * @param options defines the creation options
  52621. * @returns the cube texture as an InternalTexture
  52622. */
  52623. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52624. /**
  52625. * Update the sample count for a given multiple render target texture
  52626. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52627. * @param textures defines the textures to update
  52628. * @param samples defines the sample count to set
  52629. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52630. */
  52631. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52632. }
  52633. }
  52634. }
  52635. declare module "babylonjs/Engines/Extensions/engine.views" {
  52636. import { Camera } from "babylonjs/Cameras/camera";
  52637. import { Nullable } from "babylonjs/types";
  52638. /**
  52639. * Class used to define an additional view for the engine
  52640. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52641. */
  52642. export class EngineView {
  52643. /** Defines the canvas where to render the view */
  52644. target: HTMLCanvasElement;
  52645. /** Defines an optional camera used to render the view (will use active camera else) */
  52646. camera?: Camera;
  52647. }
  52648. module "babylonjs/Engines/engine" {
  52649. interface Engine {
  52650. /**
  52651. * Gets or sets the HTML element to use for attaching events
  52652. */
  52653. inputElement: Nullable<HTMLElement>;
  52654. /**
  52655. * Gets the current engine view
  52656. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52657. */
  52658. activeView: Nullable<EngineView>;
  52659. /** Gets or sets the list of views */
  52660. views: EngineView[];
  52661. /**
  52662. * Register a new child canvas
  52663. * @param canvas defines the canvas to register
  52664. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52665. * @returns the associated view
  52666. */
  52667. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52668. /**
  52669. * Remove a registered child canvas
  52670. * @param canvas defines the canvas to remove
  52671. * @returns the current engine
  52672. */
  52673. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52674. }
  52675. }
  52676. }
  52677. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  52678. import { Nullable } from "babylonjs/types";
  52679. module "babylonjs/Engines/engine" {
  52680. interface Engine {
  52681. /** @hidden */
  52682. _excludedCompressedTextures: string[];
  52683. /** @hidden */
  52684. _textureFormatInUse: string;
  52685. /**
  52686. * Gets the list of texture formats supported
  52687. */
  52688. readonly texturesSupported: Array<string>;
  52689. /**
  52690. * Gets the texture format in use
  52691. */
  52692. readonly textureFormatInUse: Nullable<string>;
  52693. /**
  52694. * Set the compressed texture extensions or file names to skip.
  52695. *
  52696. * @param skippedFiles defines the list of those texture files you want to skip
  52697. * Example: [".dds", ".env", "myfile.png"]
  52698. */
  52699. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52700. /**
  52701. * Set the compressed texture format to use, based on the formats you have, and the formats
  52702. * supported by the hardware / browser.
  52703. *
  52704. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52705. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52706. * to API arguments needed to compressed textures. This puts the burden on the container
  52707. * generator to house the arcane code for determining these for current & future formats.
  52708. *
  52709. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52710. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52711. *
  52712. * Note: The result of this call is not taken into account when a texture is base64.
  52713. *
  52714. * @param formatsAvailable defines the list of those format families you have created
  52715. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52716. *
  52717. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52718. * @returns The extension selected.
  52719. */
  52720. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52721. }
  52722. }
  52723. }
  52724. declare module "babylonjs/Engines/Extensions/index" {
  52725. export * from "babylonjs/Engines/Extensions/engine.alpha";
  52726. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  52727. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  52728. export * from "babylonjs/Engines/Extensions/engine.multiview";
  52729. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  52730. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52731. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  52732. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  52733. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  52734. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  52735. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52736. export * from "babylonjs/Engines/Extensions/engine.webVR";
  52737. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  52738. export * from "babylonjs/Engines/Extensions/engine.views";
  52739. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  52740. import "babylonjs/Engines/Extensions/engine.textureSelector";
  52741. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  52742. }
  52743. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  52744. import { Nullable } from "babylonjs/types";
  52745. /**
  52746. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52747. */
  52748. export interface CubeMapInfo {
  52749. /**
  52750. * The pixel array for the front face.
  52751. * This is stored in format, left to right, up to down format.
  52752. */
  52753. front: Nullable<ArrayBufferView>;
  52754. /**
  52755. * The pixel array for the back face.
  52756. * This is stored in format, left to right, up to down format.
  52757. */
  52758. back: Nullable<ArrayBufferView>;
  52759. /**
  52760. * The pixel array for the left face.
  52761. * This is stored in format, left to right, up to down format.
  52762. */
  52763. left: Nullable<ArrayBufferView>;
  52764. /**
  52765. * The pixel array for the right face.
  52766. * This is stored in format, left to right, up to down format.
  52767. */
  52768. right: Nullable<ArrayBufferView>;
  52769. /**
  52770. * The pixel array for the up face.
  52771. * This is stored in format, left to right, up to down format.
  52772. */
  52773. up: Nullable<ArrayBufferView>;
  52774. /**
  52775. * The pixel array for the down face.
  52776. * This is stored in format, left to right, up to down format.
  52777. */
  52778. down: Nullable<ArrayBufferView>;
  52779. /**
  52780. * The size of the cubemap stored.
  52781. *
  52782. * Each faces will be size * size pixels.
  52783. */
  52784. size: number;
  52785. /**
  52786. * The format of the texture.
  52787. *
  52788. * RGBA, RGB.
  52789. */
  52790. format: number;
  52791. /**
  52792. * The type of the texture data.
  52793. *
  52794. * UNSIGNED_INT, FLOAT.
  52795. */
  52796. type: number;
  52797. /**
  52798. * Specifies whether the texture is in gamma space.
  52799. */
  52800. gammaSpace: boolean;
  52801. }
  52802. /**
  52803. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52804. */
  52805. export class PanoramaToCubeMapTools {
  52806. private static FACE_LEFT;
  52807. private static FACE_RIGHT;
  52808. private static FACE_FRONT;
  52809. private static FACE_BACK;
  52810. private static FACE_DOWN;
  52811. private static FACE_UP;
  52812. /**
  52813. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52814. *
  52815. * @param float32Array The source data.
  52816. * @param inputWidth The width of the input panorama.
  52817. * @param inputHeight The height of the input panorama.
  52818. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52819. * @return The cubemap data
  52820. */
  52821. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52822. private static CreateCubemapTexture;
  52823. private static CalcProjectionSpherical;
  52824. }
  52825. }
  52826. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  52827. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52829. import { Nullable } from "babylonjs/types";
  52830. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52831. /**
  52832. * Helper class dealing with the extraction of spherical polynomial dataArray
  52833. * from a cube map.
  52834. */
  52835. export class CubeMapToSphericalPolynomialTools {
  52836. private static FileFaces;
  52837. /**
  52838. * Converts a texture to the according Spherical Polynomial data.
  52839. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52840. *
  52841. * @param texture The texture to extract the information from.
  52842. * @return The Spherical Polynomial data.
  52843. */
  52844. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52845. /**
  52846. * Converts a cubemap to the according Spherical Polynomial data.
  52847. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52848. *
  52849. * @param cubeInfo The Cube map to extract the information from.
  52850. * @return The Spherical Polynomial data.
  52851. */
  52852. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52853. }
  52854. }
  52855. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  52856. import { Nullable } from "babylonjs/types";
  52857. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52858. module "babylonjs/Materials/Textures/baseTexture" {
  52859. interface BaseTexture {
  52860. /**
  52861. * Get the polynomial representation of the texture data.
  52862. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52863. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52864. */
  52865. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52866. }
  52867. }
  52868. }
  52869. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  52870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52871. /** @hidden */
  52872. export var rgbdEncodePixelShader: {
  52873. name: string;
  52874. shader: string;
  52875. };
  52876. }
  52877. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  52878. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52879. /** @hidden */
  52880. export var rgbdDecodePixelShader: {
  52881. name: string;
  52882. shader: string;
  52883. };
  52884. }
  52885. declare module "babylonjs/Misc/environmentTextureTools" {
  52886. import { Nullable } from "babylonjs/types";
  52887. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52888. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52890. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52891. import "babylonjs/Engines/Extensions/engine.readTexture";
  52892. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52893. import "babylonjs/Shaders/rgbdEncode.fragment";
  52894. import "babylonjs/Shaders/rgbdDecode.fragment";
  52895. /**
  52896. * Raw texture data and descriptor sufficient for WebGL texture upload
  52897. */
  52898. export interface EnvironmentTextureInfo {
  52899. /**
  52900. * Version of the environment map
  52901. */
  52902. version: number;
  52903. /**
  52904. * Width of image
  52905. */
  52906. width: number;
  52907. /**
  52908. * Irradiance information stored in the file.
  52909. */
  52910. irradiance: any;
  52911. /**
  52912. * Specular information stored in the file.
  52913. */
  52914. specular: any;
  52915. }
  52916. /**
  52917. * Defines One Image in the file. It requires only the position in the file
  52918. * as well as the length.
  52919. */
  52920. interface BufferImageData {
  52921. /**
  52922. * Length of the image data.
  52923. */
  52924. length: number;
  52925. /**
  52926. * Position of the data from the null terminator delimiting the end of the JSON.
  52927. */
  52928. position: number;
  52929. }
  52930. /**
  52931. * Defines the specular data enclosed in the file.
  52932. * This corresponds to the version 1 of the data.
  52933. */
  52934. export interface EnvironmentTextureSpecularInfoV1 {
  52935. /**
  52936. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52937. */
  52938. specularDataPosition?: number;
  52939. /**
  52940. * This contains all the images data needed to reconstruct the cubemap.
  52941. */
  52942. mipmaps: Array<BufferImageData>;
  52943. /**
  52944. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52945. */
  52946. lodGenerationScale: number;
  52947. }
  52948. /**
  52949. * Sets of helpers addressing the serialization and deserialization of environment texture
  52950. * stored in a BabylonJS env file.
  52951. * Those files are usually stored as .env files.
  52952. */
  52953. export class EnvironmentTextureTools {
  52954. /**
  52955. * Magic number identifying the env file.
  52956. */
  52957. private static _MagicBytes;
  52958. /**
  52959. * Gets the environment info from an env file.
  52960. * @param data The array buffer containing the .env bytes.
  52961. * @returns the environment file info (the json header) if successfully parsed.
  52962. */
  52963. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52964. /**
  52965. * Creates an environment texture from a loaded cube texture.
  52966. * @param texture defines the cube texture to convert in env file
  52967. * @return a promise containing the environment data if succesfull.
  52968. */
  52969. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52970. /**
  52971. * Creates a JSON representation of the spherical data.
  52972. * @param texture defines the texture containing the polynomials
  52973. * @return the JSON representation of the spherical info
  52974. */
  52975. private static _CreateEnvTextureIrradiance;
  52976. /**
  52977. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52978. * @param data the image data
  52979. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52980. * @return the views described by info providing access to the underlying buffer
  52981. */
  52982. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52983. /**
  52984. * Uploads the texture info contained in the env file to the GPU.
  52985. * @param texture defines the internal texture to upload to
  52986. * @param data defines the data to load
  52987. * @param info defines the texture info retrieved through the GetEnvInfo method
  52988. * @returns a promise
  52989. */
  52990. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52991. private static _OnImageReadyAsync;
  52992. /**
  52993. * Uploads the levels of image data to the GPU.
  52994. * @param texture defines the internal texture to upload to
  52995. * @param imageData defines the array buffer views of image data [mipmap][face]
  52996. * @returns a promise
  52997. */
  52998. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52999. /**
  53000. * Uploads spherical polynomials information to the texture.
  53001. * @param texture defines the texture we are trying to upload the information to
  53002. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53003. */
  53004. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53005. /** @hidden */
  53006. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53007. }
  53008. }
  53009. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53010. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53011. /** @hidden */
  53012. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53013. private _genericAttributeLocation;
  53014. private _varyingLocationCount;
  53015. private _varyingLocationMap;
  53016. private _replacements;
  53017. private _textureCount;
  53018. private _uniforms;
  53019. lineProcessor(line: string): string;
  53020. attributeProcessor(attribute: string): string;
  53021. varyingProcessor(varying: string, isFragment: boolean): string;
  53022. uniformProcessor(uniform: string): string;
  53023. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53024. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53025. }
  53026. }
  53027. declare module "babylonjs/Engines/nativeEngine" {
  53028. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53029. import { Engine } from "babylonjs/Engines/engine";
  53030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53033. import { Effect } from "babylonjs/Materials/effect";
  53034. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53035. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53036. import { IColor4Like } from "babylonjs/Maths/math.like";
  53037. import { Scene } from "babylonjs/scene";
  53038. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53039. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53040. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53041. /**
  53042. * Container for accessors for natively-stored mesh data buffers.
  53043. */
  53044. class NativeDataBuffer extends DataBuffer {
  53045. /**
  53046. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53047. */
  53048. nativeIndexBuffer?: any;
  53049. /**
  53050. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53051. */
  53052. nativeVertexBuffer?: any;
  53053. }
  53054. /** @hidden */
  53055. class NativeTexture extends InternalTexture {
  53056. getInternalTexture(): InternalTexture;
  53057. getViewCount(): number;
  53058. }
  53059. /** @hidden */
  53060. export class NativeEngine extends Engine {
  53061. private readonly _native;
  53062. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53063. private readonly INVALID_HANDLE;
  53064. getHardwareScalingLevel(): number;
  53065. constructor();
  53066. dispose(): void;
  53067. /**
  53068. * Can be used to override the current requestAnimationFrame requester.
  53069. * @hidden
  53070. */
  53071. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53072. /**
  53073. * Override default engine behavior.
  53074. * @param color
  53075. * @param backBuffer
  53076. * @param depth
  53077. * @param stencil
  53078. */
  53079. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53080. /**
  53081. * Gets host document
  53082. * @returns the host document object
  53083. */
  53084. getHostDocument(): Nullable<Document>;
  53085. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53086. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53087. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53088. recordVertexArrayObject(vertexBuffers: {
  53089. [key: string]: VertexBuffer;
  53090. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53091. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53092. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53093. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53094. /**
  53095. * Draw a list of indexed primitives
  53096. * @param fillMode defines the primitive to use
  53097. * @param indexStart defines the starting index
  53098. * @param indexCount defines the number of index to draw
  53099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53100. */
  53101. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53102. /**
  53103. * Draw a list of unindexed primitives
  53104. * @param fillMode defines the primitive to use
  53105. * @param verticesStart defines the index of first vertex to draw
  53106. * @param verticesCount defines the count of vertices to draw
  53107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53108. */
  53109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53110. createPipelineContext(): IPipelineContext;
  53111. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53112. /** @hidden */
  53113. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53114. /** @hidden */
  53115. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53116. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53117. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53118. protected _setProgram(program: WebGLProgram): void;
  53119. _releaseEffect(effect: Effect): void;
  53120. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53121. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53122. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53123. bindSamplers(effect: Effect): void;
  53124. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53125. getRenderWidth(useScreen?: boolean): number;
  53126. getRenderHeight(useScreen?: boolean): number;
  53127. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53128. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53129. /**
  53130. * Set the z offset to apply to current rendering
  53131. * @param value defines the offset to apply
  53132. */
  53133. setZOffset(value: number): void;
  53134. /**
  53135. * Gets the current value of the zOffset
  53136. * @returns the current zOffset state
  53137. */
  53138. getZOffset(): number;
  53139. /**
  53140. * Enable or disable depth buffering
  53141. * @param enable defines the state to set
  53142. */
  53143. setDepthBuffer(enable: boolean): void;
  53144. /**
  53145. * Gets a boolean indicating if depth writing is enabled
  53146. * @returns the current depth writing state
  53147. */
  53148. getDepthWrite(): boolean;
  53149. /**
  53150. * Enable or disable depth writing
  53151. * @param enable defines the state to set
  53152. */
  53153. setDepthWrite(enable: boolean): void;
  53154. /**
  53155. * Enable or disable color writing
  53156. * @param enable defines the state to set
  53157. */
  53158. setColorWrite(enable: boolean): void;
  53159. /**
  53160. * Gets a boolean indicating if color writing is enabled
  53161. * @returns the current color writing state
  53162. */
  53163. getColorWrite(): boolean;
  53164. /**
  53165. * Sets alpha constants used by some alpha blending modes
  53166. * @param r defines the red component
  53167. * @param g defines the green component
  53168. * @param b defines the blue component
  53169. * @param a defines the alpha component
  53170. */
  53171. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53172. /**
  53173. * Sets the current alpha mode
  53174. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53175. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53176. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53177. */
  53178. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53179. /**
  53180. * Gets the current alpha mode
  53181. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53182. * @returns the current alpha mode
  53183. */
  53184. getAlphaMode(): number;
  53185. setInt(uniform: WebGLUniformLocation, int: number): void;
  53186. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53187. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53188. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53189. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53190. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53191. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53192. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53193. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53194. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53195. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53196. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53197. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53198. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53199. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53200. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53201. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53202. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53203. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53204. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53205. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53206. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53207. wipeCaches(bruteForce?: boolean): void;
  53208. _createTexture(): WebGLTexture;
  53209. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53210. /**
  53211. * Usually called from Texture.ts.
  53212. * Passed information to create a WebGLTexture
  53213. * @param url defines a value which contains one of the following:
  53214. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53215. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53216. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53217. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53218. * @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)
  53219. * @param scene needed for loading to the correct scene
  53220. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53221. * @param onLoad optional callback to be called upon successful completion
  53222. * @param onError optional callback to be called upon failure
  53223. * @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
  53224. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53225. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53226. * @param forcedExtension defines the extension to use to pick the right loader
  53227. * @param mimeType defines an optional mime type
  53228. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53229. */
  53230. 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;
  53231. /**
  53232. * Creates a cube texture
  53233. * @param rootUrl defines the url where the files to load is located
  53234. * @param scene defines the current scene
  53235. * @param files defines the list of files to load (1 per face)
  53236. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53237. * @param onLoad defines an optional callback raised when the texture is loaded
  53238. * @param onError defines an optional callback raised if there is an issue to load the texture
  53239. * @param format defines the format of the data
  53240. * @param forcedExtension defines the extension to use to pick the right loader
  53241. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53242. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53243. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53244. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53245. * @returns the cube texture as an InternalTexture
  53246. */
  53247. 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;
  53248. private _getSamplingFilter;
  53249. private static _GetNativeTextureFormat;
  53250. createRenderTargetTexture(size: number | {
  53251. width: number;
  53252. height: number;
  53253. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53254. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53255. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53256. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53257. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53258. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53259. /**
  53260. * Updates a dynamic vertex buffer.
  53261. * @param vertexBuffer the vertex buffer to update
  53262. * @param data the data used to update the vertex buffer
  53263. * @param byteOffset the byte offset of the data (optional)
  53264. * @param byteLength the byte length of the data (optional)
  53265. */
  53266. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53267. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53268. private _updateAnisotropicLevel;
  53269. private _getAddressMode;
  53270. /** @hidden */
  53271. _bindTexture(channel: number, texture: InternalTexture): void;
  53272. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53273. releaseEffects(): void;
  53274. /** @hidden */
  53275. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53276. /** @hidden */
  53277. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53278. /** @hidden */
  53279. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53280. /** @hidden */
  53281. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53282. }
  53283. }
  53284. declare module "babylonjs/Engines/index" {
  53285. export * from "babylonjs/Engines/constants";
  53286. export * from "babylonjs/Engines/engineCapabilities";
  53287. export * from "babylonjs/Engines/instancingAttributeInfo";
  53288. export * from "babylonjs/Engines/thinEngine";
  53289. export * from "babylonjs/Engines/engine";
  53290. export * from "babylonjs/Engines/engineStore";
  53291. export * from "babylonjs/Engines/nullEngine";
  53292. export * from "babylonjs/Engines/Extensions/index";
  53293. export * from "babylonjs/Engines/IPipelineContext";
  53294. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53295. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53296. export * from "babylonjs/Engines/nativeEngine";
  53297. }
  53298. declare module "babylonjs/Events/clipboardEvents" {
  53299. /**
  53300. * Gather the list of clipboard event types as constants.
  53301. */
  53302. export class ClipboardEventTypes {
  53303. /**
  53304. * The clipboard event is fired when a copy command is active (pressed).
  53305. */
  53306. static readonly COPY: number;
  53307. /**
  53308. * The clipboard event is fired when a cut command is active (pressed).
  53309. */
  53310. static readonly CUT: number;
  53311. /**
  53312. * The clipboard event is fired when a paste command is active (pressed).
  53313. */
  53314. static readonly PASTE: number;
  53315. }
  53316. /**
  53317. * This class is used to store clipboard related info for the onClipboardObservable event.
  53318. */
  53319. export class ClipboardInfo {
  53320. /**
  53321. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53322. */
  53323. type: number;
  53324. /**
  53325. * Defines the related dom event
  53326. */
  53327. event: ClipboardEvent;
  53328. /**
  53329. *Creates an instance of ClipboardInfo.
  53330. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53331. * @param event Defines the related dom event
  53332. */
  53333. constructor(
  53334. /**
  53335. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53336. */
  53337. type: number,
  53338. /**
  53339. * Defines the related dom event
  53340. */
  53341. event: ClipboardEvent);
  53342. /**
  53343. * Get the clipboard event's type from the keycode.
  53344. * @param keyCode Defines the keyCode for the current keyboard event.
  53345. * @return {number}
  53346. */
  53347. static GetTypeFromCharacter(keyCode: number): number;
  53348. }
  53349. }
  53350. declare module "babylonjs/Events/index" {
  53351. export * from "babylonjs/Events/keyboardEvents";
  53352. export * from "babylonjs/Events/pointerEvents";
  53353. export * from "babylonjs/Events/clipboardEvents";
  53354. }
  53355. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53356. import { Scene } from "babylonjs/scene";
  53357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53358. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53359. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53360. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53361. /**
  53362. * Google Daydream controller
  53363. */
  53364. export class DaydreamController extends WebVRController {
  53365. /**
  53366. * Base Url for the controller model.
  53367. */
  53368. static MODEL_BASE_URL: string;
  53369. /**
  53370. * File name for the controller model.
  53371. */
  53372. static MODEL_FILENAME: string;
  53373. /**
  53374. * Gamepad Id prefix used to identify Daydream Controller.
  53375. */
  53376. static readonly GAMEPAD_ID_PREFIX: string;
  53377. /**
  53378. * Creates a new DaydreamController from a gamepad
  53379. * @param vrGamepad the gamepad that the controller should be created from
  53380. */
  53381. constructor(vrGamepad: any);
  53382. /**
  53383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53384. * @param scene scene in which to add meshes
  53385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53386. */
  53387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53388. /**
  53389. * Called once for each button that changed state since the last frame
  53390. * @param buttonIdx Which button index changed
  53391. * @param state New state of the button
  53392. * @param changes Which properties on the state changed since last frame
  53393. */
  53394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53395. }
  53396. }
  53397. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53398. import { Scene } from "babylonjs/scene";
  53399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53401. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53402. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53403. /**
  53404. * Gear VR Controller
  53405. */
  53406. export class GearVRController extends WebVRController {
  53407. /**
  53408. * Base Url for the controller model.
  53409. */
  53410. static MODEL_BASE_URL: string;
  53411. /**
  53412. * File name for the controller model.
  53413. */
  53414. static MODEL_FILENAME: string;
  53415. /**
  53416. * Gamepad Id prefix used to identify this controller.
  53417. */
  53418. static readonly GAMEPAD_ID_PREFIX: string;
  53419. private readonly _buttonIndexToObservableNameMap;
  53420. /**
  53421. * Creates a new GearVRController from a gamepad
  53422. * @param vrGamepad the gamepad that the controller should be created from
  53423. */
  53424. constructor(vrGamepad: any);
  53425. /**
  53426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53427. * @param scene scene in which to add meshes
  53428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53429. */
  53430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53431. /**
  53432. * Called once for each button that changed state since the last frame
  53433. * @param buttonIdx Which button index changed
  53434. * @param state New state of the button
  53435. * @param changes Which properties on the state changed since last frame
  53436. */
  53437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53438. }
  53439. }
  53440. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53441. import { Scene } from "babylonjs/scene";
  53442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53443. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53444. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53445. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53446. /**
  53447. * Generic Controller
  53448. */
  53449. export class GenericController extends WebVRController {
  53450. /**
  53451. * Base Url for the controller model.
  53452. */
  53453. static readonly MODEL_BASE_URL: string;
  53454. /**
  53455. * File name for the controller model.
  53456. */
  53457. static readonly MODEL_FILENAME: string;
  53458. /**
  53459. * Creates a new GenericController from a gamepad
  53460. * @param vrGamepad the gamepad that the controller should be created from
  53461. */
  53462. constructor(vrGamepad: any);
  53463. /**
  53464. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53465. * @param scene scene in which to add meshes
  53466. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53467. */
  53468. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53469. /**
  53470. * Called once for each button that changed state since the last frame
  53471. * @param buttonIdx Which button index changed
  53472. * @param state New state of the button
  53473. * @param changes Which properties on the state changed since last frame
  53474. */
  53475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53476. }
  53477. }
  53478. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53479. import { Observable } from "babylonjs/Misc/observable";
  53480. import { Scene } from "babylonjs/scene";
  53481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53484. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53485. /**
  53486. * Oculus Touch Controller
  53487. */
  53488. export class OculusTouchController extends WebVRController {
  53489. /**
  53490. * Base Url for the controller model.
  53491. */
  53492. static MODEL_BASE_URL: string;
  53493. /**
  53494. * File name for the left controller model.
  53495. */
  53496. static MODEL_LEFT_FILENAME: string;
  53497. /**
  53498. * File name for the right controller model.
  53499. */
  53500. static MODEL_RIGHT_FILENAME: string;
  53501. /**
  53502. * Base Url for the Quest controller model.
  53503. */
  53504. static QUEST_MODEL_BASE_URL: string;
  53505. /**
  53506. * @hidden
  53507. * If the controllers are running on a device that needs the updated Quest controller models
  53508. */
  53509. static _IsQuest: boolean;
  53510. /**
  53511. * Fired when the secondary trigger on this controller is modified
  53512. */
  53513. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53514. /**
  53515. * Fired when the thumb rest on this controller is modified
  53516. */
  53517. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53518. /**
  53519. * Creates a new OculusTouchController from a gamepad
  53520. * @param vrGamepad the gamepad that the controller should be created from
  53521. */
  53522. constructor(vrGamepad: any);
  53523. /**
  53524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53525. * @param scene scene in which to add meshes
  53526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53527. */
  53528. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53529. /**
  53530. * Fired when the A button on this controller is modified
  53531. */
  53532. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53533. /**
  53534. * Fired when the B button on this controller is modified
  53535. */
  53536. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53537. /**
  53538. * Fired when the X button on this controller is modified
  53539. */
  53540. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53541. /**
  53542. * Fired when the Y button on this controller is modified
  53543. */
  53544. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53545. /**
  53546. * Called once for each button that changed state since the last frame
  53547. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53548. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53549. * 2) secondary trigger (same)
  53550. * 3) A (right) X (left), touch, pressed = value
  53551. * 4) B / Y
  53552. * 5) thumb rest
  53553. * @param buttonIdx Which button index changed
  53554. * @param state New state of the button
  53555. * @param changes Which properties on the state changed since last frame
  53556. */
  53557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53558. }
  53559. }
  53560. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53561. import { Scene } from "babylonjs/scene";
  53562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53563. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53564. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53565. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53566. import { Observable } from "babylonjs/Misc/observable";
  53567. /**
  53568. * Vive Controller
  53569. */
  53570. export class ViveController extends WebVRController {
  53571. /**
  53572. * Base Url for the controller model.
  53573. */
  53574. static MODEL_BASE_URL: string;
  53575. /**
  53576. * File name for the controller model.
  53577. */
  53578. static MODEL_FILENAME: string;
  53579. /**
  53580. * Creates a new ViveController from a gamepad
  53581. * @param vrGamepad the gamepad that the controller should be created from
  53582. */
  53583. constructor(vrGamepad: any);
  53584. /**
  53585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53586. * @param scene scene in which to add meshes
  53587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53588. */
  53589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53590. /**
  53591. * Fired when the left button on this controller is modified
  53592. */
  53593. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53594. /**
  53595. * Fired when the right button on this controller is modified
  53596. */
  53597. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53598. /**
  53599. * Fired when the menu button on this controller is modified
  53600. */
  53601. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53602. /**
  53603. * Called once for each button that changed state since the last frame
  53604. * Vive mapping:
  53605. * 0: touchpad
  53606. * 1: trigger
  53607. * 2: left AND right buttons
  53608. * 3: menu button
  53609. * @param buttonIdx Which button index changed
  53610. * @param state New state of the button
  53611. * @param changes Which properties on the state changed since last frame
  53612. */
  53613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53614. }
  53615. }
  53616. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53617. import { Observable } from "babylonjs/Misc/observable";
  53618. import { Scene } from "babylonjs/scene";
  53619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53620. import { Ray } from "babylonjs/Culling/ray";
  53621. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53622. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53623. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53624. /**
  53625. * Defines the WindowsMotionController object that the state of the windows motion controller
  53626. */
  53627. export class WindowsMotionController extends WebVRController {
  53628. /**
  53629. * The base url used to load the left and right controller models
  53630. */
  53631. static MODEL_BASE_URL: string;
  53632. /**
  53633. * The name of the left controller model file
  53634. */
  53635. static MODEL_LEFT_FILENAME: string;
  53636. /**
  53637. * The name of the right controller model file
  53638. */
  53639. static MODEL_RIGHT_FILENAME: string;
  53640. /**
  53641. * The controller name prefix for this controller type
  53642. */
  53643. static readonly GAMEPAD_ID_PREFIX: string;
  53644. /**
  53645. * The controller id pattern for this controller type
  53646. */
  53647. private static readonly GAMEPAD_ID_PATTERN;
  53648. private _loadedMeshInfo;
  53649. protected readonly _mapping: {
  53650. buttons: string[];
  53651. buttonMeshNames: {
  53652. trigger: string;
  53653. menu: string;
  53654. grip: string;
  53655. thumbstick: string;
  53656. trackpad: string;
  53657. };
  53658. buttonObservableNames: {
  53659. trigger: string;
  53660. menu: string;
  53661. grip: string;
  53662. thumbstick: string;
  53663. trackpad: string;
  53664. };
  53665. axisMeshNames: string[];
  53666. pointingPoseMeshName: string;
  53667. };
  53668. /**
  53669. * Fired when the trackpad on this controller is clicked
  53670. */
  53671. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53672. /**
  53673. * Fired when the trackpad on this controller is modified
  53674. */
  53675. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53676. /**
  53677. * The current x and y values of this controller's trackpad
  53678. */
  53679. trackpad: StickValues;
  53680. /**
  53681. * Creates a new WindowsMotionController from a gamepad
  53682. * @param vrGamepad the gamepad that the controller should be created from
  53683. */
  53684. constructor(vrGamepad: any);
  53685. /**
  53686. * Fired when the trigger on this controller is modified
  53687. */
  53688. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53689. /**
  53690. * Fired when the menu button on this controller is modified
  53691. */
  53692. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53693. /**
  53694. * Fired when the grip button on this controller is modified
  53695. */
  53696. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53697. /**
  53698. * Fired when the thumbstick button on this controller is modified
  53699. */
  53700. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53701. /**
  53702. * Fired when the touchpad button on this controller is modified
  53703. */
  53704. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53705. /**
  53706. * Fired when the touchpad values on this controller are modified
  53707. */
  53708. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53709. protected _updateTrackpad(): void;
  53710. /**
  53711. * Called once per frame by the engine.
  53712. */
  53713. update(): void;
  53714. /**
  53715. * Called once for each button that changed state since the last frame
  53716. * @param buttonIdx Which button index changed
  53717. * @param state New state of the button
  53718. * @param changes Which properties on the state changed since last frame
  53719. */
  53720. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53721. /**
  53722. * Moves the buttons on the controller mesh based on their current state
  53723. * @param buttonName the name of the button to move
  53724. * @param buttonValue the value of the button which determines the buttons new position
  53725. */
  53726. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53727. /**
  53728. * Moves the axis on the controller mesh based on its current state
  53729. * @param axis the index of the axis
  53730. * @param axisValue the value of the axis which determines the meshes new position
  53731. * @hidden
  53732. */
  53733. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53734. /**
  53735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53736. * @param scene scene in which to add meshes
  53737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53738. */
  53739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53740. /**
  53741. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53742. * can be transformed by button presses and axes values, based on this._mapping.
  53743. *
  53744. * @param scene scene in which the meshes exist
  53745. * @param meshes list of meshes that make up the controller model to process
  53746. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53747. */
  53748. private processModel;
  53749. private createMeshInfo;
  53750. /**
  53751. * Gets the ray of the controller in the direction the controller is pointing
  53752. * @param length the length the resulting ray should be
  53753. * @returns a ray in the direction the controller is pointing
  53754. */
  53755. getForwardRay(length?: number): Ray;
  53756. /**
  53757. * Disposes of the controller
  53758. */
  53759. dispose(): void;
  53760. }
  53761. /**
  53762. * This class represents a new windows motion controller in XR.
  53763. */
  53764. export class XRWindowsMotionController extends WindowsMotionController {
  53765. /**
  53766. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53767. */
  53768. protected readonly _mapping: {
  53769. buttons: string[];
  53770. buttonMeshNames: {
  53771. trigger: string;
  53772. menu: string;
  53773. grip: string;
  53774. thumbstick: string;
  53775. trackpad: string;
  53776. };
  53777. buttonObservableNames: {
  53778. trigger: string;
  53779. menu: string;
  53780. grip: string;
  53781. thumbstick: string;
  53782. trackpad: string;
  53783. };
  53784. axisMeshNames: string[];
  53785. pointingPoseMeshName: string;
  53786. };
  53787. /**
  53788. * Construct a new XR-Based windows motion controller
  53789. *
  53790. * @param gamepadInfo the gamepad object from the browser
  53791. */
  53792. constructor(gamepadInfo: any);
  53793. /**
  53794. * holds the thumbstick values (X,Y)
  53795. */
  53796. thumbstickValues: StickValues;
  53797. /**
  53798. * Fired when the thumbstick on this controller is clicked
  53799. */
  53800. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53801. /**
  53802. * Fired when the thumbstick on this controller is modified
  53803. */
  53804. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53805. /**
  53806. * Fired when the touchpad button on this controller is modified
  53807. */
  53808. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53809. /**
  53810. * Fired when the touchpad values on this controller are modified
  53811. */
  53812. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53813. /**
  53814. * Fired when the thumbstick button on this controller is modified
  53815. * here to prevent breaking changes
  53816. */
  53817. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53818. /**
  53819. * updating the thumbstick(!) and not the trackpad.
  53820. * This is named this way due to the difference between WebVR and XR and to avoid
  53821. * changing the parent class.
  53822. */
  53823. protected _updateTrackpad(): void;
  53824. /**
  53825. * Disposes the class with joy
  53826. */
  53827. dispose(): void;
  53828. }
  53829. }
  53830. declare module "babylonjs/Gamepads/Controllers/index" {
  53831. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  53832. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  53833. export * from "babylonjs/Gamepads/Controllers/genericController";
  53834. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  53835. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53836. export * from "babylonjs/Gamepads/Controllers/viveController";
  53837. export * from "babylonjs/Gamepads/Controllers/webVRController";
  53838. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  53839. }
  53840. declare module "babylonjs/Gamepads/index" {
  53841. export * from "babylonjs/Gamepads/Controllers/index";
  53842. export * from "babylonjs/Gamepads/gamepad";
  53843. export * from "babylonjs/Gamepads/gamepadManager";
  53844. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  53845. export * from "babylonjs/Gamepads/xboxGamepad";
  53846. export * from "babylonjs/Gamepads/dualShockGamepad";
  53847. }
  53848. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  53849. import { Scene } from "babylonjs/scene";
  53850. import { Vector4 } from "babylonjs/Maths/math.vector";
  53851. import { Color4 } from "babylonjs/Maths/math.color";
  53852. import { Mesh } from "babylonjs/Meshes/mesh";
  53853. import { Nullable } from "babylonjs/types";
  53854. /**
  53855. * Class containing static functions to help procedurally build meshes
  53856. */
  53857. export class PolyhedronBuilder {
  53858. /**
  53859. * Creates a polyhedron mesh
  53860. * * 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
  53861. * * The parameter `size` (positive float, default 1) sets the polygon size
  53862. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53863. * * 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`
  53864. * * 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
  53865. * * 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)`)
  53866. * * 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
  53867. * * 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
  53868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53871. * @param name defines the name of the mesh
  53872. * @param options defines the options used to create the mesh
  53873. * @param scene defines the hosting scene
  53874. * @returns the polyhedron mesh
  53875. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53876. */
  53877. static CreatePolyhedron(name: string, options: {
  53878. type?: number;
  53879. size?: number;
  53880. sizeX?: number;
  53881. sizeY?: number;
  53882. sizeZ?: number;
  53883. custom?: any;
  53884. faceUV?: Vector4[];
  53885. faceColors?: Color4[];
  53886. flat?: boolean;
  53887. updatable?: boolean;
  53888. sideOrientation?: number;
  53889. frontUVs?: Vector4;
  53890. backUVs?: Vector4;
  53891. }, scene?: Nullable<Scene>): Mesh;
  53892. }
  53893. }
  53894. declare module "babylonjs/Gizmos/scaleGizmo" {
  53895. import { Observable } from "babylonjs/Misc/observable";
  53896. import { Nullable } from "babylonjs/types";
  53897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53898. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  53899. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  53900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53901. /**
  53902. * Gizmo that enables scaling a mesh along 3 axis
  53903. */
  53904. export class ScaleGizmo extends Gizmo {
  53905. /**
  53906. * Internal gizmo used for interactions on the x axis
  53907. */
  53908. xGizmo: AxisScaleGizmo;
  53909. /**
  53910. * Internal gizmo used for interactions on the y axis
  53911. */
  53912. yGizmo: AxisScaleGizmo;
  53913. /**
  53914. * Internal gizmo used for interactions on the z axis
  53915. */
  53916. zGizmo: AxisScaleGizmo;
  53917. /**
  53918. * Internal gizmo used to scale all axis equally
  53919. */
  53920. uniformScaleGizmo: AxisScaleGizmo;
  53921. private _meshAttached;
  53922. private _updateGizmoRotationToMatchAttachedMesh;
  53923. private _snapDistance;
  53924. private _scaleRatio;
  53925. private _uniformScalingMesh;
  53926. private _octahedron;
  53927. private _sensitivity;
  53928. /** Fires an event when any of it's sub gizmos are dragged */
  53929. onDragStartObservable: Observable<unknown>;
  53930. /** Fires an event when any of it's sub gizmos are released from dragging */
  53931. onDragEndObservable: Observable<unknown>;
  53932. get attachedMesh(): Nullable<AbstractMesh>;
  53933. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53934. /**
  53935. * Creates a ScaleGizmo
  53936. * @param gizmoLayer The utility layer the gizmo will be added to
  53937. */
  53938. constructor(gizmoLayer?: UtilityLayerRenderer);
  53939. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53940. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53941. /**
  53942. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53943. */
  53944. set snapDistance(value: number);
  53945. get snapDistance(): number;
  53946. /**
  53947. * Ratio for the scale of the gizmo (Default: 1)
  53948. */
  53949. set scaleRatio(value: number);
  53950. get scaleRatio(): number;
  53951. /**
  53952. * Sensitivity factor for dragging (Default: 1)
  53953. */
  53954. set sensitivity(value: number);
  53955. get sensitivity(): number;
  53956. /**
  53957. * Disposes of the gizmo
  53958. */
  53959. dispose(): void;
  53960. }
  53961. }
  53962. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  53963. import { Observable } from "babylonjs/Misc/observable";
  53964. import { Nullable } from "babylonjs/types";
  53965. import { Vector3 } from "babylonjs/Maths/math.vector";
  53966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53967. import { Mesh } from "babylonjs/Meshes/mesh";
  53968. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  53969. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  53970. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53971. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  53972. import { Color3 } from "babylonjs/Maths/math.color";
  53973. /**
  53974. * Single axis scale gizmo
  53975. */
  53976. export class AxisScaleGizmo extends Gizmo {
  53977. /**
  53978. * Drag behavior responsible for the gizmos dragging interactions
  53979. */
  53980. dragBehavior: PointerDragBehavior;
  53981. private _pointerObserver;
  53982. /**
  53983. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53984. */
  53985. snapDistance: number;
  53986. /**
  53987. * Event that fires each time the gizmo snaps to a new location.
  53988. * * snapDistance is the the change in distance
  53989. */
  53990. onSnapObservable: Observable<{
  53991. snapDistance: number;
  53992. }>;
  53993. /**
  53994. * If the scaling operation should be done on all axis (default: false)
  53995. */
  53996. uniformScaling: boolean;
  53997. /**
  53998. * Custom sensitivity value for the drag strength
  53999. */
  54000. sensitivity: number;
  54001. private _isEnabled;
  54002. private _parent;
  54003. private _arrow;
  54004. private _coloredMaterial;
  54005. private _hoverMaterial;
  54006. /**
  54007. * Creates an AxisScaleGizmo
  54008. * @param gizmoLayer The utility layer the gizmo will be added to
  54009. * @param dragAxis The axis which the gizmo will be able to scale on
  54010. * @param color The color of the gizmo
  54011. */
  54012. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54013. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54014. /**
  54015. * If the gizmo is enabled
  54016. */
  54017. set isEnabled(value: boolean);
  54018. get isEnabled(): boolean;
  54019. /**
  54020. * Disposes of the gizmo
  54021. */
  54022. dispose(): void;
  54023. /**
  54024. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54025. * @param mesh The mesh to replace the default mesh of the gizmo
  54026. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54027. */
  54028. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54029. }
  54030. }
  54031. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54032. import { Observable } from "babylonjs/Misc/observable";
  54033. import { Nullable } from "babylonjs/types";
  54034. import { Vector3 } from "babylonjs/Maths/math.vector";
  54035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54036. import { Mesh } from "babylonjs/Meshes/mesh";
  54037. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54038. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54039. import { Color3 } from "babylonjs/Maths/math.color";
  54040. import "babylonjs/Meshes/Builders/boxBuilder";
  54041. /**
  54042. * Bounding box gizmo
  54043. */
  54044. export class BoundingBoxGizmo extends Gizmo {
  54045. private _lineBoundingBox;
  54046. private _rotateSpheresParent;
  54047. private _scaleBoxesParent;
  54048. private _boundingDimensions;
  54049. private _renderObserver;
  54050. private _pointerObserver;
  54051. private _scaleDragSpeed;
  54052. private _tmpQuaternion;
  54053. private _tmpVector;
  54054. private _tmpRotationMatrix;
  54055. /**
  54056. * 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)
  54057. */
  54058. ignoreChildren: boolean;
  54059. /**
  54060. * 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)
  54061. */
  54062. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54063. /**
  54064. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54065. */
  54066. rotationSphereSize: number;
  54067. /**
  54068. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54069. */
  54070. scaleBoxSize: number;
  54071. /**
  54072. * 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)
  54073. */
  54074. fixedDragMeshScreenSize: boolean;
  54075. /**
  54076. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54077. */
  54078. fixedDragMeshScreenSizeDistanceFactor: number;
  54079. /**
  54080. * Fired when a rotation sphere or scale box is dragged
  54081. */
  54082. onDragStartObservable: Observable<{}>;
  54083. /**
  54084. * Fired when a scale box is dragged
  54085. */
  54086. onScaleBoxDragObservable: Observable<{}>;
  54087. /**
  54088. * Fired when a scale box drag is ended
  54089. */
  54090. onScaleBoxDragEndObservable: Observable<{}>;
  54091. /**
  54092. * Fired when a rotation sphere is dragged
  54093. */
  54094. onRotationSphereDragObservable: Observable<{}>;
  54095. /**
  54096. * Fired when a rotation sphere drag is ended
  54097. */
  54098. onRotationSphereDragEndObservable: Observable<{}>;
  54099. /**
  54100. * 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)
  54101. */
  54102. scalePivot: Nullable<Vector3>;
  54103. /**
  54104. * Mesh used as a pivot to rotate the attached mesh
  54105. */
  54106. private _anchorMesh;
  54107. private _existingMeshScale;
  54108. private _dragMesh;
  54109. private pointerDragBehavior;
  54110. private coloredMaterial;
  54111. private hoverColoredMaterial;
  54112. /**
  54113. * Sets the color of the bounding box gizmo
  54114. * @param color the color to set
  54115. */
  54116. setColor(color: Color3): void;
  54117. /**
  54118. * Creates an BoundingBoxGizmo
  54119. * @param gizmoLayer The utility layer the gizmo will be added to
  54120. * @param color The color of the gizmo
  54121. */
  54122. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54123. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54124. private _selectNode;
  54125. /**
  54126. * Updates the bounding box information for the Gizmo
  54127. */
  54128. updateBoundingBox(): void;
  54129. private _updateRotationSpheres;
  54130. private _updateScaleBoxes;
  54131. /**
  54132. * Enables rotation on the specified axis and disables rotation on the others
  54133. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54134. */
  54135. setEnabledRotationAxis(axis: string): void;
  54136. /**
  54137. * Enables/disables scaling
  54138. * @param enable if scaling should be enabled
  54139. * @param homogeneousScaling defines if scaling should only be homogeneous
  54140. */
  54141. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54142. private _updateDummy;
  54143. /**
  54144. * Enables a pointer drag behavior on the bounding box of the gizmo
  54145. */
  54146. enableDragBehavior(): void;
  54147. /**
  54148. * Disposes of the gizmo
  54149. */
  54150. dispose(): void;
  54151. /**
  54152. * 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)
  54153. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54154. * @returns the bounding box mesh with the passed in mesh as a child
  54155. */
  54156. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54157. /**
  54158. * CustomMeshes are not supported by this gizmo
  54159. * @param mesh The mesh to replace the default mesh of the gizmo
  54160. */
  54161. setCustomMesh(mesh: Mesh): void;
  54162. }
  54163. }
  54164. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54165. import { Observable } from "babylonjs/Misc/observable";
  54166. import { Nullable } from "babylonjs/types";
  54167. import { Vector3 } from "babylonjs/Maths/math.vector";
  54168. import { Color3 } from "babylonjs/Maths/math.color";
  54169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54170. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54171. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54172. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54173. import "babylonjs/Meshes/Builders/linesBuilder";
  54174. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54175. /**
  54176. * Single plane rotation gizmo
  54177. */
  54178. export class PlaneRotationGizmo extends Gizmo {
  54179. /**
  54180. * Drag behavior responsible for the gizmos dragging interactions
  54181. */
  54182. dragBehavior: PointerDragBehavior;
  54183. private _pointerObserver;
  54184. /**
  54185. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54186. */
  54187. snapDistance: number;
  54188. /**
  54189. * Event that fires each time the gizmo snaps to a new location.
  54190. * * snapDistance is the the change in distance
  54191. */
  54192. onSnapObservable: Observable<{
  54193. snapDistance: number;
  54194. }>;
  54195. private _isEnabled;
  54196. private _parent;
  54197. /**
  54198. * Creates a PlaneRotationGizmo
  54199. * @param gizmoLayer The utility layer the gizmo will be added to
  54200. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54201. * @param color The color of the gizmo
  54202. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54203. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54204. */
  54205. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54207. /**
  54208. * If the gizmo is enabled
  54209. */
  54210. set isEnabled(value: boolean);
  54211. get isEnabled(): boolean;
  54212. /**
  54213. * Disposes of the gizmo
  54214. */
  54215. dispose(): void;
  54216. }
  54217. }
  54218. declare module "babylonjs/Gizmos/rotationGizmo" {
  54219. import { Observable } from "babylonjs/Misc/observable";
  54220. import { Nullable } from "babylonjs/types";
  54221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54222. import { Mesh } from "babylonjs/Meshes/mesh";
  54223. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54224. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54225. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54226. /**
  54227. * Gizmo that enables rotating a mesh along 3 axis
  54228. */
  54229. export class RotationGizmo extends Gizmo {
  54230. /**
  54231. * Internal gizmo used for interactions on the x axis
  54232. */
  54233. xGizmo: PlaneRotationGizmo;
  54234. /**
  54235. * Internal gizmo used for interactions on the y axis
  54236. */
  54237. yGizmo: PlaneRotationGizmo;
  54238. /**
  54239. * Internal gizmo used for interactions on the z axis
  54240. */
  54241. zGizmo: PlaneRotationGizmo;
  54242. /** Fires an event when any of it's sub gizmos are dragged */
  54243. onDragStartObservable: Observable<unknown>;
  54244. /** Fires an event when any of it's sub gizmos are released from dragging */
  54245. onDragEndObservable: Observable<unknown>;
  54246. private _meshAttached;
  54247. get attachedMesh(): Nullable<AbstractMesh>;
  54248. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54249. /**
  54250. * Creates a RotationGizmo
  54251. * @param gizmoLayer The utility layer the gizmo will be added to
  54252. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54253. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54254. */
  54255. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54256. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54257. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54258. /**
  54259. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54260. */
  54261. set snapDistance(value: number);
  54262. get snapDistance(): number;
  54263. /**
  54264. * Ratio for the scale of the gizmo (Default: 1)
  54265. */
  54266. set scaleRatio(value: number);
  54267. get scaleRatio(): number;
  54268. /**
  54269. * Disposes of the gizmo
  54270. */
  54271. dispose(): void;
  54272. /**
  54273. * CustomMeshes are not supported by this gizmo
  54274. * @param mesh The mesh to replace the default mesh of the gizmo
  54275. */
  54276. setCustomMesh(mesh: Mesh): void;
  54277. }
  54278. }
  54279. declare module "babylonjs/Gizmos/gizmoManager" {
  54280. import { Observable } from "babylonjs/Misc/observable";
  54281. import { Nullable } from "babylonjs/types";
  54282. import { Scene, IDisposable } from "babylonjs/scene";
  54283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54284. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54285. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54286. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54287. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54288. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54289. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54290. /**
  54291. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54292. */
  54293. export class GizmoManager implements IDisposable {
  54294. private scene;
  54295. /**
  54296. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54297. */
  54298. gizmos: {
  54299. positionGizmo: Nullable<PositionGizmo>;
  54300. rotationGizmo: Nullable<RotationGizmo>;
  54301. scaleGizmo: Nullable<ScaleGizmo>;
  54302. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54303. };
  54304. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54305. clearGizmoOnEmptyPointerEvent: boolean;
  54306. /** Fires an event when the manager is attached to a mesh */
  54307. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54308. private _gizmosEnabled;
  54309. private _pointerObserver;
  54310. private _attachedMesh;
  54311. private _boundingBoxColor;
  54312. private _defaultUtilityLayer;
  54313. private _defaultKeepDepthUtilityLayer;
  54314. /**
  54315. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54316. */
  54317. boundingBoxDragBehavior: SixDofDragBehavior;
  54318. /**
  54319. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54320. */
  54321. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54322. /**
  54323. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54324. */
  54325. usePointerToAttachGizmos: boolean;
  54326. /**
  54327. * Utility layer that the bounding box gizmo belongs to
  54328. */
  54329. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54330. /**
  54331. * Utility layer that all gizmos besides bounding box belong to
  54332. */
  54333. get utilityLayer(): UtilityLayerRenderer;
  54334. /**
  54335. * Instatiates a gizmo manager
  54336. * @param scene the scene to overlay the gizmos on top of
  54337. */
  54338. constructor(scene: Scene);
  54339. /**
  54340. * Attaches a set of gizmos to the specified mesh
  54341. * @param mesh The mesh the gizmo's should be attached to
  54342. */
  54343. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54344. /**
  54345. * If the position gizmo is enabled
  54346. */
  54347. set positionGizmoEnabled(value: boolean);
  54348. get positionGizmoEnabled(): boolean;
  54349. /**
  54350. * If the rotation gizmo is enabled
  54351. */
  54352. set rotationGizmoEnabled(value: boolean);
  54353. get rotationGizmoEnabled(): boolean;
  54354. /**
  54355. * If the scale gizmo is enabled
  54356. */
  54357. set scaleGizmoEnabled(value: boolean);
  54358. get scaleGizmoEnabled(): boolean;
  54359. /**
  54360. * If the boundingBox gizmo is enabled
  54361. */
  54362. set boundingBoxGizmoEnabled(value: boolean);
  54363. get boundingBoxGizmoEnabled(): boolean;
  54364. /**
  54365. * Disposes of the gizmo manager
  54366. */
  54367. dispose(): void;
  54368. }
  54369. }
  54370. declare module "babylonjs/Lights/directionalLight" {
  54371. import { Camera } from "babylonjs/Cameras/camera";
  54372. import { Scene } from "babylonjs/scene";
  54373. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54375. import { Light } from "babylonjs/Lights/light";
  54376. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54377. import { Effect } from "babylonjs/Materials/effect";
  54378. /**
  54379. * A directional light is defined by a direction (what a surprise!).
  54380. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54381. * 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.
  54382. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54383. */
  54384. export class DirectionalLight extends ShadowLight {
  54385. private _shadowFrustumSize;
  54386. /**
  54387. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54388. */
  54389. get shadowFrustumSize(): number;
  54390. /**
  54391. * Specifies a fix frustum size for the shadow generation.
  54392. */
  54393. set shadowFrustumSize(value: number);
  54394. private _shadowOrthoScale;
  54395. /**
  54396. * Gets the shadow projection scale against the optimal computed one.
  54397. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54398. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54399. */
  54400. get shadowOrthoScale(): number;
  54401. /**
  54402. * Sets the shadow projection scale against the optimal computed one.
  54403. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54404. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54405. */
  54406. set shadowOrthoScale(value: number);
  54407. /**
  54408. * Automatically compute the projection matrix to best fit (including all the casters)
  54409. * on each frame.
  54410. */
  54411. autoUpdateExtends: boolean;
  54412. /**
  54413. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54414. * on each frame. autoUpdateExtends must be set to true for this to work
  54415. */
  54416. autoCalcShadowZBounds: boolean;
  54417. private _orthoLeft;
  54418. private _orthoRight;
  54419. private _orthoTop;
  54420. private _orthoBottom;
  54421. /**
  54422. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54423. * The directional light is emitted from everywhere in the given direction.
  54424. * It can cast shadows.
  54425. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54426. * @param name The friendly name of the light
  54427. * @param direction The direction of the light
  54428. * @param scene The scene the light belongs to
  54429. */
  54430. constructor(name: string, direction: Vector3, scene: Scene);
  54431. /**
  54432. * Returns the string "DirectionalLight".
  54433. * @return The class name
  54434. */
  54435. getClassName(): string;
  54436. /**
  54437. * Returns the integer 1.
  54438. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54439. */
  54440. getTypeID(): number;
  54441. /**
  54442. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54443. * Returns the DirectionalLight Shadow projection matrix.
  54444. */
  54445. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54446. /**
  54447. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54448. * Returns the DirectionalLight Shadow projection matrix.
  54449. */
  54450. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54451. /**
  54452. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54453. * Returns the DirectionalLight Shadow projection matrix.
  54454. */
  54455. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54456. protected _buildUniformLayout(): void;
  54457. /**
  54458. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54459. * @param effect The effect to update
  54460. * @param lightIndex The index of the light in the effect to update
  54461. * @returns The directional light
  54462. */
  54463. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54464. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54465. /**
  54466. * Gets the minZ used for shadow according to both the scene and the light.
  54467. *
  54468. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54469. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54470. * @param activeCamera The camera we are returning the min for
  54471. * @returns the depth min z
  54472. */
  54473. getDepthMinZ(activeCamera: Camera): number;
  54474. /**
  54475. * Gets the maxZ used for shadow according to both the scene and the light.
  54476. *
  54477. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54478. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54479. * @param activeCamera The camera we are returning the max for
  54480. * @returns the depth max z
  54481. */
  54482. getDepthMaxZ(activeCamera: Camera): number;
  54483. /**
  54484. * Prepares the list of defines specific to the light type.
  54485. * @param defines the list of defines
  54486. * @param lightIndex defines the index of the light for the effect
  54487. */
  54488. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54489. }
  54490. }
  54491. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54492. import { Mesh } from "babylonjs/Meshes/mesh";
  54493. /**
  54494. * Class containing static functions to help procedurally build meshes
  54495. */
  54496. export class HemisphereBuilder {
  54497. /**
  54498. * Creates a hemisphere mesh
  54499. * @param name defines the name of the mesh
  54500. * @param options defines the options used to create the mesh
  54501. * @param scene defines the hosting scene
  54502. * @returns the hemisphere mesh
  54503. */
  54504. static CreateHemisphere(name: string, options: {
  54505. segments?: number;
  54506. diameter?: number;
  54507. sideOrientation?: number;
  54508. }, scene: any): Mesh;
  54509. }
  54510. }
  54511. declare module "babylonjs/Lights/spotLight" {
  54512. import { Nullable } from "babylonjs/types";
  54513. import { Scene } from "babylonjs/scene";
  54514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54516. import { Effect } from "babylonjs/Materials/effect";
  54517. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54518. import { Light } from "babylonjs/Lights/light";
  54519. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54520. /**
  54521. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54522. * These values define a cone of light starting from the position, emitting toward the direction.
  54523. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54524. * and the exponent defines the speed of the decay of the light with distance (reach).
  54525. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54526. */
  54527. export class SpotLight extends ShadowLight {
  54528. private _angle;
  54529. private _innerAngle;
  54530. private _cosHalfAngle;
  54531. private _lightAngleScale;
  54532. private _lightAngleOffset;
  54533. /**
  54534. * Gets the cone angle of the spot light in Radians.
  54535. */
  54536. get angle(): number;
  54537. /**
  54538. * Sets the cone angle of the spot light in Radians.
  54539. */
  54540. set angle(value: number);
  54541. /**
  54542. * Only used in gltf falloff mode, this defines the angle where
  54543. * the directional falloff will start before cutting at angle which could be seen
  54544. * as outer angle.
  54545. */
  54546. get innerAngle(): number;
  54547. /**
  54548. * Only used in gltf falloff mode, this defines the angle where
  54549. * the directional falloff will start before cutting at angle which could be seen
  54550. * as outer angle.
  54551. */
  54552. set innerAngle(value: number);
  54553. private _shadowAngleScale;
  54554. /**
  54555. * Allows scaling the angle of the light for shadow generation only.
  54556. */
  54557. get shadowAngleScale(): number;
  54558. /**
  54559. * Allows scaling the angle of the light for shadow generation only.
  54560. */
  54561. set shadowAngleScale(value: number);
  54562. /**
  54563. * The light decay speed with the distance from the emission spot.
  54564. */
  54565. exponent: number;
  54566. private _projectionTextureMatrix;
  54567. /**
  54568. * Allows reading the projecton texture
  54569. */
  54570. get projectionTextureMatrix(): Matrix;
  54571. protected _projectionTextureLightNear: number;
  54572. /**
  54573. * Gets the near clip of the Spotlight for texture projection.
  54574. */
  54575. get projectionTextureLightNear(): number;
  54576. /**
  54577. * Sets the near clip of the Spotlight for texture projection.
  54578. */
  54579. set projectionTextureLightNear(value: number);
  54580. protected _projectionTextureLightFar: number;
  54581. /**
  54582. * Gets the far clip of the Spotlight for texture projection.
  54583. */
  54584. get projectionTextureLightFar(): number;
  54585. /**
  54586. * Sets the far clip of the Spotlight for texture projection.
  54587. */
  54588. set projectionTextureLightFar(value: number);
  54589. protected _projectionTextureUpDirection: Vector3;
  54590. /**
  54591. * Gets the Up vector of the Spotlight for texture projection.
  54592. */
  54593. get projectionTextureUpDirection(): Vector3;
  54594. /**
  54595. * Sets the Up vector of the Spotlight for texture projection.
  54596. */
  54597. set projectionTextureUpDirection(value: Vector3);
  54598. private _projectionTexture;
  54599. /**
  54600. * Gets the projection texture of the light.
  54601. */
  54602. get projectionTexture(): Nullable<BaseTexture>;
  54603. /**
  54604. * Sets the projection texture of the light.
  54605. */
  54606. set projectionTexture(value: Nullable<BaseTexture>);
  54607. private _projectionTextureViewLightDirty;
  54608. private _projectionTextureProjectionLightDirty;
  54609. private _projectionTextureDirty;
  54610. private _projectionTextureViewTargetVector;
  54611. private _projectionTextureViewLightMatrix;
  54612. private _projectionTextureProjectionLightMatrix;
  54613. private _projectionTextureScalingMatrix;
  54614. /**
  54615. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54616. * It can cast shadows.
  54617. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54618. * @param name The light friendly name
  54619. * @param position The position of the spot light in the scene
  54620. * @param direction The direction of the light in the scene
  54621. * @param angle The cone angle of the light in Radians
  54622. * @param exponent The light decay speed with the distance from the emission spot
  54623. * @param scene The scene the lights belongs to
  54624. */
  54625. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54626. /**
  54627. * Returns the string "SpotLight".
  54628. * @returns the class name
  54629. */
  54630. getClassName(): string;
  54631. /**
  54632. * Returns the integer 2.
  54633. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54634. */
  54635. getTypeID(): number;
  54636. /**
  54637. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54638. */
  54639. protected _setDirection(value: Vector3): void;
  54640. /**
  54641. * Overrides the position setter to recompute the projection texture view light Matrix.
  54642. */
  54643. protected _setPosition(value: Vector3): void;
  54644. /**
  54645. * 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.
  54646. * Returns the SpotLight.
  54647. */
  54648. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54649. protected _computeProjectionTextureViewLightMatrix(): void;
  54650. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54651. /**
  54652. * Main function for light texture projection matrix computing.
  54653. */
  54654. protected _computeProjectionTextureMatrix(): void;
  54655. protected _buildUniformLayout(): void;
  54656. private _computeAngleValues;
  54657. /**
  54658. * Sets the passed Effect "effect" with the Light textures.
  54659. * @param effect The effect to update
  54660. * @param lightIndex The index of the light in the effect to update
  54661. * @returns The light
  54662. */
  54663. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54664. /**
  54665. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54666. * @param effect The effect to update
  54667. * @param lightIndex The index of the light in the effect to update
  54668. * @returns The spot light
  54669. */
  54670. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54671. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54672. /**
  54673. * Disposes the light and the associated resources.
  54674. */
  54675. dispose(): void;
  54676. /**
  54677. * Prepares the list of defines specific to the light type.
  54678. * @param defines the list of defines
  54679. * @param lightIndex defines the index of the light for the effect
  54680. */
  54681. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54682. }
  54683. }
  54684. declare module "babylonjs/Gizmos/lightGizmo" {
  54685. import { Nullable } from "babylonjs/types";
  54686. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54687. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54688. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  54689. import { Light } from "babylonjs/Lights/light";
  54690. /**
  54691. * Gizmo that enables viewing a light
  54692. */
  54693. export class LightGizmo extends Gizmo {
  54694. private _lightMesh;
  54695. private _material;
  54696. private _cachedPosition;
  54697. private _cachedForward;
  54698. private _attachedMeshParent;
  54699. /**
  54700. * Creates a LightGizmo
  54701. * @param gizmoLayer The utility layer the gizmo will be added to
  54702. */
  54703. constructor(gizmoLayer?: UtilityLayerRenderer);
  54704. private _light;
  54705. /**
  54706. * The light that the gizmo is attached to
  54707. */
  54708. set light(light: Nullable<Light>);
  54709. get light(): Nullable<Light>;
  54710. /**
  54711. * Gets the material used to render the light gizmo
  54712. */
  54713. get material(): StandardMaterial;
  54714. /**
  54715. * @hidden
  54716. * Updates the gizmo to match the attached mesh's position/rotation
  54717. */
  54718. protected _update(): void;
  54719. private static _Scale;
  54720. /**
  54721. * Creates the lines for a light mesh
  54722. */
  54723. private static _CreateLightLines;
  54724. /**
  54725. * Disposes of the light gizmo
  54726. */
  54727. dispose(): void;
  54728. private static _CreateHemisphericLightMesh;
  54729. private static _CreatePointLightMesh;
  54730. private static _CreateSpotLightMesh;
  54731. private static _CreateDirectionalLightMesh;
  54732. }
  54733. }
  54734. declare module "babylonjs/Gizmos/index" {
  54735. export * from "babylonjs/Gizmos/axisDragGizmo";
  54736. export * from "babylonjs/Gizmos/axisScaleGizmo";
  54737. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  54738. export * from "babylonjs/Gizmos/gizmo";
  54739. export * from "babylonjs/Gizmos/gizmoManager";
  54740. export * from "babylonjs/Gizmos/planeRotationGizmo";
  54741. export * from "babylonjs/Gizmos/positionGizmo";
  54742. export * from "babylonjs/Gizmos/rotationGizmo";
  54743. export * from "babylonjs/Gizmos/scaleGizmo";
  54744. export * from "babylonjs/Gizmos/lightGizmo";
  54745. export * from "babylonjs/Gizmos/planeDragGizmo";
  54746. }
  54747. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  54748. /** @hidden */
  54749. export var backgroundFragmentDeclaration: {
  54750. name: string;
  54751. shader: string;
  54752. };
  54753. }
  54754. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  54755. /** @hidden */
  54756. export var backgroundUboDeclaration: {
  54757. name: string;
  54758. shader: string;
  54759. };
  54760. }
  54761. declare module "babylonjs/Shaders/background.fragment" {
  54762. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54763. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54764. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54765. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54766. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54767. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54769. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54770. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54771. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54772. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54773. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54775. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  54776. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  54777. /** @hidden */
  54778. export var backgroundPixelShader: {
  54779. name: string;
  54780. shader: string;
  54781. };
  54782. }
  54783. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  54784. /** @hidden */
  54785. export var backgroundVertexDeclaration: {
  54786. name: string;
  54787. shader: string;
  54788. };
  54789. }
  54790. declare module "babylonjs/Shaders/background.vertex" {
  54791. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54792. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54793. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54794. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54795. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54796. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54797. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54798. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54799. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54800. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54801. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54802. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54803. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  54804. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54805. /** @hidden */
  54806. export var backgroundVertexShader: {
  54807. name: string;
  54808. shader: string;
  54809. };
  54810. }
  54811. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  54812. import { Nullable, int, float } from "babylonjs/types";
  54813. import { Scene } from "babylonjs/scene";
  54814. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54817. import { Mesh } from "babylonjs/Meshes/mesh";
  54818. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54819. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54820. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54822. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  54823. import { Color3 } from "babylonjs/Maths/math.color";
  54824. import "babylonjs/Shaders/background.fragment";
  54825. import "babylonjs/Shaders/background.vertex";
  54826. /**
  54827. * Background material used to create an efficient environement around your scene.
  54828. */
  54829. export class BackgroundMaterial extends PushMaterial {
  54830. /**
  54831. * Standard reflectance value at parallel view angle.
  54832. */
  54833. static StandardReflectance0: number;
  54834. /**
  54835. * Standard reflectance value at grazing angle.
  54836. */
  54837. static StandardReflectance90: number;
  54838. protected _primaryColor: Color3;
  54839. /**
  54840. * Key light Color (multiply against the environement texture)
  54841. */
  54842. primaryColor: Color3;
  54843. protected __perceptualColor: Nullable<Color3>;
  54844. /**
  54845. * Experimental Internal Use Only.
  54846. *
  54847. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54848. * This acts as a helper to set the primary color to a more "human friendly" value.
  54849. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54850. * output color as close as possible from the chosen value.
  54851. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54852. * part of lighting setup.)
  54853. */
  54854. get _perceptualColor(): Nullable<Color3>;
  54855. set _perceptualColor(value: Nullable<Color3>);
  54856. protected _primaryColorShadowLevel: float;
  54857. /**
  54858. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54859. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54860. */
  54861. get primaryColorShadowLevel(): float;
  54862. set primaryColorShadowLevel(value: float);
  54863. protected _primaryColorHighlightLevel: float;
  54864. /**
  54865. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54866. * The primary color is used at the level chosen to define what the white area would look.
  54867. */
  54868. get primaryColorHighlightLevel(): float;
  54869. set primaryColorHighlightLevel(value: float);
  54870. protected _reflectionTexture: Nullable<BaseTexture>;
  54871. /**
  54872. * Reflection Texture used in the material.
  54873. * Should be author in a specific way for the best result (refer to the documentation).
  54874. */
  54875. reflectionTexture: Nullable<BaseTexture>;
  54876. protected _reflectionBlur: float;
  54877. /**
  54878. * Reflection Texture level of blur.
  54879. *
  54880. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54881. * texture twice.
  54882. */
  54883. reflectionBlur: float;
  54884. protected _diffuseTexture: Nullable<BaseTexture>;
  54885. /**
  54886. * Diffuse Texture used in the material.
  54887. * Should be author in a specific way for the best result (refer to the documentation).
  54888. */
  54889. diffuseTexture: Nullable<BaseTexture>;
  54890. protected _shadowLights: Nullable<IShadowLight[]>;
  54891. /**
  54892. * Specify the list of lights casting shadow on the material.
  54893. * All scene shadow lights will be included if null.
  54894. */
  54895. shadowLights: Nullable<IShadowLight[]>;
  54896. protected _shadowLevel: float;
  54897. /**
  54898. * Helps adjusting the shadow to a softer level if required.
  54899. * 0 means black shadows and 1 means no shadows.
  54900. */
  54901. shadowLevel: float;
  54902. protected _sceneCenter: Vector3;
  54903. /**
  54904. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54905. * It is usually zero but might be interesting to modify according to your setup.
  54906. */
  54907. sceneCenter: Vector3;
  54908. protected _opacityFresnel: boolean;
  54909. /**
  54910. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54911. * This helps ensuring a nice transition when the camera goes under the ground.
  54912. */
  54913. opacityFresnel: boolean;
  54914. protected _reflectionFresnel: boolean;
  54915. /**
  54916. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54917. * This helps adding a mirror texture on the ground.
  54918. */
  54919. reflectionFresnel: boolean;
  54920. protected _reflectionFalloffDistance: number;
  54921. /**
  54922. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54923. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54924. */
  54925. reflectionFalloffDistance: number;
  54926. protected _reflectionAmount: number;
  54927. /**
  54928. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54929. */
  54930. reflectionAmount: number;
  54931. protected _reflectionReflectance0: number;
  54932. /**
  54933. * This specifies the weight of the reflection at grazing angle.
  54934. */
  54935. reflectionReflectance0: number;
  54936. protected _reflectionReflectance90: number;
  54937. /**
  54938. * This specifies the weight of the reflection at a perpendicular point of view.
  54939. */
  54940. reflectionReflectance90: number;
  54941. /**
  54942. * Sets the reflection reflectance fresnel values according to the default standard
  54943. * empirically know to work well :-)
  54944. */
  54945. set reflectionStandardFresnelWeight(value: number);
  54946. protected _useRGBColor: boolean;
  54947. /**
  54948. * Helps to directly use the maps channels instead of their level.
  54949. */
  54950. useRGBColor: boolean;
  54951. protected _enableNoise: boolean;
  54952. /**
  54953. * This helps reducing the banding effect that could occur on the background.
  54954. */
  54955. enableNoise: boolean;
  54956. /**
  54957. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54958. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54959. * Recommended to be keep at 1.0 except for special cases.
  54960. */
  54961. get fovMultiplier(): number;
  54962. set fovMultiplier(value: number);
  54963. private _fovMultiplier;
  54964. /**
  54965. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54966. */
  54967. useEquirectangularFOV: boolean;
  54968. private _maxSimultaneousLights;
  54969. /**
  54970. * Number of Simultaneous lights allowed on the material.
  54971. */
  54972. maxSimultaneousLights: int;
  54973. /**
  54974. * Default configuration related to image processing available in the Background Material.
  54975. */
  54976. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54977. /**
  54978. * Keep track of the image processing observer to allow dispose and replace.
  54979. */
  54980. private _imageProcessingObserver;
  54981. /**
  54982. * Attaches a new image processing configuration to the PBR Material.
  54983. * @param configuration (if null the scene configuration will be use)
  54984. */
  54985. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54986. /**
  54987. * Gets the image processing configuration used either in this material.
  54988. */
  54989. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54990. /**
  54991. * Sets the Default image processing configuration used either in the this material.
  54992. *
  54993. * If sets to null, the scene one is in use.
  54994. */
  54995. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54996. /**
  54997. * Gets wether the color curves effect is enabled.
  54998. */
  54999. get cameraColorCurvesEnabled(): boolean;
  55000. /**
  55001. * Sets wether the color curves effect is enabled.
  55002. */
  55003. set cameraColorCurvesEnabled(value: boolean);
  55004. /**
  55005. * Gets wether the color grading effect is enabled.
  55006. */
  55007. get cameraColorGradingEnabled(): boolean;
  55008. /**
  55009. * Gets wether the color grading effect is enabled.
  55010. */
  55011. set cameraColorGradingEnabled(value: boolean);
  55012. /**
  55013. * Gets wether tonemapping is enabled or not.
  55014. */
  55015. get cameraToneMappingEnabled(): boolean;
  55016. /**
  55017. * Sets wether tonemapping is enabled or not
  55018. */
  55019. set cameraToneMappingEnabled(value: boolean);
  55020. /**
  55021. * The camera exposure used on this material.
  55022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55023. * This corresponds to a photographic exposure.
  55024. */
  55025. get cameraExposure(): float;
  55026. /**
  55027. * The camera exposure used on this material.
  55028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55029. * This corresponds to a photographic exposure.
  55030. */
  55031. set cameraExposure(value: float);
  55032. /**
  55033. * Gets The camera contrast used on this material.
  55034. */
  55035. get cameraContrast(): float;
  55036. /**
  55037. * Sets The camera contrast used on this material.
  55038. */
  55039. set cameraContrast(value: float);
  55040. /**
  55041. * Gets the Color Grading 2D Lookup Texture.
  55042. */
  55043. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55044. /**
  55045. * Sets the Color Grading 2D Lookup Texture.
  55046. */
  55047. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55048. /**
  55049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55051. * 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;
  55052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55053. */
  55054. get cameraColorCurves(): Nullable<ColorCurves>;
  55055. /**
  55056. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55057. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55058. * 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;
  55059. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55060. */
  55061. set cameraColorCurves(value: Nullable<ColorCurves>);
  55062. /**
  55063. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55064. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55065. */
  55066. switchToBGR: boolean;
  55067. private _renderTargets;
  55068. private _reflectionControls;
  55069. private _white;
  55070. private _primaryShadowColor;
  55071. private _primaryHighlightColor;
  55072. /**
  55073. * Instantiates a Background Material in the given scene
  55074. * @param name The friendly name of the material
  55075. * @param scene The scene to add the material to
  55076. */
  55077. constructor(name: string, scene: Scene);
  55078. /**
  55079. * Gets a boolean indicating that current material needs to register RTT
  55080. */
  55081. get hasRenderTargetTextures(): boolean;
  55082. /**
  55083. * The entire material has been created in order to prevent overdraw.
  55084. * @returns false
  55085. */
  55086. needAlphaTesting(): boolean;
  55087. /**
  55088. * The entire material has been created in order to prevent overdraw.
  55089. * @returns true if blending is enable
  55090. */
  55091. needAlphaBlending(): boolean;
  55092. /**
  55093. * Checks wether the material is ready to be rendered for a given mesh.
  55094. * @param mesh The mesh to render
  55095. * @param subMesh The submesh to check against
  55096. * @param useInstances Specify wether or not the material is used with instances
  55097. * @returns true if all the dependencies are ready (Textures, Effects...)
  55098. */
  55099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55100. /**
  55101. * Compute the primary color according to the chosen perceptual color.
  55102. */
  55103. private _computePrimaryColorFromPerceptualColor;
  55104. /**
  55105. * Compute the highlights and shadow colors according to their chosen levels.
  55106. */
  55107. private _computePrimaryColors;
  55108. /**
  55109. * Build the uniform buffer used in the material.
  55110. */
  55111. buildUniformLayout(): void;
  55112. /**
  55113. * Unbind the material.
  55114. */
  55115. unbind(): void;
  55116. /**
  55117. * Bind only the world matrix to the material.
  55118. * @param world The world matrix to bind.
  55119. */
  55120. bindOnlyWorldMatrix(world: Matrix): void;
  55121. /**
  55122. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55123. * @param world The world matrix to bind.
  55124. * @param subMesh The submesh to bind for.
  55125. */
  55126. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55127. /**
  55128. * Checks to see if a texture is used in the material.
  55129. * @param texture - Base texture to use.
  55130. * @returns - Boolean specifying if a texture is used in the material.
  55131. */
  55132. hasTexture(texture: BaseTexture): boolean;
  55133. /**
  55134. * Dispose the material.
  55135. * @param forceDisposeEffect Force disposal of the associated effect.
  55136. * @param forceDisposeTextures Force disposal of the associated textures.
  55137. */
  55138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55139. /**
  55140. * Clones the material.
  55141. * @param name The cloned name.
  55142. * @returns The cloned material.
  55143. */
  55144. clone(name: string): BackgroundMaterial;
  55145. /**
  55146. * Serializes the current material to its JSON representation.
  55147. * @returns The JSON representation.
  55148. */
  55149. serialize(): any;
  55150. /**
  55151. * Gets the class name of the material
  55152. * @returns "BackgroundMaterial"
  55153. */
  55154. getClassName(): string;
  55155. /**
  55156. * Parse a JSON input to create back a background material.
  55157. * @param source The JSON data to parse
  55158. * @param scene The scene to create the parsed material in
  55159. * @param rootUrl The root url of the assets the material depends upon
  55160. * @returns the instantiated BackgroundMaterial.
  55161. */
  55162. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55163. }
  55164. }
  55165. declare module "babylonjs/Helpers/environmentHelper" {
  55166. import { Observable } from "babylonjs/Misc/observable";
  55167. import { Nullable } from "babylonjs/types";
  55168. import { Scene } from "babylonjs/scene";
  55169. import { Vector3 } from "babylonjs/Maths/math.vector";
  55170. import { Color3 } from "babylonjs/Maths/math.color";
  55171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55172. import { Mesh } from "babylonjs/Meshes/mesh";
  55173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55174. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55175. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55176. import "babylonjs/Meshes/Builders/planeBuilder";
  55177. import "babylonjs/Meshes/Builders/boxBuilder";
  55178. /**
  55179. * Represents the different options available during the creation of
  55180. * a Environment helper.
  55181. *
  55182. * This can control the default ground, skybox and image processing setup of your scene.
  55183. */
  55184. export interface IEnvironmentHelperOptions {
  55185. /**
  55186. * Specifies whether or not to create a ground.
  55187. * True by default.
  55188. */
  55189. createGround: boolean;
  55190. /**
  55191. * Specifies the ground size.
  55192. * 15 by default.
  55193. */
  55194. groundSize: number;
  55195. /**
  55196. * The texture used on the ground for the main color.
  55197. * Comes from the BabylonJS CDN by default.
  55198. *
  55199. * Remarks: Can be either a texture or a url.
  55200. */
  55201. groundTexture: string | BaseTexture;
  55202. /**
  55203. * The color mixed in the ground texture by default.
  55204. * BabylonJS clearColor by default.
  55205. */
  55206. groundColor: Color3;
  55207. /**
  55208. * Specifies the ground opacity.
  55209. * 1 by default.
  55210. */
  55211. groundOpacity: number;
  55212. /**
  55213. * Enables the ground to receive shadows.
  55214. * True by default.
  55215. */
  55216. enableGroundShadow: boolean;
  55217. /**
  55218. * Helps preventing the shadow to be fully black on the ground.
  55219. * 0.5 by default.
  55220. */
  55221. groundShadowLevel: number;
  55222. /**
  55223. * Creates a mirror texture attach to the ground.
  55224. * false by default.
  55225. */
  55226. enableGroundMirror: boolean;
  55227. /**
  55228. * Specifies the ground mirror size ratio.
  55229. * 0.3 by default as the default kernel is 64.
  55230. */
  55231. groundMirrorSizeRatio: number;
  55232. /**
  55233. * Specifies the ground mirror blur kernel size.
  55234. * 64 by default.
  55235. */
  55236. groundMirrorBlurKernel: number;
  55237. /**
  55238. * Specifies the ground mirror visibility amount.
  55239. * 1 by default
  55240. */
  55241. groundMirrorAmount: number;
  55242. /**
  55243. * Specifies the ground mirror reflectance weight.
  55244. * This uses the standard weight of the background material to setup the fresnel effect
  55245. * of the mirror.
  55246. * 1 by default.
  55247. */
  55248. groundMirrorFresnelWeight: number;
  55249. /**
  55250. * Specifies the ground mirror Falloff distance.
  55251. * This can helps reducing the size of the reflection.
  55252. * 0 by Default.
  55253. */
  55254. groundMirrorFallOffDistance: number;
  55255. /**
  55256. * Specifies the ground mirror texture type.
  55257. * Unsigned Int by Default.
  55258. */
  55259. groundMirrorTextureType: number;
  55260. /**
  55261. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55262. * the shown objects.
  55263. */
  55264. groundYBias: number;
  55265. /**
  55266. * Specifies whether or not to create a skybox.
  55267. * True by default.
  55268. */
  55269. createSkybox: boolean;
  55270. /**
  55271. * Specifies the skybox size.
  55272. * 20 by default.
  55273. */
  55274. skyboxSize: number;
  55275. /**
  55276. * The texture used on the skybox for the main color.
  55277. * Comes from the BabylonJS CDN by default.
  55278. *
  55279. * Remarks: Can be either a texture or a url.
  55280. */
  55281. skyboxTexture: string | BaseTexture;
  55282. /**
  55283. * The color mixed in the skybox texture by default.
  55284. * BabylonJS clearColor by default.
  55285. */
  55286. skyboxColor: Color3;
  55287. /**
  55288. * The background rotation around the Y axis of the scene.
  55289. * This helps aligning the key lights of your scene with the background.
  55290. * 0 by default.
  55291. */
  55292. backgroundYRotation: number;
  55293. /**
  55294. * Compute automatically the size of the elements to best fit with the scene.
  55295. */
  55296. sizeAuto: boolean;
  55297. /**
  55298. * Default position of the rootMesh if autoSize is not true.
  55299. */
  55300. rootPosition: Vector3;
  55301. /**
  55302. * Sets up the image processing in the scene.
  55303. * true by default.
  55304. */
  55305. setupImageProcessing: boolean;
  55306. /**
  55307. * The texture used as your environment texture in the scene.
  55308. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55309. *
  55310. * Remarks: Can be either a texture or a url.
  55311. */
  55312. environmentTexture: string | BaseTexture;
  55313. /**
  55314. * The value of the exposure to apply to the scene.
  55315. * 0.6 by default if setupImageProcessing is true.
  55316. */
  55317. cameraExposure: number;
  55318. /**
  55319. * The value of the contrast to apply to the scene.
  55320. * 1.6 by default if setupImageProcessing is true.
  55321. */
  55322. cameraContrast: number;
  55323. /**
  55324. * Specifies whether or not tonemapping should be enabled in the scene.
  55325. * true by default if setupImageProcessing is true.
  55326. */
  55327. toneMappingEnabled: boolean;
  55328. }
  55329. /**
  55330. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55331. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55332. * It also helps with the default setup of your imageProcessing configuration.
  55333. */
  55334. export class EnvironmentHelper {
  55335. /**
  55336. * Default ground texture URL.
  55337. */
  55338. private static _groundTextureCDNUrl;
  55339. /**
  55340. * Default skybox texture URL.
  55341. */
  55342. private static _skyboxTextureCDNUrl;
  55343. /**
  55344. * Default environment texture URL.
  55345. */
  55346. private static _environmentTextureCDNUrl;
  55347. /**
  55348. * Creates the default options for the helper.
  55349. */
  55350. private static _getDefaultOptions;
  55351. private _rootMesh;
  55352. /**
  55353. * Gets the root mesh created by the helper.
  55354. */
  55355. get rootMesh(): Mesh;
  55356. private _skybox;
  55357. /**
  55358. * Gets the skybox created by the helper.
  55359. */
  55360. get skybox(): Nullable<Mesh>;
  55361. private _skyboxTexture;
  55362. /**
  55363. * Gets the skybox texture created by the helper.
  55364. */
  55365. get skyboxTexture(): Nullable<BaseTexture>;
  55366. private _skyboxMaterial;
  55367. /**
  55368. * Gets the skybox material created by the helper.
  55369. */
  55370. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55371. private _ground;
  55372. /**
  55373. * Gets the ground mesh created by the helper.
  55374. */
  55375. get ground(): Nullable<Mesh>;
  55376. private _groundTexture;
  55377. /**
  55378. * Gets the ground texture created by the helper.
  55379. */
  55380. get groundTexture(): Nullable<BaseTexture>;
  55381. private _groundMirror;
  55382. /**
  55383. * Gets the ground mirror created by the helper.
  55384. */
  55385. get groundMirror(): Nullable<MirrorTexture>;
  55386. /**
  55387. * Gets the ground mirror render list to helps pushing the meshes
  55388. * you wish in the ground reflection.
  55389. */
  55390. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55391. private _groundMaterial;
  55392. /**
  55393. * Gets the ground material created by the helper.
  55394. */
  55395. get groundMaterial(): Nullable<BackgroundMaterial>;
  55396. /**
  55397. * Stores the creation options.
  55398. */
  55399. private readonly _scene;
  55400. private _options;
  55401. /**
  55402. * This observable will be notified with any error during the creation of the environment,
  55403. * mainly texture creation errors.
  55404. */
  55405. onErrorObservable: Observable<{
  55406. message?: string;
  55407. exception?: any;
  55408. }>;
  55409. /**
  55410. * constructor
  55411. * @param options Defines the options we want to customize the helper
  55412. * @param scene The scene to add the material to
  55413. */
  55414. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55415. /**
  55416. * Updates the background according to the new options
  55417. * @param options
  55418. */
  55419. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55420. /**
  55421. * Sets the primary color of all the available elements.
  55422. * @param color the main color to affect to the ground and the background
  55423. */
  55424. setMainColor(color: Color3): void;
  55425. /**
  55426. * Setup the image processing according to the specified options.
  55427. */
  55428. private _setupImageProcessing;
  55429. /**
  55430. * Setup the environment texture according to the specified options.
  55431. */
  55432. private _setupEnvironmentTexture;
  55433. /**
  55434. * Setup the background according to the specified options.
  55435. */
  55436. private _setupBackground;
  55437. /**
  55438. * Get the scene sizes according to the setup.
  55439. */
  55440. private _getSceneSize;
  55441. /**
  55442. * Setup the ground according to the specified options.
  55443. */
  55444. private _setupGround;
  55445. /**
  55446. * Setup the ground material according to the specified options.
  55447. */
  55448. private _setupGroundMaterial;
  55449. /**
  55450. * Setup the ground diffuse texture according to the specified options.
  55451. */
  55452. private _setupGroundDiffuseTexture;
  55453. /**
  55454. * Setup the ground mirror texture according to the specified options.
  55455. */
  55456. private _setupGroundMirrorTexture;
  55457. /**
  55458. * Setup the ground to receive the mirror texture.
  55459. */
  55460. private _setupMirrorInGroundMaterial;
  55461. /**
  55462. * Setup the skybox according to the specified options.
  55463. */
  55464. private _setupSkybox;
  55465. /**
  55466. * Setup the skybox material according to the specified options.
  55467. */
  55468. private _setupSkyboxMaterial;
  55469. /**
  55470. * Setup the skybox reflection texture according to the specified options.
  55471. */
  55472. private _setupSkyboxReflectionTexture;
  55473. private _errorHandler;
  55474. /**
  55475. * Dispose all the elements created by the Helper.
  55476. */
  55477. dispose(): void;
  55478. }
  55479. }
  55480. declare module "babylonjs/Helpers/photoDome" {
  55481. import { Observable } from "babylonjs/Misc/observable";
  55482. import { Nullable } from "babylonjs/types";
  55483. import { Scene } from "babylonjs/scene";
  55484. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55485. import { Mesh } from "babylonjs/Meshes/mesh";
  55486. import { Texture } from "babylonjs/Materials/Textures/texture";
  55487. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55488. import "babylonjs/Meshes/Builders/sphereBuilder";
  55489. /**
  55490. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55491. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55492. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55493. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55494. */
  55495. export class PhotoDome extends TransformNode {
  55496. /**
  55497. * Define the image as a Monoscopic panoramic 360 image.
  55498. */
  55499. static readonly MODE_MONOSCOPIC: number;
  55500. /**
  55501. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55502. */
  55503. static readonly MODE_TOPBOTTOM: number;
  55504. /**
  55505. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55506. */
  55507. static readonly MODE_SIDEBYSIDE: number;
  55508. private _useDirectMapping;
  55509. /**
  55510. * The texture being displayed on the sphere
  55511. */
  55512. protected _photoTexture: Texture;
  55513. /**
  55514. * Gets or sets the texture being displayed on the sphere
  55515. */
  55516. get photoTexture(): Texture;
  55517. set photoTexture(value: Texture);
  55518. /**
  55519. * Observable raised when an error occured while loading the 360 image
  55520. */
  55521. onLoadErrorObservable: Observable<string>;
  55522. /**
  55523. * The skybox material
  55524. */
  55525. protected _material: BackgroundMaterial;
  55526. /**
  55527. * The surface used for the skybox
  55528. */
  55529. protected _mesh: Mesh;
  55530. /**
  55531. * Gets the mesh used for the skybox.
  55532. */
  55533. get mesh(): Mesh;
  55534. /**
  55535. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55536. * Also see the options.resolution property.
  55537. */
  55538. get fovMultiplier(): number;
  55539. set fovMultiplier(value: number);
  55540. private _imageMode;
  55541. /**
  55542. * Gets or set the current video mode for the video. It can be:
  55543. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55544. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55545. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55546. */
  55547. get imageMode(): number;
  55548. set imageMode(value: number);
  55549. /**
  55550. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55551. * @param name Element's name, child elements will append suffixes for their own names.
  55552. * @param urlsOfPhoto defines the url of the photo to display
  55553. * @param options defines an object containing optional or exposed sub element properties
  55554. * @param onError defines a callback called when an error occured while loading the texture
  55555. */
  55556. constructor(name: string, urlOfPhoto: string, options: {
  55557. resolution?: number;
  55558. size?: number;
  55559. useDirectMapping?: boolean;
  55560. faceForward?: boolean;
  55561. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55562. private _onBeforeCameraRenderObserver;
  55563. private _changeImageMode;
  55564. /**
  55565. * Releases resources associated with this node.
  55566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55568. */
  55569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55570. }
  55571. }
  55572. declare module "babylonjs/Misc/rgbdTextureTools" {
  55573. import "babylonjs/Shaders/rgbdDecode.fragment";
  55574. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55575. import { Texture } from "babylonjs/Materials/Textures/texture";
  55576. /**
  55577. * Class used to host RGBD texture specific utilities
  55578. */
  55579. export class RGBDTextureTools {
  55580. /**
  55581. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55582. * @param texture the texture to expand.
  55583. */
  55584. static ExpandRGBDTexture(texture: Texture): void;
  55585. }
  55586. }
  55587. declare module "babylonjs/Misc/brdfTextureTools" {
  55588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55589. import { Scene } from "babylonjs/scene";
  55590. /**
  55591. * Class used to host texture specific utilities
  55592. */
  55593. export class BRDFTextureTools {
  55594. /**
  55595. * Prevents texture cache collision
  55596. */
  55597. private static _instanceNumber;
  55598. /**
  55599. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55600. * @param scene defines the hosting scene
  55601. * @returns the environment BRDF texture
  55602. */
  55603. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55604. private static _environmentBRDFBase64Texture;
  55605. }
  55606. }
  55607. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55608. import { Nullable } from "babylonjs/types";
  55609. import { Color3 } from "babylonjs/Maths/math.color";
  55610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55611. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55612. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55613. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55614. import { Engine } from "babylonjs/Engines/engine";
  55615. import { Scene } from "babylonjs/scene";
  55616. /**
  55617. * @hidden
  55618. */
  55619. export interface IMaterialClearCoatDefines {
  55620. CLEARCOAT: boolean;
  55621. CLEARCOAT_DEFAULTIOR: boolean;
  55622. CLEARCOAT_TEXTURE: boolean;
  55623. CLEARCOAT_TEXTUREDIRECTUV: number;
  55624. CLEARCOAT_BUMP: boolean;
  55625. CLEARCOAT_BUMPDIRECTUV: number;
  55626. CLEARCOAT_TINT: boolean;
  55627. CLEARCOAT_TINT_TEXTURE: boolean;
  55628. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55629. /** @hidden */
  55630. _areTexturesDirty: boolean;
  55631. }
  55632. /**
  55633. * Define the code related to the clear coat parameters of the pbr material.
  55634. */
  55635. export class PBRClearCoatConfiguration {
  55636. /**
  55637. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55638. * The default fits with a polyurethane material.
  55639. */
  55640. private static readonly _DefaultIndexOfRefraction;
  55641. private _isEnabled;
  55642. /**
  55643. * Defines if the clear coat is enabled in the material.
  55644. */
  55645. isEnabled: boolean;
  55646. /**
  55647. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55648. */
  55649. intensity: number;
  55650. /**
  55651. * Defines the clear coat layer roughness.
  55652. */
  55653. roughness: number;
  55654. private _indexOfRefraction;
  55655. /**
  55656. * Defines the index of refraction of the clear coat.
  55657. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55658. * The default fits with a polyurethane material.
  55659. * Changing the default value is more performance intensive.
  55660. */
  55661. indexOfRefraction: number;
  55662. private _texture;
  55663. /**
  55664. * Stores the clear coat values in a texture.
  55665. */
  55666. texture: Nullable<BaseTexture>;
  55667. private _bumpTexture;
  55668. /**
  55669. * Define the clear coat specific bump texture.
  55670. */
  55671. bumpTexture: Nullable<BaseTexture>;
  55672. private _isTintEnabled;
  55673. /**
  55674. * Defines if the clear coat tint is enabled in the material.
  55675. */
  55676. isTintEnabled: boolean;
  55677. /**
  55678. * Defines the clear coat tint of the material.
  55679. * This is only use if tint is enabled
  55680. */
  55681. tintColor: Color3;
  55682. /**
  55683. * Defines the distance at which the tint color should be found in the
  55684. * clear coat media.
  55685. * This is only use if tint is enabled
  55686. */
  55687. tintColorAtDistance: number;
  55688. /**
  55689. * Defines the clear coat layer thickness.
  55690. * This is only use if tint is enabled
  55691. */
  55692. tintThickness: number;
  55693. private _tintTexture;
  55694. /**
  55695. * Stores the clear tint values in a texture.
  55696. * rgb is tint
  55697. * a is a thickness factor
  55698. */
  55699. tintTexture: Nullable<BaseTexture>;
  55700. /** @hidden */
  55701. private _internalMarkAllSubMeshesAsTexturesDirty;
  55702. /** @hidden */
  55703. _markAllSubMeshesAsTexturesDirty(): void;
  55704. /**
  55705. * Instantiate a new istance of clear coat configuration.
  55706. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55707. */
  55708. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55709. /**
  55710. * Gets wehter the submesh is ready to be used or not.
  55711. * @param defines the list of "defines" to update.
  55712. * @param scene defines the scene the material belongs to.
  55713. * @param engine defines the engine the material belongs to.
  55714. * @param disableBumpMap defines wether the material disables bump or not.
  55715. * @returns - boolean indicating that the submesh is ready or not.
  55716. */
  55717. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55718. /**
  55719. * Checks to see if a texture is used in the material.
  55720. * @param defines the list of "defines" to update.
  55721. * @param scene defines the scene to the material belongs to.
  55722. */
  55723. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55724. /**
  55725. * Binds the material data.
  55726. * @param uniformBuffer defines the Uniform buffer to fill in.
  55727. * @param scene defines the scene the material belongs to.
  55728. * @param engine defines the engine the material belongs to.
  55729. * @param disableBumpMap defines wether the material disables bump or not.
  55730. * @param isFrozen defines wether the material is frozen or not.
  55731. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55732. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55733. */
  55734. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55735. /**
  55736. * Checks to see if a texture is used in the material.
  55737. * @param texture - Base texture to use.
  55738. * @returns - Boolean specifying if a texture is used in the material.
  55739. */
  55740. hasTexture(texture: BaseTexture): boolean;
  55741. /**
  55742. * Returns an array of the actively used textures.
  55743. * @param activeTextures Array of BaseTextures
  55744. */
  55745. getActiveTextures(activeTextures: BaseTexture[]): void;
  55746. /**
  55747. * Returns the animatable textures.
  55748. * @param animatables Array of animatable textures.
  55749. */
  55750. getAnimatables(animatables: IAnimatable[]): void;
  55751. /**
  55752. * Disposes the resources of the material.
  55753. * @param forceDisposeTextures - Forces the disposal of all textures.
  55754. */
  55755. dispose(forceDisposeTextures?: boolean): void;
  55756. /**
  55757. * Get the current class name of the texture useful for serialization or dynamic coding.
  55758. * @returns "PBRClearCoatConfiguration"
  55759. */
  55760. getClassName(): string;
  55761. /**
  55762. * Add fallbacks to the effect fallbacks list.
  55763. * @param defines defines the Base texture to use.
  55764. * @param fallbacks defines the current fallback list.
  55765. * @param currentRank defines the current fallback rank.
  55766. * @returns the new fallback rank.
  55767. */
  55768. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55769. /**
  55770. * Add the required uniforms to the current list.
  55771. * @param uniforms defines the current uniform list.
  55772. */
  55773. static AddUniforms(uniforms: string[]): void;
  55774. /**
  55775. * Add the required samplers to the current list.
  55776. * @param samplers defines the current sampler list.
  55777. */
  55778. static AddSamplers(samplers: string[]): void;
  55779. /**
  55780. * Add the required uniforms to the current buffer.
  55781. * @param uniformBuffer defines the current uniform buffer.
  55782. */
  55783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55784. /**
  55785. * Makes a duplicate of the current configuration into another one.
  55786. * @param clearCoatConfiguration define the config where to copy the info
  55787. */
  55788. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55789. /**
  55790. * Serializes this clear coat configuration.
  55791. * @returns - An object with the serialized config.
  55792. */
  55793. serialize(): any;
  55794. /**
  55795. * Parses a anisotropy Configuration from a serialized object.
  55796. * @param source - Serialized object.
  55797. * @param scene Defines the scene we are parsing for
  55798. * @param rootUrl Defines the rootUrl to load from
  55799. */
  55800. parse(source: any, scene: Scene, rootUrl: string): void;
  55801. }
  55802. }
  55803. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  55804. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55806. import { Vector2 } from "babylonjs/Maths/math.vector";
  55807. import { Scene } from "babylonjs/scene";
  55808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55809. import { Nullable } from "babylonjs/types";
  55810. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55811. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55812. /**
  55813. * @hidden
  55814. */
  55815. export interface IMaterialAnisotropicDefines {
  55816. ANISOTROPIC: boolean;
  55817. ANISOTROPIC_TEXTURE: boolean;
  55818. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55819. MAINUV1: boolean;
  55820. _areTexturesDirty: boolean;
  55821. _needUVs: boolean;
  55822. }
  55823. /**
  55824. * Define the code related to the anisotropic parameters of the pbr material.
  55825. */
  55826. export class PBRAnisotropicConfiguration {
  55827. private _isEnabled;
  55828. /**
  55829. * Defines if the anisotropy is enabled in the material.
  55830. */
  55831. isEnabled: boolean;
  55832. /**
  55833. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55834. */
  55835. intensity: number;
  55836. /**
  55837. * Defines if the effect is along the tangents, bitangents or in between.
  55838. * By default, the effect is "strectching" the highlights along the tangents.
  55839. */
  55840. direction: Vector2;
  55841. private _texture;
  55842. /**
  55843. * Stores the anisotropy values in a texture.
  55844. * rg is direction (like normal from -1 to 1)
  55845. * b is a intensity
  55846. */
  55847. texture: Nullable<BaseTexture>;
  55848. /** @hidden */
  55849. private _internalMarkAllSubMeshesAsTexturesDirty;
  55850. /** @hidden */
  55851. _markAllSubMeshesAsTexturesDirty(): void;
  55852. /**
  55853. * Instantiate a new istance of anisotropy configuration.
  55854. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55855. */
  55856. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55857. /**
  55858. * Specifies that the submesh is ready to be used.
  55859. * @param defines the list of "defines" to update.
  55860. * @param scene defines the scene the material belongs to.
  55861. * @returns - boolean indicating that the submesh is ready or not.
  55862. */
  55863. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55864. /**
  55865. * Checks to see if a texture is used in the material.
  55866. * @param defines the list of "defines" to update.
  55867. * @param mesh the mesh we are preparing the defines for.
  55868. * @param scene defines the scene the material belongs to.
  55869. */
  55870. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55871. /**
  55872. * Binds the material data.
  55873. * @param uniformBuffer defines the Uniform buffer to fill in.
  55874. * @param scene defines the scene the material belongs to.
  55875. * @param isFrozen defines wether the material is frozen or not.
  55876. */
  55877. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55878. /**
  55879. * Checks to see if a texture is used in the material.
  55880. * @param texture - Base texture to use.
  55881. * @returns - Boolean specifying if a texture is used in the material.
  55882. */
  55883. hasTexture(texture: BaseTexture): boolean;
  55884. /**
  55885. * Returns an array of the actively used textures.
  55886. * @param activeTextures Array of BaseTextures
  55887. */
  55888. getActiveTextures(activeTextures: BaseTexture[]): void;
  55889. /**
  55890. * Returns the animatable textures.
  55891. * @param animatables Array of animatable textures.
  55892. */
  55893. getAnimatables(animatables: IAnimatable[]): void;
  55894. /**
  55895. * Disposes the resources of the material.
  55896. * @param forceDisposeTextures - Forces the disposal of all textures.
  55897. */
  55898. dispose(forceDisposeTextures?: boolean): void;
  55899. /**
  55900. * Get the current class name of the texture useful for serialization or dynamic coding.
  55901. * @returns "PBRAnisotropicConfiguration"
  55902. */
  55903. getClassName(): string;
  55904. /**
  55905. * Add fallbacks to the effect fallbacks list.
  55906. * @param defines defines the Base texture to use.
  55907. * @param fallbacks defines the current fallback list.
  55908. * @param currentRank defines the current fallback rank.
  55909. * @returns the new fallback rank.
  55910. */
  55911. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55912. /**
  55913. * Add the required uniforms to the current list.
  55914. * @param uniforms defines the current uniform list.
  55915. */
  55916. static AddUniforms(uniforms: string[]): void;
  55917. /**
  55918. * Add the required uniforms to the current buffer.
  55919. * @param uniformBuffer defines the current uniform buffer.
  55920. */
  55921. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55922. /**
  55923. * Add the required samplers to the current list.
  55924. * @param samplers defines the current sampler list.
  55925. */
  55926. static AddSamplers(samplers: string[]): void;
  55927. /**
  55928. * Makes a duplicate of the current configuration into another one.
  55929. * @param anisotropicConfiguration define the config where to copy the info
  55930. */
  55931. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55932. /**
  55933. * Serializes this anisotropy configuration.
  55934. * @returns - An object with the serialized config.
  55935. */
  55936. serialize(): any;
  55937. /**
  55938. * Parses a anisotropy Configuration from a serialized object.
  55939. * @param source - Serialized object.
  55940. * @param scene Defines the scene we are parsing for
  55941. * @param rootUrl Defines the rootUrl to load from
  55942. */
  55943. parse(source: any, scene: Scene, rootUrl: string): void;
  55944. }
  55945. }
  55946. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  55947. import { Scene } from "babylonjs/scene";
  55948. /**
  55949. * @hidden
  55950. */
  55951. export interface IMaterialBRDFDefines {
  55952. BRDF_V_HEIGHT_CORRELATED: boolean;
  55953. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55954. SPHERICAL_HARMONICS: boolean;
  55955. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55956. /** @hidden */
  55957. _areMiscDirty: boolean;
  55958. }
  55959. /**
  55960. * Define the code related to the BRDF parameters of the pbr material.
  55961. */
  55962. export class PBRBRDFConfiguration {
  55963. /**
  55964. * Default value used for the energy conservation.
  55965. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55966. */
  55967. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55968. /**
  55969. * Default value used for the Smith Visibility Height Correlated mode.
  55970. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55971. */
  55972. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55973. /**
  55974. * Default value used for the IBL diffuse part.
  55975. * This can help switching back to the polynomials mode globally which is a tiny bit
  55976. * less GPU intensive at the drawback of a lower quality.
  55977. */
  55978. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55979. /**
  55980. * Default value used for activating energy conservation for the specular workflow.
  55981. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55982. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55983. */
  55984. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55985. private _useEnergyConservation;
  55986. /**
  55987. * Defines if the material uses energy conservation.
  55988. */
  55989. useEnergyConservation: boolean;
  55990. private _useSmithVisibilityHeightCorrelated;
  55991. /**
  55992. * LEGACY Mode set to false
  55993. * Defines if the material uses height smith correlated visibility term.
  55994. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55995. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55996. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55997. * Not relying on height correlated will also disable energy conservation.
  55998. */
  55999. useSmithVisibilityHeightCorrelated: boolean;
  56000. private _useSphericalHarmonics;
  56001. /**
  56002. * LEGACY Mode set to false
  56003. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56004. * diffuse part of the IBL.
  56005. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56006. * to the ground truth.
  56007. */
  56008. useSphericalHarmonics: boolean;
  56009. private _useSpecularGlossinessInputEnergyConservation;
  56010. /**
  56011. * Defines if the material uses energy conservation, when the specular workflow is active.
  56012. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56013. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56014. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56015. */
  56016. useSpecularGlossinessInputEnergyConservation: boolean;
  56017. /** @hidden */
  56018. private _internalMarkAllSubMeshesAsMiscDirty;
  56019. /** @hidden */
  56020. _markAllSubMeshesAsMiscDirty(): void;
  56021. /**
  56022. * Instantiate a new istance of clear coat configuration.
  56023. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56024. */
  56025. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56026. /**
  56027. * Checks to see if a texture is used in the material.
  56028. * @param defines the list of "defines" to update.
  56029. */
  56030. prepareDefines(defines: IMaterialBRDFDefines): void;
  56031. /**
  56032. * Get the current class name of the texture useful for serialization or dynamic coding.
  56033. * @returns "PBRClearCoatConfiguration"
  56034. */
  56035. getClassName(): string;
  56036. /**
  56037. * Makes a duplicate of the current configuration into another one.
  56038. * @param brdfConfiguration define the config where to copy the info
  56039. */
  56040. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56041. /**
  56042. * Serializes this BRDF configuration.
  56043. * @returns - An object with the serialized config.
  56044. */
  56045. serialize(): any;
  56046. /**
  56047. * Parses a anisotropy Configuration from a serialized object.
  56048. * @param source - Serialized object.
  56049. * @param scene Defines the scene we are parsing for
  56050. * @param rootUrl Defines the rootUrl to load from
  56051. */
  56052. parse(source: any, scene: Scene, rootUrl: string): void;
  56053. }
  56054. }
  56055. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56056. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56057. import { Color3 } from "babylonjs/Maths/math.color";
  56058. import { Scene } from "babylonjs/scene";
  56059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56060. import { Nullable } from "babylonjs/types";
  56061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56062. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56063. /**
  56064. * @hidden
  56065. */
  56066. export interface IMaterialSheenDefines {
  56067. SHEEN: boolean;
  56068. SHEEN_TEXTURE: boolean;
  56069. SHEEN_TEXTUREDIRECTUV: number;
  56070. SHEEN_LINKWITHALBEDO: boolean;
  56071. SHEEN_ROUGHNESS: boolean;
  56072. SHEEN_ALBEDOSCALING: boolean;
  56073. /** @hidden */
  56074. _areTexturesDirty: boolean;
  56075. }
  56076. /**
  56077. * Define the code related to the Sheen parameters of the pbr material.
  56078. */
  56079. export class PBRSheenConfiguration {
  56080. private _isEnabled;
  56081. /**
  56082. * Defines if the material uses sheen.
  56083. */
  56084. isEnabled: boolean;
  56085. private _linkSheenWithAlbedo;
  56086. /**
  56087. * Defines if the sheen is linked to the sheen color.
  56088. */
  56089. linkSheenWithAlbedo: boolean;
  56090. /**
  56091. * Defines the sheen intensity.
  56092. */
  56093. intensity: number;
  56094. /**
  56095. * Defines the sheen color.
  56096. */
  56097. color: Color3;
  56098. private _texture;
  56099. /**
  56100. * Stores the sheen tint values in a texture.
  56101. * rgb is tint
  56102. * a is a intensity
  56103. */
  56104. texture: Nullable<BaseTexture>;
  56105. private _roughness;
  56106. /**
  56107. * Defines the sheen roughness.
  56108. * It is not taken into account if linkSheenWithAlbedo is true.
  56109. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56110. */
  56111. roughness: Nullable<number>;
  56112. private _albedoScaling;
  56113. /**
  56114. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56115. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56116. * making it easier to setup and tweak the effect
  56117. */
  56118. albedoScaling: boolean;
  56119. /** @hidden */
  56120. private _internalMarkAllSubMeshesAsTexturesDirty;
  56121. /** @hidden */
  56122. _markAllSubMeshesAsTexturesDirty(): void;
  56123. /**
  56124. * Instantiate a new istance of clear coat configuration.
  56125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56126. */
  56127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56128. /**
  56129. * Specifies that the submesh is ready to be used.
  56130. * @param defines the list of "defines" to update.
  56131. * @param scene defines the scene the material belongs to.
  56132. * @returns - boolean indicating that the submesh is ready or not.
  56133. */
  56134. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56135. /**
  56136. * Checks to see if a texture is used in the material.
  56137. * @param defines the list of "defines" to update.
  56138. * @param scene defines the scene the material belongs to.
  56139. */
  56140. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56141. /**
  56142. * Binds the material data.
  56143. * @param uniformBuffer defines the Uniform buffer to fill in.
  56144. * @param scene defines the scene the material belongs to.
  56145. * @param isFrozen defines wether the material is frozen or not.
  56146. */
  56147. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56148. /**
  56149. * Checks to see if a texture is used in the material.
  56150. * @param texture - Base texture to use.
  56151. * @returns - Boolean specifying if a texture is used in the material.
  56152. */
  56153. hasTexture(texture: BaseTexture): boolean;
  56154. /**
  56155. * Returns an array of the actively used textures.
  56156. * @param activeTextures Array of BaseTextures
  56157. */
  56158. getActiveTextures(activeTextures: BaseTexture[]): void;
  56159. /**
  56160. * Returns the animatable textures.
  56161. * @param animatables Array of animatable textures.
  56162. */
  56163. getAnimatables(animatables: IAnimatable[]): void;
  56164. /**
  56165. * Disposes the resources of the material.
  56166. * @param forceDisposeTextures - Forces the disposal of all textures.
  56167. */
  56168. dispose(forceDisposeTextures?: boolean): void;
  56169. /**
  56170. * Get the current class name of the texture useful for serialization or dynamic coding.
  56171. * @returns "PBRSheenConfiguration"
  56172. */
  56173. getClassName(): string;
  56174. /**
  56175. * Add fallbacks to the effect fallbacks list.
  56176. * @param defines defines the Base texture to use.
  56177. * @param fallbacks defines the current fallback list.
  56178. * @param currentRank defines the current fallback rank.
  56179. * @returns the new fallback rank.
  56180. */
  56181. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56182. /**
  56183. * Add the required uniforms to the current list.
  56184. * @param uniforms defines the current uniform list.
  56185. */
  56186. static AddUniforms(uniforms: string[]): void;
  56187. /**
  56188. * Add the required uniforms to the current buffer.
  56189. * @param uniformBuffer defines the current uniform buffer.
  56190. */
  56191. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56192. /**
  56193. * Add the required samplers to the current list.
  56194. * @param samplers defines the current sampler list.
  56195. */
  56196. static AddSamplers(samplers: string[]): void;
  56197. /**
  56198. * Makes a duplicate of the current configuration into another one.
  56199. * @param sheenConfiguration define the config where to copy the info
  56200. */
  56201. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56202. /**
  56203. * Serializes this BRDF configuration.
  56204. * @returns - An object with the serialized config.
  56205. */
  56206. serialize(): any;
  56207. /**
  56208. * Parses a anisotropy Configuration from a serialized object.
  56209. * @param source - Serialized object.
  56210. * @param scene Defines the scene we are parsing for
  56211. * @param rootUrl Defines the rootUrl to load from
  56212. */
  56213. parse(source: any, scene: Scene, rootUrl: string): void;
  56214. }
  56215. }
  56216. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56217. import { Nullable } from "babylonjs/types";
  56218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56219. import { Color3 } from "babylonjs/Maths/math.color";
  56220. import { SmartArray } from "babylonjs/Misc/smartArray";
  56221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56223. import { Effect } from "babylonjs/Materials/effect";
  56224. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56225. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56226. import { Engine } from "babylonjs/Engines/engine";
  56227. import { Scene } from "babylonjs/scene";
  56228. /**
  56229. * @hidden
  56230. */
  56231. export interface IMaterialSubSurfaceDefines {
  56232. SUBSURFACE: boolean;
  56233. SS_REFRACTION: boolean;
  56234. SS_TRANSLUCENCY: boolean;
  56235. SS_SCATERRING: boolean;
  56236. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56237. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56238. SS_REFRACTIONMAP_3D: boolean;
  56239. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56240. SS_LODINREFRACTIONALPHA: boolean;
  56241. SS_GAMMAREFRACTION: boolean;
  56242. SS_RGBDREFRACTION: boolean;
  56243. SS_LINEARSPECULARREFRACTION: boolean;
  56244. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56245. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56246. /** @hidden */
  56247. _areTexturesDirty: boolean;
  56248. }
  56249. /**
  56250. * Define the code related to the sub surface parameters of the pbr material.
  56251. */
  56252. export class PBRSubSurfaceConfiguration {
  56253. private _isRefractionEnabled;
  56254. /**
  56255. * Defines if the refraction is enabled in the material.
  56256. */
  56257. isRefractionEnabled: boolean;
  56258. private _isTranslucencyEnabled;
  56259. /**
  56260. * Defines if the translucency is enabled in the material.
  56261. */
  56262. isTranslucencyEnabled: boolean;
  56263. private _isScatteringEnabled;
  56264. /**
  56265. * Defines the refraction intensity of the material.
  56266. * The refraction when enabled replaces the Diffuse part of the material.
  56267. * The intensity helps transitionning between diffuse and refraction.
  56268. */
  56269. refractionIntensity: number;
  56270. /**
  56271. * Defines the translucency intensity of the material.
  56272. * When translucency has been enabled, this defines how much of the "translucency"
  56273. * is addded to the diffuse part of the material.
  56274. */
  56275. translucencyIntensity: number;
  56276. /**
  56277. * Defines the scattering intensity of the material.
  56278. * When scattering has been enabled, this defines how much of the "scattered light"
  56279. * is addded to the diffuse part of the material.
  56280. */
  56281. scatteringIntensity: number;
  56282. private _thicknessTexture;
  56283. /**
  56284. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56285. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56286. * 0 would mean minimumThickness
  56287. * 1 would mean maximumThickness
  56288. * The other channels might be use as a mask to vary the different effects intensity.
  56289. */
  56290. thicknessTexture: Nullable<BaseTexture>;
  56291. private _refractionTexture;
  56292. /**
  56293. * Defines the texture to use for refraction.
  56294. */
  56295. refractionTexture: Nullable<BaseTexture>;
  56296. private _indexOfRefraction;
  56297. /**
  56298. * Index of refraction of the material base layer.
  56299. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56300. *
  56301. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56302. *
  56303. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56304. */
  56305. indexOfRefraction: number;
  56306. private _invertRefractionY;
  56307. /**
  56308. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56309. */
  56310. invertRefractionY: boolean;
  56311. private _linkRefractionWithTransparency;
  56312. /**
  56313. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56314. * Materials half opaque for instance using refraction could benefit from this control.
  56315. */
  56316. linkRefractionWithTransparency: boolean;
  56317. /**
  56318. * Defines the minimum thickness stored in the thickness map.
  56319. * If no thickness map is defined, this value will be used to simulate thickness.
  56320. */
  56321. minimumThickness: number;
  56322. /**
  56323. * Defines the maximum thickness stored in the thickness map.
  56324. */
  56325. maximumThickness: number;
  56326. /**
  56327. * Defines the volume tint of the material.
  56328. * This is used for both translucency and scattering.
  56329. */
  56330. tintColor: Color3;
  56331. /**
  56332. * Defines the distance at which the tint color should be found in the media.
  56333. * This is used for refraction only.
  56334. */
  56335. tintColorAtDistance: number;
  56336. /**
  56337. * Defines how far each channel transmit through the media.
  56338. * It is defined as a color to simplify it selection.
  56339. */
  56340. diffusionDistance: Color3;
  56341. private _useMaskFromThicknessTexture;
  56342. /**
  56343. * Stores the intensity of the different subsurface effects in the thickness texture.
  56344. * * the green channel is the translucency intensity.
  56345. * * the blue channel is the scattering intensity.
  56346. * * the alpha channel is the refraction intensity.
  56347. */
  56348. useMaskFromThicknessTexture: boolean;
  56349. /** @hidden */
  56350. private _internalMarkAllSubMeshesAsTexturesDirty;
  56351. /** @hidden */
  56352. _markAllSubMeshesAsTexturesDirty(): void;
  56353. /**
  56354. * Instantiate a new istance of sub surface configuration.
  56355. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56356. */
  56357. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56358. /**
  56359. * Gets wehter the submesh is ready to be used or not.
  56360. * @param defines the list of "defines" to update.
  56361. * @param scene defines the scene the material belongs to.
  56362. * @returns - boolean indicating that the submesh is ready or not.
  56363. */
  56364. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56365. /**
  56366. * Checks to see if a texture is used in the material.
  56367. * @param defines the list of "defines" to update.
  56368. * @param scene defines the scene to the material belongs to.
  56369. */
  56370. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56371. /**
  56372. * Binds the material data.
  56373. * @param uniformBuffer defines the Uniform buffer to fill in.
  56374. * @param scene defines the scene the material belongs to.
  56375. * @param engine defines the engine the material belongs to.
  56376. * @param isFrozen defines wether the material is frozen or not.
  56377. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  56378. */
  56379. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  56380. /**
  56381. * Unbinds the material from the mesh.
  56382. * @param activeEffect defines the effect that should be unbound from.
  56383. * @returns true if unbound, otherwise false
  56384. */
  56385. unbind(activeEffect: Effect): boolean;
  56386. /**
  56387. * Returns the texture used for refraction or null if none is used.
  56388. * @param scene defines the scene the material belongs to.
  56389. * @returns - Refraction texture if present. If no refraction texture and refraction
  56390. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56391. */
  56392. private _getRefractionTexture;
  56393. /**
  56394. * Returns true if alpha blending should be disabled.
  56395. */
  56396. get disableAlphaBlending(): boolean;
  56397. /**
  56398. * Fills the list of render target textures.
  56399. * @param renderTargets the list of render targets to update
  56400. */
  56401. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56402. /**
  56403. * Checks to see if a texture is used in the material.
  56404. * @param texture - Base texture to use.
  56405. * @returns - Boolean specifying if a texture is used in the material.
  56406. */
  56407. hasTexture(texture: BaseTexture): boolean;
  56408. /**
  56409. * Gets a boolean indicating that current material needs to register RTT
  56410. * @returns true if this uses a render target otherwise false.
  56411. */
  56412. hasRenderTargetTextures(): boolean;
  56413. /**
  56414. * Returns an array of the actively used textures.
  56415. * @param activeTextures Array of BaseTextures
  56416. */
  56417. getActiveTextures(activeTextures: BaseTexture[]): void;
  56418. /**
  56419. * Returns the animatable textures.
  56420. * @param animatables Array of animatable textures.
  56421. */
  56422. getAnimatables(animatables: IAnimatable[]): void;
  56423. /**
  56424. * Disposes the resources of the material.
  56425. * @param forceDisposeTextures - Forces the disposal of all textures.
  56426. */
  56427. dispose(forceDisposeTextures?: boolean): void;
  56428. /**
  56429. * Get the current class name of the texture useful for serialization or dynamic coding.
  56430. * @returns "PBRSubSurfaceConfiguration"
  56431. */
  56432. getClassName(): string;
  56433. /**
  56434. * Add fallbacks to the effect fallbacks list.
  56435. * @param defines defines the Base texture to use.
  56436. * @param fallbacks defines the current fallback list.
  56437. * @param currentRank defines the current fallback rank.
  56438. * @returns the new fallback rank.
  56439. */
  56440. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56441. /**
  56442. * Add the required uniforms to the current list.
  56443. * @param uniforms defines the current uniform list.
  56444. */
  56445. static AddUniforms(uniforms: string[]): void;
  56446. /**
  56447. * Add the required samplers to the current list.
  56448. * @param samplers defines the current sampler list.
  56449. */
  56450. static AddSamplers(samplers: string[]): void;
  56451. /**
  56452. * Add the required uniforms to the current buffer.
  56453. * @param uniformBuffer defines the current uniform buffer.
  56454. */
  56455. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56456. /**
  56457. * Makes a duplicate of the current configuration into another one.
  56458. * @param configuration define the config where to copy the info
  56459. */
  56460. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56461. /**
  56462. * Serializes this Sub Surface configuration.
  56463. * @returns - An object with the serialized config.
  56464. */
  56465. serialize(): any;
  56466. /**
  56467. * Parses a anisotropy Configuration from a serialized object.
  56468. * @param source - Serialized object.
  56469. * @param scene Defines the scene we are parsing for
  56470. * @param rootUrl Defines the rootUrl to load from
  56471. */
  56472. parse(source: any, scene: Scene, rootUrl: string): void;
  56473. }
  56474. }
  56475. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56476. /** @hidden */
  56477. export var pbrFragmentDeclaration: {
  56478. name: string;
  56479. shader: string;
  56480. };
  56481. }
  56482. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56483. /** @hidden */
  56484. export var pbrUboDeclaration: {
  56485. name: string;
  56486. shader: string;
  56487. };
  56488. }
  56489. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56490. /** @hidden */
  56491. export var pbrFragmentExtraDeclaration: {
  56492. name: string;
  56493. shader: string;
  56494. };
  56495. }
  56496. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56497. /** @hidden */
  56498. export var pbrFragmentSamplersDeclaration: {
  56499. name: string;
  56500. shader: string;
  56501. };
  56502. }
  56503. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56504. /** @hidden */
  56505. export var importanceSampling: {
  56506. name: string;
  56507. shader: string;
  56508. };
  56509. }
  56510. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56511. /** @hidden */
  56512. export var pbrHelperFunctions: {
  56513. name: string;
  56514. shader: string;
  56515. };
  56516. }
  56517. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56518. /** @hidden */
  56519. export var harmonicsFunctions: {
  56520. name: string;
  56521. shader: string;
  56522. };
  56523. }
  56524. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56525. /** @hidden */
  56526. export var pbrDirectLightingSetupFunctions: {
  56527. name: string;
  56528. shader: string;
  56529. };
  56530. }
  56531. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56532. /** @hidden */
  56533. export var pbrDirectLightingFalloffFunctions: {
  56534. name: string;
  56535. shader: string;
  56536. };
  56537. }
  56538. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56539. /** @hidden */
  56540. export var pbrBRDFFunctions: {
  56541. name: string;
  56542. shader: string;
  56543. };
  56544. }
  56545. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56546. /** @hidden */
  56547. export var hdrFilteringFunctions: {
  56548. name: string;
  56549. shader: string;
  56550. };
  56551. }
  56552. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56553. /** @hidden */
  56554. export var pbrDirectLightingFunctions: {
  56555. name: string;
  56556. shader: string;
  56557. };
  56558. }
  56559. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56560. /** @hidden */
  56561. export var pbrIBLFunctions: {
  56562. name: string;
  56563. shader: string;
  56564. };
  56565. }
  56566. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56567. /** @hidden */
  56568. export var pbrBlockAlbedoOpacity: {
  56569. name: string;
  56570. shader: string;
  56571. };
  56572. }
  56573. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56574. /** @hidden */
  56575. export var pbrBlockReflectivity: {
  56576. name: string;
  56577. shader: string;
  56578. };
  56579. }
  56580. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56581. /** @hidden */
  56582. export var pbrBlockAmbientOcclusion: {
  56583. name: string;
  56584. shader: string;
  56585. };
  56586. }
  56587. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56588. /** @hidden */
  56589. export var pbrBlockAlphaFresnel: {
  56590. name: string;
  56591. shader: string;
  56592. };
  56593. }
  56594. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56595. /** @hidden */
  56596. export var pbrBlockAnisotropic: {
  56597. name: string;
  56598. shader: string;
  56599. };
  56600. }
  56601. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56602. /** @hidden */
  56603. export var pbrBlockReflection: {
  56604. name: string;
  56605. shader: string;
  56606. };
  56607. }
  56608. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  56609. /** @hidden */
  56610. export var pbrBlockSheen: {
  56611. name: string;
  56612. shader: string;
  56613. };
  56614. }
  56615. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  56616. /** @hidden */
  56617. export var pbrBlockClearcoat: {
  56618. name: string;
  56619. shader: string;
  56620. };
  56621. }
  56622. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  56623. /** @hidden */
  56624. export var pbrBlockSubSurface: {
  56625. name: string;
  56626. shader: string;
  56627. };
  56628. }
  56629. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  56630. /** @hidden */
  56631. export var pbrBlockNormalGeometric: {
  56632. name: string;
  56633. shader: string;
  56634. };
  56635. }
  56636. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  56637. /** @hidden */
  56638. export var pbrBlockNormalFinal: {
  56639. name: string;
  56640. shader: string;
  56641. };
  56642. }
  56643. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  56644. /** @hidden */
  56645. export var pbrBlockGeometryInfo: {
  56646. name: string;
  56647. shader: string;
  56648. };
  56649. }
  56650. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  56651. /** @hidden */
  56652. export var pbrBlockReflectance0: {
  56653. name: string;
  56654. shader: string;
  56655. };
  56656. }
  56657. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  56658. /** @hidden */
  56659. export var pbrBlockReflectance: {
  56660. name: string;
  56661. shader: string;
  56662. };
  56663. }
  56664. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  56665. /** @hidden */
  56666. export var pbrBlockDirectLighting: {
  56667. name: string;
  56668. shader: string;
  56669. };
  56670. }
  56671. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  56672. /** @hidden */
  56673. export var pbrBlockFinalLitComponents: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  56679. /** @hidden */
  56680. export var pbrBlockFinalUnlitComponents: {
  56681. name: string;
  56682. shader: string;
  56683. };
  56684. }
  56685. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  56686. /** @hidden */
  56687. export var pbrBlockFinalColorComposition: {
  56688. name: string;
  56689. shader: string;
  56690. };
  56691. }
  56692. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  56693. /** @hidden */
  56694. export var pbrBlockImageProcessing: {
  56695. name: string;
  56696. shader: string;
  56697. };
  56698. }
  56699. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  56700. /** @hidden */
  56701. export var pbrDebug: {
  56702. name: string;
  56703. shader: string;
  56704. };
  56705. }
  56706. declare module "babylonjs/Shaders/pbr.fragment" {
  56707. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  56708. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56709. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  56710. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56711. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56712. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  56713. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56714. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56715. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56716. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56717. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56718. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  56719. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  56720. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56721. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56722. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56723. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  56724. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  56725. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  56726. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  56727. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  56728. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  56729. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  56730. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56731. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56732. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  56733. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  56734. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  56735. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  56736. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  56737. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  56738. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  56739. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  56740. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  56741. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56742. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  56743. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56744. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  56745. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  56746. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  56747. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  56748. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  56749. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  56750. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56751. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  56752. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  56753. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  56754. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56755. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56756. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  56757. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  56758. /** @hidden */
  56759. export var pbrPixelShader: {
  56760. name: string;
  56761. shader: string;
  56762. };
  56763. }
  56764. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  56765. /** @hidden */
  56766. export var pbrVertexDeclaration: {
  56767. name: string;
  56768. shader: string;
  56769. };
  56770. }
  56771. declare module "babylonjs/Shaders/pbr.vertex" {
  56772. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  56773. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56775. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56776. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56777. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56778. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  56779. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56780. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56781. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56782. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56784. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56785. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56787. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56788. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56789. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  56790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56791. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56792. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56793. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56794. /** @hidden */
  56795. export var pbrVertexShader: {
  56796. name: string;
  56797. shader: string;
  56798. };
  56799. }
  56800. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  56801. import { Nullable } from "babylonjs/types";
  56802. import { Scene } from "babylonjs/scene";
  56803. import { Matrix } from "babylonjs/Maths/math.vector";
  56804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56806. import { Mesh } from "babylonjs/Meshes/mesh";
  56807. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  56808. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  56809. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  56810. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  56811. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  56812. import { Color3 } from "babylonjs/Maths/math.color";
  56813. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56814. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  56815. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56816. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56818. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56819. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56820. import "babylonjs/Shaders/pbr.fragment";
  56821. import "babylonjs/Shaders/pbr.vertex";
  56822. /**
  56823. * Manages the defines for the PBR Material.
  56824. * @hidden
  56825. */
  56826. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  56827. PBR: boolean;
  56828. NUM_SAMPLES: string;
  56829. REALTIME_FILTERING: boolean;
  56830. MAINUV1: boolean;
  56831. MAINUV2: boolean;
  56832. UV1: boolean;
  56833. UV2: boolean;
  56834. ALBEDO: boolean;
  56835. GAMMAALBEDO: boolean;
  56836. ALBEDODIRECTUV: number;
  56837. VERTEXCOLOR: boolean;
  56838. AMBIENT: boolean;
  56839. AMBIENTDIRECTUV: number;
  56840. AMBIENTINGRAYSCALE: boolean;
  56841. OPACITY: boolean;
  56842. VERTEXALPHA: boolean;
  56843. OPACITYDIRECTUV: number;
  56844. OPACITYRGB: boolean;
  56845. ALPHATEST: boolean;
  56846. DEPTHPREPASS: boolean;
  56847. ALPHABLEND: boolean;
  56848. ALPHAFROMALBEDO: boolean;
  56849. ALPHATESTVALUE: string;
  56850. SPECULAROVERALPHA: boolean;
  56851. RADIANCEOVERALPHA: boolean;
  56852. ALPHAFRESNEL: boolean;
  56853. LINEARALPHAFRESNEL: boolean;
  56854. PREMULTIPLYALPHA: boolean;
  56855. EMISSIVE: boolean;
  56856. EMISSIVEDIRECTUV: number;
  56857. REFLECTIVITY: boolean;
  56858. REFLECTIVITYDIRECTUV: number;
  56859. SPECULARTERM: boolean;
  56860. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56861. MICROSURFACEAUTOMATIC: boolean;
  56862. LODBASEDMICROSFURACE: boolean;
  56863. MICROSURFACEMAP: boolean;
  56864. MICROSURFACEMAPDIRECTUV: number;
  56865. METALLICWORKFLOW: boolean;
  56866. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56867. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56868. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56869. AOSTOREINMETALMAPRED: boolean;
  56870. METALLIC_REFLECTANCE: boolean;
  56871. METALLIC_REFLECTANCEDIRECTUV: number;
  56872. ENVIRONMENTBRDF: boolean;
  56873. ENVIRONMENTBRDF_RGBD: boolean;
  56874. NORMAL: boolean;
  56875. TANGENT: boolean;
  56876. BUMP: boolean;
  56877. BUMPDIRECTUV: number;
  56878. OBJECTSPACE_NORMALMAP: boolean;
  56879. PARALLAX: boolean;
  56880. PARALLAXOCCLUSION: boolean;
  56881. NORMALXYSCALE: boolean;
  56882. LIGHTMAP: boolean;
  56883. LIGHTMAPDIRECTUV: number;
  56884. USELIGHTMAPASSHADOWMAP: boolean;
  56885. GAMMALIGHTMAP: boolean;
  56886. RGBDLIGHTMAP: boolean;
  56887. REFLECTION: boolean;
  56888. REFLECTIONMAP_3D: boolean;
  56889. REFLECTIONMAP_SPHERICAL: boolean;
  56890. REFLECTIONMAP_PLANAR: boolean;
  56891. REFLECTIONMAP_CUBIC: boolean;
  56892. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56893. REFLECTIONMAP_PROJECTION: boolean;
  56894. REFLECTIONMAP_SKYBOX: boolean;
  56895. REFLECTIONMAP_EXPLICIT: boolean;
  56896. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56897. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56898. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56899. INVERTCUBICMAP: boolean;
  56900. USESPHERICALFROMREFLECTIONMAP: boolean;
  56901. USEIRRADIANCEMAP: boolean;
  56902. SPHERICAL_HARMONICS: boolean;
  56903. USESPHERICALINVERTEX: boolean;
  56904. REFLECTIONMAP_OPPOSITEZ: boolean;
  56905. LODINREFLECTIONALPHA: boolean;
  56906. GAMMAREFLECTION: boolean;
  56907. RGBDREFLECTION: boolean;
  56908. LINEARSPECULARREFLECTION: boolean;
  56909. RADIANCEOCCLUSION: boolean;
  56910. HORIZONOCCLUSION: boolean;
  56911. INSTANCES: boolean;
  56912. NUM_BONE_INFLUENCERS: number;
  56913. BonesPerMesh: number;
  56914. BONETEXTURE: boolean;
  56915. NONUNIFORMSCALING: boolean;
  56916. MORPHTARGETS: boolean;
  56917. MORPHTARGETS_NORMAL: boolean;
  56918. MORPHTARGETS_TANGENT: boolean;
  56919. MORPHTARGETS_UV: boolean;
  56920. NUM_MORPH_INFLUENCERS: number;
  56921. IMAGEPROCESSING: boolean;
  56922. VIGNETTE: boolean;
  56923. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56924. VIGNETTEBLENDMODEOPAQUE: boolean;
  56925. TONEMAPPING: boolean;
  56926. TONEMAPPING_ACES: boolean;
  56927. CONTRAST: boolean;
  56928. COLORCURVES: boolean;
  56929. COLORGRADING: boolean;
  56930. COLORGRADING3D: boolean;
  56931. SAMPLER3DGREENDEPTH: boolean;
  56932. SAMPLER3DBGRMAP: boolean;
  56933. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56934. EXPOSURE: boolean;
  56935. MULTIVIEW: boolean;
  56936. USEPHYSICALLIGHTFALLOFF: boolean;
  56937. USEGLTFLIGHTFALLOFF: boolean;
  56938. TWOSIDEDLIGHTING: boolean;
  56939. SHADOWFLOAT: boolean;
  56940. CLIPPLANE: boolean;
  56941. CLIPPLANE2: boolean;
  56942. CLIPPLANE3: boolean;
  56943. CLIPPLANE4: boolean;
  56944. CLIPPLANE5: boolean;
  56945. CLIPPLANE6: boolean;
  56946. POINTSIZE: boolean;
  56947. FOG: boolean;
  56948. LOGARITHMICDEPTH: boolean;
  56949. FORCENORMALFORWARD: boolean;
  56950. SPECULARAA: boolean;
  56951. CLEARCOAT: boolean;
  56952. CLEARCOAT_DEFAULTIOR: boolean;
  56953. CLEARCOAT_TEXTURE: boolean;
  56954. CLEARCOAT_TEXTUREDIRECTUV: number;
  56955. CLEARCOAT_BUMP: boolean;
  56956. CLEARCOAT_BUMPDIRECTUV: number;
  56957. CLEARCOAT_TINT: boolean;
  56958. CLEARCOAT_TINT_TEXTURE: boolean;
  56959. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56960. ANISOTROPIC: boolean;
  56961. ANISOTROPIC_TEXTURE: boolean;
  56962. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56963. BRDF_V_HEIGHT_CORRELATED: boolean;
  56964. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56965. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56966. SHEEN: boolean;
  56967. SHEEN_TEXTURE: boolean;
  56968. SHEEN_TEXTUREDIRECTUV: number;
  56969. SHEEN_LINKWITHALBEDO: boolean;
  56970. SHEEN_ROUGHNESS: boolean;
  56971. SHEEN_ALBEDOSCALING: boolean;
  56972. SUBSURFACE: boolean;
  56973. SS_REFRACTION: boolean;
  56974. SS_TRANSLUCENCY: boolean;
  56975. SS_SCATERRING: boolean;
  56976. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56977. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56978. SS_REFRACTIONMAP_3D: boolean;
  56979. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56980. SS_LODINREFRACTIONALPHA: boolean;
  56981. SS_GAMMAREFRACTION: boolean;
  56982. SS_RGBDREFRACTION: boolean;
  56983. SS_LINEARSPECULARREFRACTION: boolean;
  56984. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56985. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56986. UNLIT: boolean;
  56987. DEBUGMODE: number;
  56988. /**
  56989. * Initializes the PBR Material defines.
  56990. */
  56991. constructor();
  56992. /**
  56993. * Resets the PBR Material defines.
  56994. */
  56995. reset(): void;
  56996. }
  56997. /**
  56998. * The Physically based material base class of BJS.
  56999. *
  57000. * This offers the main features of a standard PBR material.
  57001. * For more information, please refer to the documentation :
  57002. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57003. */
  57004. export abstract class PBRBaseMaterial extends PushMaterial {
  57005. /**
  57006. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57007. */
  57008. static readonly PBRMATERIAL_OPAQUE: number;
  57009. /**
  57010. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57011. */
  57012. static readonly PBRMATERIAL_ALPHATEST: number;
  57013. /**
  57014. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57015. */
  57016. static readonly PBRMATERIAL_ALPHABLEND: number;
  57017. /**
  57018. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57019. * They are also discarded below the alpha cutoff threshold to improve performances.
  57020. */
  57021. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57022. /**
  57023. * Defines the default value of how much AO map is occluding the analytical lights
  57024. * (point spot...).
  57025. */
  57026. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57027. /**
  57028. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57029. */
  57030. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57031. /**
  57032. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57033. * to enhance interoperability with other engines.
  57034. */
  57035. static readonly LIGHTFALLOFF_GLTF: number;
  57036. /**
  57037. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57038. * to enhance interoperability with other materials.
  57039. */
  57040. static readonly LIGHTFALLOFF_STANDARD: number;
  57041. /**
  57042. * Intensity of the direct lights e.g. the four lights available in your scene.
  57043. * This impacts both the direct diffuse and specular highlights.
  57044. */
  57045. protected _directIntensity: number;
  57046. /**
  57047. * Intensity of the emissive part of the material.
  57048. * This helps controlling the emissive effect without modifying the emissive color.
  57049. */
  57050. protected _emissiveIntensity: number;
  57051. /**
  57052. * Intensity of the environment e.g. how much the environment will light the object
  57053. * either through harmonics for rough material or through the refelction for shiny ones.
  57054. */
  57055. protected _environmentIntensity: number;
  57056. /**
  57057. * This is a special control allowing the reduction of the specular highlights coming from the
  57058. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57059. */
  57060. protected _specularIntensity: number;
  57061. /**
  57062. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57063. */
  57064. private _lightingInfos;
  57065. /**
  57066. * Debug Control allowing disabling the bump map on this material.
  57067. */
  57068. protected _disableBumpMap: boolean;
  57069. /**
  57070. * AKA Diffuse Texture in standard nomenclature.
  57071. */
  57072. protected _albedoTexture: Nullable<BaseTexture>;
  57073. /**
  57074. * AKA Occlusion Texture in other nomenclature.
  57075. */
  57076. protected _ambientTexture: Nullable<BaseTexture>;
  57077. /**
  57078. * AKA Occlusion Texture Intensity in other nomenclature.
  57079. */
  57080. protected _ambientTextureStrength: number;
  57081. /**
  57082. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57083. * 1 means it completely occludes it
  57084. * 0 mean it has no impact
  57085. */
  57086. protected _ambientTextureImpactOnAnalyticalLights: number;
  57087. /**
  57088. * Stores the alpha values in a texture.
  57089. */
  57090. protected _opacityTexture: Nullable<BaseTexture>;
  57091. /**
  57092. * Stores the reflection values in a texture.
  57093. */
  57094. protected _reflectionTexture: Nullable<BaseTexture>;
  57095. /**
  57096. * Stores the emissive values in a texture.
  57097. */
  57098. protected _emissiveTexture: Nullable<BaseTexture>;
  57099. /**
  57100. * AKA Specular texture in other nomenclature.
  57101. */
  57102. protected _reflectivityTexture: Nullable<BaseTexture>;
  57103. /**
  57104. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57105. */
  57106. protected _metallicTexture: Nullable<BaseTexture>;
  57107. /**
  57108. * Specifies the metallic scalar of the metallic/roughness workflow.
  57109. * Can also be used to scale the metalness values of the metallic texture.
  57110. */
  57111. protected _metallic: Nullable<number>;
  57112. /**
  57113. * Specifies the roughness scalar of the metallic/roughness workflow.
  57114. * Can also be used to scale the roughness values of the metallic texture.
  57115. */
  57116. protected _roughness: Nullable<number>;
  57117. /**
  57118. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57119. * By default the indexOfrefraction is used to compute F0;
  57120. *
  57121. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57122. *
  57123. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57124. * F90 = metallicReflectanceColor;
  57125. */
  57126. protected _metallicF0Factor: number;
  57127. /**
  57128. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57129. * By default the F90 is always 1;
  57130. *
  57131. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57132. *
  57133. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57134. * F90 = metallicReflectanceColor;
  57135. */
  57136. protected _metallicReflectanceColor: Color3;
  57137. /**
  57138. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57139. * This is multiply against the scalar values defined in the material.
  57140. */
  57141. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57142. /**
  57143. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57144. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57145. */
  57146. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57147. /**
  57148. * Stores surface normal data used to displace a mesh in a texture.
  57149. */
  57150. protected _bumpTexture: Nullable<BaseTexture>;
  57151. /**
  57152. * Stores the pre-calculated light information of a mesh in a texture.
  57153. */
  57154. protected _lightmapTexture: Nullable<BaseTexture>;
  57155. /**
  57156. * The color of a material in ambient lighting.
  57157. */
  57158. protected _ambientColor: Color3;
  57159. /**
  57160. * AKA Diffuse Color in other nomenclature.
  57161. */
  57162. protected _albedoColor: Color3;
  57163. /**
  57164. * AKA Specular Color in other nomenclature.
  57165. */
  57166. protected _reflectivityColor: Color3;
  57167. /**
  57168. * The color applied when light is reflected from a material.
  57169. */
  57170. protected _reflectionColor: Color3;
  57171. /**
  57172. * The color applied when light is emitted from a material.
  57173. */
  57174. protected _emissiveColor: Color3;
  57175. /**
  57176. * AKA Glossiness in other nomenclature.
  57177. */
  57178. protected _microSurface: number;
  57179. /**
  57180. * Specifies that the material will use the light map as a show map.
  57181. */
  57182. protected _useLightmapAsShadowmap: boolean;
  57183. /**
  57184. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57185. * makes the reflect vector face the model (under horizon).
  57186. */
  57187. protected _useHorizonOcclusion: boolean;
  57188. /**
  57189. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57190. * too much the area relying on ambient texture to define their ambient occlusion.
  57191. */
  57192. protected _useRadianceOcclusion: boolean;
  57193. /**
  57194. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57195. */
  57196. protected _useAlphaFromAlbedoTexture: boolean;
  57197. /**
  57198. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57199. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57200. */
  57201. protected _useSpecularOverAlpha: boolean;
  57202. /**
  57203. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57204. */
  57205. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57206. /**
  57207. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57208. */
  57209. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57210. /**
  57211. * Specifies if the metallic texture contains the roughness information in its green channel.
  57212. */
  57213. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57214. /**
  57215. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57216. */
  57217. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57218. /**
  57219. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57220. */
  57221. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57222. /**
  57223. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57224. */
  57225. protected _useAmbientInGrayScale: boolean;
  57226. /**
  57227. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57228. * The material will try to infer what glossiness each pixel should be.
  57229. */
  57230. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57231. /**
  57232. * Defines the falloff type used in this material.
  57233. * It by default is Physical.
  57234. */
  57235. protected _lightFalloff: number;
  57236. /**
  57237. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57238. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57239. */
  57240. protected _useRadianceOverAlpha: boolean;
  57241. /**
  57242. * Allows using an object space normal map (instead of tangent space).
  57243. */
  57244. protected _useObjectSpaceNormalMap: boolean;
  57245. /**
  57246. * Allows using the bump map in parallax mode.
  57247. */
  57248. protected _useParallax: boolean;
  57249. /**
  57250. * Allows using the bump map in parallax occlusion mode.
  57251. */
  57252. protected _useParallaxOcclusion: boolean;
  57253. /**
  57254. * Controls the scale bias of the parallax mode.
  57255. */
  57256. protected _parallaxScaleBias: number;
  57257. /**
  57258. * If sets to true, disables all the lights affecting the material.
  57259. */
  57260. protected _disableLighting: boolean;
  57261. /**
  57262. * Number of Simultaneous lights allowed on the material.
  57263. */
  57264. protected _maxSimultaneousLights: number;
  57265. /**
  57266. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57267. */
  57268. protected _invertNormalMapX: boolean;
  57269. /**
  57270. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57271. */
  57272. protected _invertNormalMapY: boolean;
  57273. /**
  57274. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57275. */
  57276. protected _twoSidedLighting: boolean;
  57277. /**
  57278. * Defines the alpha limits in alpha test mode.
  57279. */
  57280. protected _alphaCutOff: number;
  57281. /**
  57282. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57283. */
  57284. protected _forceAlphaTest: boolean;
  57285. /**
  57286. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57287. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57288. */
  57289. protected _useAlphaFresnel: boolean;
  57290. /**
  57291. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57292. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57293. */
  57294. protected _useLinearAlphaFresnel: boolean;
  57295. /**
  57296. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57297. * from cos thetav and roughness:
  57298. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57299. */
  57300. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57301. /**
  57302. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57303. */
  57304. protected _forceIrradianceInFragment: boolean;
  57305. /**
  57306. * Force normal to face away from face.
  57307. */
  57308. protected _forceNormalForward: boolean;
  57309. /**
  57310. * Enables specular anti aliasing in the PBR shader.
  57311. * It will both interacts on the Geometry for analytical and IBL lighting.
  57312. * It also prefilter the roughness map based on the bump values.
  57313. */
  57314. protected _enableSpecularAntiAliasing: boolean;
  57315. /**
  57316. * Default configuration related to image processing available in the PBR Material.
  57317. */
  57318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57319. /**
  57320. * Keep track of the image processing observer to allow dispose and replace.
  57321. */
  57322. private _imageProcessingObserver;
  57323. /**
  57324. * Attaches a new image processing configuration to the PBR Material.
  57325. * @param configuration
  57326. */
  57327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57328. /**
  57329. * Stores the available render targets.
  57330. */
  57331. private _renderTargets;
  57332. /**
  57333. * Sets the global ambient color for the material used in lighting calculations.
  57334. */
  57335. private _globalAmbientColor;
  57336. /**
  57337. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57338. */
  57339. private _useLogarithmicDepth;
  57340. /**
  57341. * If set to true, no lighting calculations will be applied.
  57342. */
  57343. private _unlit;
  57344. private _debugMode;
  57345. /**
  57346. * @hidden
  57347. * This is reserved for the inspector.
  57348. * Defines the material debug mode.
  57349. * It helps seeing only some components of the material while troubleshooting.
  57350. */
  57351. debugMode: number;
  57352. /**
  57353. * @hidden
  57354. * This is reserved for the inspector.
  57355. * Specify from where on screen the debug mode should start.
  57356. * The value goes from -1 (full screen) to 1 (not visible)
  57357. * It helps with side by side comparison against the final render
  57358. * This defaults to -1
  57359. */
  57360. private debugLimit;
  57361. /**
  57362. * @hidden
  57363. * This is reserved for the inspector.
  57364. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57365. * You can use the factor to better multiply the final value.
  57366. */
  57367. private debugFactor;
  57368. /**
  57369. * Defines the clear coat layer parameters for the material.
  57370. */
  57371. readonly clearCoat: PBRClearCoatConfiguration;
  57372. /**
  57373. * Defines the anisotropic parameters for the material.
  57374. */
  57375. readonly anisotropy: PBRAnisotropicConfiguration;
  57376. /**
  57377. * Defines the BRDF parameters for the material.
  57378. */
  57379. readonly brdf: PBRBRDFConfiguration;
  57380. /**
  57381. * Defines the Sheen parameters for the material.
  57382. */
  57383. readonly sheen: PBRSheenConfiguration;
  57384. /**
  57385. * Defines the SubSurface parameters for the material.
  57386. */
  57387. readonly subSurface: PBRSubSurfaceConfiguration;
  57388. protected _rebuildInParallel: boolean;
  57389. /**
  57390. * Instantiates a new PBRMaterial instance.
  57391. *
  57392. * @param name The material name
  57393. * @param scene The scene the material will be use in.
  57394. */
  57395. constructor(name: string, scene: Scene);
  57396. /**
  57397. * Gets a boolean indicating that current material needs to register RTT
  57398. */
  57399. get hasRenderTargetTextures(): boolean;
  57400. /**
  57401. * Gets the name of the material class.
  57402. */
  57403. getClassName(): string;
  57404. /**
  57405. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57406. */
  57407. get useLogarithmicDepth(): boolean;
  57408. /**
  57409. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57410. */
  57411. set useLogarithmicDepth(value: boolean);
  57412. /**
  57413. * Returns true if alpha blending should be disabled.
  57414. */
  57415. protected get _disableAlphaBlending(): boolean;
  57416. /**
  57417. * Specifies whether or not this material should be rendered in alpha blend mode.
  57418. */
  57419. needAlphaBlending(): boolean;
  57420. /**
  57421. * Specifies whether or not this material should be rendered in alpha test mode.
  57422. */
  57423. needAlphaTesting(): boolean;
  57424. /**
  57425. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57426. */
  57427. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57428. /**
  57429. * Gets the texture used for the alpha test.
  57430. */
  57431. getAlphaTestTexture(): Nullable<BaseTexture>;
  57432. /**
  57433. * Specifies that the submesh is ready to be used.
  57434. * @param mesh - BJS mesh.
  57435. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57436. * @param useInstances - Specifies that instances should be used.
  57437. * @returns - boolean indicating that the submesh is ready or not.
  57438. */
  57439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57440. /**
  57441. * Specifies if the material uses metallic roughness workflow.
  57442. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57443. */
  57444. isMetallicWorkflow(): boolean;
  57445. private _prepareEffect;
  57446. private _prepareDefines;
  57447. /**
  57448. * Force shader compilation
  57449. */
  57450. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57451. /**
  57452. * Initializes the uniform buffer layout for the shader.
  57453. */
  57454. buildUniformLayout(): void;
  57455. /**
  57456. * Unbinds the material from the mesh
  57457. */
  57458. unbind(): void;
  57459. /**
  57460. * Binds the submesh data.
  57461. * @param world - The world matrix.
  57462. * @param mesh - The BJS mesh.
  57463. * @param subMesh - A submesh of the BJS mesh.
  57464. */
  57465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57466. /**
  57467. * Returns the animatable textures.
  57468. * @returns - Array of animatable textures.
  57469. */
  57470. getAnimatables(): IAnimatable[];
  57471. /**
  57472. * Returns the texture used for reflections.
  57473. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57474. */
  57475. private _getReflectionTexture;
  57476. /**
  57477. * Returns an array of the actively used textures.
  57478. * @returns - Array of BaseTextures
  57479. */
  57480. getActiveTextures(): BaseTexture[];
  57481. /**
  57482. * Checks to see if a texture is used in the material.
  57483. * @param texture - Base texture to use.
  57484. * @returns - Boolean specifying if a texture is used in the material.
  57485. */
  57486. hasTexture(texture: BaseTexture): boolean;
  57487. /**
  57488. * Disposes the resources of the material.
  57489. * @param forceDisposeEffect - Forces the disposal of effects.
  57490. * @param forceDisposeTextures - Forces the disposal of all textures.
  57491. */
  57492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57493. }
  57494. }
  57495. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57496. import { Nullable } from "babylonjs/types";
  57497. import { Scene } from "babylonjs/scene";
  57498. import { Color3 } from "babylonjs/Maths/math.color";
  57499. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57500. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57502. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57503. /**
  57504. * The Physically based material of BJS.
  57505. *
  57506. * This offers the main features of a standard PBR material.
  57507. * For more information, please refer to the documentation :
  57508. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57509. */
  57510. export class PBRMaterial extends PBRBaseMaterial {
  57511. /**
  57512. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57513. */
  57514. static readonly PBRMATERIAL_OPAQUE: number;
  57515. /**
  57516. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57517. */
  57518. static readonly PBRMATERIAL_ALPHATEST: number;
  57519. /**
  57520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57521. */
  57522. static readonly PBRMATERIAL_ALPHABLEND: number;
  57523. /**
  57524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57525. * They are also discarded below the alpha cutoff threshold to improve performances.
  57526. */
  57527. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57528. /**
  57529. * Defines the default value of how much AO map is occluding the analytical lights
  57530. * (point spot...).
  57531. */
  57532. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57533. /**
  57534. * Intensity of the direct lights e.g. the four lights available in your scene.
  57535. * This impacts both the direct diffuse and specular highlights.
  57536. */
  57537. directIntensity: number;
  57538. /**
  57539. * Intensity of the emissive part of the material.
  57540. * This helps controlling the emissive effect without modifying the emissive color.
  57541. */
  57542. emissiveIntensity: number;
  57543. /**
  57544. * Intensity of the environment e.g. how much the environment will light the object
  57545. * either through harmonics for rough material or through the refelction for shiny ones.
  57546. */
  57547. environmentIntensity: number;
  57548. /**
  57549. * This is a special control allowing the reduction of the specular highlights coming from the
  57550. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57551. */
  57552. specularIntensity: number;
  57553. /**
  57554. * Debug Control allowing disabling the bump map on this material.
  57555. */
  57556. disableBumpMap: boolean;
  57557. /**
  57558. * AKA Diffuse Texture in standard nomenclature.
  57559. */
  57560. albedoTexture: BaseTexture;
  57561. /**
  57562. * AKA Occlusion Texture in other nomenclature.
  57563. */
  57564. ambientTexture: BaseTexture;
  57565. /**
  57566. * AKA Occlusion Texture Intensity in other nomenclature.
  57567. */
  57568. ambientTextureStrength: number;
  57569. /**
  57570. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57571. * 1 means it completely occludes it
  57572. * 0 mean it has no impact
  57573. */
  57574. ambientTextureImpactOnAnalyticalLights: number;
  57575. /**
  57576. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57577. */
  57578. opacityTexture: BaseTexture;
  57579. /**
  57580. * Stores the reflection values in a texture.
  57581. */
  57582. reflectionTexture: Nullable<BaseTexture>;
  57583. /**
  57584. * Stores the emissive values in a texture.
  57585. */
  57586. emissiveTexture: BaseTexture;
  57587. /**
  57588. * AKA Specular texture in other nomenclature.
  57589. */
  57590. reflectivityTexture: BaseTexture;
  57591. /**
  57592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57593. */
  57594. metallicTexture: BaseTexture;
  57595. /**
  57596. * Specifies the metallic scalar of the metallic/roughness workflow.
  57597. * Can also be used to scale the metalness values of the metallic texture.
  57598. */
  57599. metallic: Nullable<number>;
  57600. /**
  57601. * Specifies the roughness scalar of the metallic/roughness workflow.
  57602. * Can also be used to scale the roughness values of the metallic texture.
  57603. */
  57604. roughness: Nullable<number>;
  57605. /**
  57606. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57607. * By default the indexOfrefraction is used to compute F0;
  57608. *
  57609. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57610. *
  57611. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57612. * F90 = metallicReflectanceColor;
  57613. */
  57614. metallicF0Factor: number;
  57615. /**
  57616. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57617. * By default the F90 is always 1;
  57618. *
  57619. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57620. *
  57621. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57622. * F90 = metallicReflectanceColor;
  57623. */
  57624. metallicReflectanceColor: Color3;
  57625. /**
  57626. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57627. * This is multiply against the scalar values defined in the material.
  57628. */
  57629. metallicReflectanceTexture: Nullable<BaseTexture>;
  57630. /**
  57631. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57632. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57633. */
  57634. microSurfaceTexture: BaseTexture;
  57635. /**
  57636. * Stores surface normal data used to displace a mesh in a texture.
  57637. */
  57638. bumpTexture: BaseTexture;
  57639. /**
  57640. * Stores the pre-calculated light information of a mesh in a texture.
  57641. */
  57642. lightmapTexture: BaseTexture;
  57643. /**
  57644. * Stores the refracted light information in a texture.
  57645. */
  57646. get refractionTexture(): Nullable<BaseTexture>;
  57647. set refractionTexture(value: Nullable<BaseTexture>);
  57648. /**
  57649. * The color of a material in ambient lighting.
  57650. */
  57651. ambientColor: Color3;
  57652. /**
  57653. * AKA Diffuse Color in other nomenclature.
  57654. */
  57655. albedoColor: Color3;
  57656. /**
  57657. * AKA Specular Color in other nomenclature.
  57658. */
  57659. reflectivityColor: Color3;
  57660. /**
  57661. * The color reflected from the material.
  57662. */
  57663. reflectionColor: Color3;
  57664. /**
  57665. * The color emitted from the material.
  57666. */
  57667. emissiveColor: Color3;
  57668. /**
  57669. * AKA Glossiness in other nomenclature.
  57670. */
  57671. microSurface: number;
  57672. /**
  57673. * Index of refraction of the material base layer.
  57674. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57675. *
  57676. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57677. *
  57678. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57679. */
  57680. get indexOfRefraction(): number;
  57681. set indexOfRefraction(value: number);
  57682. /**
  57683. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57684. */
  57685. get invertRefractionY(): boolean;
  57686. set invertRefractionY(value: boolean);
  57687. /**
  57688. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57689. * Materials half opaque for instance using refraction could benefit from this control.
  57690. */
  57691. get linkRefractionWithTransparency(): boolean;
  57692. set linkRefractionWithTransparency(value: boolean);
  57693. /**
  57694. * If true, the light map contains occlusion information instead of lighting info.
  57695. */
  57696. useLightmapAsShadowmap: boolean;
  57697. /**
  57698. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57699. */
  57700. useAlphaFromAlbedoTexture: boolean;
  57701. /**
  57702. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57703. */
  57704. forceAlphaTest: boolean;
  57705. /**
  57706. * Defines the alpha limits in alpha test mode.
  57707. */
  57708. alphaCutOff: number;
  57709. /**
  57710. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57711. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57712. */
  57713. useSpecularOverAlpha: boolean;
  57714. /**
  57715. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57716. */
  57717. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57718. /**
  57719. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57720. */
  57721. useRoughnessFromMetallicTextureAlpha: boolean;
  57722. /**
  57723. * Specifies if the metallic texture contains the roughness information in its green channel.
  57724. */
  57725. useRoughnessFromMetallicTextureGreen: boolean;
  57726. /**
  57727. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57728. */
  57729. useMetallnessFromMetallicTextureBlue: boolean;
  57730. /**
  57731. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57732. */
  57733. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57734. /**
  57735. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57736. */
  57737. useAmbientInGrayScale: boolean;
  57738. /**
  57739. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57740. * The material will try to infer what glossiness each pixel should be.
  57741. */
  57742. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57743. /**
  57744. * BJS is using an harcoded light falloff based on a manually sets up range.
  57745. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57746. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57747. */
  57748. get usePhysicalLightFalloff(): boolean;
  57749. /**
  57750. * BJS is using an harcoded light falloff based on a manually sets up range.
  57751. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57752. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57753. */
  57754. set usePhysicalLightFalloff(value: boolean);
  57755. /**
  57756. * In order to support the falloff compatibility with gltf, a special mode has been added
  57757. * to reproduce the gltf light falloff.
  57758. */
  57759. get useGLTFLightFalloff(): boolean;
  57760. /**
  57761. * In order to support the falloff compatibility with gltf, a special mode has been added
  57762. * to reproduce the gltf light falloff.
  57763. */
  57764. set useGLTFLightFalloff(value: boolean);
  57765. /**
  57766. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57767. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57768. */
  57769. useRadianceOverAlpha: boolean;
  57770. /**
  57771. * Allows using an object space normal map (instead of tangent space).
  57772. */
  57773. useObjectSpaceNormalMap: boolean;
  57774. /**
  57775. * Allows using the bump map in parallax mode.
  57776. */
  57777. useParallax: boolean;
  57778. /**
  57779. * Allows using the bump map in parallax occlusion mode.
  57780. */
  57781. useParallaxOcclusion: boolean;
  57782. /**
  57783. * Controls the scale bias of the parallax mode.
  57784. */
  57785. parallaxScaleBias: number;
  57786. /**
  57787. * If sets to true, disables all the lights affecting the material.
  57788. */
  57789. disableLighting: boolean;
  57790. /**
  57791. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57792. */
  57793. forceIrradianceInFragment: boolean;
  57794. /**
  57795. * Number of Simultaneous lights allowed on the material.
  57796. */
  57797. maxSimultaneousLights: number;
  57798. /**
  57799. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57800. */
  57801. invertNormalMapX: boolean;
  57802. /**
  57803. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57804. */
  57805. invertNormalMapY: boolean;
  57806. /**
  57807. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57808. */
  57809. twoSidedLighting: boolean;
  57810. /**
  57811. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57812. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57813. */
  57814. useAlphaFresnel: boolean;
  57815. /**
  57816. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57817. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57818. */
  57819. useLinearAlphaFresnel: boolean;
  57820. /**
  57821. * Let user defines the brdf lookup texture used for IBL.
  57822. * A default 8bit version is embedded but you could point at :
  57823. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57824. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57825. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57826. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57827. */
  57828. environmentBRDFTexture: Nullable<BaseTexture>;
  57829. /**
  57830. * Force normal to face away from face.
  57831. */
  57832. forceNormalForward: boolean;
  57833. /**
  57834. * Enables specular anti aliasing in the PBR shader.
  57835. * It will both interacts on the Geometry for analytical and IBL lighting.
  57836. * It also prefilter the roughness map based on the bump values.
  57837. */
  57838. enableSpecularAntiAliasing: boolean;
  57839. /**
  57840. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57841. * makes the reflect vector face the model (under horizon).
  57842. */
  57843. useHorizonOcclusion: boolean;
  57844. /**
  57845. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57846. * too much the area relying on ambient texture to define their ambient occlusion.
  57847. */
  57848. useRadianceOcclusion: boolean;
  57849. /**
  57850. * If set to true, no lighting calculations will be applied.
  57851. */
  57852. unlit: boolean;
  57853. /**
  57854. * Gets the image processing configuration used either in this material.
  57855. */
  57856. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57857. /**
  57858. * Sets the Default image processing configuration used either in the this material.
  57859. *
  57860. * If sets to null, the scene one is in use.
  57861. */
  57862. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57863. /**
  57864. * Gets wether the color curves effect is enabled.
  57865. */
  57866. get cameraColorCurvesEnabled(): boolean;
  57867. /**
  57868. * Sets wether the color curves effect is enabled.
  57869. */
  57870. set cameraColorCurvesEnabled(value: boolean);
  57871. /**
  57872. * Gets wether the color grading effect is enabled.
  57873. */
  57874. get cameraColorGradingEnabled(): boolean;
  57875. /**
  57876. * Gets wether the color grading effect is enabled.
  57877. */
  57878. set cameraColorGradingEnabled(value: boolean);
  57879. /**
  57880. * Gets wether tonemapping is enabled or not.
  57881. */
  57882. get cameraToneMappingEnabled(): boolean;
  57883. /**
  57884. * Sets wether tonemapping is enabled or not
  57885. */
  57886. set cameraToneMappingEnabled(value: boolean);
  57887. /**
  57888. * The camera exposure used on this material.
  57889. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57890. * This corresponds to a photographic exposure.
  57891. */
  57892. get cameraExposure(): number;
  57893. /**
  57894. * The camera exposure used on this material.
  57895. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57896. * This corresponds to a photographic exposure.
  57897. */
  57898. set cameraExposure(value: number);
  57899. /**
  57900. * Gets The camera contrast used on this material.
  57901. */
  57902. get cameraContrast(): number;
  57903. /**
  57904. * Sets The camera contrast used on this material.
  57905. */
  57906. set cameraContrast(value: number);
  57907. /**
  57908. * Gets the Color Grading 2D Lookup Texture.
  57909. */
  57910. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57911. /**
  57912. * Sets the Color Grading 2D Lookup Texture.
  57913. */
  57914. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57915. /**
  57916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57918. * 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;
  57919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57920. */
  57921. get cameraColorCurves(): Nullable<ColorCurves>;
  57922. /**
  57923. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57924. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57925. * 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;
  57926. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57927. */
  57928. set cameraColorCurves(value: Nullable<ColorCurves>);
  57929. /**
  57930. * Instantiates a new PBRMaterial instance.
  57931. *
  57932. * @param name The material name
  57933. * @param scene The scene the material will be use in.
  57934. */
  57935. constructor(name: string, scene: Scene);
  57936. /**
  57937. * Returns the name of this material class.
  57938. */
  57939. getClassName(): string;
  57940. /**
  57941. * Makes a duplicate of the current material.
  57942. * @param name - name to use for the new material.
  57943. */
  57944. clone(name: string): PBRMaterial;
  57945. /**
  57946. * Serializes this PBR Material.
  57947. * @returns - An object with the serialized material.
  57948. */
  57949. serialize(): any;
  57950. /**
  57951. * Parses a PBR Material from a serialized object.
  57952. * @param source - Serialized object.
  57953. * @param scene - BJS scene instance.
  57954. * @param rootUrl - url for the scene object
  57955. * @returns - PBRMaterial
  57956. */
  57957. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57958. }
  57959. }
  57960. declare module "babylonjs/Misc/dds" {
  57961. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57962. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57963. import { Nullable } from "babylonjs/types";
  57964. import { Scene } from "babylonjs/scene";
  57965. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  57966. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57967. /**
  57968. * Direct draw surface info
  57969. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57970. */
  57971. export interface DDSInfo {
  57972. /**
  57973. * Width of the texture
  57974. */
  57975. width: number;
  57976. /**
  57977. * Width of the texture
  57978. */
  57979. height: number;
  57980. /**
  57981. * Number of Mipmaps for the texture
  57982. * @see https://en.wikipedia.org/wiki/Mipmap
  57983. */
  57984. mipmapCount: number;
  57985. /**
  57986. * If the textures format is a known fourCC format
  57987. * @see https://www.fourcc.org/
  57988. */
  57989. isFourCC: boolean;
  57990. /**
  57991. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57992. */
  57993. isRGB: boolean;
  57994. /**
  57995. * If the texture is a lumincance format
  57996. */
  57997. isLuminance: boolean;
  57998. /**
  57999. * If this is a cube texture
  58000. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58001. */
  58002. isCube: boolean;
  58003. /**
  58004. * If the texture is a compressed format eg. FOURCC_DXT1
  58005. */
  58006. isCompressed: boolean;
  58007. /**
  58008. * The dxgiFormat of the texture
  58009. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58010. */
  58011. dxgiFormat: number;
  58012. /**
  58013. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58014. */
  58015. textureType: number;
  58016. /**
  58017. * Sphericle polynomial created for the dds texture
  58018. */
  58019. sphericalPolynomial?: SphericalPolynomial;
  58020. }
  58021. /**
  58022. * Class used to provide DDS decompression tools
  58023. */
  58024. export class DDSTools {
  58025. /**
  58026. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58027. */
  58028. static StoreLODInAlphaChannel: boolean;
  58029. /**
  58030. * Gets DDS information from an array buffer
  58031. * @param data defines the array buffer view to read data from
  58032. * @returns the DDS information
  58033. */
  58034. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58035. private static _FloatView;
  58036. private static _Int32View;
  58037. private static _ToHalfFloat;
  58038. private static _FromHalfFloat;
  58039. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58040. private static _GetHalfFloatRGBAArrayBuffer;
  58041. private static _GetFloatRGBAArrayBuffer;
  58042. private static _GetFloatAsUIntRGBAArrayBuffer;
  58043. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58044. private static _GetRGBAArrayBuffer;
  58045. private static _ExtractLongWordOrder;
  58046. private static _GetRGBArrayBuffer;
  58047. private static _GetLuminanceArrayBuffer;
  58048. /**
  58049. * Uploads DDS Levels to a Babylon Texture
  58050. * @hidden
  58051. */
  58052. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58053. }
  58054. module "babylonjs/Engines/thinEngine" {
  58055. interface ThinEngine {
  58056. /**
  58057. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58058. * @param rootUrl defines the url where the file to load is located
  58059. * @param scene defines the current scene
  58060. * @param lodScale defines scale to apply to the mip map selection
  58061. * @param lodOffset defines offset to apply to the mip map selection
  58062. * @param onLoad defines an optional callback raised when the texture is loaded
  58063. * @param onError defines an optional callback raised if there is an issue to load the texture
  58064. * @param format defines the format of the data
  58065. * @param forcedExtension defines the extension to use to pick the right loader
  58066. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58067. * @returns the cube texture as an InternalTexture
  58068. */
  58069. 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;
  58070. }
  58071. }
  58072. }
  58073. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58074. import { Nullable } from "babylonjs/types";
  58075. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58076. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58077. /**
  58078. * Implementation of the DDS Texture Loader.
  58079. * @hidden
  58080. */
  58081. export class _DDSTextureLoader implements IInternalTextureLoader {
  58082. /**
  58083. * Defines wether the loader supports cascade loading the different faces.
  58084. */
  58085. readonly supportCascades: boolean;
  58086. /**
  58087. * This returns if the loader support the current file information.
  58088. * @param extension defines the file extension of the file being loaded
  58089. * @returns true if the loader can load the specified file
  58090. */
  58091. canLoad(extension: string): boolean;
  58092. /**
  58093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58094. * @param data contains the texture data
  58095. * @param texture defines the BabylonJS internal texture
  58096. * @param createPolynomials will be true if polynomials have been requested
  58097. * @param onLoad defines the callback to trigger once the texture is ready
  58098. * @param onError defines the callback to trigger in case of error
  58099. */
  58100. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58101. /**
  58102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58103. * @param data contains the texture data
  58104. * @param texture defines the BabylonJS internal texture
  58105. * @param callback defines the method to call once ready to upload
  58106. */
  58107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58108. }
  58109. }
  58110. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58111. import { Nullable } from "babylonjs/types";
  58112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58113. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58114. /**
  58115. * Implementation of the ENV Texture Loader.
  58116. * @hidden
  58117. */
  58118. export class _ENVTextureLoader implements IInternalTextureLoader {
  58119. /**
  58120. * Defines wether the loader supports cascade loading the different faces.
  58121. */
  58122. readonly supportCascades: boolean;
  58123. /**
  58124. * This returns if the loader support the current file information.
  58125. * @param extension defines the file extension of the file being loaded
  58126. * @returns true if the loader can load the specified file
  58127. */
  58128. canLoad(extension: string): boolean;
  58129. /**
  58130. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58131. * @param data contains the texture data
  58132. * @param texture defines the BabylonJS internal texture
  58133. * @param createPolynomials will be true if polynomials have been requested
  58134. * @param onLoad defines the callback to trigger once the texture is ready
  58135. * @param onError defines the callback to trigger in case of error
  58136. */
  58137. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58138. /**
  58139. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58140. * @param data contains the texture data
  58141. * @param texture defines the BabylonJS internal texture
  58142. * @param callback defines the method to call once ready to upload
  58143. */
  58144. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58145. }
  58146. }
  58147. declare module "babylonjs/Misc/khronosTextureContainer" {
  58148. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58149. /**
  58150. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58151. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58152. */
  58153. export class KhronosTextureContainer {
  58154. /** contents of the KTX container file */
  58155. data: ArrayBufferView;
  58156. private static HEADER_LEN;
  58157. private static COMPRESSED_2D;
  58158. private static COMPRESSED_3D;
  58159. private static TEX_2D;
  58160. private static TEX_3D;
  58161. /**
  58162. * Gets the openGL type
  58163. */
  58164. glType: number;
  58165. /**
  58166. * Gets the openGL type size
  58167. */
  58168. glTypeSize: number;
  58169. /**
  58170. * Gets the openGL format
  58171. */
  58172. glFormat: number;
  58173. /**
  58174. * Gets the openGL internal format
  58175. */
  58176. glInternalFormat: number;
  58177. /**
  58178. * Gets the base internal format
  58179. */
  58180. glBaseInternalFormat: number;
  58181. /**
  58182. * Gets image width in pixel
  58183. */
  58184. pixelWidth: number;
  58185. /**
  58186. * Gets image height in pixel
  58187. */
  58188. pixelHeight: number;
  58189. /**
  58190. * Gets image depth in pixels
  58191. */
  58192. pixelDepth: number;
  58193. /**
  58194. * Gets the number of array elements
  58195. */
  58196. numberOfArrayElements: number;
  58197. /**
  58198. * Gets the number of faces
  58199. */
  58200. numberOfFaces: number;
  58201. /**
  58202. * Gets the number of mipmap levels
  58203. */
  58204. numberOfMipmapLevels: number;
  58205. /**
  58206. * Gets the bytes of key value data
  58207. */
  58208. bytesOfKeyValueData: number;
  58209. /**
  58210. * Gets the load type
  58211. */
  58212. loadType: number;
  58213. /**
  58214. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58215. */
  58216. isInvalid: boolean;
  58217. /**
  58218. * Creates a new KhronosTextureContainer
  58219. * @param data contents of the KTX container file
  58220. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58221. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58222. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58223. */
  58224. constructor(
  58225. /** contents of the KTX container file */
  58226. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58227. /**
  58228. * Uploads KTX content to a Babylon Texture.
  58229. * It is assumed that the texture has already been created & is currently bound
  58230. * @hidden
  58231. */
  58232. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58233. private _upload2DCompressedLevels;
  58234. /**
  58235. * Checks if the given data starts with a KTX file identifier.
  58236. * @param data the data to check
  58237. * @returns true if the data is a KTX file or false otherwise
  58238. */
  58239. static IsValid(data: ArrayBufferView): boolean;
  58240. }
  58241. }
  58242. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58244. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58245. /**
  58246. * Class for loading KTX2 files
  58247. * !!! Experimental Extension Subject to Changes !!!
  58248. * @hidden
  58249. */
  58250. export class KhronosTextureContainer2 {
  58251. private static _ModulePromise;
  58252. private static _TranscodeFormat;
  58253. constructor(engine: ThinEngine);
  58254. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58255. private _determineTranscodeFormat;
  58256. /**
  58257. * Checks if the given data starts with a KTX2 file identifier.
  58258. * @param data the data to check
  58259. * @returns true if the data is a KTX2 file or false otherwise
  58260. */
  58261. static IsValid(data: ArrayBufferView): boolean;
  58262. }
  58263. }
  58264. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58265. import { Nullable } from "babylonjs/types";
  58266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58267. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58268. /**
  58269. * Implementation of the KTX Texture Loader.
  58270. * @hidden
  58271. */
  58272. export class _KTXTextureLoader implements IInternalTextureLoader {
  58273. /**
  58274. * Defines wether the loader supports cascade loading the different faces.
  58275. */
  58276. readonly supportCascades: boolean;
  58277. /**
  58278. * This returns if the loader support the current file information.
  58279. * @param extension defines the file extension of the file being loaded
  58280. * @returns true if the loader can load the specified file
  58281. */
  58282. canLoad(extension: string): boolean;
  58283. /**
  58284. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58285. * @param data contains the texture data
  58286. * @param texture defines the BabylonJS internal texture
  58287. * @param createPolynomials will be true if polynomials have been requested
  58288. * @param onLoad defines the callback to trigger once the texture is ready
  58289. * @param onError defines the callback to trigger in case of error
  58290. */
  58291. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58292. /**
  58293. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58294. * @param data contains the texture data
  58295. * @param texture defines the BabylonJS internal texture
  58296. * @param callback defines the method to call once ready to upload
  58297. */
  58298. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58299. }
  58300. }
  58301. declare module "babylonjs/Helpers/sceneHelpers" {
  58302. import { Nullable } from "babylonjs/types";
  58303. import { Mesh } from "babylonjs/Meshes/mesh";
  58304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58305. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58306. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58307. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58308. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58309. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58310. import "babylonjs/Meshes/Builders/boxBuilder";
  58311. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58312. /** @hidden */
  58313. export var _forceSceneHelpersToBundle: boolean;
  58314. module "babylonjs/scene" {
  58315. interface Scene {
  58316. /**
  58317. * Creates a default light for the scene.
  58318. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58319. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58320. */
  58321. createDefaultLight(replace?: boolean): void;
  58322. /**
  58323. * Creates a default camera for the scene.
  58324. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58325. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58326. * @param replace has default false, when true replaces the active camera in the scene
  58327. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58328. */
  58329. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58330. /**
  58331. * Creates a default camera and a default light.
  58332. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58333. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58334. * @param replace has the default false, when true replaces the active camera/light in the scene
  58335. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58336. */
  58337. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58338. /**
  58339. * Creates a new sky box
  58340. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58341. * @param environmentTexture defines the texture to use as environment texture
  58342. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58343. * @param scale defines the overall scale of the skybox
  58344. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58345. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58346. * @returns a new mesh holding the sky box
  58347. */
  58348. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58349. /**
  58350. * Creates a new environment
  58351. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58352. * @param options defines the options you can use to configure the environment
  58353. * @returns the new EnvironmentHelper
  58354. */
  58355. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58356. /**
  58357. * Creates a new VREXperienceHelper
  58358. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58359. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58360. * @returns a new VREXperienceHelper
  58361. */
  58362. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58363. /**
  58364. * Creates a new WebXRDefaultExperience
  58365. * @see http://doc.babylonjs.com/how_to/webxr
  58366. * @param options experience options
  58367. * @returns a promise for a new WebXRDefaultExperience
  58368. */
  58369. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58370. }
  58371. }
  58372. }
  58373. declare module "babylonjs/Helpers/videoDome" {
  58374. import { Scene } from "babylonjs/scene";
  58375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58376. import { Mesh } from "babylonjs/Meshes/mesh";
  58377. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58378. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58379. import "babylonjs/Meshes/Builders/sphereBuilder";
  58380. /**
  58381. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58382. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58383. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58384. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58385. */
  58386. export class VideoDome extends TransformNode {
  58387. /**
  58388. * Define the video source as a Monoscopic panoramic 360 video.
  58389. */
  58390. static readonly MODE_MONOSCOPIC: number;
  58391. /**
  58392. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58393. */
  58394. static readonly MODE_TOPBOTTOM: number;
  58395. /**
  58396. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58397. */
  58398. static readonly MODE_SIDEBYSIDE: number;
  58399. private _halfDome;
  58400. private _useDirectMapping;
  58401. /**
  58402. * The video texture being displayed on the sphere
  58403. */
  58404. protected _videoTexture: VideoTexture;
  58405. /**
  58406. * Gets the video texture being displayed on the sphere
  58407. */
  58408. get videoTexture(): VideoTexture;
  58409. /**
  58410. * The skybox material
  58411. */
  58412. protected _material: BackgroundMaterial;
  58413. /**
  58414. * The surface used for the skybox
  58415. */
  58416. protected _mesh: Mesh;
  58417. /**
  58418. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58419. */
  58420. private _halfDomeMask;
  58421. /**
  58422. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58423. * Also see the options.resolution property.
  58424. */
  58425. get fovMultiplier(): number;
  58426. set fovMultiplier(value: number);
  58427. private _videoMode;
  58428. /**
  58429. * Gets or set the current video mode for the video. It can be:
  58430. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58431. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58432. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58433. */
  58434. get videoMode(): number;
  58435. set videoMode(value: number);
  58436. /**
  58437. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58438. *
  58439. */
  58440. get halfDome(): boolean;
  58441. /**
  58442. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58443. */
  58444. set halfDome(enabled: boolean);
  58445. /**
  58446. * Oberserver used in Stereoscopic VR Mode.
  58447. */
  58448. private _onBeforeCameraRenderObserver;
  58449. /**
  58450. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58451. * @param name Element's name, child elements will append suffixes for their own names.
  58452. * @param urlsOrVideo defines the url(s) or the video element to use
  58453. * @param options An object containing optional or exposed sub element properties
  58454. */
  58455. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58456. resolution?: number;
  58457. clickToPlay?: boolean;
  58458. autoPlay?: boolean;
  58459. loop?: boolean;
  58460. size?: number;
  58461. poster?: string;
  58462. faceForward?: boolean;
  58463. useDirectMapping?: boolean;
  58464. halfDomeMode?: boolean;
  58465. }, scene: Scene);
  58466. private _changeVideoMode;
  58467. /**
  58468. * Releases resources associated with this node.
  58469. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58470. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58471. */
  58472. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58473. }
  58474. }
  58475. declare module "babylonjs/Helpers/index" {
  58476. export * from "babylonjs/Helpers/environmentHelper";
  58477. export * from "babylonjs/Helpers/photoDome";
  58478. export * from "babylonjs/Helpers/sceneHelpers";
  58479. export * from "babylonjs/Helpers/videoDome";
  58480. }
  58481. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58482. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58483. import { IDisposable } from "babylonjs/scene";
  58484. import { Engine } from "babylonjs/Engines/engine";
  58485. /**
  58486. * This class can be used to get instrumentation data from a Babylon engine
  58487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58488. */
  58489. export class EngineInstrumentation implements IDisposable {
  58490. /**
  58491. * Define the instrumented engine.
  58492. */
  58493. engine: Engine;
  58494. private _captureGPUFrameTime;
  58495. private _gpuFrameTimeToken;
  58496. private _gpuFrameTime;
  58497. private _captureShaderCompilationTime;
  58498. private _shaderCompilationTime;
  58499. private _onBeginFrameObserver;
  58500. private _onEndFrameObserver;
  58501. private _onBeforeShaderCompilationObserver;
  58502. private _onAfterShaderCompilationObserver;
  58503. /**
  58504. * Gets the perf counter used for GPU frame time
  58505. */
  58506. get gpuFrameTimeCounter(): PerfCounter;
  58507. /**
  58508. * Gets the GPU frame time capture status
  58509. */
  58510. get captureGPUFrameTime(): boolean;
  58511. /**
  58512. * Enable or disable the GPU frame time capture
  58513. */
  58514. set captureGPUFrameTime(value: boolean);
  58515. /**
  58516. * Gets the perf counter used for shader compilation time
  58517. */
  58518. get shaderCompilationTimeCounter(): PerfCounter;
  58519. /**
  58520. * Gets the shader compilation time capture status
  58521. */
  58522. get captureShaderCompilationTime(): boolean;
  58523. /**
  58524. * Enable or disable the shader compilation time capture
  58525. */
  58526. set captureShaderCompilationTime(value: boolean);
  58527. /**
  58528. * Instantiates a new engine instrumentation.
  58529. * This class can be used to get instrumentation data from a Babylon engine
  58530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58531. * @param engine Defines the engine to instrument
  58532. */
  58533. constructor(
  58534. /**
  58535. * Define the instrumented engine.
  58536. */
  58537. engine: Engine);
  58538. /**
  58539. * Dispose and release associated resources.
  58540. */
  58541. dispose(): void;
  58542. }
  58543. }
  58544. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58545. import { Scene, IDisposable } from "babylonjs/scene";
  58546. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58547. /**
  58548. * This class can be used to get instrumentation data from a Babylon engine
  58549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58550. */
  58551. export class SceneInstrumentation implements IDisposable {
  58552. /**
  58553. * Defines the scene to instrument
  58554. */
  58555. scene: Scene;
  58556. private _captureActiveMeshesEvaluationTime;
  58557. private _activeMeshesEvaluationTime;
  58558. private _captureRenderTargetsRenderTime;
  58559. private _renderTargetsRenderTime;
  58560. private _captureFrameTime;
  58561. private _frameTime;
  58562. private _captureRenderTime;
  58563. private _renderTime;
  58564. private _captureInterFrameTime;
  58565. private _interFrameTime;
  58566. private _captureParticlesRenderTime;
  58567. private _particlesRenderTime;
  58568. private _captureSpritesRenderTime;
  58569. private _spritesRenderTime;
  58570. private _capturePhysicsTime;
  58571. private _physicsTime;
  58572. private _captureAnimationsTime;
  58573. private _animationsTime;
  58574. private _captureCameraRenderTime;
  58575. private _cameraRenderTime;
  58576. private _onBeforeActiveMeshesEvaluationObserver;
  58577. private _onAfterActiveMeshesEvaluationObserver;
  58578. private _onBeforeRenderTargetsRenderObserver;
  58579. private _onAfterRenderTargetsRenderObserver;
  58580. private _onAfterRenderObserver;
  58581. private _onBeforeDrawPhaseObserver;
  58582. private _onAfterDrawPhaseObserver;
  58583. private _onBeforeAnimationsObserver;
  58584. private _onBeforeParticlesRenderingObserver;
  58585. private _onAfterParticlesRenderingObserver;
  58586. private _onBeforeSpritesRenderingObserver;
  58587. private _onAfterSpritesRenderingObserver;
  58588. private _onBeforePhysicsObserver;
  58589. private _onAfterPhysicsObserver;
  58590. private _onAfterAnimationsObserver;
  58591. private _onBeforeCameraRenderObserver;
  58592. private _onAfterCameraRenderObserver;
  58593. /**
  58594. * Gets the perf counter used for active meshes evaluation time
  58595. */
  58596. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58597. /**
  58598. * Gets the active meshes evaluation time capture status
  58599. */
  58600. get captureActiveMeshesEvaluationTime(): boolean;
  58601. /**
  58602. * Enable or disable the active meshes evaluation time capture
  58603. */
  58604. set captureActiveMeshesEvaluationTime(value: boolean);
  58605. /**
  58606. * Gets the perf counter used for render targets render time
  58607. */
  58608. get renderTargetsRenderTimeCounter(): PerfCounter;
  58609. /**
  58610. * Gets the render targets render time capture status
  58611. */
  58612. get captureRenderTargetsRenderTime(): boolean;
  58613. /**
  58614. * Enable or disable the render targets render time capture
  58615. */
  58616. set captureRenderTargetsRenderTime(value: boolean);
  58617. /**
  58618. * Gets the perf counter used for particles render time
  58619. */
  58620. get particlesRenderTimeCounter(): PerfCounter;
  58621. /**
  58622. * Gets the particles render time capture status
  58623. */
  58624. get captureParticlesRenderTime(): boolean;
  58625. /**
  58626. * Enable or disable the particles render time capture
  58627. */
  58628. set captureParticlesRenderTime(value: boolean);
  58629. /**
  58630. * Gets the perf counter used for sprites render time
  58631. */
  58632. get spritesRenderTimeCounter(): PerfCounter;
  58633. /**
  58634. * Gets the sprites render time capture status
  58635. */
  58636. get captureSpritesRenderTime(): boolean;
  58637. /**
  58638. * Enable or disable the sprites render time capture
  58639. */
  58640. set captureSpritesRenderTime(value: boolean);
  58641. /**
  58642. * Gets the perf counter used for physics time
  58643. */
  58644. get physicsTimeCounter(): PerfCounter;
  58645. /**
  58646. * Gets the physics time capture status
  58647. */
  58648. get capturePhysicsTime(): boolean;
  58649. /**
  58650. * Enable or disable the physics time capture
  58651. */
  58652. set capturePhysicsTime(value: boolean);
  58653. /**
  58654. * Gets the perf counter used for animations time
  58655. */
  58656. get animationsTimeCounter(): PerfCounter;
  58657. /**
  58658. * Gets the animations time capture status
  58659. */
  58660. get captureAnimationsTime(): boolean;
  58661. /**
  58662. * Enable or disable the animations time capture
  58663. */
  58664. set captureAnimationsTime(value: boolean);
  58665. /**
  58666. * Gets the perf counter used for frame time capture
  58667. */
  58668. get frameTimeCounter(): PerfCounter;
  58669. /**
  58670. * Gets the frame time capture status
  58671. */
  58672. get captureFrameTime(): boolean;
  58673. /**
  58674. * Enable or disable the frame time capture
  58675. */
  58676. set captureFrameTime(value: boolean);
  58677. /**
  58678. * Gets the perf counter used for inter-frames time capture
  58679. */
  58680. get interFrameTimeCounter(): PerfCounter;
  58681. /**
  58682. * Gets the inter-frames time capture status
  58683. */
  58684. get captureInterFrameTime(): boolean;
  58685. /**
  58686. * Enable or disable the inter-frames time capture
  58687. */
  58688. set captureInterFrameTime(value: boolean);
  58689. /**
  58690. * Gets the perf counter used for render time capture
  58691. */
  58692. get renderTimeCounter(): PerfCounter;
  58693. /**
  58694. * Gets the render time capture status
  58695. */
  58696. get captureRenderTime(): boolean;
  58697. /**
  58698. * Enable or disable the render time capture
  58699. */
  58700. set captureRenderTime(value: boolean);
  58701. /**
  58702. * Gets the perf counter used for camera render time capture
  58703. */
  58704. get cameraRenderTimeCounter(): PerfCounter;
  58705. /**
  58706. * Gets the camera render time capture status
  58707. */
  58708. get captureCameraRenderTime(): boolean;
  58709. /**
  58710. * Enable or disable the camera render time capture
  58711. */
  58712. set captureCameraRenderTime(value: boolean);
  58713. /**
  58714. * Gets the perf counter used for draw calls
  58715. */
  58716. get drawCallsCounter(): PerfCounter;
  58717. /**
  58718. * Instantiates a new scene instrumentation.
  58719. * This class can be used to get instrumentation data from a Babylon engine
  58720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58721. * @param scene Defines the scene to instrument
  58722. */
  58723. constructor(
  58724. /**
  58725. * Defines the scene to instrument
  58726. */
  58727. scene: Scene);
  58728. /**
  58729. * Dispose and release associated resources.
  58730. */
  58731. dispose(): void;
  58732. }
  58733. }
  58734. declare module "babylonjs/Instrumentation/index" {
  58735. export * from "babylonjs/Instrumentation/engineInstrumentation";
  58736. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  58737. export * from "babylonjs/Instrumentation/timeToken";
  58738. }
  58739. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  58740. /** @hidden */
  58741. export var glowMapGenerationPixelShader: {
  58742. name: string;
  58743. shader: string;
  58744. };
  58745. }
  58746. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  58747. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58750. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58751. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58752. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58753. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58754. /** @hidden */
  58755. export var glowMapGenerationVertexShader: {
  58756. name: string;
  58757. shader: string;
  58758. };
  58759. }
  58760. declare module "babylonjs/Layers/effectLayer" {
  58761. import { Observable } from "babylonjs/Misc/observable";
  58762. import { Nullable } from "babylonjs/types";
  58763. import { Camera } from "babylonjs/Cameras/camera";
  58764. import { Scene } from "babylonjs/scene";
  58765. import { ISize } from "babylonjs/Maths/math.size";
  58766. import { Color4 } from "babylonjs/Maths/math.color";
  58767. import { Engine } from "babylonjs/Engines/engine";
  58768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58770. import { Mesh } from "babylonjs/Meshes/mesh";
  58771. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58774. import { Effect } from "babylonjs/Materials/effect";
  58775. import { Material } from "babylonjs/Materials/material";
  58776. import "babylonjs/Shaders/glowMapGeneration.fragment";
  58777. import "babylonjs/Shaders/glowMapGeneration.vertex";
  58778. /**
  58779. * Effect layer options. This helps customizing the behaviour
  58780. * of the effect layer.
  58781. */
  58782. export interface IEffectLayerOptions {
  58783. /**
  58784. * Multiplication factor apply to the canvas size to compute the render target size
  58785. * used to generated the objects (the smaller the faster).
  58786. */
  58787. mainTextureRatio: number;
  58788. /**
  58789. * Enforces a fixed size texture to ensure effect stability across devices.
  58790. */
  58791. mainTextureFixedSize?: number;
  58792. /**
  58793. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58794. */
  58795. alphaBlendingMode: number;
  58796. /**
  58797. * The camera attached to the layer.
  58798. */
  58799. camera: Nullable<Camera>;
  58800. /**
  58801. * The rendering group to draw the layer in.
  58802. */
  58803. renderingGroupId: number;
  58804. }
  58805. /**
  58806. * The effect layer Helps adding post process effect blended with the main pass.
  58807. *
  58808. * This can be for instance use to generate glow or higlight effects on the scene.
  58809. *
  58810. * The effect layer class can not be used directly and is intented to inherited from to be
  58811. * customized per effects.
  58812. */
  58813. export abstract class EffectLayer {
  58814. private _vertexBuffers;
  58815. private _indexBuffer;
  58816. private _cachedDefines;
  58817. private _effectLayerMapGenerationEffect;
  58818. private _effectLayerOptions;
  58819. private _mergeEffect;
  58820. protected _scene: Scene;
  58821. protected _engine: Engine;
  58822. protected _maxSize: number;
  58823. protected _mainTextureDesiredSize: ISize;
  58824. protected _mainTexture: RenderTargetTexture;
  58825. protected _shouldRender: boolean;
  58826. protected _postProcesses: PostProcess[];
  58827. protected _textures: BaseTexture[];
  58828. protected _emissiveTextureAndColor: {
  58829. texture: Nullable<BaseTexture>;
  58830. color: Color4;
  58831. };
  58832. /**
  58833. * The name of the layer
  58834. */
  58835. name: string;
  58836. /**
  58837. * The clear color of the texture used to generate the glow map.
  58838. */
  58839. neutralColor: Color4;
  58840. /**
  58841. * Specifies whether the highlight layer is enabled or not.
  58842. */
  58843. isEnabled: boolean;
  58844. /**
  58845. * Gets the camera attached to the layer.
  58846. */
  58847. get camera(): Nullable<Camera>;
  58848. /**
  58849. * Gets the rendering group id the layer should render in.
  58850. */
  58851. get renderingGroupId(): number;
  58852. set renderingGroupId(renderingGroupId: number);
  58853. /**
  58854. * An event triggered when the effect layer has been disposed.
  58855. */
  58856. onDisposeObservable: Observable<EffectLayer>;
  58857. /**
  58858. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58859. */
  58860. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58861. /**
  58862. * An event triggered when the generated texture is being merged in the scene.
  58863. */
  58864. onBeforeComposeObservable: Observable<EffectLayer>;
  58865. /**
  58866. * An event triggered when the mesh is rendered into the effect render target.
  58867. */
  58868. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58869. /**
  58870. * An event triggered after the mesh has been rendered into the effect render target.
  58871. */
  58872. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58873. /**
  58874. * An event triggered when the generated texture has been merged in the scene.
  58875. */
  58876. onAfterComposeObservable: Observable<EffectLayer>;
  58877. /**
  58878. * An event triggered when the efffect layer changes its size.
  58879. */
  58880. onSizeChangedObservable: Observable<EffectLayer>;
  58881. /** @hidden */
  58882. static _SceneComponentInitialization: (scene: Scene) => void;
  58883. /**
  58884. * Instantiates a new effect Layer and references it in the scene.
  58885. * @param name The name of the layer
  58886. * @param scene The scene to use the layer in
  58887. */
  58888. constructor(
  58889. /** The Friendly of the effect in the scene */
  58890. name: string, scene: Scene);
  58891. /**
  58892. * Get the effect name of the layer.
  58893. * @return The effect name
  58894. */
  58895. abstract getEffectName(): string;
  58896. /**
  58897. * Checks for the readiness of the element composing the layer.
  58898. * @param subMesh the mesh to check for
  58899. * @param useInstances specify whether or not to use instances to render the mesh
  58900. * @return true if ready otherwise, false
  58901. */
  58902. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58903. /**
  58904. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58905. * @returns true if the effect requires stencil during the main canvas render pass.
  58906. */
  58907. abstract needStencil(): boolean;
  58908. /**
  58909. * Create the merge effect. This is the shader use to blit the information back
  58910. * to the main canvas at the end of the scene rendering.
  58911. * @returns The effect containing the shader used to merge the effect on the main canvas
  58912. */
  58913. protected abstract _createMergeEffect(): Effect;
  58914. /**
  58915. * Creates the render target textures and post processes used in the effect layer.
  58916. */
  58917. protected abstract _createTextureAndPostProcesses(): void;
  58918. /**
  58919. * Implementation specific of rendering the generating effect on the main canvas.
  58920. * @param effect The effect used to render through
  58921. */
  58922. protected abstract _internalRender(effect: Effect): void;
  58923. /**
  58924. * Sets the required values for both the emissive texture and and the main color.
  58925. */
  58926. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58927. /**
  58928. * Free any resources and references associated to a mesh.
  58929. * Internal use
  58930. * @param mesh The mesh to free.
  58931. */
  58932. abstract _disposeMesh(mesh: Mesh): void;
  58933. /**
  58934. * Serializes this layer (Glow or Highlight for example)
  58935. * @returns a serialized layer object
  58936. */
  58937. abstract serialize?(): any;
  58938. /**
  58939. * Initializes the effect layer with the required options.
  58940. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58941. */
  58942. protected _init(options: Partial<IEffectLayerOptions>): void;
  58943. /**
  58944. * Generates the index buffer of the full screen quad blending to the main canvas.
  58945. */
  58946. private _generateIndexBuffer;
  58947. /**
  58948. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58949. */
  58950. private _generateVertexBuffer;
  58951. /**
  58952. * Sets the main texture desired size which is the closest power of two
  58953. * of the engine canvas size.
  58954. */
  58955. private _setMainTextureSize;
  58956. /**
  58957. * Creates the main texture for the effect layer.
  58958. */
  58959. protected _createMainTexture(): void;
  58960. /**
  58961. * Adds specific effects defines.
  58962. * @param defines The defines to add specifics to.
  58963. */
  58964. protected _addCustomEffectDefines(defines: string[]): void;
  58965. /**
  58966. * Checks for the readiness of the element composing the layer.
  58967. * @param subMesh the mesh to check for
  58968. * @param useInstances specify whether or not to use instances to render the mesh
  58969. * @param emissiveTexture the associated emissive texture used to generate the glow
  58970. * @return true if ready otherwise, false
  58971. */
  58972. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58973. /**
  58974. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58975. */
  58976. render(): void;
  58977. /**
  58978. * Determine if a given mesh will be used in the current effect.
  58979. * @param mesh mesh to test
  58980. * @returns true if the mesh will be used
  58981. */
  58982. hasMesh(mesh: AbstractMesh): boolean;
  58983. /**
  58984. * Returns true if the layer contains information to display, otherwise false.
  58985. * @returns true if the glow layer should be rendered
  58986. */
  58987. shouldRender(): boolean;
  58988. /**
  58989. * Returns true if the mesh should render, otherwise false.
  58990. * @param mesh The mesh to render
  58991. * @returns true if it should render otherwise false
  58992. */
  58993. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58994. /**
  58995. * Returns true if the mesh can be rendered, otherwise false.
  58996. * @param mesh The mesh to render
  58997. * @param material The material used on the mesh
  58998. * @returns true if it can be rendered otherwise false
  58999. */
  59000. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59001. /**
  59002. * Returns true if the mesh should render, otherwise false.
  59003. * @param mesh The mesh to render
  59004. * @returns true if it should render otherwise false
  59005. */
  59006. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59007. /**
  59008. * Renders the submesh passed in parameter to the generation map.
  59009. */
  59010. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59011. /**
  59012. * Defines whether the current material of the mesh should be use to render the effect.
  59013. * @param mesh defines the current mesh to render
  59014. */
  59015. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59016. /**
  59017. * Rebuild the required buffers.
  59018. * @hidden Internal use only.
  59019. */
  59020. _rebuild(): void;
  59021. /**
  59022. * Dispose only the render target textures and post process.
  59023. */
  59024. private _disposeTextureAndPostProcesses;
  59025. /**
  59026. * Dispose the highlight layer and free resources.
  59027. */
  59028. dispose(): void;
  59029. /**
  59030. * Gets the class name of the effect layer
  59031. * @returns the string with the class name of the effect layer
  59032. */
  59033. getClassName(): string;
  59034. /**
  59035. * Creates an effect layer from parsed effect layer data
  59036. * @param parsedEffectLayer defines effect layer data
  59037. * @param scene defines the current scene
  59038. * @param rootUrl defines the root URL containing the effect layer information
  59039. * @returns a parsed effect Layer
  59040. */
  59041. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59042. }
  59043. }
  59044. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59045. import { Scene } from "babylonjs/scene";
  59046. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59047. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59048. import { AbstractScene } from "babylonjs/abstractScene";
  59049. module "babylonjs/abstractScene" {
  59050. interface AbstractScene {
  59051. /**
  59052. * The list of effect layers (highlights/glow) added to the scene
  59053. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59054. * @see http://doc.babylonjs.com/how_to/glow_layer
  59055. */
  59056. effectLayers: Array<EffectLayer>;
  59057. /**
  59058. * Removes the given effect layer from this scene.
  59059. * @param toRemove defines the effect layer to remove
  59060. * @returns the index of the removed effect layer
  59061. */
  59062. removeEffectLayer(toRemove: EffectLayer): number;
  59063. /**
  59064. * Adds the given effect layer to this scene
  59065. * @param newEffectLayer defines the effect layer to add
  59066. */
  59067. addEffectLayer(newEffectLayer: EffectLayer): void;
  59068. }
  59069. }
  59070. /**
  59071. * Defines the layer scene component responsible to manage any effect layers
  59072. * in a given scene.
  59073. */
  59074. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59075. /**
  59076. * The component name helpfull to identify the component in the list of scene components.
  59077. */
  59078. readonly name: string;
  59079. /**
  59080. * The scene the component belongs to.
  59081. */
  59082. scene: Scene;
  59083. private _engine;
  59084. private _renderEffects;
  59085. private _needStencil;
  59086. private _previousStencilState;
  59087. /**
  59088. * Creates a new instance of the component for the given scene
  59089. * @param scene Defines the scene to register the component in
  59090. */
  59091. constructor(scene: Scene);
  59092. /**
  59093. * Registers the component in a given scene
  59094. */
  59095. register(): void;
  59096. /**
  59097. * Rebuilds the elements related to this component in case of
  59098. * context lost for instance.
  59099. */
  59100. rebuild(): void;
  59101. /**
  59102. * Serializes the component data to the specified json object
  59103. * @param serializationObject The object to serialize to
  59104. */
  59105. serialize(serializationObject: any): void;
  59106. /**
  59107. * Adds all the elements from the container to the scene
  59108. * @param container the container holding the elements
  59109. */
  59110. addFromContainer(container: AbstractScene): void;
  59111. /**
  59112. * Removes all the elements in the container from the scene
  59113. * @param container contains the elements to remove
  59114. * @param dispose if the removed element should be disposed (default: false)
  59115. */
  59116. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59117. /**
  59118. * Disposes the component and the associated ressources.
  59119. */
  59120. dispose(): void;
  59121. private _isReadyForMesh;
  59122. private _renderMainTexture;
  59123. private _setStencil;
  59124. private _setStencilBack;
  59125. private _draw;
  59126. private _drawCamera;
  59127. private _drawRenderingGroup;
  59128. }
  59129. }
  59130. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59131. /** @hidden */
  59132. export var glowMapMergePixelShader: {
  59133. name: string;
  59134. shader: string;
  59135. };
  59136. }
  59137. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59138. /** @hidden */
  59139. export var glowMapMergeVertexShader: {
  59140. name: string;
  59141. shader: string;
  59142. };
  59143. }
  59144. declare module "babylonjs/Layers/glowLayer" {
  59145. import { Nullable } from "babylonjs/types";
  59146. import { Camera } from "babylonjs/Cameras/camera";
  59147. import { Scene } from "babylonjs/scene";
  59148. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59150. import { Mesh } from "babylonjs/Meshes/mesh";
  59151. import { Texture } from "babylonjs/Materials/Textures/texture";
  59152. import { Effect } from "babylonjs/Materials/effect";
  59153. import { Material } from "babylonjs/Materials/material";
  59154. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59155. import { Color4 } from "babylonjs/Maths/math.color";
  59156. import "babylonjs/Shaders/glowMapMerge.fragment";
  59157. import "babylonjs/Shaders/glowMapMerge.vertex";
  59158. import "babylonjs/Layers/effectLayerSceneComponent";
  59159. module "babylonjs/abstractScene" {
  59160. interface AbstractScene {
  59161. /**
  59162. * Return a the first highlight layer of the scene with a given name.
  59163. * @param name The name of the highlight layer to look for.
  59164. * @return The highlight layer if found otherwise null.
  59165. */
  59166. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59167. }
  59168. }
  59169. /**
  59170. * Glow layer options. This helps customizing the behaviour
  59171. * of the glow layer.
  59172. */
  59173. export interface IGlowLayerOptions {
  59174. /**
  59175. * Multiplication factor apply to the canvas size to compute the render target size
  59176. * used to generated the glowing objects (the smaller the faster).
  59177. */
  59178. mainTextureRatio: number;
  59179. /**
  59180. * Enforces a fixed size texture to ensure resize independant blur.
  59181. */
  59182. mainTextureFixedSize?: number;
  59183. /**
  59184. * How big is the kernel of the blur texture.
  59185. */
  59186. blurKernelSize: number;
  59187. /**
  59188. * The camera attached to the layer.
  59189. */
  59190. camera: Nullable<Camera>;
  59191. /**
  59192. * Enable MSAA by chosing the number of samples.
  59193. */
  59194. mainTextureSamples?: number;
  59195. /**
  59196. * The rendering group to draw the layer in.
  59197. */
  59198. renderingGroupId: number;
  59199. }
  59200. /**
  59201. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59202. *
  59203. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59204. *
  59205. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59206. */
  59207. export class GlowLayer extends EffectLayer {
  59208. /**
  59209. * Effect Name of the layer.
  59210. */
  59211. static readonly EffectName: string;
  59212. /**
  59213. * The default blur kernel size used for the glow.
  59214. */
  59215. static DefaultBlurKernelSize: number;
  59216. /**
  59217. * The default texture size ratio used for the glow.
  59218. */
  59219. static DefaultTextureRatio: number;
  59220. /**
  59221. * Sets the kernel size of the blur.
  59222. */
  59223. set blurKernelSize(value: number);
  59224. /**
  59225. * Gets the kernel size of the blur.
  59226. */
  59227. get blurKernelSize(): number;
  59228. /**
  59229. * Sets the glow intensity.
  59230. */
  59231. set intensity(value: number);
  59232. /**
  59233. * Gets the glow intensity.
  59234. */
  59235. get intensity(): number;
  59236. private _options;
  59237. private _intensity;
  59238. private _horizontalBlurPostprocess1;
  59239. private _verticalBlurPostprocess1;
  59240. private _horizontalBlurPostprocess2;
  59241. private _verticalBlurPostprocess2;
  59242. private _blurTexture1;
  59243. private _blurTexture2;
  59244. private _postProcesses1;
  59245. private _postProcesses2;
  59246. private _includedOnlyMeshes;
  59247. private _excludedMeshes;
  59248. private _meshesUsingTheirOwnMaterials;
  59249. /**
  59250. * Callback used to let the user override the color selection on a per mesh basis
  59251. */
  59252. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59253. /**
  59254. * Callback used to let the user override the texture selection on a per mesh basis
  59255. */
  59256. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59257. /**
  59258. * Instantiates a new glow Layer and references it to the scene.
  59259. * @param name The name of the layer
  59260. * @param scene The scene to use the layer in
  59261. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59262. */
  59263. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59264. /**
  59265. * Get the effect name of the layer.
  59266. * @return The effect name
  59267. */
  59268. getEffectName(): string;
  59269. /**
  59270. * Create the merge effect. This is the shader use to blit the information back
  59271. * to the main canvas at the end of the scene rendering.
  59272. */
  59273. protected _createMergeEffect(): Effect;
  59274. /**
  59275. * Creates the render target textures and post processes used in the glow layer.
  59276. */
  59277. protected _createTextureAndPostProcesses(): void;
  59278. /**
  59279. * Checks for the readiness of the element composing the layer.
  59280. * @param subMesh the mesh to check for
  59281. * @param useInstances specify wether or not to use instances to render the mesh
  59282. * @param emissiveTexture the associated emissive texture used to generate the glow
  59283. * @return true if ready otherwise, false
  59284. */
  59285. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59286. /**
  59287. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59288. */
  59289. needStencil(): boolean;
  59290. /**
  59291. * Returns true if the mesh can be rendered, otherwise false.
  59292. * @param mesh The mesh to render
  59293. * @param material The material used on the mesh
  59294. * @returns true if it can be rendered otherwise false
  59295. */
  59296. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59297. /**
  59298. * Implementation specific of rendering the generating effect on the main canvas.
  59299. * @param effect The effect used to render through
  59300. */
  59301. protected _internalRender(effect: Effect): void;
  59302. /**
  59303. * Sets the required values for both the emissive texture and and the main color.
  59304. */
  59305. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59306. /**
  59307. * Returns true if the mesh should render, otherwise false.
  59308. * @param mesh The mesh to render
  59309. * @returns true if it should render otherwise false
  59310. */
  59311. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59312. /**
  59313. * Adds specific effects defines.
  59314. * @param defines The defines to add specifics to.
  59315. */
  59316. protected _addCustomEffectDefines(defines: string[]): void;
  59317. /**
  59318. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59319. * @param mesh The mesh to exclude from the glow layer
  59320. */
  59321. addExcludedMesh(mesh: Mesh): void;
  59322. /**
  59323. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59324. * @param mesh The mesh to remove
  59325. */
  59326. removeExcludedMesh(mesh: Mesh): void;
  59327. /**
  59328. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59329. * @param mesh The mesh to include in the glow layer
  59330. */
  59331. addIncludedOnlyMesh(mesh: Mesh): void;
  59332. /**
  59333. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59334. * @param mesh The mesh to remove
  59335. */
  59336. removeIncludedOnlyMesh(mesh: Mesh): void;
  59337. /**
  59338. * Determine if a given mesh will be used in the glow layer
  59339. * @param mesh The mesh to test
  59340. * @returns true if the mesh will be highlighted by the current glow layer
  59341. */
  59342. hasMesh(mesh: AbstractMesh): boolean;
  59343. /**
  59344. * Defines whether the current material of the mesh should be use to render the effect.
  59345. * @param mesh defines the current mesh to render
  59346. */
  59347. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59348. /**
  59349. * Add a mesh to be rendered through its own material and not with emissive only.
  59350. * @param mesh The mesh for which we need to use its material
  59351. */
  59352. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59353. /**
  59354. * Remove a mesh from being rendered through its own material and not with emissive only.
  59355. * @param mesh The mesh for which we need to not use its material
  59356. */
  59357. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59358. /**
  59359. * Free any resources and references associated to a mesh.
  59360. * Internal use
  59361. * @param mesh The mesh to free.
  59362. * @hidden
  59363. */
  59364. _disposeMesh(mesh: Mesh): void;
  59365. /**
  59366. * Gets the class name of the effect layer
  59367. * @returns the string with the class name of the effect layer
  59368. */
  59369. getClassName(): string;
  59370. /**
  59371. * Serializes this glow layer
  59372. * @returns a serialized glow layer object
  59373. */
  59374. serialize(): any;
  59375. /**
  59376. * Creates a Glow Layer from parsed glow layer data
  59377. * @param parsedGlowLayer defines glow layer data
  59378. * @param scene defines the current scene
  59379. * @param rootUrl defines the root URL containing the glow layer information
  59380. * @returns a parsed Glow Layer
  59381. */
  59382. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59383. }
  59384. }
  59385. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59386. /** @hidden */
  59387. export var glowBlurPostProcessPixelShader: {
  59388. name: string;
  59389. shader: string;
  59390. };
  59391. }
  59392. declare module "babylonjs/Layers/highlightLayer" {
  59393. import { Observable } from "babylonjs/Misc/observable";
  59394. import { Nullable } from "babylonjs/types";
  59395. import { Camera } from "babylonjs/Cameras/camera";
  59396. import { Scene } from "babylonjs/scene";
  59397. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59399. import { Mesh } from "babylonjs/Meshes/mesh";
  59400. import { Effect } from "babylonjs/Materials/effect";
  59401. import { Material } from "babylonjs/Materials/material";
  59402. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59403. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59404. import "babylonjs/Shaders/glowMapMerge.fragment";
  59405. import "babylonjs/Shaders/glowMapMerge.vertex";
  59406. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59407. module "babylonjs/abstractScene" {
  59408. interface AbstractScene {
  59409. /**
  59410. * Return a the first highlight layer of the scene with a given name.
  59411. * @param name The name of the highlight layer to look for.
  59412. * @return The highlight layer if found otherwise null.
  59413. */
  59414. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59415. }
  59416. }
  59417. /**
  59418. * Highlight layer options. This helps customizing the behaviour
  59419. * of the highlight layer.
  59420. */
  59421. export interface IHighlightLayerOptions {
  59422. /**
  59423. * Multiplication factor apply to the canvas size to compute the render target size
  59424. * used to generated the glowing objects (the smaller the faster).
  59425. */
  59426. mainTextureRatio: number;
  59427. /**
  59428. * Enforces a fixed size texture to ensure resize independant blur.
  59429. */
  59430. mainTextureFixedSize?: number;
  59431. /**
  59432. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59433. * of the picture to blur (the smaller the faster).
  59434. */
  59435. blurTextureSizeRatio: number;
  59436. /**
  59437. * How big in texel of the blur texture is the vertical blur.
  59438. */
  59439. blurVerticalSize: number;
  59440. /**
  59441. * How big in texel of the blur texture is the horizontal blur.
  59442. */
  59443. blurHorizontalSize: number;
  59444. /**
  59445. * Alpha blending mode used to apply the blur. Default is combine.
  59446. */
  59447. alphaBlendingMode: number;
  59448. /**
  59449. * The camera attached to the layer.
  59450. */
  59451. camera: Nullable<Camera>;
  59452. /**
  59453. * Should we display highlight as a solid stroke?
  59454. */
  59455. isStroke?: boolean;
  59456. /**
  59457. * The rendering group to draw the layer in.
  59458. */
  59459. renderingGroupId: number;
  59460. }
  59461. /**
  59462. * The highlight layer Helps adding a glow effect around a mesh.
  59463. *
  59464. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59465. * glowy meshes to your scene.
  59466. *
  59467. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59468. */
  59469. export class HighlightLayer extends EffectLayer {
  59470. name: string;
  59471. /**
  59472. * Effect Name of the highlight layer.
  59473. */
  59474. static readonly EffectName: string;
  59475. /**
  59476. * The neutral color used during the preparation of the glow effect.
  59477. * This is black by default as the blend operation is a blend operation.
  59478. */
  59479. static NeutralColor: Color4;
  59480. /**
  59481. * Stencil value used for glowing meshes.
  59482. */
  59483. static GlowingMeshStencilReference: number;
  59484. /**
  59485. * Stencil value used for the other meshes in the scene.
  59486. */
  59487. static NormalMeshStencilReference: number;
  59488. /**
  59489. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59490. */
  59491. innerGlow: boolean;
  59492. /**
  59493. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59494. */
  59495. outerGlow: boolean;
  59496. /**
  59497. * Specifies the horizontal size of the blur.
  59498. */
  59499. set blurHorizontalSize(value: number);
  59500. /**
  59501. * Specifies the vertical size of the blur.
  59502. */
  59503. set blurVerticalSize(value: number);
  59504. /**
  59505. * Gets the horizontal size of the blur.
  59506. */
  59507. get blurHorizontalSize(): number;
  59508. /**
  59509. * Gets the vertical size of the blur.
  59510. */
  59511. get blurVerticalSize(): number;
  59512. /**
  59513. * An event triggered when the highlight layer is being blurred.
  59514. */
  59515. onBeforeBlurObservable: Observable<HighlightLayer>;
  59516. /**
  59517. * An event triggered when the highlight layer has been blurred.
  59518. */
  59519. onAfterBlurObservable: Observable<HighlightLayer>;
  59520. private _instanceGlowingMeshStencilReference;
  59521. private _options;
  59522. private _downSamplePostprocess;
  59523. private _horizontalBlurPostprocess;
  59524. private _verticalBlurPostprocess;
  59525. private _blurTexture;
  59526. private _meshes;
  59527. private _excludedMeshes;
  59528. /**
  59529. * Instantiates a new highlight Layer and references it to the scene..
  59530. * @param name The name of the layer
  59531. * @param scene The scene to use the layer in
  59532. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59533. */
  59534. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59535. /**
  59536. * Get the effect name of the layer.
  59537. * @return The effect name
  59538. */
  59539. getEffectName(): string;
  59540. /**
  59541. * Create the merge effect. This is the shader use to blit the information back
  59542. * to the main canvas at the end of the scene rendering.
  59543. */
  59544. protected _createMergeEffect(): Effect;
  59545. /**
  59546. * Creates the render target textures and post processes used in the highlight layer.
  59547. */
  59548. protected _createTextureAndPostProcesses(): void;
  59549. /**
  59550. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59551. */
  59552. needStencil(): boolean;
  59553. /**
  59554. * Checks for the readiness of the element composing the layer.
  59555. * @param subMesh the mesh to check for
  59556. * @param useInstances specify wether or not to use instances to render the mesh
  59557. * @param emissiveTexture the associated emissive texture used to generate the glow
  59558. * @return true if ready otherwise, false
  59559. */
  59560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59561. /**
  59562. * Implementation specific of rendering the generating effect on the main canvas.
  59563. * @param effect The effect used to render through
  59564. */
  59565. protected _internalRender(effect: Effect): void;
  59566. /**
  59567. * Returns true if the layer contains information to display, otherwise false.
  59568. */
  59569. shouldRender(): boolean;
  59570. /**
  59571. * Returns true if the mesh should render, otherwise false.
  59572. * @param mesh The mesh to render
  59573. * @returns true if it should render otherwise false
  59574. */
  59575. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59576. /**
  59577. * Adds specific effects defines.
  59578. * @param defines The defines to add specifics to.
  59579. */
  59580. protected _addCustomEffectDefines(defines: string[]): void;
  59581. /**
  59582. * Sets the required values for both the emissive texture and and the main color.
  59583. */
  59584. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59585. /**
  59586. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59587. * @param mesh The mesh to exclude from the highlight layer
  59588. */
  59589. addExcludedMesh(mesh: Mesh): void;
  59590. /**
  59591. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59592. * @param mesh The mesh to highlight
  59593. */
  59594. removeExcludedMesh(mesh: Mesh): void;
  59595. /**
  59596. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59597. * @param mesh mesh to test
  59598. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59599. */
  59600. hasMesh(mesh: AbstractMesh): boolean;
  59601. /**
  59602. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59603. * @param mesh The mesh to highlight
  59604. * @param color The color of the highlight
  59605. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59606. */
  59607. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59608. /**
  59609. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59610. * @param mesh The mesh to highlight
  59611. */
  59612. removeMesh(mesh: Mesh): void;
  59613. /**
  59614. * Remove all the meshes currently referenced in the highlight layer
  59615. */
  59616. removeAllMeshes(): void;
  59617. /**
  59618. * Force the stencil to the normal expected value for none glowing parts
  59619. */
  59620. private _defaultStencilReference;
  59621. /**
  59622. * Free any resources and references associated to a mesh.
  59623. * Internal use
  59624. * @param mesh The mesh to free.
  59625. * @hidden
  59626. */
  59627. _disposeMesh(mesh: Mesh): void;
  59628. /**
  59629. * Dispose the highlight layer and free resources.
  59630. */
  59631. dispose(): void;
  59632. /**
  59633. * Gets the class name of the effect layer
  59634. * @returns the string with the class name of the effect layer
  59635. */
  59636. getClassName(): string;
  59637. /**
  59638. * Serializes this Highlight layer
  59639. * @returns a serialized Highlight layer object
  59640. */
  59641. serialize(): any;
  59642. /**
  59643. * Creates a Highlight layer from parsed Highlight layer data
  59644. * @param parsedHightlightLayer defines the Highlight layer data
  59645. * @param scene defines the current scene
  59646. * @param rootUrl defines the root URL containing the Highlight layer information
  59647. * @returns a parsed Highlight layer
  59648. */
  59649. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59650. }
  59651. }
  59652. declare module "babylonjs/Layers/layerSceneComponent" {
  59653. import { Scene } from "babylonjs/scene";
  59654. import { ISceneComponent } from "babylonjs/sceneComponent";
  59655. import { Layer } from "babylonjs/Layers/layer";
  59656. import { AbstractScene } from "babylonjs/abstractScene";
  59657. module "babylonjs/abstractScene" {
  59658. interface AbstractScene {
  59659. /**
  59660. * The list of layers (background and foreground) of the scene
  59661. */
  59662. layers: Array<Layer>;
  59663. }
  59664. }
  59665. /**
  59666. * Defines the layer scene component responsible to manage any layers
  59667. * in a given scene.
  59668. */
  59669. export class LayerSceneComponent implements ISceneComponent {
  59670. /**
  59671. * The component name helpfull to identify the component in the list of scene components.
  59672. */
  59673. readonly name: string;
  59674. /**
  59675. * The scene the component belongs to.
  59676. */
  59677. scene: Scene;
  59678. private _engine;
  59679. /**
  59680. * Creates a new instance of the component for the given scene
  59681. * @param scene Defines the scene to register the component in
  59682. */
  59683. constructor(scene: Scene);
  59684. /**
  59685. * Registers the component in a given scene
  59686. */
  59687. register(): void;
  59688. /**
  59689. * Rebuilds the elements related to this component in case of
  59690. * context lost for instance.
  59691. */
  59692. rebuild(): void;
  59693. /**
  59694. * Disposes the component and the associated ressources.
  59695. */
  59696. dispose(): void;
  59697. private _draw;
  59698. private _drawCameraPredicate;
  59699. private _drawCameraBackground;
  59700. private _drawCameraForeground;
  59701. private _drawRenderTargetPredicate;
  59702. private _drawRenderTargetBackground;
  59703. private _drawRenderTargetForeground;
  59704. /**
  59705. * Adds all the elements from the container to the scene
  59706. * @param container the container holding the elements
  59707. */
  59708. addFromContainer(container: AbstractScene): void;
  59709. /**
  59710. * Removes all the elements in the container from the scene
  59711. * @param container contains the elements to remove
  59712. * @param dispose if the removed element should be disposed (default: false)
  59713. */
  59714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59715. }
  59716. }
  59717. declare module "babylonjs/Shaders/layer.fragment" {
  59718. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59719. /** @hidden */
  59720. export var layerPixelShader: {
  59721. name: string;
  59722. shader: string;
  59723. };
  59724. }
  59725. declare module "babylonjs/Shaders/layer.vertex" {
  59726. /** @hidden */
  59727. export var layerVertexShader: {
  59728. name: string;
  59729. shader: string;
  59730. };
  59731. }
  59732. declare module "babylonjs/Layers/layer" {
  59733. import { Observable } from "babylonjs/Misc/observable";
  59734. import { Nullable } from "babylonjs/types";
  59735. import { Scene } from "babylonjs/scene";
  59736. import { Vector2 } from "babylonjs/Maths/math.vector";
  59737. import { Color4 } from "babylonjs/Maths/math.color";
  59738. import { Texture } from "babylonjs/Materials/Textures/texture";
  59739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59740. import "babylonjs/Shaders/layer.fragment";
  59741. import "babylonjs/Shaders/layer.vertex";
  59742. /**
  59743. * This represents a full screen 2d layer.
  59744. * This can be useful to display a picture in the background of your scene for instance.
  59745. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59746. */
  59747. export class Layer {
  59748. /**
  59749. * Define the name of the layer.
  59750. */
  59751. name: string;
  59752. /**
  59753. * Define the texture the layer should display.
  59754. */
  59755. texture: Nullable<Texture>;
  59756. /**
  59757. * Is the layer in background or foreground.
  59758. */
  59759. isBackground: boolean;
  59760. /**
  59761. * Define the color of the layer (instead of texture).
  59762. */
  59763. color: Color4;
  59764. /**
  59765. * Define the scale of the layer in order to zoom in out of the texture.
  59766. */
  59767. scale: Vector2;
  59768. /**
  59769. * Define an offset for the layer in order to shift the texture.
  59770. */
  59771. offset: Vector2;
  59772. /**
  59773. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59774. */
  59775. alphaBlendingMode: number;
  59776. /**
  59777. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59778. * Alpha test will not mix with the background color in case of transparency.
  59779. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59780. */
  59781. alphaTest: boolean;
  59782. /**
  59783. * Define a mask to restrict the layer to only some of the scene cameras.
  59784. */
  59785. layerMask: number;
  59786. /**
  59787. * Define the list of render target the layer is visible into.
  59788. */
  59789. renderTargetTextures: RenderTargetTexture[];
  59790. /**
  59791. * Define if the layer is only used in renderTarget or if it also
  59792. * renders in the main frame buffer of the canvas.
  59793. */
  59794. renderOnlyInRenderTargetTextures: boolean;
  59795. private _scene;
  59796. private _vertexBuffers;
  59797. private _indexBuffer;
  59798. private _effect;
  59799. private _previousDefines;
  59800. /**
  59801. * An event triggered when the layer is disposed.
  59802. */
  59803. onDisposeObservable: Observable<Layer>;
  59804. private _onDisposeObserver;
  59805. /**
  59806. * Back compatibility with callback before the onDisposeObservable existed.
  59807. * The set callback will be triggered when the layer has been disposed.
  59808. */
  59809. set onDispose(callback: () => void);
  59810. /**
  59811. * An event triggered before rendering the scene
  59812. */
  59813. onBeforeRenderObservable: Observable<Layer>;
  59814. private _onBeforeRenderObserver;
  59815. /**
  59816. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59817. * The set callback will be triggered just before rendering the layer.
  59818. */
  59819. set onBeforeRender(callback: () => void);
  59820. /**
  59821. * An event triggered after rendering the scene
  59822. */
  59823. onAfterRenderObservable: Observable<Layer>;
  59824. private _onAfterRenderObserver;
  59825. /**
  59826. * Back compatibility with callback before the onAfterRenderObservable existed.
  59827. * The set callback will be triggered just after rendering the layer.
  59828. */
  59829. set onAfterRender(callback: () => void);
  59830. /**
  59831. * Instantiates a new layer.
  59832. * This represents a full screen 2d layer.
  59833. * This can be useful to display a picture in the background of your scene for instance.
  59834. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59835. * @param name Define the name of the layer in the scene
  59836. * @param imgUrl Define the url of the texture to display in the layer
  59837. * @param scene Define the scene the layer belongs to
  59838. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59839. * @param color Defines a color for the layer
  59840. */
  59841. constructor(
  59842. /**
  59843. * Define the name of the layer.
  59844. */
  59845. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59846. private _createIndexBuffer;
  59847. /** @hidden */
  59848. _rebuild(): void;
  59849. /**
  59850. * Renders the layer in the scene.
  59851. */
  59852. render(): void;
  59853. /**
  59854. * Disposes and releases the associated ressources.
  59855. */
  59856. dispose(): void;
  59857. }
  59858. }
  59859. declare module "babylonjs/Layers/index" {
  59860. export * from "babylonjs/Layers/effectLayer";
  59861. export * from "babylonjs/Layers/effectLayerSceneComponent";
  59862. export * from "babylonjs/Layers/glowLayer";
  59863. export * from "babylonjs/Layers/highlightLayer";
  59864. export * from "babylonjs/Layers/layer";
  59865. export * from "babylonjs/Layers/layerSceneComponent";
  59866. }
  59867. declare module "babylonjs/Shaders/lensFlare.fragment" {
  59868. /** @hidden */
  59869. export var lensFlarePixelShader: {
  59870. name: string;
  59871. shader: string;
  59872. };
  59873. }
  59874. declare module "babylonjs/Shaders/lensFlare.vertex" {
  59875. /** @hidden */
  59876. export var lensFlareVertexShader: {
  59877. name: string;
  59878. shader: string;
  59879. };
  59880. }
  59881. declare module "babylonjs/LensFlares/lensFlareSystem" {
  59882. import { Scene } from "babylonjs/scene";
  59883. import { Vector3 } from "babylonjs/Maths/math.vector";
  59884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59885. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  59886. import "babylonjs/Shaders/lensFlare.fragment";
  59887. import "babylonjs/Shaders/lensFlare.vertex";
  59888. import { Viewport } from "babylonjs/Maths/math.viewport";
  59889. /**
  59890. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59891. * It is usually composed of several `lensFlare`.
  59892. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59893. */
  59894. export class LensFlareSystem {
  59895. /**
  59896. * Define the name of the lens flare system
  59897. */
  59898. name: string;
  59899. /**
  59900. * List of lens flares used in this system.
  59901. */
  59902. lensFlares: LensFlare[];
  59903. /**
  59904. * Define a limit from the border the lens flare can be visible.
  59905. */
  59906. borderLimit: number;
  59907. /**
  59908. * Define a viewport border we do not want to see the lens flare in.
  59909. */
  59910. viewportBorder: number;
  59911. /**
  59912. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59913. */
  59914. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59915. /**
  59916. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59917. */
  59918. layerMask: number;
  59919. /**
  59920. * Define the id of the lens flare system in the scene.
  59921. * (equal to name by default)
  59922. */
  59923. id: string;
  59924. private _scene;
  59925. private _emitter;
  59926. private _vertexBuffers;
  59927. private _indexBuffer;
  59928. private _effect;
  59929. private _positionX;
  59930. private _positionY;
  59931. private _isEnabled;
  59932. /** @hidden */
  59933. static _SceneComponentInitialization: (scene: Scene) => void;
  59934. /**
  59935. * Instantiates a lens flare system.
  59936. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59937. * It is usually composed of several `lensFlare`.
  59938. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59939. * @param name Define the name of the lens flare system in the scene
  59940. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59941. * @param scene Define the scene the lens flare system belongs to
  59942. */
  59943. constructor(
  59944. /**
  59945. * Define the name of the lens flare system
  59946. */
  59947. name: string, emitter: any, scene: Scene);
  59948. /**
  59949. * Define if the lens flare system is enabled.
  59950. */
  59951. get isEnabled(): boolean;
  59952. set isEnabled(value: boolean);
  59953. /**
  59954. * Get the scene the effects belongs to.
  59955. * @returns the scene holding the lens flare system
  59956. */
  59957. getScene(): Scene;
  59958. /**
  59959. * Get the emitter of the lens flare system.
  59960. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59961. * @returns the emitter of the lens flare system
  59962. */
  59963. getEmitter(): any;
  59964. /**
  59965. * Set the emitter of the lens flare system.
  59966. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59967. * @param newEmitter Define the new emitter of the system
  59968. */
  59969. setEmitter(newEmitter: any): void;
  59970. /**
  59971. * Get the lens flare system emitter position.
  59972. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59973. * @returns the position
  59974. */
  59975. getEmitterPosition(): Vector3;
  59976. /**
  59977. * @hidden
  59978. */
  59979. computeEffectivePosition(globalViewport: Viewport): boolean;
  59980. /** @hidden */
  59981. _isVisible(): boolean;
  59982. /**
  59983. * @hidden
  59984. */
  59985. render(): boolean;
  59986. /**
  59987. * Dispose and release the lens flare with its associated resources.
  59988. */
  59989. dispose(): void;
  59990. /**
  59991. * Parse a lens flare system from a JSON repressentation
  59992. * @param parsedLensFlareSystem Define the JSON to parse
  59993. * @param scene Define the scene the parsed system should be instantiated in
  59994. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59995. * @returns the parsed system
  59996. */
  59997. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59998. /**
  59999. * Serialize the current Lens Flare System into a JSON representation.
  60000. * @returns the serialized JSON
  60001. */
  60002. serialize(): any;
  60003. }
  60004. }
  60005. declare module "babylonjs/LensFlares/lensFlare" {
  60006. import { Nullable } from "babylonjs/types";
  60007. import { Color3 } from "babylonjs/Maths/math.color";
  60008. import { Texture } from "babylonjs/Materials/Textures/texture";
  60009. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60010. /**
  60011. * This represents one of the lens effect in a `lensFlareSystem`.
  60012. * It controls one of the indiviual texture used in the effect.
  60013. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60014. */
  60015. export class LensFlare {
  60016. /**
  60017. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60018. */
  60019. size: number;
  60020. /**
  60021. * 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.
  60022. */
  60023. position: number;
  60024. /**
  60025. * Define the lens color.
  60026. */
  60027. color: Color3;
  60028. /**
  60029. * Define the lens texture.
  60030. */
  60031. texture: Nullable<Texture>;
  60032. /**
  60033. * Define the alpha mode to render this particular lens.
  60034. */
  60035. alphaMode: number;
  60036. private _system;
  60037. /**
  60038. * Creates a new Lens Flare.
  60039. * This represents one of the lens effect in a `lensFlareSystem`.
  60040. * It controls one of the indiviual texture used in the effect.
  60041. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60042. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60043. * @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.
  60044. * @param color Define the lens color
  60045. * @param imgUrl Define the lens texture url
  60046. * @param system Define the `lensFlareSystem` this flare is part of
  60047. * @returns The newly created Lens Flare
  60048. */
  60049. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60050. /**
  60051. * Instantiates a new Lens Flare.
  60052. * This represents one of the lens effect in a `lensFlareSystem`.
  60053. * It controls one of the indiviual texture used in the effect.
  60054. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60055. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60056. * @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.
  60057. * @param color Define the lens color
  60058. * @param imgUrl Define the lens texture url
  60059. * @param system Define the `lensFlareSystem` this flare is part of
  60060. */
  60061. constructor(
  60062. /**
  60063. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60064. */
  60065. size: number,
  60066. /**
  60067. * 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.
  60068. */
  60069. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60070. /**
  60071. * Dispose and release the lens flare with its associated resources.
  60072. */
  60073. dispose(): void;
  60074. }
  60075. }
  60076. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60077. import { Nullable } from "babylonjs/types";
  60078. import { Scene } from "babylonjs/scene";
  60079. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60080. import { AbstractScene } from "babylonjs/abstractScene";
  60081. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60082. module "babylonjs/abstractScene" {
  60083. interface AbstractScene {
  60084. /**
  60085. * The list of lens flare system added to the scene
  60086. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60087. */
  60088. lensFlareSystems: Array<LensFlareSystem>;
  60089. /**
  60090. * Removes the given lens flare system from this scene.
  60091. * @param toRemove The lens flare system to remove
  60092. * @returns The index of the removed lens flare system
  60093. */
  60094. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60095. /**
  60096. * Adds the given lens flare system to this scene
  60097. * @param newLensFlareSystem The lens flare system to add
  60098. */
  60099. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60100. /**
  60101. * Gets a lens flare system using its name
  60102. * @param name defines the name to look for
  60103. * @returns the lens flare system or null if not found
  60104. */
  60105. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60106. /**
  60107. * Gets a lens flare system using its id
  60108. * @param id defines the id to look for
  60109. * @returns the lens flare system or null if not found
  60110. */
  60111. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60112. }
  60113. }
  60114. /**
  60115. * Defines the lens flare scene component responsible to manage any lens flares
  60116. * in a given scene.
  60117. */
  60118. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60119. /**
  60120. * The component name helpfull to identify the component in the list of scene components.
  60121. */
  60122. readonly name: string;
  60123. /**
  60124. * The scene the component belongs to.
  60125. */
  60126. scene: Scene;
  60127. /**
  60128. * Creates a new instance of the component for the given scene
  60129. * @param scene Defines the scene to register the component in
  60130. */
  60131. constructor(scene: Scene);
  60132. /**
  60133. * Registers the component in a given scene
  60134. */
  60135. register(): void;
  60136. /**
  60137. * Rebuilds the elements related to this component in case of
  60138. * context lost for instance.
  60139. */
  60140. rebuild(): void;
  60141. /**
  60142. * Adds all the elements from the container to the scene
  60143. * @param container the container holding the elements
  60144. */
  60145. addFromContainer(container: AbstractScene): void;
  60146. /**
  60147. * Removes all the elements in the container from the scene
  60148. * @param container contains the elements to remove
  60149. * @param dispose if the removed element should be disposed (default: false)
  60150. */
  60151. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60152. /**
  60153. * Serializes the component data to the specified json object
  60154. * @param serializationObject The object to serialize to
  60155. */
  60156. serialize(serializationObject: any): void;
  60157. /**
  60158. * Disposes the component and the associated ressources.
  60159. */
  60160. dispose(): void;
  60161. private _draw;
  60162. }
  60163. }
  60164. declare module "babylonjs/LensFlares/index" {
  60165. export * from "babylonjs/LensFlares/lensFlare";
  60166. export * from "babylonjs/LensFlares/lensFlareSystem";
  60167. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60168. }
  60169. declare module "babylonjs/Shaders/depth.fragment" {
  60170. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60171. /** @hidden */
  60172. export var depthPixelShader: {
  60173. name: string;
  60174. shader: string;
  60175. };
  60176. }
  60177. declare module "babylonjs/Shaders/depth.vertex" {
  60178. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60179. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60180. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60181. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60182. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60183. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60184. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60185. /** @hidden */
  60186. export var depthVertexShader: {
  60187. name: string;
  60188. shader: string;
  60189. };
  60190. }
  60191. declare module "babylonjs/Rendering/depthRenderer" {
  60192. import { Nullable } from "babylonjs/types";
  60193. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60194. import { Scene } from "babylonjs/scene";
  60195. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60196. import { Camera } from "babylonjs/Cameras/camera";
  60197. import "babylonjs/Shaders/depth.fragment";
  60198. import "babylonjs/Shaders/depth.vertex";
  60199. /**
  60200. * This represents a depth renderer in Babylon.
  60201. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60202. */
  60203. export class DepthRenderer {
  60204. private _scene;
  60205. private _depthMap;
  60206. private _effect;
  60207. private readonly _storeNonLinearDepth;
  60208. private readonly _clearColor;
  60209. /** Get if the depth renderer is using packed depth or not */
  60210. readonly isPacked: boolean;
  60211. private _cachedDefines;
  60212. private _camera;
  60213. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60214. enabled: boolean;
  60215. /**
  60216. * Specifiess that the depth renderer will only be used within
  60217. * the camera it is created for.
  60218. * This can help forcing its rendering during the camera processing.
  60219. */
  60220. useOnlyInActiveCamera: boolean;
  60221. /** @hidden */
  60222. static _SceneComponentInitialization: (scene: Scene) => void;
  60223. /**
  60224. * Instantiates a depth renderer
  60225. * @param scene The scene the renderer belongs to
  60226. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60227. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60228. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60229. */
  60230. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60231. /**
  60232. * Creates the depth rendering effect and checks if the effect is ready.
  60233. * @param subMesh The submesh to be used to render the depth map of
  60234. * @param useInstances If multiple world instances should be used
  60235. * @returns if the depth renderer is ready to render the depth map
  60236. */
  60237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60238. /**
  60239. * Gets the texture which the depth map will be written to.
  60240. * @returns The depth map texture
  60241. */
  60242. getDepthMap(): RenderTargetTexture;
  60243. /**
  60244. * Disposes of the depth renderer.
  60245. */
  60246. dispose(): void;
  60247. }
  60248. }
  60249. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60250. /** @hidden */
  60251. export var minmaxReduxPixelShader: {
  60252. name: string;
  60253. shader: string;
  60254. };
  60255. }
  60256. declare module "babylonjs/Misc/minMaxReducer" {
  60257. import { Nullable } from "babylonjs/types";
  60258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60259. import { Camera } from "babylonjs/Cameras/camera";
  60260. import { Observer } from "babylonjs/Misc/observable";
  60261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60262. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60263. import { Observable } from "babylonjs/Misc/observable";
  60264. import "babylonjs/Shaders/minmaxRedux.fragment";
  60265. /**
  60266. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60267. * and maximum values from all values of the texture.
  60268. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60269. * The source values are read from the red channel of the texture.
  60270. */
  60271. export class MinMaxReducer {
  60272. /**
  60273. * Observable triggered when the computation has been performed
  60274. */
  60275. onAfterReductionPerformed: Observable<{
  60276. min: number;
  60277. max: number;
  60278. }>;
  60279. protected _camera: Camera;
  60280. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60281. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60282. protected _postProcessManager: PostProcessManager;
  60283. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60284. protected _forceFullscreenViewport: boolean;
  60285. /**
  60286. * Creates a min/max reducer
  60287. * @param camera The camera to use for the post processes
  60288. */
  60289. constructor(camera: Camera);
  60290. /**
  60291. * Gets the texture used to read the values from.
  60292. */
  60293. get sourceTexture(): Nullable<RenderTargetTexture>;
  60294. /**
  60295. * Sets the source texture to read the values from.
  60296. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60297. * because in such textures '1' value must not be taken into account to compute the maximum
  60298. * as this value is used to clear the texture.
  60299. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60300. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60301. * @param depthRedux Indicates if the texture is a depth texture or not
  60302. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60303. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60304. */
  60305. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60306. /**
  60307. * Defines the refresh rate of the computation.
  60308. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60309. */
  60310. get refreshRate(): number;
  60311. set refreshRate(value: number);
  60312. protected _activated: boolean;
  60313. /**
  60314. * Gets the activation status of the reducer
  60315. */
  60316. get activated(): boolean;
  60317. /**
  60318. * Activates the reduction computation.
  60319. * When activated, the observers registered in onAfterReductionPerformed are
  60320. * called after the compuation is performed
  60321. */
  60322. activate(): void;
  60323. /**
  60324. * Deactivates the reduction computation.
  60325. */
  60326. deactivate(): void;
  60327. /**
  60328. * Disposes the min/max reducer
  60329. * @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.
  60330. */
  60331. dispose(disposeAll?: boolean): void;
  60332. }
  60333. }
  60334. declare module "babylonjs/Misc/depthReducer" {
  60335. import { Nullable } from "babylonjs/types";
  60336. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60337. import { Camera } from "babylonjs/Cameras/camera";
  60338. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60339. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60340. /**
  60341. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60342. */
  60343. export class DepthReducer extends MinMaxReducer {
  60344. private _depthRenderer;
  60345. private _depthRendererId;
  60346. /**
  60347. * Gets the depth renderer used for the computation.
  60348. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60349. */
  60350. get depthRenderer(): Nullable<DepthRenderer>;
  60351. /**
  60352. * Creates a depth reducer
  60353. * @param camera The camera used to render the depth texture
  60354. */
  60355. constructor(camera: Camera);
  60356. /**
  60357. * Sets the depth renderer to use to generate the depth map
  60358. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60359. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60360. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60361. */
  60362. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60363. /** @hidden */
  60364. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60365. /**
  60366. * Activates the reduction computation.
  60367. * When activated, the observers registered in onAfterReductionPerformed are
  60368. * called after the compuation is performed
  60369. */
  60370. activate(): void;
  60371. /**
  60372. * Deactivates the reduction computation.
  60373. */
  60374. deactivate(): void;
  60375. /**
  60376. * Disposes the depth reducer
  60377. * @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.
  60378. */
  60379. dispose(disposeAll?: boolean): void;
  60380. }
  60381. }
  60382. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60383. import { Nullable } from "babylonjs/types";
  60384. import { Scene } from "babylonjs/scene";
  60385. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60388. import { Effect } from "babylonjs/Materials/effect";
  60389. import "babylonjs/Shaders/shadowMap.fragment";
  60390. import "babylonjs/Shaders/shadowMap.vertex";
  60391. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60392. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60393. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60394. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60395. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60396. /**
  60397. * A CSM implementation allowing casting shadows on large scenes.
  60398. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60399. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60400. */
  60401. export class CascadedShadowGenerator extends ShadowGenerator {
  60402. private static readonly frustumCornersNDCSpace;
  60403. /**
  60404. * Name of the CSM class
  60405. */
  60406. static CLASSNAME: string;
  60407. /**
  60408. * Defines the default number of cascades used by the CSM.
  60409. */
  60410. static readonly DEFAULT_CASCADES_COUNT: number;
  60411. /**
  60412. * Defines the minimum number of cascades used by the CSM.
  60413. */
  60414. static readonly MIN_CASCADES_COUNT: number;
  60415. /**
  60416. * Defines the maximum number of cascades used by the CSM.
  60417. */
  60418. static readonly MAX_CASCADES_COUNT: number;
  60419. protected _validateFilter(filter: number): number;
  60420. /**
  60421. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60422. */
  60423. penumbraDarkness: number;
  60424. private _numCascades;
  60425. /**
  60426. * Gets or set the number of cascades used by the CSM.
  60427. */
  60428. get numCascades(): number;
  60429. set numCascades(value: number);
  60430. /**
  60431. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60432. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60433. */
  60434. stabilizeCascades: boolean;
  60435. private _freezeShadowCastersBoundingInfo;
  60436. private _freezeShadowCastersBoundingInfoObservable;
  60437. /**
  60438. * Enables or disables the shadow casters bounding info computation.
  60439. * If your shadow casters don't move, you can disable this feature.
  60440. * If it is enabled, the bounding box computation is done every frame.
  60441. */
  60442. get freezeShadowCastersBoundingInfo(): boolean;
  60443. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60444. private _scbiMin;
  60445. private _scbiMax;
  60446. protected _computeShadowCastersBoundingInfo(): void;
  60447. protected _shadowCastersBoundingInfo: BoundingInfo;
  60448. /**
  60449. * Gets or sets the shadow casters bounding info.
  60450. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60451. * so that the system won't overwrite the bounds you provide
  60452. */
  60453. get shadowCastersBoundingInfo(): BoundingInfo;
  60454. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60455. protected _breaksAreDirty: boolean;
  60456. protected _minDistance: number;
  60457. protected _maxDistance: number;
  60458. /**
  60459. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60460. *
  60461. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60462. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60463. * @param min minimal distance for the breaks (default to 0.)
  60464. * @param max maximal distance for the breaks (default to 1.)
  60465. */
  60466. setMinMaxDistance(min: number, max: number): void;
  60467. /** Gets the minimal distance used in the cascade break computation */
  60468. get minDistance(): number;
  60469. /** Gets the maximal distance used in the cascade break computation */
  60470. get maxDistance(): number;
  60471. /**
  60472. * Gets the class name of that object
  60473. * @returns "CascadedShadowGenerator"
  60474. */
  60475. getClassName(): string;
  60476. private _cascadeMinExtents;
  60477. private _cascadeMaxExtents;
  60478. /**
  60479. * Gets a cascade minimum extents
  60480. * @param cascadeIndex index of the cascade
  60481. * @returns the minimum cascade extents
  60482. */
  60483. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60484. /**
  60485. * Gets a cascade maximum extents
  60486. * @param cascadeIndex index of the cascade
  60487. * @returns the maximum cascade extents
  60488. */
  60489. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60490. private _cascades;
  60491. private _currentLayer;
  60492. private _viewSpaceFrustumsZ;
  60493. private _viewMatrices;
  60494. private _projectionMatrices;
  60495. private _transformMatrices;
  60496. private _transformMatricesAsArray;
  60497. private _frustumLengths;
  60498. private _lightSizeUVCorrection;
  60499. private _depthCorrection;
  60500. private _frustumCornersWorldSpace;
  60501. private _frustumCenter;
  60502. private _shadowCameraPos;
  60503. private _shadowMaxZ;
  60504. /**
  60505. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60506. * It defaults to camera.maxZ
  60507. */
  60508. get shadowMaxZ(): number;
  60509. /**
  60510. * Sets the shadow max z distance.
  60511. */
  60512. set shadowMaxZ(value: number);
  60513. protected _debug: boolean;
  60514. /**
  60515. * Gets or sets the debug flag.
  60516. * When enabled, the cascades are materialized by different colors on the screen.
  60517. */
  60518. get debug(): boolean;
  60519. set debug(dbg: boolean);
  60520. private _depthClamp;
  60521. /**
  60522. * Gets or sets the depth clamping value.
  60523. *
  60524. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60525. * to account for the shadow casters far away.
  60526. *
  60527. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60528. */
  60529. get depthClamp(): boolean;
  60530. set depthClamp(value: boolean);
  60531. private _cascadeBlendPercentage;
  60532. /**
  60533. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60534. * It defaults to 0.1 (10% blending).
  60535. */
  60536. get cascadeBlendPercentage(): number;
  60537. set cascadeBlendPercentage(value: number);
  60538. private _lambda;
  60539. /**
  60540. * Gets or set the lambda parameter.
  60541. * This parameter is used to split the camera frustum and create the cascades.
  60542. * 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.
  60543. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60544. */
  60545. get lambda(): number;
  60546. set lambda(value: number);
  60547. /**
  60548. * Gets the view matrix corresponding to a given cascade
  60549. * @param cascadeNum cascade to retrieve the view matrix from
  60550. * @returns the cascade view matrix
  60551. */
  60552. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60553. /**
  60554. * Gets the projection matrix corresponding to a given cascade
  60555. * @param cascadeNum cascade to retrieve the projection matrix from
  60556. * @returns the cascade projection matrix
  60557. */
  60558. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60559. /**
  60560. * Gets the transformation matrix corresponding to a given cascade
  60561. * @param cascadeNum cascade to retrieve the transformation matrix from
  60562. * @returns the cascade transformation matrix
  60563. */
  60564. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60565. private _depthRenderer;
  60566. /**
  60567. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60568. *
  60569. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60570. *
  60571. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60572. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60573. * @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
  60574. */
  60575. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60576. private _depthReducer;
  60577. private _autoCalcDepthBounds;
  60578. /**
  60579. * Gets or sets the autoCalcDepthBounds property.
  60580. *
  60581. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60582. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60583. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60584. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60585. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60586. */
  60587. get autoCalcDepthBounds(): boolean;
  60588. set autoCalcDepthBounds(value: boolean);
  60589. /**
  60590. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60591. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60592. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60593. * for setting the refresh rate on the renderer yourself!
  60594. */
  60595. get autoCalcDepthBoundsRefreshRate(): number;
  60596. set autoCalcDepthBoundsRefreshRate(value: number);
  60597. /**
  60598. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60599. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60600. * you change the camera near/far planes!
  60601. */
  60602. splitFrustum(): void;
  60603. private _splitFrustum;
  60604. private _computeMatrices;
  60605. private _computeFrustumInWorldSpace;
  60606. private _computeCascadeFrustum;
  60607. /**
  60608. * Support test.
  60609. */
  60610. static get IsSupported(): boolean;
  60611. /** @hidden */
  60612. static _SceneComponentInitialization: (scene: Scene) => void;
  60613. /**
  60614. * Creates a Cascaded Shadow Generator object.
  60615. * A ShadowGenerator is the required tool to use the shadows.
  60616. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60617. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60618. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60619. * @param light The directional light object generating the shadows.
  60620. * @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.
  60621. */
  60622. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60623. protected _initializeGenerator(): void;
  60624. protected _createTargetRenderTexture(): void;
  60625. protected _initializeShadowMap(): void;
  60626. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60627. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60628. /**
  60629. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60630. * @param defines Defines of the material we want to update
  60631. * @param lightIndex Index of the light in the enabled light list of the material
  60632. */
  60633. prepareDefines(defines: any, lightIndex: number): void;
  60634. /**
  60635. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60636. * defined in the generator but impacting the effect).
  60637. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60638. * @param effect The effect we are binfing the information for
  60639. */
  60640. bindShadowLight(lightIndex: string, effect: Effect): void;
  60641. /**
  60642. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60643. * (eq to view projection * shadow projection matrices)
  60644. * @returns The transform matrix used to create the shadow map
  60645. */
  60646. getTransformMatrix(): Matrix;
  60647. /**
  60648. * Disposes the ShadowGenerator.
  60649. * Returns nothing.
  60650. */
  60651. dispose(): void;
  60652. /**
  60653. * Serializes the shadow generator setup to a json object.
  60654. * @returns The serialized JSON object
  60655. */
  60656. serialize(): any;
  60657. /**
  60658. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60659. * @param parsedShadowGenerator The JSON object to parse
  60660. * @param scene The scene to create the shadow map for
  60661. * @returns The parsed shadow generator
  60662. */
  60663. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60664. }
  60665. }
  60666. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  60667. import { Scene } from "babylonjs/scene";
  60668. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60669. import { AbstractScene } from "babylonjs/abstractScene";
  60670. /**
  60671. * Defines the shadow generator component responsible to manage any shadow generators
  60672. * in a given scene.
  60673. */
  60674. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60675. /**
  60676. * The component name helpfull to identify the component in the list of scene components.
  60677. */
  60678. readonly name: string;
  60679. /**
  60680. * The scene the component belongs to.
  60681. */
  60682. scene: Scene;
  60683. /**
  60684. * Creates a new instance of the component for the given scene
  60685. * @param scene Defines the scene to register the component in
  60686. */
  60687. constructor(scene: Scene);
  60688. /**
  60689. * Registers the component in a given scene
  60690. */
  60691. register(): void;
  60692. /**
  60693. * Rebuilds the elements related to this component in case of
  60694. * context lost for instance.
  60695. */
  60696. rebuild(): void;
  60697. /**
  60698. * Serializes the component data to the specified json object
  60699. * @param serializationObject The object to serialize to
  60700. */
  60701. serialize(serializationObject: any): void;
  60702. /**
  60703. * Adds all the elements from the container to the scene
  60704. * @param container the container holding the elements
  60705. */
  60706. addFromContainer(container: AbstractScene): void;
  60707. /**
  60708. * Removes all the elements in the container from the scene
  60709. * @param container contains the elements to remove
  60710. * @param dispose if the removed element should be disposed (default: false)
  60711. */
  60712. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60713. /**
  60714. * Rebuilds the elements related to this component in case of
  60715. * context lost for instance.
  60716. */
  60717. dispose(): void;
  60718. private _gatherRenderTargets;
  60719. }
  60720. }
  60721. declare module "babylonjs/Lights/Shadows/index" {
  60722. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  60723. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  60724. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  60725. }
  60726. declare module "babylonjs/Lights/pointLight" {
  60727. import { Scene } from "babylonjs/scene";
  60728. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60730. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60731. import { Effect } from "babylonjs/Materials/effect";
  60732. /**
  60733. * A point light is a light defined by an unique point in world space.
  60734. * The light is emitted in every direction from this point.
  60735. * A good example of a point light is a standard light bulb.
  60736. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60737. */
  60738. export class PointLight extends ShadowLight {
  60739. private _shadowAngle;
  60740. /**
  60741. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60742. * This specifies what angle the shadow will use to be created.
  60743. *
  60744. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60745. */
  60746. get shadowAngle(): number;
  60747. /**
  60748. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60749. * This specifies what angle the shadow will use to be created.
  60750. *
  60751. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60752. */
  60753. set shadowAngle(value: number);
  60754. /**
  60755. * Gets the direction if it has been set.
  60756. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60757. */
  60758. get direction(): Vector3;
  60759. /**
  60760. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60761. */
  60762. set direction(value: Vector3);
  60763. /**
  60764. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60765. * A PointLight emits the light in every direction.
  60766. * It can cast shadows.
  60767. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60768. * ```javascript
  60769. * var pointLight = new PointLight("pl", camera.position, scene);
  60770. * ```
  60771. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60772. * @param name The light friendly name
  60773. * @param position The position of the point light in the scene
  60774. * @param scene The scene the lights belongs to
  60775. */
  60776. constructor(name: string, position: Vector3, scene: Scene);
  60777. /**
  60778. * Returns the string "PointLight"
  60779. * @returns the class name
  60780. */
  60781. getClassName(): string;
  60782. /**
  60783. * Returns the integer 0.
  60784. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60785. */
  60786. getTypeID(): number;
  60787. /**
  60788. * Specifies wether or not the shadowmap should be a cube texture.
  60789. * @returns true if the shadowmap needs to be a cube texture.
  60790. */
  60791. needCube(): boolean;
  60792. /**
  60793. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60794. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60795. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60796. */
  60797. getShadowDirection(faceIndex?: number): Vector3;
  60798. /**
  60799. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60800. * - fov = PI / 2
  60801. * - aspect ratio : 1.0
  60802. * - z-near and far equal to the active camera minZ and maxZ.
  60803. * Returns the PointLight.
  60804. */
  60805. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60806. protected _buildUniformLayout(): void;
  60807. /**
  60808. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60809. * @param effect The effect to update
  60810. * @param lightIndex The index of the light in the effect to update
  60811. * @returns The point light
  60812. */
  60813. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60814. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60815. /**
  60816. * Prepares the list of defines specific to the light type.
  60817. * @param defines the list of defines
  60818. * @param lightIndex defines the index of the light for the effect
  60819. */
  60820. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60821. }
  60822. }
  60823. declare module "babylonjs/Lights/index" {
  60824. export * from "babylonjs/Lights/light";
  60825. export * from "babylonjs/Lights/shadowLight";
  60826. export * from "babylonjs/Lights/Shadows/index";
  60827. export * from "babylonjs/Lights/directionalLight";
  60828. export * from "babylonjs/Lights/hemisphericLight";
  60829. export * from "babylonjs/Lights/pointLight";
  60830. export * from "babylonjs/Lights/spotLight";
  60831. }
  60832. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  60833. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60834. /**
  60835. * Header information of HDR texture files.
  60836. */
  60837. export interface HDRInfo {
  60838. /**
  60839. * The height of the texture in pixels.
  60840. */
  60841. height: number;
  60842. /**
  60843. * The width of the texture in pixels.
  60844. */
  60845. width: number;
  60846. /**
  60847. * The index of the beginning of the data in the binary file.
  60848. */
  60849. dataPosition: number;
  60850. }
  60851. /**
  60852. * This groups tools to convert HDR texture to native colors array.
  60853. */
  60854. export class HDRTools {
  60855. private static Ldexp;
  60856. private static Rgbe2float;
  60857. private static readStringLine;
  60858. /**
  60859. * Reads header information from an RGBE texture stored in a native array.
  60860. * More information on this format are available here:
  60861. * https://en.wikipedia.org/wiki/RGBE_image_format
  60862. *
  60863. * @param uint8array The binary file stored in native array.
  60864. * @return The header information.
  60865. */
  60866. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60867. /**
  60868. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60869. * This RGBE texture needs to store the information as a panorama.
  60870. *
  60871. * More information on this format are available here:
  60872. * https://en.wikipedia.org/wiki/RGBE_image_format
  60873. *
  60874. * @param buffer The binary file stored in an array buffer.
  60875. * @param size The expected size of the extracted cubemap.
  60876. * @return The Cube Map information.
  60877. */
  60878. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60879. /**
  60880. * Returns the pixels data extracted from an RGBE texture.
  60881. * This pixels will be stored left to right up to down in the R G B order in one array.
  60882. *
  60883. * More information on this format are available here:
  60884. * https://en.wikipedia.org/wiki/RGBE_image_format
  60885. *
  60886. * @param uint8array The binary file stored in an array buffer.
  60887. * @param hdrInfo The header information of the file.
  60888. * @return The pixels data in RGB right to left up to down order.
  60889. */
  60890. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60891. private static RGBE_ReadPixels_RLE;
  60892. }
  60893. }
  60894. declare module "babylonjs/Materials/effectRenderer" {
  60895. import { Nullable } from "babylonjs/types";
  60896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60898. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60899. import { Viewport } from "babylonjs/Maths/math.viewport";
  60900. import { Observable } from "babylonjs/Misc/observable";
  60901. import { Effect } from "babylonjs/Materials/effect";
  60902. import "babylonjs/Shaders/postprocess.vertex";
  60903. /**
  60904. * Effect Render Options
  60905. */
  60906. export interface IEffectRendererOptions {
  60907. /**
  60908. * Defines the vertices positions.
  60909. */
  60910. positions?: number[];
  60911. /**
  60912. * Defines the indices.
  60913. */
  60914. indices?: number[];
  60915. }
  60916. /**
  60917. * Helper class to render one or more effects.
  60918. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60919. */
  60920. export class EffectRenderer {
  60921. private engine;
  60922. private static _DefaultOptions;
  60923. private _vertexBuffers;
  60924. private _indexBuffer;
  60925. private _fullscreenViewport;
  60926. /**
  60927. * Creates an effect renderer
  60928. * @param engine the engine to use for rendering
  60929. * @param options defines the options of the effect renderer
  60930. */
  60931. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60932. /**
  60933. * Sets the current viewport in normalized coordinates 0-1
  60934. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60935. */
  60936. setViewport(viewport?: Viewport): void;
  60937. /**
  60938. * Binds the embedded attributes buffer to the effect.
  60939. * @param effect Defines the effect to bind the attributes for
  60940. */
  60941. bindBuffers(effect: Effect): void;
  60942. /**
  60943. * Sets the current effect wrapper to use during draw.
  60944. * The effect needs to be ready before calling this api.
  60945. * This also sets the default full screen position attribute.
  60946. * @param effectWrapper Defines the effect to draw with
  60947. */
  60948. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60949. /**
  60950. * Restores engine states
  60951. */
  60952. restoreStates(): void;
  60953. /**
  60954. * Draws a full screen quad.
  60955. */
  60956. draw(): void;
  60957. private isRenderTargetTexture;
  60958. /**
  60959. * renders one or more effects to a specified texture
  60960. * @param effectWrapper the effect to renderer
  60961. * @param outputTexture texture to draw to, if null it will render to the screen.
  60962. */
  60963. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60964. /**
  60965. * Disposes of the effect renderer
  60966. */
  60967. dispose(): void;
  60968. }
  60969. /**
  60970. * Options to create an EffectWrapper
  60971. */
  60972. interface EffectWrapperCreationOptions {
  60973. /**
  60974. * Engine to use to create the effect
  60975. */
  60976. engine: ThinEngine;
  60977. /**
  60978. * Fragment shader for the effect
  60979. */
  60980. fragmentShader: string;
  60981. /**
  60982. * Use the shader store instead of direct source code
  60983. */
  60984. useShaderStore?: boolean;
  60985. /**
  60986. * Vertex shader for the effect
  60987. */
  60988. vertexShader?: string;
  60989. /**
  60990. * Attributes to use in the shader
  60991. */
  60992. attributeNames?: Array<string>;
  60993. /**
  60994. * Uniforms to use in the shader
  60995. */
  60996. uniformNames?: Array<string>;
  60997. /**
  60998. * Texture sampler names to use in the shader
  60999. */
  61000. samplerNames?: Array<string>;
  61001. /**
  61002. * Defines to use in the shader
  61003. */
  61004. defines?: Array<string>;
  61005. /**
  61006. * Callback when effect is compiled
  61007. */
  61008. onCompiled?: Nullable<(effect: Effect) => void>;
  61009. /**
  61010. * The friendly name of the effect displayed in Spector.
  61011. */
  61012. name?: string;
  61013. }
  61014. /**
  61015. * Wraps an effect to be used for rendering
  61016. */
  61017. export class EffectWrapper {
  61018. /**
  61019. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61020. */
  61021. onApplyObservable: Observable<{}>;
  61022. /**
  61023. * The underlying effect
  61024. */
  61025. effect: Effect;
  61026. /**
  61027. * Creates an effect to be renderer
  61028. * @param creationOptions options to create the effect
  61029. */
  61030. constructor(creationOptions: EffectWrapperCreationOptions);
  61031. /**
  61032. * Disposes of the effect wrapper
  61033. */
  61034. dispose(): void;
  61035. }
  61036. }
  61037. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61038. /** @hidden */
  61039. export var hdrFilteringVertexShader: {
  61040. name: string;
  61041. shader: string;
  61042. };
  61043. }
  61044. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61045. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61046. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61047. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61048. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61049. /** @hidden */
  61050. export var hdrFilteringPixelShader: {
  61051. name: string;
  61052. shader: string;
  61053. };
  61054. }
  61055. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61057. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61058. import { Nullable } from "babylonjs/types";
  61059. import "babylonjs/Shaders/hdrFiltering.vertex";
  61060. import "babylonjs/Shaders/hdrFiltering.fragment";
  61061. /**
  61062. * Options for texture filtering
  61063. */
  61064. interface IHDRFilteringOptions {
  61065. /**
  61066. * Scales pixel intensity for the input HDR map.
  61067. */
  61068. hdrScale?: number;
  61069. /**
  61070. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61071. */
  61072. quality?: number;
  61073. }
  61074. /**
  61075. * Filters HDR maps to get correct renderings of PBR reflections
  61076. */
  61077. export class HDRFiltering {
  61078. private _engine;
  61079. private _effectRenderer;
  61080. private _effectWrapper;
  61081. private _lodGenerationOffset;
  61082. private _lodGenerationScale;
  61083. /**
  61084. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61085. * you care about baking speed.
  61086. */
  61087. quality: number;
  61088. /**
  61089. * Scales pixel intensity for the input HDR map.
  61090. */
  61091. hdrScale: number;
  61092. /**
  61093. * Instantiates HDR filter for reflection maps
  61094. *
  61095. * @param engine Thin engine
  61096. * @param options Options
  61097. */
  61098. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61099. private _createRenderTarget;
  61100. private _prefilterInternal;
  61101. private _createEffect;
  61102. /**
  61103. * Get a value indicating if the filter is ready to be used
  61104. * @param texture Texture to filter
  61105. * @returns true if the filter is ready
  61106. */
  61107. isReady(texture: BaseTexture): boolean;
  61108. /**
  61109. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61110. * Prefiltering will be invoked at the end of next rendering pass.
  61111. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61112. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61113. * @param texture Texture to filter
  61114. * @param onFinished Callback when filtering is done
  61115. * @return Promise called when prefiltering is done
  61116. */
  61117. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown>;
  61118. }
  61119. }
  61120. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61121. import { Nullable } from "babylonjs/types";
  61122. import { Scene } from "babylonjs/scene";
  61123. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61125. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61126. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61127. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61128. /**
  61129. * This represents a texture coming from an HDR input.
  61130. *
  61131. * The only supported format is currently panorama picture stored in RGBE format.
  61132. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61133. */
  61134. export class HDRCubeTexture extends BaseTexture {
  61135. private static _facesMapping;
  61136. private _generateHarmonics;
  61137. private _noMipmap;
  61138. private _prefilterOnLoad;
  61139. private _textureMatrix;
  61140. private _size;
  61141. private _onLoad;
  61142. private _onError;
  61143. /**
  61144. * The texture URL.
  61145. */
  61146. url: string;
  61147. /**
  61148. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61149. */
  61150. coordinatesMode: number;
  61151. protected _isBlocking: boolean;
  61152. /**
  61153. * Sets wether or not the texture is blocking during loading.
  61154. */
  61155. set isBlocking(value: boolean);
  61156. /**
  61157. * Gets wether or not the texture is blocking during loading.
  61158. */
  61159. get isBlocking(): boolean;
  61160. protected _rotationY: number;
  61161. /**
  61162. * Sets texture matrix rotation angle around Y axis in radians.
  61163. */
  61164. set rotationY(value: number);
  61165. /**
  61166. * Gets texture matrix rotation angle around Y axis radians.
  61167. */
  61168. get rotationY(): number;
  61169. /**
  61170. * Gets or sets the center of the bounding box associated with the cube texture
  61171. * It must define where the camera used to render the texture was set
  61172. */
  61173. boundingBoxPosition: Vector3;
  61174. private _boundingBoxSize;
  61175. /**
  61176. * Gets or sets the size of the bounding box associated with the cube texture
  61177. * When defined, the cubemap will switch to local mode
  61178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61179. * @example https://www.babylonjs-playground.com/#RNASML
  61180. */
  61181. set boundingBoxSize(value: Vector3);
  61182. get boundingBoxSize(): Vector3;
  61183. /**
  61184. * Instantiates an HDRTexture from the following parameters.
  61185. *
  61186. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61187. * @param sceneOrEngine The scene or engine the texture will be used in
  61188. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61189. * @param noMipmap Forces to not generate the mipmap if true
  61190. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61191. * @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)
  61192. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61193. */
  61194. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61195. /**
  61196. * Get the current class name of the texture useful for serialization or dynamic coding.
  61197. * @returns "HDRCubeTexture"
  61198. */
  61199. getClassName(): string;
  61200. /**
  61201. * Occurs when the file is raw .hdr file.
  61202. */
  61203. private loadTexture;
  61204. clone(): HDRCubeTexture;
  61205. delayLoad(): void;
  61206. /**
  61207. * Get the texture reflection matrix used to rotate/transform the reflection.
  61208. * @returns the reflection matrix
  61209. */
  61210. getReflectionTextureMatrix(): Matrix;
  61211. /**
  61212. * Set the texture reflection matrix used to rotate/transform the reflection.
  61213. * @param value Define the reflection matrix to set
  61214. */
  61215. setReflectionTextureMatrix(value: Matrix): void;
  61216. /**
  61217. * Parses a JSON representation of an HDR Texture in order to create the texture
  61218. * @param parsedTexture Define the JSON representation
  61219. * @param scene Define the scene the texture should be created in
  61220. * @param rootUrl Define the root url in case we need to load relative dependencies
  61221. * @returns the newly created texture after parsing
  61222. */
  61223. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61224. serialize(): any;
  61225. }
  61226. }
  61227. declare module "babylonjs/Physics/physicsEngine" {
  61228. import { Nullable } from "babylonjs/types";
  61229. import { Vector3 } from "babylonjs/Maths/math.vector";
  61230. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61231. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61232. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61233. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61234. /**
  61235. * Class used to control physics engine
  61236. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61237. */
  61238. export class PhysicsEngine implements IPhysicsEngine {
  61239. private _physicsPlugin;
  61240. /**
  61241. * Global value used to control the smallest number supported by the simulation
  61242. */
  61243. static Epsilon: number;
  61244. private _impostors;
  61245. private _joints;
  61246. private _subTimeStep;
  61247. /**
  61248. * Gets the gravity vector used by the simulation
  61249. */
  61250. gravity: Vector3;
  61251. /**
  61252. * Factory used to create the default physics plugin.
  61253. * @returns The default physics plugin
  61254. */
  61255. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61256. /**
  61257. * Creates a new Physics Engine
  61258. * @param gravity defines the gravity vector used by the simulation
  61259. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61260. */
  61261. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61262. /**
  61263. * Sets the gravity vector used by the simulation
  61264. * @param gravity defines the gravity vector to use
  61265. */
  61266. setGravity(gravity: Vector3): void;
  61267. /**
  61268. * Set the time step of the physics engine.
  61269. * Default is 1/60.
  61270. * To slow it down, enter 1/600 for example.
  61271. * To speed it up, 1/30
  61272. * @param newTimeStep defines the new timestep to apply to this world.
  61273. */
  61274. setTimeStep(newTimeStep?: number): void;
  61275. /**
  61276. * Get the time step of the physics engine.
  61277. * @returns the current time step
  61278. */
  61279. getTimeStep(): number;
  61280. /**
  61281. * Set the sub time step of the physics engine.
  61282. * Default is 0 meaning there is no sub steps
  61283. * To increase physics resolution precision, set a small value (like 1 ms)
  61284. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61285. */
  61286. setSubTimeStep(subTimeStep?: number): void;
  61287. /**
  61288. * Get the sub time step of the physics engine.
  61289. * @returns the current sub time step
  61290. */
  61291. getSubTimeStep(): number;
  61292. /**
  61293. * Release all resources
  61294. */
  61295. dispose(): void;
  61296. /**
  61297. * Gets the name of the current physics plugin
  61298. * @returns the name of the plugin
  61299. */
  61300. getPhysicsPluginName(): string;
  61301. /**
  61302. * Adding a new impostor for the impostor tracking.
  61303. * This will be done by the impostor itself.
  61304. * @param impostor the impostor to add
  61305. */
  61306. addImpostor(impostor: PhysicsImpostor): void;
  61307. /**
  61308. * Remove an impostor from the engine.
  61309. * This impostor and its mesh will not longer be updated by the physics engine.
  61310. * @param impostor the impostor to remove
  61311. */
  61312. removeImpostor(impostor: PhysicsImpostor): void;
  61313. /**
  61314. * Add a joint to the physics engine
  61315. * @param mainImpostor defines the main impostor to which the joint is added.
  61316. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61317. * @param joint defines the joint that will connect both impostors.
  61318. */
  61319. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61320. /**
  61321. * Removes a joint from the simulation
  61322. * @param mainImpostor defines the impostor used with the joint
  61323. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61324. * @param joint defines the joint to remove
  61325. */
  61326. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61327. /**
  61328. * Called by the scene. No need to call it.
  61329. * @param delta defines the timespam between frames
  61330. */
  61331. _step(delta: number): void;
  61332. /**
  61333. * Gets the current plugin used to run the simulation
  61334. * @returns current plugin
  61335. */
  61336. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61337. /**
  61338. * Gets the list of physic impostors
  61339. * @returns an array of PhysicsImpostor
  61340. */
  61341. getImpostors(): Array<PhysicsImpostor>;
  61342. /**
  61343. * Gets the impostor for a physics enabled object
  61344. * @param object defines the object impersonated by the impostor
  61345. * @returns the PhysicsImpostor or null if not found
  61346. */
  61347. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61348. /**
  61349. * Gets the impostor for a physics body object
  61350. * @param body defines physics body used by the impostor
  61351. * @returns the PhysicsImpostor or null if not found
  61352. */
  61353. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61354. /**
  61355. * Does a raycast in the physics world
  61356. * @param from when should the ray start?
  61357. * @param to when should the ray end?
  61358. * @returns PhysicsRaycastResult
  61359. */
  61360. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61361. }
  61362. }
  61363. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61364. import { Nullable } from "babylonjs/types";
  61365. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61367. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61368. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61369. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61370. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61371. /** @hidden */
  61372. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61373. private _useDeltaForWorldStep;
  61374. world: any;
  61375. name: string;
  61376. private _physicsMaterials;
  61377. private _fixedTimeStep;
  61378. private _cannonRaycastResult;
  61379. private _raycastResult;
  61380. private _physicsBodysToRemoveAfterStep;
  61381. BJSCANNON: any;
  61382. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61383. setGravity(gravity: Vector3): void;
  61384. setTimeStep(timeStep: number): void;
  61385. getTimeStep(): number;
  61386. executeStep(delta: number): void;
  61387. private _removeMarkedPhysicsBodiesFromWorld;
  61388. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61390. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61391. private _processChildMeshes;
  61392. removePhysicsBody(impostor: PhysicsImpostor): void;
  61393. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61394. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61395. private _addMaterial;
  61396. private _checkWithEpsilon;
  61397. private _createShape;
  61398. private _createHeightmap;
  61399. private _minus90X;
  61400. private _plus90X;
  61401. private _tmpPosition;
  61402. private _tmpDeltaPosition;
  61403. private _tmpUnityRotation;
  61404. private _updatePhysicsBodyTransformation;
  61405. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61406. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61407. isSupported(): boolean;
  61408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61413. getBodyMass(impostor: PhysicsImpostor): number;
  61414. getBodyFriction(impostor: PhysicsImpostor): number;
  61415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61416. getBodyRestitution(impostor: PhysicsImpostor): number;
  61417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61418. sleepBody(impostor: PhysicsImpostor): void;
  61419. wakeUpBody(impostor: PhysicsImpostor): void;
  61420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61424. getRadius(impostor: PhysicsImpostor): number;
  61425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61426. dispose(): void;
  61427. private _extendNamespace;
  61428. /**
  61429. * Does a raycast in the physics world
  61430. * @param from when should the ray start?
  61431. * @param to when should the ray end?
  61432. * @returns PhysicsRaycastResult
  61433. */
  61434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61435. }
  61436. }
  61437. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61438. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61439. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61440. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61442. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61443. import { Nullable } from "babylonjs/types";
  61444. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61445. /** @hidden */
  61446. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61447. private _useDeltaForWorldStep;
  61448. world: any;
  61449. name: string;
  61450. BJSOIMO: any;
  61451. private _raycastResult;
  61452. private _fixedTimeStep;
  61453. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61454. setGravity(gravity: Vector3): void;
  61455. setTimeStep(timeStep: number): void;
  61456. getTimeStep(): number;
  61457. private _tmpImpostorsArray;
  61458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61462. private _tmpPositionVector;
  61463. removePhysicsBody(impostor: PhysicsImpostor): void;
  61464. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61465. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61466. isSupported(): boolean;
  61467. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61468. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61469. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61471. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61472. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61473. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61474. getBodyMass(impostor: PhysicsImpostor): number;
  61475. getBodyFriction(impostor: PhysicsImpostor): number;
  61476. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61477. getBodyRestitution(impostor: PhysicsImpostor): number;
  61478. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61479. sleepBody(impostor: PhysicsImpostor): void;
  61480. wakeUpBody(impostor: PhysicsImpostor): void;
  61481. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61482. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61483. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61484. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61485. getRadius(impostor: PhysicsImpostor): number;
  61486. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61487. dispose(): void;
  61488. /**
  61489. * Does a raycast in the physics world
  61490. * @param from when should the ray start?
  61491. * @param to when should the ray end?
  61492. * @returns PhysicsRaycastResult
  61493. */
  61494. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61495. }
  61496. }
  61497. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61498. import { Nullable } from "babylonjs/types";
  61499. import { Scene } from "babylonjs/scene";
  61500. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61501. import { Color4 } from "babylonjs/Maths/math.color";
  61502. import { Mesh } from "babylonjs/Meshes/mesh";
  61503. /**
  61504. * Class containing static functions to help procedurally build meshes
  61505. */
  61506. export class RibbonBuilder {
  61507. /**
  61508. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61509. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61510. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61511. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61512. * * 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
  61513. * * 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
  61514. * * 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
  61515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61518. * * 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
  61519. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61520. * * 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
  61521. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61523. * @param name defines the name of the mesh
  61524. * @param options defines the options used to create the mesh
  61525. * @param scene defines the hosting scene
  61526. * @returns the ribbon mesh
  61527. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61528. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61529. */
  61530. static CreateRibbon(name: string, options: {
  61531. pathArray: Vector3[][];
  61532. closeArray?: boolean;
  61533. closePath?: boolean;
  61534. offset?: number;
  61535. updatable?: boolean;
  61536. sideOrientation?: number;
  61537. frontUVs?: Vector4;
  61538. backUVs?: Vector4;
  61539. instance?: Mesh;
  61540. invertUV?: boolean;
  61541. uvs?: Vector2[];
  61542. colors?: Color4[];
  61543. }, scene?: Nullable<Scene>): Mesh;
  61544. }
  61545. }
  61546. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61547. import { Nullable } from "babylonjs/types";
  61548. import { Scene } from "babylonjs/scene";
  61549. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61550. import { Mesh } from "babylonjs/Meshes/mesh";
  61551. /**
  61552. * Class containing static functions to help procedurally build meshes
  61553. */
  61554. export class ShapeBuilder {
  61555. /**
  61556. * 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.
  61557. * * 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.
  61558. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61559. * * 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.
  61560. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61561. * * 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
  61562. * * 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
  61563. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61568. * @param name defines the name of the mesh
  61569. * @param options defines the options used to create the mesh
  61570. * @param scene defines the hosting scene
  61571. * @returns the extruded shape mesh
  61572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61574. */
  61575. static ExtrudeShape(name: string, options: {
  61576. shape: Vector3[];
  61577. path: Vector3[];
  61578. scale?: number;
  61579. rotation?: number;
  61580. cap?: number;
  61581. updatable?: boolean;
  61582. sideOrientation?: number;
  61583. frontUVs?: Vector4;
  61584. backUVs?: Vector4;
  61585. instance?: Mesh;
  61586. invertUV?: boolean;
  61587. }, scene?: Nullable<Scene>): Mesh;
  61588. /**
  61589. * Creates an custom extruded shape mesh.
  61590. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61591. * * 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.
  61592. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61593. * * 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
  61594. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61595. * * 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
  61596. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61597. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61598. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61599. * * 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
  61600. * * 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
  61601. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61606. * @param name defines the name of the mesh
  61607. * @param options defines the options used to create the mesh
  61608. * @param scene defines the hosting scene
  61609. * @returns the custom extruded shape mesh
  61610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61613. */
  61614. static ExtrudeShapeCustom(name: string, options: {
  61615. shape: Vector3[];
  61616. path: Vector3[];
  61617. scaleFunction?: any;
  61618. rotationFunction?: any;
  61619. ribbonCloseArray?: boolean;
  61620. ribbonClosePath?: boolean;
  61621. cap?: number;
  61622. updatable?: boolean;
  61623. sideOrientation?: number;
  61624. frontUVs?: Vector4;
  61625. backUVs?: Vector4;
  61626. instance?: Mesh;
  61627. invertUV?: boolean;
  61628. }, scene?: Nullable<Scene>): Mesh;
  61629. private static _ExtrudeShapeGeneric;
  61630. }
  61631. }
  61632. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  61633. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  61634. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61635. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61636. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61637. import { Nullable } from "babylonjs/types";
  61638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61639. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61640. /**
  61641. * AmmoJS Physics plugin
  61642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61643. * @see https://github.com/kripken/ammo.js/
  61644. */
  61645. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61646. private _useDeltaForWorldStep;
  61647. /**
  61648. * Reference to the Ammo library
  61649. */
  61650. bjsAMMO: any;
  61651. /**
  61652. * Created ammoJS world which physics bodies are added to
  61653. */
  61654. world: any;
  61655. /**
  61656. * Name of the plugin
  61657. */
  61658. name: string;
  61659. private _timeStep;
  61660. private _fixedTimeStep;
  61661. private _maxSteps;
  61662. private _tmpQuaternion;
  61663. private _tmpAmmoTransform;
  61664. private _tmpAmmoQuaternion;
  61665. private _tmpAmmoConcreteContactResultCallback;
  61666. private _collisionConfiguration;
  61667. private _dispatcher;
  61668. private _overlappingPairCache;
  61669. private _solver;
  61670. private _softBodySolver;
  61671. private _tmpAmmoVectorA;
  61672. private _tmpAmmoVectorB;
  61673. private _tmpAmmoVectorC;
  61674. private _tmpAmmoVectorD;
  61675. private _tmpContactCallbackResult;
  61676. private _tmpAmmoVectorRCA;
  61677. private _tmpAmmoVectorRCB;
  61678. private _raycastResult;
  61679. private static readonly DISABLE_COLLISION_FLAG;
  61680. private static readonly KINEMATIC_FLAG;
  61681. private static readonly DISABLE_DEACTIVATION_FLAG;
  61682. /**
  61683. * Initializes the ammoJS plugin
  61684. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61685. * @param ammoInjection can be used to inject your own ammo reference
  61686. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61687. */
  61688. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61689. /**
  61690. * Sets the gravity of the physics world (m/(s^2))
  61691. * @param gravity Gravity to set
  61692. */
  61693. setGravity(gravity: Vector3): void;
  61694. /**
  61695. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61696. * @param timeStep timestep to use in seconds
  61697. */
  61698. setTimeStep(timeStep: number): void;
  61699. /**
  61700. * 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)
  61701. * @param fixedTimeStep fixedTimeStep to use in seconds
  61702. */
  61703. setFixedTimeStep(fixedTimeStep: number): void;
  61704. /**
  61705. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61706. * @param maxSteps the maximum number of steps by the physics engine per frame
  61707. */
  61708. setMaxSteps(maxSteps: number): void;
  61709. /**
  61710. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61711. * @returns the current timestep in seconds
  61712. */
  61713. getTimeStep(): number;
  61714. /**
  61715. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61716. */
  61717. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61718. private _isImpostorInContact;
  61719. private _isImpostorPairInContact;
  61720. private _stepSimulation;
  61721. /**
  61722. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61723. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61724. * After the step the babylon meshes are set to the position of the physics imposters
  61725. * @param delta amount of time to step forward
  61726. * @param impostors array of imposters to update before/after the step
  61727. */
  61728. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61729. /**
  61730. * Update babylon mesh to match physics world object
  61731. * @param impostor imposter to match
  61732. */
  61733. private _afterSoftStep;
  61734. /**
  61735. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61736. * @param impostor imposter to match
  61737. */
  61738. private _ropeStep;
  61739. /**
  61740. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61741. * @param impostor imposter to match
  61742. */
  61743. private _softbodyOrClothStep;
  61744. private _tmpMatrix;
  61745. /**
  61746. * Applies an impulse on the imposter
  61747. * @param impostor imposter to apply impulse to
  61748. * @param force amount of force to be applied to the imposter
  61749. * @param contactPoint the location to apply the impulse on the imposter
  61750. */
  61751. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61752. /**
  61753. * Applies a force on the imposter
  61754. * @param impostor imposter to apply force
  61755. * @param force amount of force to be applied to the imposter
  61756. * @param contactPoint the location to apply the force on the imposter
  61757. */
  61758. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61759. /**
  61760. * Creates a physics body using the plugin
  61761. * @param impostor the imposter to create the physics body on
  61762. */
  61763. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61764. /**
  61765. * Removes the physics body from the imposter and disposes of the body's memory
  61766. * @param impostor imposter to remove the physics body from
  61767. */
  61768. removePhysicsBody(impostor: PhysicsImpostor): void;
  61769. /**
  61770. * Generates a joint
  61771. * @param impostorJoint the imposter joint to create the joint with
  61772. */
  61773. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61774. /**
  61775. * Removes a joint
  61776. * @param impostorJoint the imposter joint to remove the joint from
  61777. */
  61778. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61779. private _addMeshVerts;
  61780. /**
  61781. * Initialise the soft body vertices to match its object's (mesh) vertices
  61782. * Softbody vertices (nodes) are in world space and to match this
  61783. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61784. * @param impostor to create the softbody for
  61785. */
  61786. private _softVertexData;
  61787. /**
  61788. * Create an impostor's soft body
  61789. * @param impostor to create the softbody for
  61790. */
  61791. private _createSoftbody;
  61792. /**
  61793. * Create cloth for an impostor
  61794. * @param impostor to create the softbody for
  61795. */
  61796. private _createCloth;
  61797. /**
  61798. * Create rope for an impostor
  61799. * @param impostor to create the softbody for
  61800. */
  61801. private _createRope;
  61802. /**
  61803. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61804. * @param impostor to create the custom physics shape for
  61805. */
  61806. private _createCustom;
  61807. private _addHullVerts;
  61808. private _createShape;
  61809. /**
  61810. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61811. * @param impostor imposter containing the physics body and babylon object
  61812. */
  61813. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61814. /**
  61815. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61816. * @param impostor imposter containing the physics body and babylon object
  61817. * @param newPosition new position
  61818. * @param newRotation new rotation
  61819. */
  61820. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61821. /**
  61822. * If this plugin is supported
  61823. * @returns true if its supported
  61824. */
  61825. isSupported(): boolean;
  61826. /**
  61827. * Sets the linear velocity of the physics body
  61828. * @param impostor imposter to set the velocity on
  61829. * @param velocity velocity to set
  61830. */
  61831. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61832. /**
  61833. * Sets the angular velocity of the physics body
  61834. * @param impostor imposter to set the velocity on
  61835. * @param velocity velocity to set
  61836. */
  61837. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61838. /**
  61839. * gets the linear velocity
  61840. * @param impostor imposter to get linear velocity from
  61841. * @returns linear velocity
  61842. */
  61843. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61844. /**
  61845. * gets the angular velocity
  61846. * @param impostor imposter to get angular velocity from
  61847. * @returns angular velocity
  61848. */
  61849. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61850. /**
  61851. * Sets the mass of physics body
  61852. * @param impostor imposter to set the mass on
  61853. * @param mass mass to set
  61854. */
  61855. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61856. /**
  61857. * Gets the mass of the physics body
  61858. * @param impostor imposter to get the mass from
  61859. * @returns mass
  61860. */
  61861. getBodyMass(impostor: PhysicsImpostor): number;
  61862. /**
  61863. * Gets friction of the impostor
  61864. * @param impostor impostor to get friction from
  61865. * @returns friction value
  61866. */
  61867. getBodyFriction(impostor: PhysicsImpostor): number;
  61868. /**
  61869. * Sets friction of the impostor
  61870. * @param impostor impostor to set friction on
  61871. * @param friction friction value
  61872. */
  61873. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61874. /**
  61875. * Gets restitution of the impostor
  61876. * @param impostor impostor to get restitution from
  61877. * @returns restitution value
  61878. */
  61879. getBodyRestitution(impostor: PhysicsImpostor): number;
  61880. /**
  61881. * Sets resitution of the impostor
  61882. * @param impostor impostor to set resitution on
  61883. * @param restitution resitution value
  61884. */
  61885. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61886. /**
  61887. * Gets pressure inside the impostor
  61888. * @param impostor impostor to get pressure from
  61889. * @returns pressure value
  61890. */
  61891. getBodyPressure(impostor: PhysicsImpostor): number;
  61892. /**
  61893. * Sets pressure inside a soft body impostor
  61894. * Cloth and rope must remain 0 pressure
  61895. * @param impostor impostor to set pressure on
  61896. * @param pressure pressure value
  61897. */
  61898. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61899. /**
  61900. * Gets stiffness of the impostor
  61901. * @param impostor impostor to get stiffness from
  61902. * @returns pressure value
  61903. */
  61904. getBodyStiffness(impostor: PhysicsImpostor): number;
  61905. /**
  61906. * Sets stiffness of the impostor
  61907. * @param impostor impostor to set stiffness on
  61908. * @param stiffness stiffness value from 0 to 1
  61909. */
  61910. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61911. /**
  61912. * Gets velocityIterations of the impostor
  61913. * @param impostor impostor to get velocity iterations from
  61914. * @returns velocityIterations value
  61915. */
  61916. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61917. /**
  61918. * Sets velocityIterations of the impostor
  61919. * @param impostor impostor to set velocity iterations on
  61920. * @param velocityIterations velocityIterations value
  61921. */
  61922. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61923. /**
  61924. * Gets positionIterations of the impostor
  61925. * @param impostor impostor to get position iterations from
  61926. * @returns positionIterations value
  61927. */
  61928. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61929. /**
  61930. * Sets positionIterations of the impostor
  61931. * @param impostor impostor to set position on
  61932. * @param positionIterations positionIterations value
  61933. */
  61934. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61935. /**
  61936. * Append an anchor to a cloth object
  61937. * @param impostor is the cloth impostor to add anchor to
  61938. * @param otherImpostor is the rigid impostor to anchor to
  61939. * @param width ratio across width from 0 to 1
  61940. * @param height ratio up height from 0 to 1
  61941. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61942. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61943. */
  61944. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61945. /**
  61946. * Append an hook to a rope object
  61947. * @param impostor is the rope impostor to add hook to
  61948. * @param otherImpostor is the rigid impostor to hook to
  61949. * @param length ratio along the rope from 0 to 1
  61950. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61951. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61952. */
  61953. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61954. /**
  61955. * Sleeps the physics body and stops it from being active
  61956. * @param impostor impostor to sleep
  61957. */
  61958. sleepBody(impostor: PhysicsImpostor): void;
  61959. /**
  61960. * Activates the physics body
  61961. * @param impostor impostor to activate
  61962. */
  61963. wakeUpBody(impostor: PhysicsImpostor): void;
  61964. /**
  61965. * Updates the distance parameters of the joint
  61966. * @param joint joint to update
  61967. * @param maxDistance maximum distance of the joint
  61968. * @param minDistance minimum distance of the joint
  61969. */
  61970. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61971. /**
  61972. * Sets a motor on the joint
  61973. * @param joint joint to set motor on
  61974. * @param speed speed of the motor
  61975. * @param maxForce maximum force of the motor
  61976. * @param motorIndex index of the motor
  61977. */
  61978. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61979. /**
  61980. * Sets the motors limit
  61981. * @param joint joint to set limit on
  61982. * @param upperLimit upper limit
  61983. * @param lowerLimit lower limit
  61984. */
  61985. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61986. /**
  61987. * Syncs the position and rotation of a mesh with the impostor
  61988. * @param mesh mesh to sync
  61989. * @param impostor impostor to update the mesh with
  61990. */
  61991. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61992. /**
  61993. * Gets the radius of the impostor
  61994. * @param impostor impostor to get radius from
  61995. * @returns the radius
  61996. */
  61997. getRadius(impostor: PhysicsImpostor): number;
  61998. /**
  61999. * Gets the box size of the impostor
  62000. * @param impostor impostor to get box size from
  62001. * @param result the resulting box size
  62002. */
  62003. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62004. /**
  62005. * Disposes of the impostor
  62006. */
  62007. dispose(): void;
  62008. /**
  62009. * Does a raycast in the physics world
  62010. * @param from when should the ray start?
  62011. * @param to when should the ray end?
  62012. * @returns PhysicsRaycastResult
  62013. */
  62014. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62015. }
  62016. }
  62017. declare module "babylonjs/Probes/reflectionProbe" {
  62018. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62019. import { Vector3 } from "babylonjs/Maths/math.vector";
  62020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62021. import { Nullable } from "babylonjs/types";
  62022. import { Scene } from "babylonjs/scene";
  62023. module "babylonjs/abstractScene" {
  62024. interface AbstractScene {
  62025. /**
  62026. * The list of reflection probes added to the scene
  62027. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62028. */
  62029. reflectionProbes: Array<ReflectionProbe>;
  62030. /**
  62031. * Removes the given reflection probe from this scene.
  62032. * @param toRemove The reflection probe to remove
  62033. * @returns The index of the removed reflection probe
  62034. */
  62035. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62036. /**
  62037. * Adds the given reflection probe to this scene.
  62038. * @param newReflectionProbe The reflection probe to add
  62039. */
  62040. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62041. }
  62042. }
  62043. /**
  62044. * Class used to generate realtime reflection / refraction cube textures
  62045. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62046. */
  62047. export class ReflectionProbe {
  62048. /** defines the name of the probe */
  62049. name: string;
  62050. private _scene;
  62051. private _renderTargetTexture;
  62052. private _projectionMatrix;
  62053. private _viewMatrix;
  62054. private _target;
  62055. private _add;
  62056. private _attachedMesh;
  62057. private _invertYAxis;
  62058. /** Gets or sets probe position (center of the cube map) */
  62059. position: Vector3;
  62060. /**
  62061. * Creates a new reflection probe
  62062. * @param name defines the name of the probe
  62063. * @param size defines the texture resolution (for each face)
  62064. * @param scene defines the hosting scene
  62065. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62066. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62067. */
  62068. constructor(
  62069. /** defines the name of the probe */
  62070. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62071. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62072. get samples(): number;
  62073. set samples(value: number);
  62074. /** Gets or sets the refresh rate to use (on every frame by default) */
  62075. get refreshRate(): number;
  62076. set refreshRate(value: number);
  62077. /**
  62078. * Gets the hosting scene
  62079. * @returns a Scene
  62080. */
  62081. getScene(): Scene;
  62082. /** Gets the internal CubeTexture used to render to */
  62083. get cubeTexture(): RenderTargetTexture;
  62084. /** Gets the list of meshes to render */
  62085. get renderList(): Nullable<AbstractMesh[]>;
  62086. /**
  62087. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62088. * @param mesh defines the mesh to attach to
  62089. */
  62090. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62091. /**
  62092. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62093. * @param renderingGroupId The rendering group id corresponding to its index
  62094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62095. */
  62096. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62097. /**
  62098. * Clean all associated resources
  62099. */
  62100. dispose(): void;
  62101. /**
  62102. * Converts the reflection probe information to a readable string for debug purpose.
  62103. * @param fullDetails Supports for multiple levels of logging within scene loading
  62104. * @returns the human readable reflection probe info
  62105. */
  62106. toString(fullDetails?: boolean): string;
  62107. /**
  62108. * Get the class name of the relfection probe.
  62109. * @returns "ReflectionProbe"
  62110. */
  62111. getClassName(): string;
  62112. /**
  62113. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62114. * @returns The JSON representation of the texture
  62115. */
  62116. serialize(): any;
  62117. /**
  62118. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62119. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62120. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62121. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62122. * @returns The parsed reflection probe if successful
  62123. */
  62124. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62125. }
  62126. }
  62127. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62128. /** @hidden */
  62129. export var _BabylonLoaderRegistered: boolean;
  62130. /**
  62131. * Helps setting up some configuration for the babylon file loader.
  62132. */
  62133. export class BabylonFileLoaderConfiguration {
  62134. /**
  62135. * The loader does not allow injecting custom physix engine into the plugins.
  62136. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62137. * So you could set this variable to your engine import to make it work.
  62138. */
  62139. static LoaderInjectedPhysicsEngine: any;
  62140. }
  62141. }
  62142. declare module "babylonjs/Loading/Plugins/index" {
  62143. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62144. }
  62145. declare module "babylonjs/Loading/index" {
  62146. export * from "babylonjs/Loading/loadingScreen";
  62147. export * from "babylonjs/Loading/Plugins/index";
  62148. export * from "babylonjs/Loading/sceneLoader";
  62149. export * from "babylonjs/Loading/sceneLoaderFlags";
  62150. }
  62151. declare module "babylonjs/Materials/Background/index" {
  62152. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62153. }
  62154. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62155. import { Scene } from "babylonjs/scene";
  62156. import { Color3 } from "babylonjs/Maths/math.color";
  62157. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62159. /**
  62160. * The Physically based simple base material of BJS.
  62161. *
  62162. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62163. * It is used as the base class for both the specGloss and metalRough conventions.
  62164. */
  62165. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62166. /**
  62167. * Number of Simultaneous lights allowed on the material.
  62168. */
  62169. maxSimultaneousLights: number;
  62170. /**
  62171. * If sets to true, disables all the lights affecting the material.
  62172. */
  62173. disableLighting: boolean;
  62174. /**
  62175. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62176. */
  62177. environmentTexture: BaseTexture;
  62178. /**
  62179. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62180. */
  62181. invertNormalMapX: boolean;
  62182. /**
  62183. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62184. */
  62185. invertNormalMapY: boolean;
  62186. /**
  62187. * Normal map used in the model.
  62188. */
  62189. normalTexture: BaseTexture;
  62190. /**
  62191. * Emissivie color used to self-illuminate the model.
  62192. */
  62193. emissiveColor: Color3;
  62194. /**
  62195. * Emissivie texture used to self-illuminate the model.
  62196. */
  62197. emissiveTexture: BaseTexture;
  62198. /**
  62199. * Occlusion Channel Strenght.
  62200. */
  62201. occlusionStrength: number;
  62202. /**
  62203. * Occlusion Texture of the material (adding extra occlusion effects).
  62204. */
  62205. occlusionTexture: BaseTexture;
  62206. /**
  62207. * Defines the alpha limits in alpha test mode.
  62208. */
  62209. alphaCutOff: number;
  62210. /**
  62211. * Gets the current double sided mode.
  62212. */
  62213. get doubleSided(): boolean;
  62214. /**
  62215. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62216. */
  62217. set doubleSided(value: boolean);
  62218. /**
  62219. * Stores the pre-calculated light information of a mesh in a texture.
  62220. */
  62221. lightmapTexture: BaseTexture;
  62222. /**
  62223. * If true, the light map contains occlusion information instead of lighting info.
  62224. */
  62225. useLightmapAsShadowmap: boolean;
  62226. /**
  62227. * Instantiates a new PBRMaterial instance.
  62228. *
  62229. * @param name The material name
  62230. * @param scene The scene the material will be use in.
  62231. */
  62232. constructor(name: string, scene: Scene);
  62233. getClassName(): string;
  62234. }
  62235. }
  62236. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62237. import { Scene } from "babylonjs/scene";
  62238. import { Color3 } from "babylonjs/Maths/math.color";
  62239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62240. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62241. /**
  62242. * The PBR material of BJS following the metal roughness convention.
  62243. *
  62244. * This fits to the PBR convention in the GLTF definition:
  62245. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62246. */
  62247. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62248. /**
  62249. * The base color has two different interpretations depending on the value of metalness.
  62250. * When the material is a metal, the base color is the specific measured reflectance value
  62251. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62252. * of the material.
  62253. */
  62254. baseColor: Color3;
  62255. /**
  62256. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62257. * well as opacity information in the alpha channel.
  62258. */
  62259. baseTexture: BaseTexture;
  62260. /**
  62261. * Specifies the metallic scalar value of the material.
  62262. * Can also be used to scale the metalness values of the metallic texture.
  62263. */
  62264. metallic: number;
  62265. /**
  62266. * Specifies the roughness scalar value of the material.
  62267. * Can also be used to scale the roughness values of the metallic texture.
  62268. */
  62269. roughness: number;
  62270. /**
  62271. * Texture containing both the metallic value in the B channel and the
  62272. * roughness value in the G channel to keep better precision.
  62273. */
  62274. metallicRoughnessTexture: BaseTexture;
  62275. /**
  62276. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62277. *
  62278. * @param name The material name
  62279. * @param scene The scene the material will be use in.
  62280. */
  62281. constructor(name: string, scene: Scene);
  62282. /**
  62283. * Return the currrent class name of the material.
  62284. */
  62285. getClassName(): string;
  62286. /**
  62287. * Makes a duplicate of the current material.
  62288. * @param name - name to use for the new material.
  62289. */
  62290. clone(name: string): PBRMetallicRoughnessMaterial;
  62291. /**
  62292. * Serialize the material to a parsable JSON object.
  62293. */
  62294. serialize(): any;
  62295. /**
  62296. * Parses a JSON object correponding to the serialize function.
  62297. */
  62298. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62299. }
  62300. }
  62301. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62302. import { Scene } from "babylonjs/scene";
  62303. import { Color3 } from "babylonjs/Maths/math.color";
  62304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62305. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62306. /**
  62307. * The PBR material of BJS following the specular glossiness convention.
  62308. *
  62309. * This fits to the PBR convention in the GLTF definition:
  62310. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62311. */
  62312. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62313. /**
  62314. * Specifies the diffuse color of the material.
  62315. */
  62316. diffuseColor: Color3;
  62317. /**
  62318. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62319. * channel.
  62320. */
  62321. diffuseTexture: BaseTexture;
  62322. /**
  62323. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62324. */
  62325. specularColor: Color3;
  62326. /**
  62327. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62328. */
  62329. glossiness: number;
  62330. /**
  62331. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62332. */
  62333. specularGlossinessTexture: BaseTexture;
  62334. /**
  62335. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62336. *
  62337. * @param name The material name
  62338. * @param scene The scene the material will be use in.
  62339. */
  62340. constructor(name: string, scene: Scene);
  62341. /**
  62342. * Return the currrent class name of the material.
  62343. */
  62344. getClassName(): string;
  62345. /**
  62346. * Makes a duplicate of the current material.
  62347. * @param name - name to use for the new material.
  62348. */
  62349. clone(name: string): PBRSpecularGlossinessMaterial;
  62350. /**
  62351. * Serialize the material to a parsable JSON object.
  62352. */
  62353. serialize(): any;
  62354. /**
  62355. * Parses a JSON object correponding to the serialize function.
  62356. */
  62357. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62358. }
  62359. }
  62360. declare module "babylonjs/Materials/PBR/index" {
  62361. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62362. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62363. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62364. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62365. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62366. }
  62367. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62368. import { Nullable } from "babylonjs/types";
  62369. import { Scene } from "babylonjs/scene";
  62370. import { Matrix } from "babylonjs/Maths/math.vector";
  62371. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62372. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62373. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62374. /**
  62375. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62376. * It can help converting any input color in a desired output one. This can then be used to create effects
  62377. * from sepia, black and white to sixties or futuristic rendering...
  62378. *
  62379. * The only supported format is currently 3dl.
  62380. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62381. */
  62382. export class ColorGradingTexture extends BaseTexture {
  62383. /**
  62384. * The texture URL.
  62385. */
  62386. url: string;
  62387. /**
  62388. * Empty line regex stored for GC.
  62389. */
  62390. private static _noneEmptyLineRegex;
  62391. private _textureMatrix;
  62392. private _onLoad;
  62393. /**
  62394. * Instantiates a ColorGradingTexture from the following parameters.
  62395. *
  62396. * @param url The location of the color gradind data (currently only supporting 3dl)
  62397. * @param sceneOrEngine The scene or engine the texture will be used in
  62398. * @param onLoad defines a callback triggered when the texture has been loaded
  62399. */
  62400. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62401. /**
  62402. * Fires the onload event from the constructor if requested.
  62403. */
  62404. private _triggerOnLoad;
  62405. /**
  62406. * Returns the texture matrix used in most of the material.
  62407. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62408. */
  62409. getTextureMatrix(): Matrix;
  62410. /**
  62411. * Occurs when the file being loaded is a .3dl LUT file.
  62412. */
  62413. private load3dlTexture;
  62414. /**
  62415. * Starts the loading process of the texture.
  62416. */
  62417. private loadTexture;
  62418. /**
  62419. * Clones the color gradind texture.
  62420. */
  62421. clone(): ColorGradingTexture;
  62422. /**
  62423. * Called during delayed load for textures.
  62424. */
  62425. delayLoad(): void;
  62426. /**
  62427. * Parses a color grading texture serialized by Babylon.
  62428. * @param parsedTexture The texture information being parsedTexture
  62429. * @param scene The scene to load the texture in
  62430. * @param rootUrl The root url of the data assets to load
  62431. * @return A color gradind texture
  62432. */
  62433. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62434. /**
  62435. * Serializes the LUT texture to json format.
  62436. */
  62437. serialize(): any;
  62438. }
  62439. }
  62440. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62442. import { Scene } from "babylonjs/scene";
  62443. import { Nullable } from "babylonjs/types";
  62444. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62445. /**
  62446. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62447. */
  62448. export class EquiRectangularCubeTexture extends BaseTexture {
  62449. /** The six faces of the cube. */
  62450. private static _FacesMapping;
  62451. private _noMipmap;
  62452. private _onLoad;
  62453. private _onError;
  62454. /** The size of the cubemap. */
  62455. private _size;
  62456. /** The buffer of the image. */
  62457. private _buffer;
  62458. /** The width of the input image. */
  62459. private _width;
  62460. /** The height of the input image. */
  62461. private _height;
  62462. /** The URL to the image. */
  62463. url: string;
  62464. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62465. coordinatesMode: number;
  62466. /**
  62467. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62468. * @param url The location of the image
  62469. * @param scene The scene the texture will be used in
  62470. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62471. * @param noMipmap Forces to not generate the mipmap if true
  62472. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62473. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62474. * @param onLoad — defines a callback called when texture is loaded
  62475. * @param onError — defines a callback called if there is an error
  62476. */
  62477. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62478. /**
  62479. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62480. */
  62481. private loadImage;
  62482. /**
  62483. * Convert the image buffer into a cubemap and create a CubeTexture.
  62484. */
  62485. private loadTexture;
  62486. /**
  62487. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62488. * @param buffer The ArrayBuffer that should be converted.
  62489. * @returns The buffer as Float32Array.
  62490. */
  62491. private getFloat32ArrayFromArrayBuffer;
  62492. /**
  62493. * Get the current class name of the texture useful for serialization or dynamic coding.
  62494. * @returns "EquiRectangularCubeTexture"
  62495. */
  62496. getClassName(): string;
  62497. /**
  62498. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62499. * @returns A clone of the current EquiRectangularCubeTexture.
  62500. */
  62501. clone(): EquiRectangularCubeTexture;
  62502. }
  62503. }
  62504. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62505. import { Nullable } from "babylonjs/types";
  62506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62507. import { Matrix } from "babylonjs/Maths/math.vector";
  62508. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62509. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62510. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62511. import { Scene } from "babylonjs/scene";
  62512. /**
  62513. * Defines the options related to the creation of an HtmlElementTexture
  62514. */
  62515. export interface IHtmlElementTextureOptions {
  62516. /**
  62517. * Defines wether mip maps should be created or not.
  62518. */
  62519. generateMipMaps?: boolean;
  62520. /**
  62521. * Defines the sampling mode of the texture.
  62522. */
  62523. samplingMode?: number;
  62524. /**
  62525. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62526. */
  62527. engine: Nullable<ThinEngine>;
  62528. /**
  62529. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62530. */
  62531. scene: Nullable<Scene>;
  62532. }
  62533. /**
  62534. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62535. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62536. * is automatically managed.
  62537. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62538. * in your application.
  62539. *
  62540. * As the update is not automatic, you need to call them manually.
  62541. */
  62542. export class HtmlElementTexture extends BaseTexture {
  62543. /**
  62544. * The texture URL.
  62545. */
  62546. element: HTMLVideoElement | HTMLCanvasElement;
  62547. private static readonly DefaultOptions;
  62548. private _textureMatrix;
  62549. private _isVideo;
  62550. private _generateMipMaps;
  62551. private _samplingMode;
  62552. /**
  62553. * Instantiates a HtmlElementTexture from the following parameters.
  62554. *
  62555. * @param name Defines the name of the texture
  62556. * @param element Defines the video or canvas the texture is filled with
  62557. * @param options Defines the other none mandatory texture creation options
  62558. */
  62559. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62560. private _createInternalTexture;
  62561. /**
  62562. * Returns the texture matrix used in most of the material.
  62563. */
  62564. getTextureMatrix(): Matrix;
  62565. /**
  62566. * Updates the content of the texture.
  62567. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62568. */
  62569. update(invertY?: Nullable<boolean>): void;
  62570. }
  62571. }
  62572. declare module "babylonjs/Misc/tga" {
  62573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62574. /**
  62575. * Based on jsTGALoader - Javascript loader for TGA file
  62576. * By Vincent Thibault
  62577. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62578. */
  62579. export class TGATools {
  62580. private static _TYPE_INDEXED;
  62581. private static _TYPE_RGB;
  62582. private static _TYPE_GREY;
  62583. private static _TYPE_RLE_INDEXED;
  62584. private static _TYPE_RLE_RGB;
  62585. private static _TYPE_RLE_GREY;
  62586. private static _ORIGIN_MASK;
  62587. private static _ORIGIN_SHIFT;
  62588. private static _ORIGIN_BL;
  62589. private static _ORIGIN_BR;
  62590. private static _ORIGIN_UL;
  62591. private static _ORIGIN_UR;
  62592. /**
  62593. * Gets the header of a TGA file
  62594. * @param data defines the TGA data
  62595. * @returns the header
  62596. */
  62597. static GetTGAHeader(data: Uint8Array): any;
  62598. /**
  62599. * Uploads TGA content to a Babylon Texture
  62600. * @hidden
  62601. */
  62602. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62603. /** @hidden */
  62604. 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;
  62605. /** @hidden */
  62606. 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;
  62607. /** @hidden */
  62608. 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;
  62609. /** @hidden */
  62610. 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;
  62611. /** @hidden */
  62612. 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;
  62613. /** @hidden */
  62614. 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;
  62615. }
  62616. }
  62617. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  62618. import { Nullable } from "babylonjs/types";
  62619. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62620. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62621. /**
  62622. * Implementation of the TGA Texture Loader.
  62623. * @hidden
  62624. */
  62625. export class _TGATextureLoader implements IInternalTextureLoader {
  62626. /**
  62627. * Defines wether the loader supports cascade loading the different faces.
  62628. */
  62629. readonly supportCascades: boolean;
  62630. /**
  62631. * This returns if the loader support the current file information.
  62632. * @param extension defines the file extension of the file being loaded
  62633. * @returns true if the loader can load the specified file
  62634. */
  62635. canLoad(extension: string): boolean;
  62636. /**
  62637. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62638. * @param data contains the texture data
  62639. * @param texture defines the BabylonJS internal texture
  62640. * @param createPolynomials will be true if polynomials have been requested
  62641. * @param onLoad defines the callback to trigger once the texture is ready
  62642. * @param onError defines the callback to trigger in case of error
  62643. */
  62644. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62645. /**
  62646. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62647. * @param data contains the texture data
  62648. * @param texture defines the BabylonJS internal texture
  62649. * @param callback defines the method to call once ready to upload
  62650. */
  62651. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62652. }
  62653. }
  62654. declare module "babylonjs/Misc/basis" {
  62655. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62656. /**
  62657. * Info about the .basis files
  62658. */
  62659. class BasisFileInfo {
  62660. /**
  62661. * If the file has alpha
  62662. */
  62663. hasAlpha: boolean;
  62664. /**
  62665. * Info about each image of the basis file
  62666. */
  62667. images: Array<{
  62668. levels: Array<{
  62669. width: number;
  62670. height: number;
  62671. transcodedPixels: ArrayBufferView;
  62672. }>;
  62673. }>;
  62674. }
  62675. /**
  62676. * Result of transcoding a basis file
  62677. */
  62678. class TranscodeResult {
  62679. /**
  62680. * Info about the .basis file
  62681. */
  62682. fileInfo: BasisFileInfo;
  62683. /**
  62684. * Format to use when loading the file
  62685. */
  62686. format: number;
  62687. }
  62688. /**
  62689. * Configuration options for the Basis transcoder
  62690. */
  62691. export class BasisTranscodeConfiguration {
  62692. /**
  62693. * Supported compression formats used to determine the supported output format of the transcoder
  62694. */
  62695. supportedCompressionFormats?: {
  62696. /**
  62697. * etc1 compression format
  62698. */
  62699. etc1?: boolean;
  62700. /**
  62701. * s3tc compression format
  62702. */
  62703. s3tc?: boolean;
  62704. /**
  62705. * pvrtc compression format
  62706. */
  62707. pvrtc?: boolean;
  62708. /**
  62709. * etc2 compression format
  62710. */
  62711. etc2?: boolean;
  62712. };
  62713. /**
  62714. * If mipmap levels should be loaded for transcoded images (Default: true)
  62715. */
  62716. loadMipmapLevels?: boolean;
  62717. /**
  62718. * Index of a single image to load (Default: all images)
  62719. */
  62720. loadSingleImage?: number;
  62721. }
  62722. /**
  62723. * Used to load .Basis files
  62724. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62725. */
  62726. export class BasisTools {
  62727. private static _IgnoreSupportedFormats;
  62728. /**
  62729. * URL to use when loading the basis transcoder
  62730. */
  62731. static JSModuleURL: string;
  62732. /**
  62733. * URL to use when loading the wasm module for the transcoder
  62734. */
  62735. static WasmModuleURL: string;
  62736. /**
  62737. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62738. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62739. * @returns internal format corresponding to the Basis format
  62740. */
  62741. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62742. private static _WorkerPromise;
  62743. private static _Worker;
  62744. private static _actionId;
  62745. private static _CreateWorkerAsync;
  62746. /**
  62747. * Transcodes a loaded image file to compressed pixel data
  62748. * @param data image data to transcode
  62749. * @param config configuration options for the transcoding
  62750. * @returns a promise resulting in the transcoded image
  62751. */
  62752. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62753. /**
  62754. * Loads a texture from the transcode result
  62755. * @param texture texture load to
  62756. * @param transcodeResult the result of transcoding the basis file to load from
  62757. */
  62758. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62759. }
  62760. }
  62761. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  62762. import { Nullable } from "babylonjs/types";
  62763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62764. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62765. /**
  62766. * Loader for .basis file format
  62767. */
  62768. export class _BasisTextureLoader implements IInternalTextureLoader {
  62769. /**
  62770. * Defines whether the loader supports cascade loading the different faces.
  62771. */
  62772. readonly supportCascades: boolean;
  62773. /**
  62774. * This returns if the loader support the current file information.
  62775. * @param extension defines the file extension of the file being loaded
  62776. * @returns true if the loader can load the specified file
  62777. */
  62778. canLoad(extension: string): boolean;
  62779. /**
  62780. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62781. * @param data contains the texture data
  62782. * @param texture defines the BabylonJS internal texture
  62783. * @param createPolynomials will be true if polynomials have been requested
  62784. * @param onLoad defines the callback to trigger once the texture is ready
  62785. * @param onError defines the callback to trigger in case of error
  62786. */
  62787. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62788. /**
  62789. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62790. * @param data contains the texture data
  62791. * @param texture defines the BabylonJS internal texture
  62792. * @param callback defines the method to call once ready to upload
  62793. */
  62794. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62795. }
  62796. }
  62797. declare module "babylonjs/Materials/Textures/Loaders/index" {
  62798. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62799. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62800. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62801. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  62802. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  62803. }
  62804. declare module "babylonjs/Materials/Textures/Packer/frame" {
  62805. import { Vector2 } from "babylonjs/Maths/math.vector";
  62806. /**
  62807. * Defines the basic options interface of a TexturePacker Frame
  62808. */
  62809. export interface ITexturePackerFrame {
  62810. /**
  62811. * The frame ID
  62812. */
  62813. id: number;
  62814. /**
  62815. * The frames Scale
  62816. */
  62817. scale: Vector2;
  62818. /**
  62819. * The Frames offset
  62820. */
  62821. offset: Vector2;
  62822. }
  62823. /**
  62824. * This is a support class for frame Data on texture packer sets.
  62825. */
  62826. export class TexturePackerFrame implements ITexturePackerFrame {
  62827. /**
  62828. * The frame ID
  62829. */
  62830. id: number;
  62831. /**
  62832. * The frames Scale
  62833. */
  62834. scale: Vector2;
  62835. /**
  62836. * The Frames offset
  62837. */
  62838. offset: Vector2;
  62839. /**
  62840. * Initializes a texture package frame.
  62841. * @param id The numerical frame identifier
  62842. * @param scale Scalar Vector2 for UV frame
  62843. * @param offset Vector2 for the frame position in UV units.
  62844. * @returns TexturePackerFrame
  62845. */
  62846. constructor(id: number, scale: Vector2, offset: Vector2);
  62847. }
  62848. }
  62849. declare module "babylonjs/Materials/Textures/Packer/packer" {
  62850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62851. import { Scene } from "babylonjs/scene";
  62852. import { Nullable } from "babylonjs/types";
  62853. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  62854. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  62855. /**
  62856. * Defines the basic options interface of a TexturePacker
  62857. */
  62858. export interface ITexturePackerOptions {
  62859. /**
  62860. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62861. */
  62862. map?: string[];
  62863. /**
  62864. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62865. */
  62866. uvsIn?: string;
  62867. /**
  62868. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62869. */
  62870. uvsOut?: string;
  62871. /**
  62872. * number representing the layout style. Defaults to LAYOUT_STRIP
  62873. */
  62874. layout?: number;
  62875. /**
  62876. * number of columns if using custom column count layout(2). This defaults to 4.
  62877. */
  62878. colnum?: number;
  62879. /**
  62880. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62881. */
  62882. updateInputMeshes?: boolean;
  62883. /**
  62884. * boolean flag to dispose all the source textures. Defaults to true.
  62885. */
  62886. disposeSources?: boolean;
  62887. /**
  62888. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62889. */
  62890. fillBlanks?: boolean;
  62891. /**
  62892. * string value representing the context fill style color. Defaults to 'black'.
  62893. */
  62894. customFillColor?: string;
  62895. /**
  62896. * Width and Height Value of each Frame in the TexturePacker Sets
  62897. */
  62898. frameSize?: number;
  62899. /**
  62900. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62901. */
  62902. paddingRatio?: number;
  62903. /**
  62904. * Number that declares the fill method for the padding gutter.
  62905. */
  62906. paddingMode?: number;
  62907. /**
  62908. * If in SUBUV_COLOR padding mode what color to use.
  62909. */
  62910. paddingColor?: Color3 | Color4;
  62911. }
  62912. /**
  62913. * Defines the basic interface of a TexturePacker JSON File
  62914. */
  62915. export interface ITexturePackerJSON {
  62916. /**
  62917. * The frame ID
  62918. */
  62919. name: string;
  62920. /**
  62921. * The base64 channel data
  62922. */
  62923. sets: any;
  62924. /**
  62925. * The options of the Packer
  62926. */
  62927. options: ITexturePackerOptions;
  62928. /**
  62929. * The frame data of the Packer
  62930. */
  62931. frames: Array<number>;
  62932. }
  62933. /**
  62934. * This is a support class that generates a series of packed texture sets.
  62935. * @see https://doc.babylonjs.com/babylon101/materials
  62936. */
  62937. export class TexturePacker {
  62938. /** Packer Layout Constant 0 */
  62939. static readonly LAYOUT_STRIP: number;
  62940. /** Packer Layout Constant 1 */
  62941. static readonly LAYOUT_POWER2: number;
  62942. /** Packer Layout Constant 2 */
  62943. static readonly LAYOUT_COLNUM: number;
  62944. /** Packer Layout Constant 0 */
  62945. static readonly SUBUV_WRAP: number;
  62946. /** Packer Layout Constant 1 */
  62947. static readonly SUBUV_EXTEND: number;
  62948. /** Packer Layout Constant 2 */
  62949. static readonly SUBUV_COLOR: number;
  62950. /** The Name of the Texture Package */
  62951. name: string;
  62952. /** The scene scope of the TexturePacker */
  62953. scene: Scene;
  62954. /** The Meshes to target */
  62955. meshes: AbstractMesh[];
  62956. /** Arguments passed with the Constructor */
  62957. options: ITexturePackerOptions;
  62958. /** The promise that is started upon initialization */
  62959. promise: Nullable<Promise<TexturePacker | string>>;
  62960. /** The Container object for the channel sets that are generated */
  62961. sets: object;
  62962. /** The Container array for the frames that are generated */
  62963. frames: TexturePackerFrame[];
  62964. /** The expected number of textures the system is parsing. */
  62965. private _expecting;
  62966. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62967. private _paddingValue;
  62968. /**
  62969. * Initializes a texture package series from an array of meshes or a single mesh.
  62970. * @param name The name of the package
  62971. * @param meshes The target meshes to compose the package from
  62972. * @param options The arguments that texture packer should follow while building.
  62973. * @param scene The scene which the textures are scoped to.
  62974. * @returns TexturePacker
  62975. */
  62976. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62977. /**
  62978. * Starts the package process
  62979. * @param resolve The promises resolution function
  62980. * @returns TexturePacker
  62981. */
  62982. private _createFrames;
  62983. /**
  62984. * Calculates the Size of the Channel Sets
  62985. * @returns Vector2
  62986. */
  62987. private _calculateSize;
  62988. /**
  62989. * Calculates the UV data for the frames.
  62990. * @param baseSize the base frameSize
  62991. * @param padding the base frame padding
  62992. * @param dtSize size of the Dynamic Texture for that channel
  62993. * @param dtUnits is 1/dtSize
  62994. * @param update flag to update the input meshes
  62995. */
  62996. private _calculateMeshUVFrames;
  62997. /**
  62998. * Calculates the frames Offset.
  62999. * @param index of the frame
  63000. * @returns Vector2
  63001. */
  63002. private _getFrameOffset;
  63003. /**
  63004. * Updates a Mesh to the frame data
  63005. * @param mesh that is the target
  63006. * @param frameID or the frame index
  63007. */
  63008. private _updateMeshUV;
  63009. /**
  63010. * Updates a Meshes materials to use the texture packer channels
  63011. * @param m is the mesh to target
  63012. * @param force all channels on the packer to be set.
  63013. */
  63014. private _updateTextureReferences;
  63015. /**
  63016. * Public method to set a Mesh to a frame
  63017. * @param m that is the target
  63018. * @param frameID or the frame index
  63019. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63020. */
  63021. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63022. /**
  63023. * Starts the async promise to compile the texture packer.
  63024. * @returns Promise<void>
  63025. */
  63026. processAsync(): Promise<void>;
  63027. /**
  63028. * Disposes all textures associated with this packer
  63029. */
  63030. dispose(): void;
  63031. /**
  63032. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63033. * @param imageType is the image type to use.
  63034. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63035. */
  63036. download(imageType?: string, quality?: number): void;
  63037. /**
  63038. * Public method to load a texturePacker JSON file.
  63039. * @param data of the JSON file in string format.
  63040. */
  63041. updateFromJSON(data: string): void;
  63042. }
  63043. }
  63044. declare module "babylonjs/Materials/Textures/Packer/index" {
  63045. export * from "babylonjs/Materials/Textures/Packer/packer";
  63046. export * from "babylonjs/Materials/Textures/Packer/frame";
  63047. }
  63048. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63049. import { Scene } from "babylonjs/scene";
  63050. import { Texture } from "babylonjs/Materials/Textures/texture";
  63051. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63052. /**
  63053. * 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.
  63054. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63055. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63056. */
  63057. export class CustomProceduralTexture extends ProceduralTexture {
  63058. private _animate;
  63059. private _time;
  63060. private _config;
  63061. private _texturePath;
  63062. /**
  63063. * Instantiates a new Custom Procedural Texture.
  63064. * 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.
  63065. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63066. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63067. * @param name Define the name of the texture
  63068. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63069. * @param size Define the size of the texture to create
  63070. * @param scene Define the scene the texture belongs to
  63071. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63072. * @param generateMipMaps Define if the texture should creates mip maps or not
  63073. */
  63074. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63075. private _loadJson;
  63076. /**
  63077. * Is the texture ready to be used ? (rendered at least once)
  63078. * @returns true if ready, otherwise, false.
  63079. */
  63080. isReady(): boolean;
  63081. /**
  63082. * Render the texture to its associated render target.
  63083. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63084. */
  63085. render(useCameraPostProcess?: boolean): void;
  63086. /**
  63087. * Update the list of dependant textures samplers in the shader.
  63088. */
  63089. updateTextures(): void;
  63090. /**
  63091. * Update the uniform values of the procedural texture in the shader.
  63092. */
  63093. updateShaderUniforms(): void;
  63094. /**
  63095. * Define if the texture animates or not.
  63096. */
  63097. get animate(): boolean;
  63098. set animate(value: boolean);
  63099. }
  63100. }
  63101. declare module "babylonjs/Shaders/noise.fragment" {
  63102. /** @hidden */
  63103. export var noisePixelShader: {
  63104. name: string;
  63105. shader: string;
  63106. };
  63107. }
  63108. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63109. import { Nullable } from "babylonjs/types";
  63110. import { Scene } from "babylonjs/scene";
  63111. import { Texture } from "babylonjs/Materials/Textures/texture";
  63112. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63113. import "babylonjs/Shaders/noise.fragment";
  63114. /**
  63115. * Class used to generate noise procedural textures
  63116. */
  63117. export class NoiseProceduralTexture extends ProceduralTexture {
  63118. private _time;
  63119. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63120. brightness: number;
  63121. /** Defines the number of octaves to process */
  63122. octaves: number;
  63123. /** Defines the level of persistence (0.8 by default) */
  63124. persistence: number;
  63125. /** Gets or sets animation speed factor (default is 1) */
  63126. animationSpeedFactor: number;
  63127. /**
  63128. * Creates a new NoiseProceduralTexture
  63129. * @param name defines the name fo the texture
  63130. * @param size defines the size of the texture (default is 256)
  63131. * @param scene defines the hosting scene
  63132. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63133. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63134. */
  63135. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63136. private _updateShaderUniforms;
  63137. protected _getDefines(): string;
  63138. /** Generate the current state of the procedural texture */
  63139. render(useCameraPostProcess?: boolean): void;
  63140. /**
  63141. * Serializes this noise procedural texture
  63142. * @returns a serialized noise procedural texture object
  63143. */
  63144. serialize(): any;
  63145. /**
  63146. * Clone the texture.
  63147. * @returns the cloned texture
  63148. */
  63149. clone(): NoiseProceduralTexture;
  63150. /**
  63151. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63152. * @param parsedTexture defines parsed texture data
  63153. * @param scene defines the current scene
  63154. * @param rootUrl defines the root URL containing noise procedural texture information
  63155. * @returns a parsed NoiseProceduralTexture
  63156. */
  63157. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63158. }
  63159. }
  63160. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63161. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63162. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63163. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63164. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63165. }
  63166. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63167. import { Nullable } from "babylonjs/types";
  63168. import { Scene } from "babylonjs/scene";
  63169. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63171. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63172. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63173. /**
  63174. * Raw cube texture where the raw buffers are passed in
  63175. */
  63176. export class RawCubeTexture extends CubeTexture {
  63177. /**
  63178. * Creates a cube texture where the raw buffers are passed in.
  63179. * @param scene defines the scene the texture is attached to
  63180. * @param data defines the array of data to use to create each face
  63181. * @param size defines the size of the textures
  63182. * @param format defines the format of the data
  63183. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63184. * @param generateMipMaps defines if the engine should generate the mip levels
  63185. * @param invertY defines if data must be stored with Y axis inverted
  63186. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63187. * @param compression defines the compression used (null by default)
  63188. */
  63189. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63190. /**
  63191. * Updates the raw cube texture.
  63192. * @param data defines the data to store
  63193. * @param format defines the data format
  63194. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63195. * @param invertY defines if data must be stored with Y axis inverted
  63196. * @param compression defines the compression used (null by default)
  63197. * @param level defines which level of the texture to update
  63198. */
  63199. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63200. /**
  63201. * Updates a raw cube texture with RGBD encoded data.
  63202. * @param data defines the array of data [mipmap][face] to use to create each face
  63203. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63204. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63205. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63206. * @returns a promsie that resolves when the operation is complete
  63207. */
  63208. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63209. /**
  63210. * Clones the raw cube texture.
  63211. * @return a new cube texture
  63212. */
  63213. clone(): CubeTexture;
  63214. /** @hidden */
  63215. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63216. }
  63217. }
  63218. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63219. import { Scene } from "babylonjs/scene";
  63220. import { Texture } from "babylonjs/Materials/Textures/texture";
  63221. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63222. /**
  63223. * Class used to store 2D array textures containing user data
  63224. */
  63225. export class RawTexture2DArray extends Texture {
  63226. /** Gets or sets the texture format to use */
  63227. format: number;
  63228. /**
  63229. * Create a new RawTexture2DArray
  63230. * @param data defines the data of the texture
  63231. * @param width defines the width of the texture
  63232. * @param height defines the height of the texture
  63233. * @param depth defines the number of layers of the texture
  63234. * @param format defines the texture format to use
  63235. * @param scene defines the hosting scene
  63236. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63237. * @param invertY defines if texture must be stored with Y axis inverted
  63238. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63239. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63240. */
  63241. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63242. /** Gets or sets the texture format to use */
  63243. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63244. /**
  63245. * Update the texture with new data
  63246. * @param data defines the data to store in the texture
  63247. */
  63248. update(data: ArrayBufferView): void;
  63249. }
  63250. }
  63251. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63252. import { Scene } from "babylonjs/scene";
  63253. import { Texture } from "babylonjs/Materials/Textures/texture";
  63254. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63255. /**
  63256. * Class used to store 3D textures containing user data
  63257. */
  63258. export class RawTexture3D extends Texture {
  63259. /** Gets or sets the texture format to use */
  63260. format: number;
  63261. /**
  63262. * Create a new RawTexture3D
  63263. * @param data defines the data of the texture
  63264. * @param width defines the width of the texture
  63265. * @param height defines the height of the texture
  63266. * @param depth defines the depth of the texture
  63267. * @param format defines the texture format to use
  63268. * @param scene defines the hosting scene
  63269. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63270. * @param invertY defines if texture must be stored with Y axis inverted
  63271. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63272. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63273. */
  63274. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63275. /** Gets or sets the texture format to use */
  63276. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63277. /**
  63278. * Update the texture with new data
  63279. * @param data defines the data to store in the texture
  63280. */
  63281. update(data: ArrayBufferView): void;
  63282. }
  63283. }
  63284. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63285. import { Scene } from "babylonjs/scene";
  63286. import { Plane } from "babylonjs/Maths/math.plane";
  63287. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63288. /**
  63289. * Creates a refraction texture used by refraction channel of the standard material.
  63290. * It is like a mirror but to see through a material.
  63291. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63292. */
  63293. export class RefractionTexture extends RenderTargetTexture {
  63294. /**
  63295. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63296. * 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.
  63297. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63298. */
  63299. refractionPlane: Plane;
  63300. /**
  63301. * Define how deep under the surface we should see.
  63302. */
  63303. depth: number;
  63304. /**
  63305. * Creates a refraction texture used by refraction channel of the standard material.
  63306. * It is like a mirror but to see through a material.
  63307. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63308. * @param name Define the texture name
  63309. * @param size Define the size of the underlying texture
  63310. * @param scene Define the scene the refraction belongs to
  63311. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63312. */
  63313. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63314. /**
  63315. * Clone the refraction texture.
  63316. * @returns the cloned texture
  63317. */
  63318. clone(): RefractionTexture;
  63319. /**
  63320. * Serialize the texture to a JSON representation you could use in Parse later on
  63321. * @returns the serialized JSON representation
  63322. */
  63323. serialize(): any;
  63324. }
  63325. }
  63326. declare module "babylonjs/Materials/Textures/index" {
  63327. export * from "babylonjs/Materials/Textures/baseTexture";
  63328. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63329. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63330. export * from "babylonjs/Materials/Textures/cubeTexture";
  63331. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63332. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63333. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63334. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63335. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63336. export * from "babylonjs/Materials/Textures/internalTexture";
  63337. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63338. export * from "babylonjs/Materials/Textures/Loaders/index";
  63339. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63340. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63341. export * from "babylonjs/Materials/Textures/Packer/index";
  63342. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63343. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63344. export * from "babylonjs/Materials/Textures/rawTexture";
  63345. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63346. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63347. export * from "babylonjs/Materials/Textures/refractionTexture";
  63348. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63349. export * from "babylonjs/Materials/Textures/texture";
  63350. export * from "babylonjs/Materials/Textures/videoTexture";
  63351. }
  63352. declare module "babylonjs/Materials/Node/Enums/index" {
  63353. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63354. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63355. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63356. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63357. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63358. }
  63359. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63363. import { Mesh } from "babylonjs/Meshes/mesh";
  63364. import { Effect } from "babylonjs/Materials/effect";
  63365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63366. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63367. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63368. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63369. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63370. /**
  63371. * Block used to add support for vertex skinning (bones)
  63372. */
  63373. export class BonesBlock extends NodeMaterialBlock {
  63374. /**
  63375. * Creates a new BonesBlock
  63376. * @param name defines the block name
  63377. */
  63378. constructor(name: string);
  63379. /**
  63380. * Initialize the block and prepare the context for build
  63381. * @param state defines the state that will be used for the build
  63382. */
  63383. initialize(state: NodeMaterialBuildState): void;
  63384. /**
  63385. * Gets the current class name
  63386. * @returns the class name
  63387. */
  63388. getClassName(): string;
  63389. /**
  63390. * Gets the matrix indices input component
  63391. */
  63392. get matricesIndices(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the matrix weights input component
  63395. */
  63396. get matricesWeights(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the extra matrix indices input component
  63399. */
  63400. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63401. /**
  63402. * Gets the extra matrix weights input component
  63403. */
  63404. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63405. /**
  63406. * Gets the world input component
  63407. */
  63408. get world(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the output component
  63411. */
  63412. get output(): NodeMaterialConnectionPoint;
  63413. autoConfigure(material: NodeMaterial): void;
  63414. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63416. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63417. protected _buildBlock(state: NodeMaterialBuildState): this;
  63418. }
  63419. }
  63420. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63425. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63426. /**
  63427. * Block used to add support for instances
  63428. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63429. */
  63430. export class InstancesBlock extends NodeMaterialBlock {
  63431. /**
  63432. * Creates a new InstancesBlock
  63433. * @param name defines the block name
  63434. */
  63435. constructor(name: string);
  63436. /**
  63437. * Gets the current class name
  63438. * @returns the class name
  63439. */
  63440. getClassName(): string;
  63441. /**
  63442. * Gets the first world row input component
  63443. */
  63444. get world0(): NodeMaterialConnectionPoint;
  63445. /**
  63446. * Gets the second world row input component
  63447. */
  63448. get world1(): NodeMaterialConnectionPoint;
  63449. /**
  63450. * Gets the third world row input component
  63451. */
  63452. get world2(): NodeMaterialConnectionPoint;
  63453. /**
  63454. * Gets the forth world row input component
  63455. */
  63456. get world3(): NodeMaterialConnectionPoint;
  63457. /**
  63458. * Gets the world input component
  63459. */
  63460. get world(): NodeMaterialConnectionPoint;
  63461. /**
  63462. * Gets the output component
  63463. */
  63464. get output(): NodeMaterialConnectionPoint;
  63465. /**
  63466. * Gets the isntanceID component
  63467. */
  63468. get instanceID(): NodeMaterialConnectionPoint;
  63469. autoConfigure(material: NodeMaterial): void;
  63470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  63471. protected _buildBlock(state: NodeMaterialBuildState): this;
  63472. }
  63473. }
  63474. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63479. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63480. import { Effect } from "babylonjs/Materials/effect";
  63481. import { Mesh } from "babylonjs/Meshes/mesh";
  63482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63483. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63484. /**
  63485. * Block used to add morph targets support to vertex shader
  63486. */
  63487. export class MorphTargetsBlock extends NodeMaterialBlock {
  63488. private _repeatableContentAnchor;
  63489. /**
  63490. * Create a new MorphTargetsBlock
  63491. * @param name defines the block name
  63492. */
  63493. constructor(name: string);
  63494. /**
  63495. * Gets the current class name
  63496. * @returns the class name
  63497. */
  63498. getClassName(): string;
  63499. /**
  63500. * Gets the position input component
  63501. */
  63502. get position(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the normal input component
  63505. */
  63506. get normal(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the tangent input component
  63509. */
  63510. get tangent(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the tangent input component
  63513. */
  63514. get uv(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the position output component
  63517. */
  63518. get positionOutput(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the normal output component
  63521. */
  63522. get normalOutput(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the tangent output component
  63525. */
  63526. get tangentOutput(): NodeMaterialConnectionPoint;
  63527. /**
  63528. * Gets the tangent output component
  63529. */
  63530. get uvOutput(): NodeMaterialConnectionPoint;
  63531. initialize(state: NodeMaterialBuildState): void;
  63532. autoConfigure(material: NodeMaterial): void;
  63533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63535. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63536. protected _buildBlock(state: NodeMaterialBuildState): this;
  63537. }
  63538. }
  63539. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63543. import { Nullable } from "babylonjs/types";
  63544. import { Scene } from "babylonjs/scene";
  63545. import { Effect } from "babylonjs/Materials/effect";
  63546. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63547. import { Mesh } from "babylonjs/Meshes/mesh";
  63548. import { Light } from "babylonjs/Lights/light";
  63549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63550. /**
  63551. * Block used to get data information from a light
  63552. */
  63553. export class LightInformationBlock extends NodeMaterialBlock {
  63554. private _lightDataUniformName;
  63555. private _lightColorUniformName;
  63556. private _lightTypeDefineName;
  63557. /**
  63558. * Gets or sets the light associated with this block
  63559. */
  63560. light: Nullable<Light>;
  63561. /**
  63562. * Creates a new LightInformationBlock
  63563. * @param name defines the block name
  63564. */
  63565. constructor(name: string);
  63566. /**
  63567. * Gets the current class name
  63568. * @returns the class name
  63569. */
  63570. getClassName(): string;
  63571. /**
  63572. * Gets the world position input component
  63573. */
  63574. get worldPosition(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the direction output component
  63577. */
  63578. get direction(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the direction output component
  63581. */
  63582. get color(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the direction output component
  63585. */
  63586. get intensity(): NodeMaterialConnectionPoint;
  63587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63589. protected _buildBlock(state: NodeMaterialBuildState): this;
  63590. serialize(): any;
  63591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63592. }
  63593. }
  63594. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  63595. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  63596. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  63597. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  63598. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  63599. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  63600. }
  63601. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  63602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63606. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63607. import { Effect } from "babylonjs/Materials/effect";
  63608. import { Mesh } from "babylonjs/Meshes/mesh";
  63609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63610. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63611. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63612. /**
  63613. * Block used to add image processing support to fragment shader
  63614. */
  63615. export class ImageProcessingBlock extends NodeMaterialBlock {
  63616. /**
  63617. * Create a new ImageProcessingBlock
  63618. * @param name defines the block name
  63619. */
  63620. constructor(name: string);
  63621. /**
  63622. * Gets the current class name
  63623. * @returns the class name
  63624. */
  63625. getClassName(): string;
  63626. /**
  63627. * Gets the color input component
  63628. */
  63629. get color(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the output component
  63632. */
  63633. get output(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Initialize the block and prepare the context for build
  63636. * @param state defines the state that will be used for the build
  63637. */
  63638. initialize(state: NodeMaterialBuildState): void;
  63639. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63642. protected _buildBlock(state: NodeMaterialBuildState): this;
  63643. }
  63644. }
  63645. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  63646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63649. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63651. import { Effect } from "babylonjs/Materials/effect";
  63652. import { Mesh } from "babylonjs/Meshes/mesh";
  63653. import { Scene } from "babylonjs/scene";
  63654. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  63655. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  63656. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  63657. /**
  63658. * Block used to pertub normals based on a normal map
  63659. */
  63660. export class PerturbNormalBlock extends NodeMaterialBlock {
  63661. private _tangentSpaceParameterName;
  63662. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63663. invertX: boolean;
  63664. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63665. invertY: boolean;
  63666. /**
  63667. * Create a new PerturbNormalBlock
  63668. * @param name defines the block name
  63669. */
  63670. constructor(name: string);
  63671. /**
  63672. * Gets the current class name
  63673. * @returns the class name
  63674. */
  63675. getClassName(): string;
  63676. /**
  63677. * Gets the world position input component
  63678. */
  63679. get worldPosition(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the world normal input component
  63682. */
  63683. get worldNormal(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the world tangent input component
  63686. */
  63687. get worldTangent(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the uv input component
  63690. */
  63691. get uv(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the normal map color input component
  63694. */
  63695. get normalMapColor(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the strength input component
  63698. */
  63699. get strength(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the output component
  63702. */
  63703. get output(): NodeMaterialConnectionPoint;
  63704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63706. autoConfigure(material: NodeMaterial): void;
  63707. protected _buildBlock(state: NodeMaterialBuildState): this;
  63708. protected _dumpPropertiesCode(): string;
  63709. serialize(): any;
  63710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63711. }
  63712. }
  63713. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  63714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63717. /**
  63718. * Block used to discard a pixel if a value is smaller than a cutoff
  63719. */
  63720. export class DiscardBlock extends NodeMaterialBlock {
  63721. /**
  63722. * Create a new DiscardBlock
  63723. * @param name defines the block name
  63724. */
  63725. constructor(name: string);
  63726. /**
  63727. * Gets the current class name
  63728. * @returns the class name
  63729. */
  63730. getClassName(): string;
  63731. /**
  63732. * Gets the color input component
  63733. */
  63734. get value(): NodeMaterialConnectionPoint;
  63735. /**
  63736. * Gets the cutoff input component
  63737. */
  63738. get cutoff(): NodeMaterialConnectionPoint;
  63739. protected _buildBlock(state: NodeMaterialBuildState): this;
  63740. }
  63741. }
  63742. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  63743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63746. /**
  63747. * Block used to test if the fragment shader is front facing
  63748. */
  63749. export class FrontFacingBlock extends NodeMaterialBlock {
  63750. /**
  63751. * Creates a new FrontFacingBlock
  63752. * @param name defines the block name
  63753. */
  63754. constructor(name: string);
  63755. /**
  63756. * Gets the current class name
  63757. * @returns the class name
  63758. */
  63759. getClassName(): string;
  63760. /**
  63761. * Gets the output component
  63762. */
  63763. get output(): NodeMaterialConnectionPoint;
  63764. protected _buildBlock(state: NodeMaterialBuildState): this;
  63765. }
  63766. }
  63767. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  63768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63771. /**
  63772. * Block used to get the derivative value on x and y of a given input
  63773. */
  63774. export class DerivativeBlock extends NodeMaterialBlock {
  63775. /**
  63776. * Create a new DerivativeBlock
  63777. * @param name defines the block name
  63778. */
  63779. constructor(name: string);
  63780. /**
  63781. * Gets the current class name
  63782. * @returns the class name
  63783. */
  63784. getClassName(): string;
  63785. /**
  63786. * Gets the input component
  63787. */
  63788. get input(): NodeMaterialConnectionPoint;
  63789. /**
  63790. * Gets the derivative output on x
  63791. */
  63792. get dx(): NodeMaterialConnectionPoint;
  63793. /**
  63794. * Gets the derivative output on y
  63795. */
  63796. get dy(): NodeMaterialConnectionPoint;
  63797. protected _buildBlock(state: NodeMaterialBuildState): this;
  63798. }
  63799. }
  63800. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  63801. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  63802. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  63803. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  63804. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  63805. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  63806. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  63807. }
  63808. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  63809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63811. import { Mesh } from "babylonjs/Meshes/mesh";
  63812. import { Effect } from "babylonjs/Materials/effect";
  63813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63816. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63817. /**
  63818. * Block used to add support for scene fog
  63819. */
  63820. export class FogBlock extends NodeMaterialBlock {
  63821. private _fogDistanceName;
  63822. private _fogParameters;
  63823. /**
  63824. * Create a new FogBlock
  63825. * @param name defines the block name
  63826. */
  63827. constructor(name: string);
  63828. /**
  63829. * Gets the current class name
  63830. * @returns the class name
  63831. */
  63832. getClassName(): string;
  63833. /**
  63834. * Gets the world position input component
  63835. */
  63836. get worldPosition(): NodeMaterialConnectionPoint;
  63837. /**
  63838. * Gets the view input component
  63839. */
  63840. get view(): NodeMaterialConnectionPoint;
  63841. /**
  63842. * Gets the color input component
  63843. */
  63844. get input(): NodeMaterialConnectionPoint;
  63845. /**
  63846. * Gets the fog color input component
  63847. */
  63848. get fogColor(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the output component
  63851. */
  63852. get output(): NodeMaterialConnectionPoint;
  63853. autoConfigure(material: NodeMaterial): void;
  63854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63855. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63856. protected _buildBlock(state: NodeMaterialBuildState): this;
  63857. }
  63858. }
  63859. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  63860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63865. import { Effect } from "babylonjs/Materials/effect";
  63866. import { Mesh } from "babylonjs/Meshes/mesh";
  63867. import { Light } from "babylonjs/Lights/light";
  63868. import { Nullable } from "babylonjs/types";
  63869. import { Scene } from "babylonjs/scene";
  63870. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63871. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63872. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  63873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63874. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  63875. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  63876. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  63877. /**
  63878. * Block used to add light in the fragment shader
  63879. */
  63880. export class LightBlock extends NodeMaterialBlock {
  63881. private _lightId;
  63882. /**
  63883. * Gets or sets the light associated with this block
  63884. */
  63885. light: Nullable<Light>;
  63886. /**
  63887. * Create a new LightBlock
  63888. * @param name defines the block name
  63889. */
  63890. constructor(name: string);
  63891. /**
  63892. * Gets the current class name
  63893. * @returns the class name
  63894. */
  63895. getClassName(): string;
  63896. /**
  63897. * Gets the world position input component
  63898. */
  63899. get worldPosition(): NodeMaterialConnectionPoint;
  63900. /**
  63901. * Gets the world normal input component
  63902. */
  63903. get worldNormal(): NodeMaterialConnectionPoint;
  63904. /**
  63905. * Gets the camera (or eye) position component
  63906. */
  63907. get cameraPosition(): NodeMaterialConnectionPoint;
  63908. /**
  63909. * Gets the glossiness component
  63910. */
  63911. get glossiness(): NodeMaterialConnectionPoint;
  63912. /**
  63913. * Gets the glossinness power component
  63914. */
  63915. get glossPower(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the diffuse color component
  63918. */
  63919. get diffuseColor(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the specular color component
  63922. */
  63923. get specularColor(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the diffuse output component
  63926. */
  63927. get diffuseOutput(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the specular output component
  63930. */
  63931. get specularOutput(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the shadow output component
  63934. */
  63935. get shadow(): NodeMaterialConnectionPoint;
  63936. autoConfigure(material: NodeMaterial): void;
  63937. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63938. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63940. private _injectVertexCode;
  63941. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63942. serialize(): any;
  63943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63944. }
  63945. }
  63946. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  63947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63949. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63950. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  63951. /**
  63952. * Block used to read a reflection texture from a sampler
  63953. */
  63954. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63955. /**
  63956. * Create a new ReflectionTextureBlock
  63957. * @param name defines the block name
  63958. */
  63959. constructor(name: string);
  63960. /**
  63961. * Gets the current class name
  63962. * @returns the class name
  63963. */
  63964. getClassName(): string;
  63965. /**
  63966. * Gets the world position input component
  63967. */
  63968. get position(): NodeMaterialConnectionPoint;
  63969. /**
  63970. * Gets the world position input component
  63971. */
  63972. get worldPosition(): NodeMaterialConnectionPoint;
  63973. /**
  63974. * Gets the world normal input component
  63975. */
  63976. get worldNormal(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the world input component
  63979. */
  63980. get world(): NodeMaterialConnectionPoint;
  63981. /**
  63982. * Gets the camera (or eye) position component
  63983. */
  63984. get cameraPosition(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the view input component
  63987. */
  63988. get view(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the rgb output component
  63991. */
  63992. get rgb(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the r output component
  63995. */
  63996. get r(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the g output component
  63999. */
  64000. get g(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the b output component
  64003. */
  64004. get b(): NodeMaterialConnectionPoint;
  64005. autoConfigure(material: NodeMaterial): void;
  64006. protected _buildBlock(state: NodeMaterialBuildState): this;
  64007. }
  64008. }
  64009. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64010. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64011. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64012. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64013. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64014. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64015. }
  64016. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64017. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64018. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64019. }
  64020. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64024. /**
  64025. * Block used to add 2 vectors
  64026. */
  64027. export class AddBlock extends NodeMaterialBlock {
  64028. /**
  64029. * Creates a new AddBlock
  64030. * @param name defines the block name
  64031. */
  64032. constructor(name: string);
  64033. /**
  64034. * Gets the current class name
  64035. * @returns the class name
  64036. */
  64037. getClassName(): string;
  64038. /**
  64039. * Gets the left operand input component
  64040. */
  64041. get left(): NodeMaterialConnectionPoint;
  64042. /**
  64043. * Gets the right operand input component
  64044. */
  64045. get right(): NodeMaterialConnectionPoint;
  64046. /**
  64047. * Gets the output component
  64048. */
  64049. get output(): NodeMaterialConnectionPoint;
  64050. protected _buildBlock(state: NodeMaterialBuildState): this;
  64051. }
  64052. }
  64053. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64057. /**
  64058. * Block used to scale a vector by a float
  64059. */
  64060. export class ScaleBlock extends NodeMaterialBlock {
  64061. /**
  64062. * Creates a new ScaleBlock
  64063. * @param name defines the block name
  64064. */
  64065. constructor(name: string);
  64066. /**
  64067. * Gets the current class name
  64068. * @returns the class name
  64069. */
  64070. getClassName(): string;
  64071. /**
  64072. * Gets the input component
  64073. */
  64074. get input(): NodeMaterialConnectionPoint;
  64075. /**
  64076. * Gets the factor input component
  64077. */
  64078. get factor(): NodeMaterialConnectionPoint;
  64079. /**
  64080. * Gets the output component
  64081. */
  64082. get output(): NodeMaterialConnectionPoint;
  64083. protected _buildBlock(state: NodeMaterialBuildState): this;
  64084. }
  64085. }
  64086. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64090. import { Scene } from "babylonjs/scene";
  64091. /**
  64092. * Block used to clamp a float
  64093. */
  64094. export class ClampBlock extends NodeMaterialBlock {
  64095. /** Gets or sets the minimum range */
  64096. minimum: number;
  64097. /** Gets or sets the maximum range */
  64098. maximum: number;
  64099. /**
  64100. * Creates a new ClampBlock
  64101. * @param name defines the block name
  64102. */
  64103. constructor(name: string);
  64104. /**
  64105. * Gets the current class name
  64106. * @returns the class name
  64107. */
  64108. getClassName(): string;
  64109. /**
  64110. * Gets the value input component
  64111. */
  64112. get value(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the output component
  64115. */
  64116. get output(): NodeMaterialConnectionPoint;
  64117. protected _buildBlock(state: NodeMaterialBuildState): this;
  64118. protected _dumpPropertiesCode(): string;
  64119. serialize(): any;
  64120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64121. }
  64122. }
  64123. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64127. /**
  64128. * Block used to apply a cross product between 2 vectors
  64129. */
  64130. export class CrossBlock extends NodeMaterialBlock {
  64131. /**
  64132. * Creates a new CrossBlock
  64133. * @param name defines the block name
  64134. */
  64135. constructor(name: string);
  64136. /**
  64137. * Gets the current class name
  64138. * @returns the class name
  64139. */
  64140. getClassName(): string;
  64141. /**
  64142. * Gets the left operand input component
  64143. */
  64144. get left(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the right operand input component
  64147. */
  64148. get right(): NodeMaterialConnectionPoint;
  64149. /**
  64150. * Gets the output component
  64151. */
  64152. get output(): NodeMaterialConnectionPoint;
  64153. protected _buildBlock(state: NodeMaterialBuildState): this;
  64154. }
  64155. }
  64156. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64160. /**
  64161. * Block used to apply a dot product between 2 vectors
  64162. */
  64163. export class DotBlock extends NodeMaterialBlock {
  64164. /**
  64165. * Creates a new DotBlock
  64166. * @param name defines the block name
  64167. */
  64168. constructor(name: string);
  64169. /**
  64170. * Gets the current class name
  64171. * @returns the class name
  64172. */
  64173. getClassName(): string;
  64174. /**
  64175. * Gets the left operand input component
  64176. */
  64177. get left(): NodeMaterialConnectionPoint;
  64178. /**
  64179. * Gets the right operand input component
  64180. */
  64181. get right(): NodeMaterialConnectionPoint;
  64182. /**
  64183. * Gets the output component
  64184. */
  64185. get output(): NodeMaterialConnectionPoint;
  64186. protected _buildBlock(state: NodeMaterialBuildState): this;
  64187. }
  64188. }
  64189. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64193. /**
  64194. * Block used to normalize a vector
  64195. */
  64196. export class NormalizeBlock extends NodeMaterialBlock {
  64197. /**
  64198. * Creates a new NormalizeBlock
  64199. * @param name defines the block name
  64200. */
  64201. constructor(name: string);
  64202. /**
  64203. * Gets the current class name
  64204. * @returns the class name
  64205. */
  64206. getClassName(): string;
  64207. /**
  64208. * Gets the input component
  64209. */
  64210. get input(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64222. import { Scene } from "babylonjs/scene";
  64223. /**
  64224. * Operations supported by the Trigonometry block
  64225. */
  64226. export enum TrigonometryBlockOperations {
  64227. /** Cos */
  64228. Cos = 0,
  64229. /** Sin */
  64230. Sin = 1,
  64231. /** Abs */
  64232. Abs = 2,
  64233. /** Exp */
  64234. Exp = 3,
  64235. /** Exp2 */
  64236. Exp2 = 4,
  64237. /** Round */
  64238. Round = 5,
  64239. /** Floor */
  64240. Floor = 6,
  64241. /** Ceiling */
  64242. Ceiling = 7,
  64243. /** Square root */
  64244. Sqrt = 8,
  64245. /** Log */
  64246. Log = 9,
  64247. /** Tangent */
  64248. Tan = 10,
  64249. /** Arc tangent */
  64250. ArcTan = 11,
  64251. /** Arc cosinus */
  64252. ArcCos = 12,
  64253. /** Arc sinus */
  64254. ArcSin = 13,
  64255. /** Fraction */
  64256. Fract = 14,
  64257. /** Sign */
  64258. Sign = 15,
  64259. /** To radians (from degrees) */
  64260. Radians = 16,
  64261. /** To degrees (from radians) */
  64262. Degrees = 17
  64263. }
  64264. /**
  64265. * Block used to apply trigonometry operation to floats
  64266. */
  64267. export class TrigonometryBlock extends NodeMaterialBlock {
  64268. /**
  64269. * Gets or sets the operation applied by the block
  64270. */
  64271. operation: TrigonometryBlockOperations;
  64272. /**
  64273. * Creates a new TrigonometryBlock
  64274. * @param name defines the block name
  64275. */
  64276. constructor(name: string);
  64277. /**
  64278. * Gets the current class name
  64279. * @returns the class name
  64280. */
  64281. getClassName(): string;
  64282. /**
  64283. * Gets the input component
  64284. */
  64285. get input(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the output component
  64288. */
  64289. get output(): NodeMaterialConnectionPoint;
  64290. protected _buildBlock(state: NodeMaterialBuildState): this;
  64291. serialize(): any;
  64292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64293. protected _dumpPropertiesCode(): string;
  64294. }
  64295. }
  64296. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64300. /**
  64301. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64302. */
  64303. export class ColorMergerBlock extends NodeMaterialBlock {
  64304. /**
  64305. * Create a new ColorMergerBlock
  64306. * @param name defines the block name
  64307. */
  64308. constructor(name: string);
  64309. /**
  64310. * Gets the current class name
  64311. * @returns the class name
  64312. */
  64313. getClassName(): string;
  64314. /**
  64315. * Gets the rgb component (input)
  64316. */
  64317. get rgbIn(): NodeMaterialConnectionPoint;
  64318. /**
  64319. * Gets the r component (input)
  64320. */
  64321. get r(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the g component (input)
  64324. */
  64325. get g(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the b component (input)
  64328. */
  64329. get b(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the a component (input)
  64332. */
  64333. get a(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the rgba component (output)
  64336. */
  64337. get rgba(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the rgb component (output)
  64340. */
  64341. get rgbOut(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the rgb component (output)
  64344. * @deprecated Please use rgbOut instead.
  64345. */
  64346. get rgb(): NodeMaterialConnectionPoint;
  64347. protected _buildBlock(state: NodeMaterialBuildState): this;
  64348. }
  64349. }
  64350. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64354. /**
  64355. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64356. */
  64357. export class VectorSplitterBlock extends NodeMaterialBlock {
  64358. /**
  64359. * Create a new VectorSplitterBlock
  64360. * @param name defines the block name
  64361. */
  64362. constructor(name: string);
  64363. /**
  64364. * Gets the current class name
  64365. * @returns the class name
  64366. */
  64367. getClassName(): string;
  64368. /**
  64369. * Gets the xyzw component (input)
  64370. */
  64371. get xyzw(): NodeMaterialConnectionPoint;
  64372. /**
  64373. * Gets the xyz component (input)
  64374. */
  64375. get xyzIn(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the xy component (input)
  64378. */
  64379. get xyIn(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the xyz component (output)
  64382. */
  64383. get xyzOut(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the xy component (output)
  64386. */
  64387. get xyOut(): NodeMaterialConnectionPoint;
  64388. /**
  64389. * Gets the x component (output)
  64390. */
  64391. get x(): NodeMaterialConnectionPoint;
  64392. /**
  64393. * Gets the y component (output)
  64394. */
  64395. get y(): NodeMaterialConnectionPoint;
  64396. /**
  64397. * Gets the z component (output)
  64398. */
  64399. get z(): NodeMaterialConnectionPoint;
  64400. /**
  64401. * Gets the w component (output)
  64402. */
  64403. get w(): NodeMaterialConnectionPoint;
  64404. protected _inputRename(name: string): string;
  64405. protected _outputRename(name: string): string;
  64406. protected _buildBlock(state: NodeMaterialBuildState): this;
  64407. }
  64408. }
  64409. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64413. /**
  64414. * Block used to lerp between 2 values
  64415. */
  64416. export class LerpBlock extends NodeMaterialBlock {
  64417. /**
  64418. * Creates a new LerpBlock
  64419. * @param name defines the block name
  64420. */
  64421. constructor(name: string);
  64422. /**
  64423. * Gets the current class name
  64424. * @returns the class name
  64425. */
  64426. getClassName(): string;
  64427. /**
  64428. * Gets the left operand input component
  64429. */
  64430. get left(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the right operand input component
  64433. */
  64434. get right(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the gradient operand input component
  64437. */
  64438. get gradient(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the output component
  64441. */
  64442. get output(): NodeMaterialConnectionPoint;
  64443. protected _buildBlock(state: NodeMaterialBuildState): this;
  64444. }
  64445. }
  64446. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64450. /**
  64451. * Block used to divide 2 vectors
  64452. */
  64453. export class DivideBlock extends NodeMaterialBlock {
  64454. /**
  64455. * Creates a new DivideBlock
  64456. * @param name defines the block name
  64457. */
  64458. constructor(name: string);
  64459. /**
  64460. * Gets the current class name
  64461. * @returns the class name
  64462. */
  64463. getClassName(): string;
  64464. /**
  64465. * Gets the left operand input component
  64466. */
  64467. get left(): NodeMaterialConnectionPoint;
  64468. /**
  64469. * Gets the right operand input component
  64470. */
  64471. get right(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the output component
  64474. */
  64475. get output(): NodeMaterialConnectionPoint;
  64476. protected _buildBlock(state: NodeMaterialBuildState): this;
  64477. }
  64478. }
  64479. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64483. /**
  64484. * Block used to subtract 2 vectors
  64485. */
  64486. export class SubtractBlock extends NodeMaterialBlock {
  64487. /**
  64488. * Creates a new SubtractBlock
  64489. * @param name defines the block name
  64490. */
  64491. constructor(name: string);
  64492. /**
  64493. * Gets the current class name
  64494. * @returns the class name
  64495. */
  64496. getClassName(): string;
  64497. /**
  64498. * Gets the left operand input component
  64499. */
  64500. get left(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the right operand input component
  64503. */
  64504. get right(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the output component
  64507. */
  64508. get output(): NodeMaterialConnectionPoint;
  64509. protected _buildBlock(state: NodeMaterialBuildState): this;
  64510. }
  64511. }
  64512. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  64513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64516. /**
  64517. * Block used to step a value
  64518. */
  64519. export class StepBlock extends NodeMaterialBlock {
  64520. /**
  64521. * Creates a new StepBlock
  64522. * @param name defines the block name
  64523. */
  64524. constructor(name: string);
  64525. /**
  64526. * Gets the current class name
  64527. * @returns the class name
  64528. */
  64529. getClassName(): string;
  64530. /**
  64531. * Gets the value operand input component
  64532. */
  64533. get value(): NodeMaterialConnectionPoint;
  64534. /**
  64535. * Gets the edge operand input component
  64536. */
  64537. get edge(): NodeMaterialConnectionPoint;
  64538. /**
  64539. * Gets the output component
  64540. */
  64541. get output(): NodeMaterialConnectionPoint;
  64542. protected _buildBlock(state: NodeMaterialBuildState): this;
  64543. }
  64544. }
  64545. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  64546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64549. /**
  64550. * Block used to get the opposite (1 - x) of a value
  64551. */
  64552. export class OneMinusBlock extends NodeMaterialBlock {
  64553. /**
  64554. * Creates a new OneMinusBlock
  64555. * @param name defines the block name
  64556. */
  64557. constructor(name: string);
  64558. /**
  64559. * Gets the current class name
  64560. * @returns the class name
  64561. */
  64562. getClassName(): string;
  64563. /**
  64564. * Gets the input component
  64565. */
  64566. get input(): NodeMaterialConnectionPoint;
  64567. /**
  64568. * Gets the output component
  64569. */
  64570. get output(): NodeMaterialConnectionPoint;
  64571. protected _buildBlock(state: NodeMaterialBuildState): this;
  64572. }
  64573. }
  64574. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  64575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64578. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64579. /**
  64580. * Block used to get the view direction
  64581. */
  64582. export class ViewDirectionBlock extends NodeMaterialBlock {
  64583. /**
  64584. * Creates a new ViewDirectionBlock
  64585. * @param name defines the block name
  64586. */
  64587. constructor(name: string);
  64588. /**
  64589. * Gets the current class name
  64590. * @returns the class name
  64591. */
  64592. getClassName(): string;
  64593. /**
  64594. * Gets the world position component
  64595. */
  64596. get worldPosition(): NodeMaterialConnectionPoint;
  64597. /**
  64598. * Gets the camera position component
  64599. */
  64600. get cameraPosition(): NodeMaterialConnectionPoint;
  64601. /**
  64602. * Gets the output component
  64603. */
  64604. get output(): NodeMaterialConnectionPoint;
  64605. autoConfigure(material: NodeMaterial): void;
  64606. protected _buildBlock(state: NodeMaterialBuildState): this;
  64607. }
  64608. }
  64609. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  64610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64613. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64614. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  64615. /**
  64616. * Block used to compute fresnel value
  64617. */
  64618. export class FresnelBlock extends NodeMaterialBlock {
  64619. /**
  64620. * Create a new FresnelBlock
  64621. * @param name defines the block name
  64622. */
  64623. constructor(name: string);
  64624. /**
  64625. * Gets the current class name
  64626. * @returns the class name
  64627. */
  64628. getClassName(): string;
  64629. /**
  64630. * Gets the world normal input component
  64631. */
  64632. get worldNormal(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the view direction input component
  64635. */
  64636. get viewDirection(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the bias input component
  64639. */
  64640. get bias(): NodeMaterialConnectionPoint;
  64641. /**
  64642. * Gets the camera (or eye) position component
  64643. */
  64644. get power(): NodeMaterialConnectionPoint;
  64645. /**
  64646. * Gets the fresnel output component
  64647. */
  64648. get fresnel(): NodeMaterialConnectionPoint;
  64649. autoConfigure(material: NodeMaterial): void;
  64650. protected _buildBlock(state: NodeMaterialBuildState): this;
  64651. }
  64652. }
  64653. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  64654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64657. /**
  64658. * Block used to get the max of 2 values
  64659. */
  64660. export class MaxBlock extends NodeMaterialBlock {
  64661. /**
  64662. * Creates a new MaxBlock
  64663. * @param name defines the block name
  64664. */
  64665. constructor(name: string);
  64666. /**
  64667. * Gets the current class name
  64668. * @returns the class name
  64669. */
  64670. getClassName(): string;
  64671. /**
  64672. * Gets the left operand input component
  64673. */
  64674. get left(): NodeMaterialConnectionPoint;
  64675. /**
  64676. * Gets the right operand input component
  64677. */
  64678. get right(): NodeMaterialConnectionPoint;
  64679. /**
  64680. * Gets the output component
  64681. */
  64682. get output(): NodeMaterialConnectionPoint;
  64683. protected _buildBlock(state: NodeMaterialBuildState): this;
  64684. }
  64685. }
  64686. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  64687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64690. /**
  64691. * Block used to get the min of 2 values
  64692. */
  64693. export class MinBlock extends NodeMaterialBlock {
  64694. /**
  64695. * Creates a new MinBlock
  64696. * @param name defines the block name
  64697. */
  64698. constructor(name: string);
  64699. /**
  64700. * Gets the current class name
  64701. * @returns the class name
  64702. */
  64703. getClassName(): string;
  64704. /**
  64705. * Gets the left operand input component
  64706. */
  64707. get left(): NodeMaterialConnectionPoint;
  64708. /**
  64709. * Gets the right operand input component
  64710. */
  64711. get right(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the output component
  64714. */
  64715. get output(): NodeMaterialConnectionPoint;
  64716. protected _buildBlock(state: NodeMaterialBuildState): this;
  64717. }
  64718. }
  64719. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  64720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64723. /**
  64724. * Block used to get the distance between 2 values
  64725. */
  64726. export class DistanceBlock extends NodeMaterialBlock {
  64727. /**
  64728. * Creates a new DistanceBlock
  64729. * @param name defines the block name
  64730. */
  64731. constructor(name: string);
  64732. /**
  64733. * Gets the current class name
  64734. * @returns the class name
  64735. */
  64736. getClassName(): string;
  64737. /**
  64738. * Gets the left operand input component
  64739. */
  64740. get left(): NodeMaterialConnectionPoint;
  64741. /**
  64742. * Gets the right operand input component
  64743. */
  64744. get right(): NodeMaterialConnectionPoint;
  64745. /**
  64746. * Gets the output component
  64747. */
  64748. get output(): NodeMaterialConnectionPoint;
  64749. protected _buildBlock(state: NodeMaterialBuildState): this;
  64750. }
  64751. }
  64752. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  64753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64756. /**
  64757. * Block used to get the length of a vector
  64758. */
  64759. export class LengthBlock extends NodeMaterialBlock {
  64760. /**
  64761. * Creates a new LengthBlock
  64762. * @param name defines the block name
  64763. */
  64764. constructor(name: string);
  64765. /**
  64766. * Gets the current class name
  64767. * @returns the class name
  64768. */
  64769. getClassName(): string;
  64770. /**
  64771. * Gets the value input component
  64772. */
  64773. get value(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the output component
  64776. */
  64777. get output(): NodeMaterialConnectionPoint;
  64778. protected _buildBlock(state: NodeMaterialBuildState): this;
  64779. }
  64780. }
  64781. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  64782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64785. /**
  64786. * Block used to get negative version of a value (i.e. x * -1)
  64787. */
  64788. export class NegateBlock extends NodeMaterialBlock {
  64789. /**
  64790. * Creates a new NegateBlock
  64791. * @param name defines the block name
  64792. */
  64793. constructor(name: string);
  64794. /**
  64795. * Gets the current class name
  64796. * @returns the class name
  64797. */
  64798. getClassName(): string;
  64799. /**
  64800. * Gets the value input component
  64801. */
  64802. get value(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the output component
  64805. */
  64806. get output(): NodeMaterialConnectionPoint;
  64807. protected _buildBlock(state: NodeMaterialBuildState): this;
  64808. }
  64809. }
  64810. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  64811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64814. /**
  64815. * Block used to get the value of the first parameter raised to the power of the second
  64816. */
  64817. export class PowBlock extends NodeMaterialBlock {
  64818. /**
  64819. * Creates a new PowBlock
  64820. * @param name defines the block name
  64821. */
  64822. constructor(name: string);
  64823. /**
  64824. * Gets the current class name
  64825. * @returns the class name
  64826. */
  64827. getClassName(): string;
  64828. /**
  64829. * Gets the value operand input component
  64830. */
  64831. get value(): NodeMaterialConnectionPoint;
  64832. /**
  64833. * Gets the power operand input component
  64834. */
  64835. get power(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the output component
  64838. */
  64839. get output(): NodeMaterialConnectionPoint;
  64840. protected _buildBlock(state: NodeMaterialBuildState): this;
  64841. }
  64842. }
  64843. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  64844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64848. /**
  64849. * Block used to get a random number
  64850. */
  64851. export class RandomNumberBlock extends NodeMaterialBlock {
  64852. /**
  64853. * Creates a new RandomNumberBlock
  64854. * @param name defines the block name
  64855. */
  64856. constructor(name: string);
  64857. /**
  64858. * Gets the current class name
  64859. * @returns the class name
  64860. */
  64861. getClassName(): string;
  64862. /**
  64863. * Gets the seed input component
  64864. */
  64865. get seed(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the output component
  64868. */
  64869. get output(): NodeMaterialConnectionPoint;
  64870. protected _buildBlock(state: NodeMaterialBuildState): this;
  64871. }
  64872. }
  64873. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  64874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64877. /**
  64878. * Block used to compute arc tangent of 2 values
  64879. */
  64880. export class ArcTan2Block extends NodeMaterialBlock {
  64881. /**
  64882. * Creates a new ArcTan2Block
  64883. * @param name defines the block name
  64884. */
  64885. constructor(name: string);
  64886. /**
  64887. * Gets the current class name
  64888. * @returns the class name
  64889. */
  64890. getClassName(): string;
  64891. /**
  64892. * Gets the x operand input component
  64893. */
  64894. get x(): NodeMaterialConnectionPoint;
  64895. /**
  64896. * Gets the y operand input component
  64897. */
  64898. get y(): NodeMaterialConnectionPoint;
  64899. /**
  64900. * Gets the output component
  64901. */
  64902. get output(): NodeMaterialConnectionPoint;
  64903. protected _buildBlock(state: NodeMaterialBuildState): this;
  64904. }
  64905. }
  64906. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  64907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64910. /**
  64911. * Block used to smooth step a value
  64912. */
  64913. export class SmoothStepBlock extends NodeMaterialBlock {
  64914. /**
  64915. * Creates a new SmoothStepBlock
  64916. * @param name defines the block name
  64917. */
  64918. constructor(name: string);
  64919. /**
  64920. * Gets the current class name
  64921. * @returns the class name
  64922. */
  64923. getClassName(): string;
  64924. /**
  64925. * Gets the value operand input component
  64926. */
  64927. get value(): NodeMaterialConnectionPoint;
  64928. /**
  64929. * Gets the first edge operand input component
  64930. */
  64931. get edge0(): NodeMaterialConnectionPoint;
  64932. /**
  64933. * Gets the second edge operand input component
  64934. */
  64935. get edge1(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the output component
  64938. */
  64939. get output(): NodeMaterialConnectionPoint;
  64940. protected _buildBlock(state: NodeMaterialBuildState): this;
  64941. }
  64942. }
  64943. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  64944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64947. /**
  64948. * Block used to get the reciprocal (1 / x) of a value
  64949. */
  64950. export class ReciprocalBlock extends NodeMaterialBlock {
  64951. /**
  64952. * Creates a new ReciprocalBlock
  64953. * @param name defines the block name
  64954. */
  64955. constructor(name: string);
  64956. /**
  64957. * Gets the current class name
  64958. * @returns the class name
  64959. */
  64960. getClassName(): string;
  64961. /**
  64962. * Gets the input component
  64963. */
  64964. get input(): NodeMaterialConnectionPoint;
  64965. /**
  64966. * Gets the output component
  64967. */
  64968. get output(): NodeMaterialConnectionPoint;
  64969. protected _buildBlock(state: NodeMaterialBuildState): this;
  64970. }
  64971. }
  64972. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  64973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64976. /**
  64977. * Block used to replace a color by another one
  64978. */
  64979. export class ReplaceColorBlock extends NodeMaterialBlock {
  64980. /**
  64981. * Creates a new ReplaceColorBlock
  64982. * @param name defines the block name
  64983. */
  64984. constructor(name: string);
  64985. /**
  64986. * Gets the current class name
  64987. * @returns the class name
  64988. */
  64989. getClassName(): string;
  64990. /**
  64991. * Gets the value input component
  64992. */
  64993. get value(): NodeMaterialConnectionPoint;
  64994. /**
  64995. * Gets the reference input component
  64996. */
  64997. get reference(): NodeMaterialConnectionPoint;
  64998. /**
  64999. * Gets the distance input component
  65000. */
  65001. get distance(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the replacement input component
  65004. */
  65005. get replacement(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the output component
  65008. */
  65009. get output(): NodeMaterialConnectionPoint;
  65010. protected _buildBlock(state: NodeMaterialBuildState): this;
  65011. }
  65012. }
  65013. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65017. /**
  65018. * Block used to posterize a value
  65019. * @see https://en.wikipedia.org/wiki/Posterization
  65020. */
  65021. export class PosterizeBlock extends NodeMaterialBlock {
  65022. /**
  65023. * Creates a new PosterizeBlock
  65024. * @param name defines the block name
  65025. */
  65026. constructor(name: string);
  65027. /**
  65028. * Gets the current class name
  65029. * @returns the class name
  65030. */
  65031. getClassName(): string;
  65032. /**
  65033. * Gets the value input component
  65034. */
  65035. get value(): NodeMaterialConnectionPoint;
  65036. /**
  65037. * Gets the steps input component
  65038. */
  65039. get steps(): NodeMaterialConnectionPoint;
  65040. /**
  65041. * Gets the output component
  65042. */
  65043. get output(): NodeMaterialConnectionPoint;
  65044. protected _buildBlock(state: NodeMaterialBuildState): this;
  65045. }
  65046. }
  65047. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65051. import { Scene } from "babylonjs/scene";
  65052. /**
  65053. * Operations supported by the Wave block
  65054. */
  65055. export enum WaveBlockKind {
  65056. /** SawTooth */
  65057. SawTooth = 0,
  65058. /** Square */
  65059. Square = 1,
  65060. /** Triangle */
  65061. Triangle = 2
  65062. }
  65063. /**
  65064. * Block used to apply wave operation to floats
  65065. */
  65066. export class WaveBlock extends NodeMaterialBlock {
  65067. /**
  65068. * Gets or sets the kibnd of wave to be applied by the block
  65069. */
  65070. kind: WaveBlockKind;
  65071. /**
  65072. * Creates a new WaveBlock
  65073. * @param name defines the block name
  65074. */
  65075. constructor(name: string);
  65076. /**
  65077. * Gets the current class name
  65078. * @returns the class name
  65079. */
  65080. getClassName(): string;
  65081. /**
  65082. * Gets the input component
  65083. */
  65084. get input(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the output component
  65087. */
  65088. get output(): NodeMaterialConnectionPoint;
  65089. protected _buildBlock(state: NodeMaterialBuildState): this;
  65090. serialize(): any;
  65091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65092. }
  65093. }
  65094. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65098. import { Color3 } from "babylonjs/Maths/math.color";
  65099. import { Scene } from "babylonjs/scene";
  65100. /**
  65101. * Class used to store a color step for the GradientBlock
  65102. */
  65103. export class GradientBlockColorStep {
  65104. /**
  65105. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65106. */
  65107. step: number;
  65108. /**
  65109. * Gets or sets the color associated with this step
  65110. */
  65111. color: Color3;
  65112. /**
  65113. * Creates a new GradientBlockColorStep
  65114. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65115. * @param color defines the color associated with this step
  65116. */
  65117. constructor(
  65118. /**
  65119. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65120. */
  65121. step: number,
  65122. /**
  65123. * Gets or sets the color associated with this step
  65124. */
  65125. color: Color3);
  65126. }
  65127. /**
  65128. * Block used to return a color from a gradient based on an input value between 0 and 1
  65129. */
  65130. export class GradientBlock extends NodeMaterialBlock {
  65131. /**
  65132. * Gets or sets the list of color steps
  65133. */
  65134. colorSteps: GradientBlockColorStep[];
  65135. /**
  65136. * Creates a new GradientBlock
  65137. * @param name defines the block name
  65138. */
  65139. constructor(name: string);
  65140. /**
  65141. * Gets the current class name
  65142. * @returns the class name
  65143. */
  65144. getClassName(): string;
  65145. /**
  65146. * Gets the gradient input component
  65147. */
  65148. get gradient(): NodeMaterialConnectionPoint;
  65149. /**
  65150. * Gets the output component
  65151. */
  65152. get output(): NodeMaterialConnectionPoint;
  65153. private _writeColorConstant;
  65154. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65155. serialize(): any;
  65156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65157. protected _dumpPropertiesCode(): string;
  65158. }
  65159. }
  65160. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65164. /**
  65165. * Block used to normalize lerp between 2 values
  65166. */
  65167. export class NLerpBlock extends NodeMaterialBlock {
  65168. /**
  65169. * Creates a new NLerpBlock
  65170. * @param name defines the block name
  65171. */
  65172. constructor(name: string);
  65173. /**
  65174. * Gets the current class name
  65175. * @returns the class name
  65176. */
  65177. getClassName(): string;
  65178. /**
  65179. * Gets the left operand input component
  65180. */
  65181. get left(): NodeMaterialConnectionPoint;
  65182. /**
  65183. * Gets the right operand input component
  65184. */
  65185. get right(): NodeMaterialConnectionPoint;
  65186. /**
  65187. * Gets the gradient operand input component
  65188. */
  65189. get gradient(): NodeMaterialConnectionPoint;
  65190. /**
  65191. * Gets the output component
  65192. */
  65193. get output(): NodeMaterialConnectionPoint;
  65194. protected _buildBlock(state: NodeMaterialBuildState): this;
  65195. }
  65196. }
  65197. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65201. import { Scene } from "babylonjs/scene";
  65202. /**
  65203. * block used to Generate a Worley Noise 3D Noise Pattern
  65204. */
  65205. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65206. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65207. manhattanDistance: boolean;
  65208. /**
  65209. * Creates a new WorleyNoise3DBlock
  65210. * @param name defines the block name
  65211. */
  65212. constructor(name: string);
  65213. /**
  65214. * Gets the current class name
  65215. * @returns the class name
  65216. */
  65217. getClassName(): string;
  65218. /**
  65219. * Gets the seed input component
  65220. */
  65221. get seed(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the jitter input component
  65224. */
  65225. get jitter(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the output component
  65228. */
  65229. get output(): NodeMaterialConnectionPoint;
  65230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65231. /**
  65232. * Exposes the properties to the UI?
  65233. */
  65234. protected _dumpPropertiesCode(): string;
  65235. /**
  65236. * Exposes the properties to the Seralize?
  65237. */
  65238. serialize(): any;
  65239. /**
  65240. * Exposes the properties to the deseralize?
  65241. */
  65242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65243. }
  65244. }
  65245. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65249. /**
  65250. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65251. */
  65252. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65253. /**
  65254. * Creates a new SimplexPerlin3DBlock
  65255. * @param name defines the block name
  65256. */
  65257. constructor(name: string);
  65258. /**
  65259. * Gets the current class name
  65260. * @returns the class name
  65261. */
  65262. getClassName(): string;
  65263. /**
  65264. * Gets the seed operand input component
  65265. */
  65266. get seed(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Gets the output component
  65269. */
  65270. get output(): NodeMaterialConnectionPoint;
  65271. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65272. }
  65273. }
  65274. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65278. /**
  65279. * Block used to blend normals
  65280. */
  65281. export class NormalBlendBlock extends NodeMaterialBlock {
  65282. /**
  65283. * Creates a new NormalBlendBlock
  65284. * @param name defines the block name
  65285. */
  65286. constructor(name: string);
  65287. /**
  65288. * Gets the current class name
  65289. * @returns the class name
  65290. */
  65291. getClassName(): string;
  65292. /**
  65293. * Gets the first input component
  65294. */
  65295. get normalMap0(): NodeMaterialConnectionPoint;
  65296. /**
  65297. * Gets the second input component
  65298. */
  65299. get normalMap1(): NodeMaterialConnectionPoint;
  65300. /**
  65301. * Gets the output component
  65302. */
  65303. get output(): NodeMaterialConnectionPoint;
  65304. protected _buildBlock(state: NodeMaterialBuildState): this;
  65305. }
  65306. }
  65307. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65311. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65312. /**
  65313. * Block used to rotate a 2d vector by a given angle
  65314. */
  65315. export class Rotate2dBlock extends NodeMaterialBlock {
  65316. /**
  65317. * Creates a new Rotate2dBlock
  65318. * @param name defines the block name
  65319. */
  65320. constructor(name: string);
  65321. /**
  65322. * Gets the current class name
  65323. * @returns the class name
  65324. */
  65325. getClassName(): string;
  65326. /**
  65327. * Gets the input vector
  65328. */
  65329. get input(): NodeMaterialConnectionPoint;
  65330. /**
  65331. * Gets the input angle
  65332. */
  65333. get angle(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the output component
  65336. */
  65337. get output(): NodeMaterialConnectionPoint;
  65338. autoConfigure(material: NodeMaterial): void;
  65339. protected _buildBlock(state: NodeMaterialBuildState): this;
  65340. }
  65341. }
  65342. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65346. /**
  65347. * Block used to get the reflected vector from a direction and a normal
  65348. */
  65349. export class ReflectBlock extends NodeMaterialBlock {
  65350. /**
  65351. * Creates a new ReflectBlock
  65352. * @param name defines the block name
  65353. */
  65354. constructor(name: string);
  65355. /**
  65356. * Gets the current class name
  65357. * @returns the class name
  65358. */
  65359. getClassName(): string;
  65360. /**
  65361. * Gets the incident component
  65362. */
  65363. get incident(): NodeMaterialConnectionPoint;
  65364. /**
  65365. * Gets the normal component
  65366. */
  65367. get normal(): NodeMaterialConnectionPoint;
  65368. /**
  65369. * Gets the output component
  65370. */
  65371. get output(): NodeMaterialConnectionPoint;
  65372. protected _buildBlock(state: NodeMaterialBuildState): this;
  65373. }
  65374. }
  65375. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65379. /**
  65380. * Block used to get the refracted vector from a direction and a normal
  65381. */
  65382. export class RefractBlock extends NodeMaterialBlock {
  65383. /**
  65384. * Creates a new RefractBlock
  65385. * @param name defines the block name
  65386. */
  65387. constructor(name: string);
  65388. /**
  65389. * Gets the current class name
  65390. * @returns the class name
  65391. */
  65392. getClassName(): string;
  65393. /**
  65394. * Gets the incident component
  65395. */
  65396. get incident(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the normal component
  65399. */
  65400. get normal(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the index of refraction component
  65403. */
  65404. get ior(): NodeMaterialConnectionPoint;
  65405. /**
  65406. * Gets the output component
  65407. */
  65408. get output(): NodeMaterialConnectionPoint;
  65409. protected _buildBlock(state: NodeMaterialBuildState): this;
  65410. }
  65411. }
  65412. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  65413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65416. /**
  65417. * Block used to desaturate a color
  65418. */
  65419. export class DesaturateBlock extends NodeMaterialBlock {
  65420. /**
  65421. * Creates a new DesaturateBlock
  65422. * @param name defines the block name
  65423. */
  65424. constructor(name: string);
  65425. /**
  65426. * Gets the current class name
  65427. * @returns the class name
  65428. */
  65429. getClassName(): string;
  65430. /**
  65431. * Gets the color operand input component
  65432. */
  65433. get color(): NodeMaterialConnectionPoint;
  65434. /**
  65435. * Gets the level operand input component
  65436. */
  65437. get level(): NodeMaterialConnectionPoint;
  65438. /**
  65439. * Gets the output component
  65440. */
  65441. get output(): NodeMaterialConnectionPoint;
  65442. protected _buildBlock(state: NodeMaterialBuildState): this;
  65443. }
  65444. }
  65445. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  65446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65449. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65450. import { Nullable } from "babylonjs/types";
  65451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65452. import { Scene } from "babylonjs/scene";
  65453. /**
  65454. * Block used to implement the ambient occlusion module of the PBR material
  65455. */
  65456. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65457. /**
  65458. * Create a new AmbientOcclusionBlock
  65459. * @param name defines the block name
  65460. */
  65461. constructor(name: string);
  65462. /**
  65463. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65464. */
  65465. useAmbientInGrayScale: boolean;
  65466. /**
  65467. * Initialize the block and prepare the context for build
  65468. * @param state defines the state that will be used for the build
  65469. */
  65470. initialize(state: NodeMaterialBuildState): void;
  65471. /**
  65472. * Gets the current class name
  65473. * @returns the class name
  65474. */
  65475. getClassName(): string;
  65476. /**
  65477. * Gets the texture input component
  65478. */
  65479. get texture(): NodeMaterialConnectionPoint;
  65480. /**
  65481. * Gets the texture intensity component
  65482. */
  65483. get intensity(): NodeMaterialConnectionPoint;
  65484. /**
  65485. * Gets the direct light intensity input component
  65486. */
  65487. get directLightIntensity(): NodeMaterialConnectionPoint;
  65488. /**
  65489. * Gets the ambient occlusion object output component
  65490. */
  65491. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65492. /**
  65493. * Gets the main code of the block (fragment side)
  65494. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65495. * @returns the shader code
  65496. */
  65497. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65498. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65499. protected _buildBlock(state: NodeMaterialBuildState): this;
  65500. protected _dumpPropertiesCode(): string;
  65501. serialize(): any;
  65502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65503. }
  65504. }
  65505. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  65506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65508. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65509. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65511. import { Nullable } from "babylonjs/types";
  65512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65513. import { Mesh } from "babylonjs/Meshes/mesh";
  65514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65515. import { Effect } from "babylonjs/Materials/effect";
  65516. import { Scene } from "babylonjs/scene";
  65517. /**
  65518. * Block used to implement the reflection module of the PBR material
  65519. */
  65520. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65521. /** @hidden */
  65522. _defineLODReflectionAlpha: string;
  65523. /** @hidden */
  65524. _defineLinearSpecularReflection: string;
  65525. private _vEnvironmentIrradianceName;
  65526. /** @hidden */
  65527. _vReflectionMicrosurfaceInfosName: string;
  65528. /** @hidden */
  65529. _vReflectionInfosName: string;
  65530. private _scene;
  65531. /**
  65532. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65533. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65534. * It's less burden on the user side in the editor part.
  65535. */
  65536. /** @hidden */
  65537. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65538. /** @hidden */
  65539. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65540. /** @hidden */
  65541. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65542. /**
  65543. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65544. * diffuse part of the IBL.
  65545. */
  65546. useSphericalHarmonics: boolean;
  65547. /**
  65548. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65549. */
  65550. forceIrradianceInFragment: boolean;
  65551. /**
  65552. * Create a new ReflectionBlock
  65553. * @param name defines the block name
  65554. */
  65555. constructor(name: string);
  65556. /**
  65557. * Gets the current class name
  65558. * @returns the class name
  65559. */
  65560. getClassName(): string;
  65561. /**
  65562. * Gets the position input component
  65563. */
  65564. get position(): NodeMaterialConnectionPoint;
  65565. /**
  65566. * Gets the world position input component
  65567. */
  65568. get worldPosition(): NodeMaterialConnectionPoint;
  65569. /**
  65570. * Gets the world normal input component
  65571. */
  65572. get worldNormal(): NodeMaterialConnectionPoint;
  65573. /**
  65574. * Gets the world input component
  65575. */
  65576. get world(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the camera (or eye) position component
  65579. */
  65580. get cameraPosition(): NodeMaterialConnectionPoint;
  65581. /**
  65582. * Gets the view input component
  65583. */
  65584. get view(): NodeMaterialConnectionPoint;
  65585. /**
  65586. * Gets the color input component
  65587. */
  65588. get color(): NodeMaterialConnectionPoint;
  65589. /**
  65590. * Gets the reflection object output component
  65591. */
  65592. get reflection(): NodeMaterialConnectionPoint;
  65593. /**
  65594. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65595. */
  65596. get hasTexture(): boolean;
  65597. /**
  65598. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65599. */
  65600. get reflectionColor(): string;
  65601. protected _getTexture(): Nullable<BaseTexture>;
  65602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65604. /**
  65605. * Gets the code to inject in the vertex shader
  65606. * @param state current state of the node material building
  65607. * @returns the shader code
  65608. */
  65609. handleVertexSide(state: NodeMaterialBuildState): string;
  65610. /**
  65611. * Gets the main code of the block (fragment side)
  65612. * @param state current state of the node material building
  65613. * @param normalVarName name of the existing variable corresponding to the normal
  65614. * @returns the shader code
  65615. */
  65616. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65617. protected _buildBlock(state: NodeMaterialBuildState): this;
  65618. protected _dumpPropertiesCode(): string;
  65619. serialize(): any;
  65620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65621. }
  65622. }
  65623. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  65624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65627. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65629. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65630. import { Scene } from "babylonjs/scene";
  65631. import { Nullable } from "babylonjs/types";
  65632. /**
  65633. * Block used to implement the sheen module of the PBR material
  65634. */
  65635. export class SheenBlock extends NodeMaterialBlock {
  65636. /**
  65637. * Create a new SheenBlock
  65638. * @param name defines the block name
  65639. */
  65640. constructor(name: string);
  65641. /**
  65642. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65643. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65644. * making it easier to setup and tweak the effect
  65645. */
  65646. albedoScaling: boolean;
  65647. /**
  65648. * Defines if the sheen is linked to the sheen color.
  65649. */
  65650. linkSheenWithAlbedo: boolean;
  65651. /**
  65652. * Initialize the block and prepare the context for build
  65653. * @param state defines the state that will be used for the build
  65654. */
  65655. initialize(state: NodeMaterialBuildState): void;
  65656. /**
  65657. * Gets the current class name
  65658. * @returns the class name
  65659. */
  65660. getClassName(): string;
  65661. /**
  65662. * Gets the intensity input component
  65663. */
  65664. get intensity(): NodeMaterialConnectionPoint;
  65665. /**
  65666. * Gets the color input component
  65667. */
  65668. get color(): NodeMaterialConnectionPoint;
  65669. /**
  65670. * Gets the roughness input component
  65671. */
  65672. get roughness(): NodeMaterialConnectionPoint;
  65673. /**
  65674. * Gets the texture input component
  65675. */
  65676. get texture(): NodeMaterialConnectionPoint;
  65677. /**
  65678. * Gets the sheen object output component
  65679. */
  65680. get sheen(): NodeMaterialConnectionPoint;
  65681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65682. /**
  65683. * Gets the main code of the block (fragment side)
  65684. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65685. * @returns the shader code
  65686. */
  65687. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65688. protected _buildBlock(state: NodeMaterialBuildState): this;
  65689. protected _dumpPropertiesCode(): string;
  65690. serialize(): any;
  65691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65692. }
  65693. }
  65694. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  65695. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65700. import { Scene } from "babylonjs/scene";
  65701. /**
  65702. * Block used to implement the reflectivity module of the PBR material
  65703. */
  65704. export class ReflectivityBlock extends NodeMaterialBlock {
  65705. /**
  65706. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65707. */
  65708. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65709. /**
  65710. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65711. */
  65712. useMetallnessFromMetallicTextureBlue: boolean;
  65713. /**
  65714. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65715. */
  65716. useRoughnessFromMetallicTextureAlpha: boolean;
  65717. /**
  65718. * Specifies if the metallic texture contains the roughness information in its green channel.
  65719. */
  65720. useRoughnessFromMetallicTextureGreen: boolean;
  65721. /**
  65722. * Create a new ReflectivityBlock
  65723. * @param name defines the block name
  65724. */
  65725. constructor(name: string);
  65726. /**
  65727. * Initialize the block and prepare the context for build
  65728. * @param state defines the state that will be used for the build
  65729. */
  65730. initialize(state: NodeMaterialBuildState): void;
  65731. /**
  65732. * Gets the current class name
  65733. * @returns the class name
  65734. */
  65735. getClassName(): string;
  65736. /**
  65737. * Gets the metallic input component
  65738. */
  65739. get metallic(): NodeMaterialConnectionPoint;
  65740. /**
  65741. * Gets the roughness input component
  65742. */
  65743. get roughness(): NodeMaterialConnectionPoint;
  65744. /**
  65745. * Gets the texture input component
  65746. */
  65747. get texture(): NodeMaterialConnectionPoint;
  65748. /**
  65749. * Gets the reflectivity object output component
  65750. */
  65751. get reflectivity(): NodeMaterialConnectionPoint;
  65752. /**
  65753. * Gets the main code of the block (fragment side)
  65754. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65755. * @returns the shader code
  65756. */
  65757. getCode(aoIntensityVarName: string): string;
  65758. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65759. protected _buildBlock(state: NodeMaterialBuildState): this;
  65760. protected _dumpPropertiesCode(): string;
  65761. serialize(): any;
  65762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65763. }
  65764. }
  65765. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  65766. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65771. /**
  65772. * Block used to implement the anisotropy module of the PBR material
  65773. */
  65774. export class AnisotropyBlock extends NodeMaterialBlock {
  65775. /**
  65776. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65777. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65778. * It's less burden on the user side in the editor part.
  65779. */
  65780. /** @hidden */
  65781. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65782. /** @hidden */
  65783. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65784. /**
  65785. * Create a new AnisotropyBlock
  65786. * @param name defines the block name
  65787. */
  65788. constructor(name: string);
  65789. /**
  65790. * Initialize the block and prepare the context for build
  65791. * @param state defines the state that will be used for the build
  65792. */
  65793. initialize(state: NodeMaterialBuildState): void;
  65794. /**
  65795. * Gets the current class name
  65796. * @returns the class name
  65797. */
  65798. getClassName(): string;
  65799. /**
  65800. * Gets the intensity input component
  65801. */
  65802. get intensity(): NodeMaterialConnectionPoint;
  65803. /**
  65804. * Gets the direction input component
  65805. */
  65806. get direction(): NodeMaterialConnectionPoint;
  65807. /**
  65808. * Gets the texture input component
  65809. */
  65810. get texture(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the uv input component
  65813. */
  65814. get uv(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the worldTangent input component
  65817. */
  65818. get worldTangent(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the anisotropy object output component
  65821. */
  65822. get anisotropy(): NodeMaterialConnectionPoint;
  65823. private _generateTBNSpace;
  65824. /**
  65825. * Gets the main code of the block (fragment side)
  65826. * @param state current state of the node material building
  65827. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65828. * @returns the shader code
  65829. */
  65830. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65832. protected _buildBlock(state: NodeMaterialBuildState): this;
  65833. }
  65834. }
  65835. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  65836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65839. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65841. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65842. import { Nullable } from "babylonjs/types";
  65843. import { Mesh } from "babylonjs/Meshes/mesh";
  65844. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65845. import { Effect } from "babylonjs/Materials/effect";
  65846. /**
  65847. * Block used to implement the clear coat module of the PBR material
  65848. */
  65849. export class ClearCoatBlock extends NodeMaterialBlock {
  65850. private _scene;
  65851. /**
  65852. * Create a new ClearCoatBlock
  65853. * @param name defines the block name
  65854. */
  65855. constructor(name: string);
  65856. /**
  65857. * Initialize the block and prepare the context for build
  65858. * @param state defines the state that will be used for the build
  65859. */
  65860. initialize(state: NodeMaterialBuildState): void;
  65861. /**
  65862. * Gets the current class name
  65863. * @returns the class name
  65864. */
  65865. getClassName(): string;
  65866. /**
  65867. * Gets the intensity input component
  65868. */
  65869. get intensity(): NodeMaterialConnectionPoint;
  65870. /**
  65871. * Gets the roughness input component
  65872. */
  65873. get roughness(): NodeMaterialConnectionPoint;
  65874. /**
  65875. * Gets the ior input component
  65876. */
  65877. get ior(): NodeMaterialConnectionPoint;
  65878. /**
  65879. * Gets the texture input component
  65880. */
  65881. get texture(): NodeMaterialConnectionPoint;
  65882. /**
  65883. * Gets the bump texture input component
  65884. */
  65885. get bumpTexture(): NodeMaterialConnectionPoint;
  65886. /**
  65887. * Gets the uv input component
  65888. */
  65889. get uv(): NodeMaterialConnectionPoint;
  65890. /**
  65891. * Gets the tint color input component
  65892. */
  65893. get tintColor(): NodeMaterialConnectionPoint;
  65894. /**
  65895. * Gets the tint "at distance" input component
  65896. */
  65897. get tintAtDistance(): NodeMaterialConnectionPoint;
  65898. /**
  65899. * Gets the tint thickness input component
  65900. */
  65901. get tintThickness(): NodeMaterialConnectionPoint;
  65902. /**
  65903. * Gets the tint texture input component
  65904. */
  65905. get tintTexture(): NodeMaterialConnectionPoint;
  65906. /**
  65907. * Gets the world tangent input component
  65908. */
  65909. get worldTangent(): NodeMaterialConnectionPoint;
  65910. /**
  65911. * Gets the clear coat object output component
  65912. */
  65913. get clearcoat(): NodeMaterialConnectionPoint;
  65914. autoConfigure(material: NodeMaterial): void;
  65915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65917. private _generateTBNSpace;
  65918. /**
  65919. * Gets the main code of the block (fragment side)
  65920. * @param state current state of the node material building
  65921. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65922. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65923. * @param worldPosVarName name of the variable holding the world position
  65924. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65925. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65926. * @param worldNormalVarName name of the variable holding the world normal
  65927. * @returns the shader code
  65928. */
  65929. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65930. protected _buildBlock(state: NodeMaterialBuildState): this;
  65931. }
  65932. }
  65933. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  65934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65939. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65940. import { Nullable } from "babylonjs/types";
  65941. /**
  65942. * Block used to implement the sub surface module of the PBR material
  65943. */
  65944. export class SubSurfaceBlock extends NodeMaterialBlock {
  65945. /**
  65946. * Create a new SubSurfaceBlock
  65947. * @param name defines the block name
  65948. */
  65949. constructor(name: string);
  65950. /**
  65951. * Stores the intensity of the different subsurface effects in the thickness texture.
  65952. * * the green channel is the translucency intensity.
  65953. * * the blue channel is the scattering intensity.
  65954. * * the alpha channel is the refraction intensity.
  65955. */
  65956. useMaskFromThicknessTexture: boolean;
  65957. /**
  65958. * Initialize the block and prepare the context for build
  65959. * @param state defines the state that will be used for the build
  65960. */
  65961. initialize(state: NodeMaterialBuildState): void;
  65962. /**
  65963. * Gets the current class name
  65964. * @returns the class name
  65965. */
  65966. getClassName(): string;
  65967. /**
  65968. * Gets the min thickness input component
  65969. */
  65970. get minThickness(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the max thickness input component
  65973. */
  65974. get maxThickness(): NodeMaterialConnectionPoint;
  65975. /**
  65976. * Gets the thickness texture component
  65977. */
  65978. get thicknessTexture(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the tint color input component
  65981. */
  65982. get tintColor(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the translucency intensity input component
  65985. */
  65986. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65987. /**
  65988. * Gets the translucency diffusion distance input component
  65989. */
  65990. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65991. /**
  65992. * Gets the refraction object parameters
  65993. */
  65994. get refraction(): NodeMaterialConnectionPoint;
  65995. /**
  65996. * Gets the sub surface object output component
  65997. */
  65998. get subsurface(): NodeMaterialConnectionPoint;
  65999. autoConfigure(material: NodeMaterial): void;
  66000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66001. /**
  66002. * Gets the main code of the block (fragment side)
  66003. * @param state current state of the node material building
  66004. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66005. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66006. * @param worldPosVarName name of the variable holding the world position
  66007. * @returns the shader code
  66008. */
  66009. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66010. protected _buildBlock(state: NodeMaterialBuildState): this;
  66011. }
  66012. }
  66013. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66017. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66018. import { Light } from "babylonjs/Lights/light";
  66019. import { Nullable } from "babylonjs/types";
  66020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66021. import { Effect } from "babylonjs/Materials/effect";
  66022. import { Mesh } from "babylonjs/Meshes/mesh";
  66023. import { Scene } from "babylonjs/scene";
  66024. /**
  66025. * Block used to implement the PBR metallic/roughness model
  66026. */
  66027. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66028. /**
  66029. * Gets or sets the light associated with this block
  66030. */
  66031. light: Nullable<Light>;
  66032. private _lightId;
  66033. private _scene;
  66034. private _environmentBRDFTexture;
  66035. private _environmentBrdfSamplerName;
  66036. private _vNormalWName;
  66037. private _invertNormalName;
  66038. /**
  66039. * Create a new ReflectionBlock
  66040. * @param name defines the block name
  66041. */
  66042. constructor(name: string);
  66043. /**
  66044. * Intensity of the direct lights e.g. the four lights available in your scene.
  66045. * This impacts both the direct diffuse and specular highlights.
  66046. */
  66047. directIntensity: number;
  66048. /**
  66049. * Intensity of the environment e.g. how much the environment will light the object
  66050. * either through harmonics for rough material or through the refelction for shiny ones.
  66051. */
  66052. environmentIntensity: number;
  66053. /**
  66054. * This is a special control allowing the reduction of the specular highlights coming from the
  66055. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66056. */
  66057. specularIntensity: number;
  66058. /**
  66059. * Defines the falloff type used in this material.
  66060. * It by default is Physical.
  66061. */
  66062. lightFalloff: number;
  66063. /**
  66064. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66065. */
  66066. useAlphaFromAlbedoTexture: boolean;
  66067. /**
  66068. * Specifies that alpha test should be used
  66069. */
  66070. useAlphaTest: boolean;
  66071. /**
  66072. * Defines the alpha limits in alpha test mode.
  66073. */
  66074. alphaTestCutoff: number;
  66075. /**
  66076. * Specifies that alpha blending should be used
  66077. */
  66078. useAlphaBlending: boolean;
  66079. /**
  66080. * Defines if the alpha value should be determined via the rgb values.
  66081. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66082. */
  66083. opacityRGB: boolean;
  66084. /**
  66085. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66086. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66087. */
  66088. useRadianceOverAlpha: boolean;
  66089. /**
  66090. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66091. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66092. */
  66093. useSpecularOverAlpha: boolean;
  66094. /**
  66095. * Enables specular anti aliasing in the PBR shader.
  66096. * It will both interacts on the Geometry for analytical and IBL lighting.
  66097. * It also prefilter the roughness map based on the bump values.
  66098. */
  66099. enableSpecularAntiAliasing: boolean;
  66100. /**
  66101. * Defines if the material uses energy conservation.
  66102. */
  66103. useEnergyConservation: boolean;
  66104. /**
  66105. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66106. * too much the area relying on ambient texture to define their ambient occlusion.
  66107. */
  66108. useRadianceOcclusion: boolean;
  66109. /**
  66110. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66111. * makes the reflect vector face the model (under horizon).
  66112. */
  66113. useHorizonOcclusion: boolean;
  66114. /**
  66115. * If set to true, no lighting calculations will be applied.
  66116. */
  66117. unlit: boolean;
  66118. /**
  66119. * Force normal to face away from face.
  66120. */
  66121. forceNormalForward: boolean;
  66122. /**
  66123. * Defines the material debug mode.
  66124. * It helps seeing only some components of the material while troubleshooting.
  66125. */
  66126. debugMode: number;
  66127. /**
  66128. * Specify from where on screen the debug mode should start.
  66129. * The value goes from -1 (full screen) to 1 (not visible)
  66130. * It helps with side by side comparison against the final render
  66131. * This defaults to 0
  66132. */
  66133. debugLimit: number;
  66134. /**
  66135. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66136. * You can use the factor to better multiply the final value.
  66137. */
  66138. debugFactor: number;
  66139. /**
  66140. * Initialize the block and prepare the context for build
  66141. * @param state defines the state that will be used for the build
  66142. */
  66143. initialize(state: NodeMaterialBuildState): void;
  66144. /**
  66145. * Gets the current class name
  66146. * @returns the class name
  66147. */
  66148. getClassName(): string;
  66149. /**
  66150. * Gets the world position input component
  66151. */
  66152. get worldPosition(): NodeMaterialConnectionPoint;
  66153. /**
  66154. * Gets the world normal input component
  66155. */
  66156. get worldNormal(): NodeMaterialConnectionPoint;
  66157. /**
  66158. * Gets the perturbed normal input component
  66159. */
  66160. get perturbedNormal(): NodeMaterialConnectionPoint;
  66161. /**
  66162. * Gets the camera position input component
  66163. */
  66164. get cameraPosition(): NodeMaterialConnectionPoint;
  66165. /**
  66166. * Gets the base color input component
  66167. */
  66168. get baseColor(): NodeMaterialConnectionPoint;
  66169. /**
  66170. * Gets the base texture input component
  66171. */
  66172. get baseTexture(): NodeMaterialConnectionPoint;
  66173. /**
  66174. * Gets the opacity texture input component
  66175. */
  66176. get opacityTexture(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the ambient color input component
  66179. */
  66180. get ambientColor(): NodeMaterialConnectionPoint;
  66181. /**
  66182. * Gets the reflectivity object parameters
  66183. */
  66184. get reflectivity(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the ambient occlusion object parameters
  66187. */
  66188. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the reflection object parameters
  66191. */
  66192. get reflection(): NodeMaterialConnectionPoint;
  66193. /**
  66194. * Gets the sheen object parameters
  66195. */
  66196. get sheen(): NodeMaterialConnectionPoint;
  66197. /**
  66198. * Gets the clear coat object parameters
  66199. */
  66200. get clearcoat(): NodeMaterialConnectionPoint;
  66201. /**
  66202. * Gets the sub surface object parameters
  66203. */
  66204. get subsurface(): NodeMaterialConnectionPoint;
  66205. /**
  66206. * Gets the anisotropy object parameters
  66207. */
  66208. get anisotropy(): NodeMaterialConnectionPoint;
  66209. /**
  66210. * Gets the ambient output component
  66211. */
  66212. get ambient(): NodeMaterialConnectionPoint;
  66213. /**
  66214. * Gets the diffuse output component
  66215. */
  66216. get diffuse(): NodeMaterialConnectionPoint;
  66217. /**
  66218. * Gets the specular output component
  66219. */
  66220. get specular(): NodeMaterialConnectionPoint;
  66221. /**
  66222. * Gets the sheen output component
  66223. */
  66224. get sheenDir(): NodeMaterialConnectionPoint;
  66225. /**
  66226. * Gets the clear coat output component
  66227. */
  66228. get clearcoatDir(): NodeMaterialConnectionPoint;
  66229. /**
  66230. * Gets the indirect diffuse output component
  66231. */
  66232. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the indirect specular output component
  66235. */
  66236. get specularIndirect(): NodeMaterialConnectionPoint;
  66237. /**
  66238. * Gets the indirect sheen output component
  66239. */
  66240. get sheenIndirect(): NodeMaterialConnectionPoint;
  66241. /**
  66242. * Gets the indirect clear coat output component
  66243. */
  66244. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66245. /**
  66246. * Gets the refraction output component
  66247. */
  66248. get refraction(): NodeMaterialConnectionPoint;
  66249. /**
  66250. * Gets the global lighting output component
  66251. */
  66252. get lighting(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the shadow output component
  66255. */
  66256. get shadow(): NodeMaterialConnectionPoint;
  66257. /**
  66258. * Gets the alpha output component
  66259. */
  66260. get alpha(): NodeMaterialConnectionPoint;
  66261. autoConfigure(material: NodeMaterial): void;
  66262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66263. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66265. private _injectVertexCode;
  66266. /**
  66267. * Gets the code corresponding to the albedo/opacity module
  66268. * @returns the shader code
  66269. */
  66270. getAlbedoOpacityCode(): string;
  66271. protected _buildBlock(state: NodeMaterialBuildState): this;
  66272. protected _dumpPropertiesCode(): string;
  66273. serialize(): any;
  66274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66275. }
  66276. }
  66277. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66278. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66279. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66280. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66281. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66282. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66283. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66284. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66285. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66286. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66287. }
  66288. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66289. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66290. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66291. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66292. }
  66293. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66297. /**
  66298. * Block used to compute value of one parameter modulo another
  66299. */
  66300. export class ModBlock extends NodeMaterialBlock {
  66301. /**
  66302. * Creates a new ModBlock
  66303. * @param name defines the block name
  66304. */
  66305. constructor(name: string);
  66306. /**
  66307. * Gets the current class name
  66308. * @returns the class name
  66309. */
  66310. getClassName(): string;
  66311. /**
  66312. * Gets the left operand input component
  66313. */
  66314. get left(): NodeMaterialConnectionPoint;
  66315. /**
  66316. * Gets the right operand input component
  66317. */
  66318. get right(): NodeMaterialConnectionPoint;
  66319. /**
  66320. * Gets the output component
  66321. */
  66322. get output(): NodeMaterialConnectionPoint;
  66323. protected _buildBlock(state: NodeMaterialBuildState): this;
  66324. }
  66325. }
  66326. declare module "babylonjs/Materials/Node/Blocks/index" {
  66327. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66328. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66329. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66330. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66331. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66332. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66333. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66334. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66335. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66336. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66337. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66338. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66339. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66340. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66341. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66342. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66343. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66344. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66345. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66346. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66347. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66348. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66349. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66350. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66351. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66352. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66353. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66354. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66355. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66356. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66357. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66358. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66359. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66360. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66361. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66362. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66363. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66364. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66365. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66366. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66367. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66368. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66369. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66370. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66371. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66372. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66373. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66374. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66375. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66376. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66377. }
  66378. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66379. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66380. }
  66381. declare module "babylonjs/Materials/Node/index" {
  66382. export * from "babylonjs/Materials/Node/Enums/index";
  66383. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66384. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66385. export * from "babylonjs/Materials/Node/nodeMaterial";
  66386. export * from "babylonjs/Materials/Node/Blocks/index";
  66387. export * from "babylonjs/Materials/Node/Optimizers/index";
  66388. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66389. }
  66390. declare module "babylonjs/Materials/index" {
  66391. export * from "babylonjs/Materials/Background/index";
  66392. export * from "babylonjs/Materials/colorCurves";
  66393. export * from "babylonjs/Materials/iEffectFallbacks";
  66394. export * from "babylonjs/Materials/effectFallbacks";
  66395. export * from "babylonjs/Materials/effect";
  66396. export * from "babylonjs/Materials/fresnelParameters";
  66397. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66398. export * from "babylonjs/Materials/material";
  66399. export * from "babylonjs/Materials/materialDefines";
  66400. export * from "babylonjs/Materials/materialHelper";
  66401. export * from "babylonjs/Materials/multiMaterial";
  66402. export * from "babylonjs/Materials/PBR/index";
  66403. export * from "babylonjs/Materials/pushMaterial";
  66404. export * from "babylonjs/Materials/shaderMaterial";
  66405. export * from "babylonjs/Materials/standardMaterial";
  66406. export * from "babylonjs/Materials/Textures/index";
  66407. export * from "babylonjs/Materials/uniformBuffer";
  66408. export * from "babylonjs/Materials/materialFlags";
  66409. export * from "babylonjs/Materials/Node/index";
  66410. export * from "babylonjs/Materials/effectRenderer";
  66411. export * from "babylonjs/Materials/shadowDepthWrapper";
  66412. }
  66413. declare module "babylonjs/Maths/index" {
  66414. export * from "babylonjs/Maths/math.scalar";
  66415. export * from "babylonjs/Maths/math";
  66416. export * from "babylonjs/Maths/sphericalPolynomial";
  66417. }
  66418. declare module "babylonjs/Misc/workerPool" {
  66419. import { IDisposable } from "babylonjs/scene";
  66420. /**
  66421. * Helper class to push actions to a pool of workers.
  66422. */
  66423. export class WorkerPool implements IDisposable {
  66424. private _workerInfos;
  66425. private _pendingActions;
  66426. /**
  66427. * Constructor
  66428. * @param workers Array of workers to use for actions
  66429. */
  66430. constructor(workers: Array<Worker>);
  66431. /**
  66432. * Terminates all workers and clears any pending actions.
  66433. */
  66434. dispose(): void;
  66435. /**
  66436. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66437. * pended until a worker has completed its action.
  66438. * @param action The action to perform. Call onComplete when the action is complete.
  66439. */
  66440. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66441. private _execute;
  66442. }
  66443. }
  66444. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66445. import { IDisposable } from "babylonjs/scene";
  66446. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66447. /**
  66448. * Configuration for Draco compression
  66449. */
  66450. export interface IDracoCompressionConfiguration {
  66451. /**
  66452. * Configuration for the decoder.
  66453. */
  66454. decoder: {
  66455. /**
  66456. * The url to the WebAssembly module.
  66457. */
  66458. wasmUrl?: string;
  66459. /**
  66460. * The url to the WebAssembly binary.
  66461. */
  66462. wasmBinaryUrl?: string;
  66463. /**
  66464. * The url to the fallback JavaScript module.
  66465. */
  66466. fallbackUrl?: string;
  66467. };
  66468. }
  66469. /**
  66470. * Draco compression (https://google.github.io/draco/)
  66471. *
  66472. * This class wraps the Draco module.
  66473. *
  66474. * **Encoder**
  66475. *
  66476. * The encoder is not currently implemented.
  66477. *
  66478. * **Decoder**
  66479. *
  66480. * 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.
  66481. *
  66482. * To update the configuration, use the following code:
  66483. * ```javascript
  66484. * DracoCompression.Configuration = {
  66485. * decoder: {
  66486. * wasmUrl: "<url to the WebAssembly library>",
  66487. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66488. * fallbackUrl: "<url to the fallback JavaScript library>",
  66489. * }
  66490. * };
  66491. * ```
  66492. *
  66493. * 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.
  66494. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66495. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66496. *
  66497. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66498. * ```javascript
  66499. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66500. * ```
  66501. *
  66502. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66503. */
  66504. export class DracoCompression implements IDisposable {
  66505. private _workerPoolPromise?;
  66506. private _decoderModulePromise?;
  66507. /**
  66508. * The configuration. Defaults to the following urls:
  66509. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66510. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66511. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66512. */
  66513. static Configuration: IDracoCompressionConfiguration;
  66514. /**
  66515. * Returns true if the decoder configuration is available.
  66516. */
  66517. static get DecoderAvailable(): boolean;
  66518. /**
  66519. * Default number of workers to create when creating the draco compression object.
  66520. */
  66521. static DefaultNumWorkers: number;
  66522. private static GetDefaultNumWorkers;
  66523. private static _Default;
  66524. /**
  66525. * Default instance for the draco compression object.
  66526. */
  66527. static get Default(): DracoCompression;
  66528. /**
  66529. * Constructor
  66530. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66531. */
  66532. constructor(numWorkers?: number);
  66533. /**
  66534. * Stop all async operations and release resources.
  66535. */
  66536. dispose(): void;
  66537. /**
  66538. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66539. * @returns a promise that resolves when ready
  66540. */
  66541. whenReadyAsync(): Promise<void>;
  66542. /**
  66543. * Decode Draco compressed mesh data to vertex data.
  66544. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66545. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66546. * @returns A promise that resolves with the decoded vertex data
  66547. */
  66548. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66549. [kind: string]: number;
  66550. }): Promise<VertexData>;
  66551. }
  66552. }
  66553. declare module "babylonjs/Meshes/Compression/index" {
  66554. export * from "babylonjs/Meshes/Compression/dracoCompression";
  66555. }
  66556. declare module "babylonjs/Meshes/csg" {
  66557. import { Nullable } from "babylonjs/types";
  66558. import { Scene } from "babylonjs/scene";
  66559. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66560. import { Mesh } from "babylonjs/Meshes/mesh";
  66561. import { Material } from "babylonjs/Materials/material";
  66562. /**
  66563. * Class for building Constructive Solid Geometry
  66564. */
  66565. export class CSG {
  66566. private polygons;
  66567. /**
  66568. * The world matrix
  66569. */
  66570. matrix: Matrix;
  66571. /**
  66572. * Stores the position
  66573. */
  66574. position: Vector3;
  66575. /**
  66576. * Stores the rotation
  66577. */
  66578. rotation: Vector3;
  66579. /**
  66580. * Stores the rotation quaternion
  66581. */
  66582. rotationQuaternion: Nullable<Quaternion>;
  66583. /**
  66584. * Stores the scaling vector
  66585. */
  66586. scaling: Vector3;
  66587. /**
  66588. * Convert the Mesh to CSG
  66589. * @param mesh The Mesh to convert to CSG
  66590. * @returns A new CSG from the Mesh
  66591. */
  66592. static FromMesh(mesh: Mesh): CSG;
  66593. /**
  66594. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66595. * @param polygons Polygons used to construct a CSG solid
  66596. */
  66597. private static FromPolygons;
  66598. /**
  66599. * Clones, or makes a deep copy, of the CSG
  66600. * @returns A new CSG
  66601. */
  66602. clone(): CSG;
  66603. /**
  66604. * Unions this CSG with another CSG
  66605. * @param csg The CSG to union against this CSG
  66606. * @returns The unioned CSG
  66607. */
  66608. union(csg: CSG): CSG;
  66609. /**
  66610. * Unions this CSG with another CSG in place
  66611. * @param csg The CSG to union against this CSG
  66612. */
  66613. unionInPlace(csg: CSG): void;
  66614. /**
  66615. * Subtracts this CSG with another CSG
  66616. * @param csg The CSG to subtract against this CSG
  66617. * @returns A new CSG
  66618. */
  66619. subtract(csg: CSG): CSG;
  66620. /**
  66621. * Subtracts this CSG with another CSG in place
  66622. * @param csg The CSG to subtact against this CSG
  66623. */
  66624. subtractInPlace(csg: CSG): void;
  66625. /**
  66626. * Intersect this CSG with another CSG
  66627. * @param csg The CSG to intersect against this CSG
  66628. * @returns A new CSG
  66629. */
  66630. intersect(csg: CSG): CSG;
  66631. /**
  66632. * Intersects this CSG with another CSG in place
  66633. * @param csg The CSG to intersect against this CSG
  66634. */
  66635. intersectInPlace(csg: CSG): void;
  66636. /**
  66637. * Return a new CSG solid with solid and empty space switched. This solid is
  66638. * not modified.
  66639. * @returns A new CSG solid with solid and empty space switched
  66640. */
  66641. inverse(): CSG;
  66642. /**
  66643. * Inverses the CSG in place
  66644. */
  66645. inverseInPlace(): void;
  66646. /**
  66647. * This is used to keep meshes transformations so they can be restored
  66648. * when we build back a Babylon Mesh
  66649. * NB : All CSG operations are performed in world coordinates
  66650. * @param csg The CSG to copy the transform attributes from
  66651. * @returns This CSG
  66652. */
  66653. copyTransformAttributes(csg: CSG): CSG;
  66654. /**
  66655. * Build Raw mesh from CSG
  66656. * Coordinates here are in world space
  66657. * @param name The name of the mesh geometry
  66658. * @param scene The Scene
  66659. * @param keepSubMeshes Specifies if the submeshes should be kept
  66660. * @returns A new Mesh
  66661. */
  66662. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66663. /**
  66664. * Build Mesh from CSG taking material and transforms into account
  66665. * @param name The name of the Mesh
  66666. * @param material The material of the Mesh
  66667. * @param scene The Scene
  66668. * @param keepSubMeshes Specifies if submeshes should be kept
  66669. * @returns The new Mesh
  66670. */
  66671. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66672. }
  66673. }
  66674. declare module "babylonjs/Meshes/trailMesh" {
  66675. import { Mesh } from "babylonjs/Meshes/mesh";
  66676. import { Scene } from "babylonjs/scene";
  66677. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66678. /**
  66679. * Class used to create a trail following a mesh
  66680. */
  66681. export class TrailMesh extends Mesh {
  66682. private _generator;
  66683. private _autoStart;
  66684. private _running;
  66685. private _diameter;
  66686. private _length;
  66687. private _sectionPolygonPointsCount;
  66688. private _sectionVectors;
  66689. private _sectionNormalVectors;
  66690. private _beforeRenderObserver;
  66691. /**
  66692. * @constructor
  66693. * @param name The value used by scene.getMeshByName() to do a lookup.
  66694. * @param generator The mesh or transform node to generate a trail.
  66695. * @param scene The scene to add this mesh to.
  66696. * @param diameter Diameter of trailing mesh. Default is 1.
  66697. * @param length Length of trailing mesh. Default is 60.
  66698. * @param autoStart Automatically start trailing mesh. Default true.
  66699. */
  66700. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66701. /**
  66702. * "TrailMesh"
  66703. * @returns "TrailMesh"
  66704. */
  66705. getClassName(): string;
  66706. private _createMesh;
  66707. /**
  66708. * Start trailing mesh.
  66709. */
  66710. start(): void;
  66711. /**
  66712. * Stop trailing mesh.
  66713. */
  66714. stop(): void;
  66715. /**
  66716. * Update trailing mesh geometry.
  66717. */
  66718. update(): void;
  66719. /**
  66720. * Returns a new TrailMesh object.
  66721. * @param name is a string, the name given to the new mesh
  66722. * @param newGenerator use new generator object for cloned trail mesh
  66723. * @returns a new mesh
  66724. */
  66725. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66726. /**
  66727. * Serializes this trail mesh
  66728. * @param serializationObject object to write serialization to
  66729. */
  66730. serialize(serializationObject: any): void;
  66731. /**
  66732. * Parses a serialized trail mesh
  66733. * @param parsedMesh the serialized mesh
  66734. * @param scene the scene to create the trail mesh in
  66735. * @returns the created trail mesh
  66736. */
  66737. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66738. }
  66739. }
  66740. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  66741. import { Nullable } from "babylonjs/types";
  66742. import { Scene } from "babylonjs/scene";
  66743. import { Vector4 } from "babylonjs/Maths/math.vector";
  66744. import { Color4 } from "babylonjs/Maths/math.color";
  66745. import { Mesh } from "babylonjs/Meshes/mesh";
  66746. /**
  66747. * Class containing static functions to help procedurally build meshes
  66748. */
  66749. export class TiledBoxBuilder {
  66750. /**
  66751. * Creates a box mesh
  66752. * 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)
  66753. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66757. * @param name defines the name of the mesh
  66758. * @param options defines the options used to create the mesh
  66759. * @param scene defines the hosting scene
  66760. * @returns the box mesh
  66761. */
  66762. static CreateTiledBox(name: string, options: {
  66763. pattern?: number;
  66764. width?: number;
  66765. height?: number;
  66766. depth?: number;
  66767. tileSize?: number;
  66768. tileWidth?: number;
  66769. tileHeight?: number;
  66770. alignHorizontal?: number;
  66771. alignVertical?: number;
  66772. faceUV?: Vector4[];
  66773. faceColors?: Color4[];
  66774. sideOrientation?: number;
  66775. updatable?: boolean;
  66776. }, scene?: Nullable<Scene>): Mesh;
  66777. }
  66778. }
  66779. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  66780. import { Vector4 } from "babylonjs/Maths/math.vector";
  66781. import { Mesh } from "babylonjs/Meshes/mesh";
  66782. /**
  66783. * Class containing static functions to help procedurally build meshes
  66784. */
  66785. export class TorusKnotBuilder {
  66786. /**
  66787. * Creates a torus knot mesh
  66788. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66789. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66790. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66791. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66795. * @param name defines the name of the mesh
  66796. * @param options defines the options used to create the mesh
  66797. * @param scene defines the hosting scene
  66798. * @returns the torus knot mesh
  66799. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66800. */
  66801. static CreateTorusKnot(name: string, options: {
  66802. radius?: number;
  66803. tube?: number;
  66804. radialSegments?: number;
  66805. tubularSegments?: number;
  66806. p?: number;
  66807. q?: number;
  66808. updatable?: boolean;
  66809. sideOrientation?: number;
  66810. frontUVs?: Vector4;
  66811. backUVs?: Vector4;
  66812. }, scene: any): Mesh;
  66813. }
  66814. }
  66815. declare module "babylonjs/Meshes/polygonMesh" {
  66816. import { Scene } from "babylonjs/scene";
  66817. import { Vector2 } from "babylonjs/Maths/math.vector";
  66818. import { Mesh } from "babylonjs/Meshes/mesh";
  66819. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66820. import { Path2 } from "babylonjs/Maths/math.path";
  66821. /**
  66822. * Polygon
  66823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66824. */
  66825. export class Polygon {
  66826. /**
  66827. * Creates a rectangle
  66828. * @param xmin bottom X coord
  66829. * @param ymin bottom Y coord
  66830. * @param xmax top X coord
  66831. * @param ymax top Y coord
  66832. * @returns points that make the resulting rectation
  66833. */
  66834. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66835. /**
  66836. * Creates a circle
  66837. * @param radius radius of circle
  66838. * @param cx scale in x
  66839. * @param cy scale in y
  66840. * @param numberOfSides number of sides that make up the circle
  66841. * @returns points that make the resulting circle
  66842. */
  66843. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66844. /**
  66845. * Creates a polygon from input string
  66846. * @param input Input polygon data
  66847. * @returns the parsed points
  66848. */
  66849. static Parse(input: string): Vector2[];
  66850. /**
  66851. * Starts building a polygon from x and y coordinates
  66852. * @param x x coordinate
  66853. * @param y y coordinate
  66854. * @returns the started path2
  66855. */
  66856. static StartingAt(x: number, y: number): Path2;
  66857. }
  66858. /**
  66859. * Builds a polygon
  66860. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66861. */
  66862. export class PolygonMeshBuilder {
  66863. private _points;
  66864. private _outlinepoints;
  66865. private _holes;
  66866. private _name;
  66867. private _scene;
  66868. private _epoints;
  66869. private _eholes;
  66870. private _addToepoint;
  66871. /**
  66872. * Babylon reference to the earcut plugin.
  66873. */
  66874. bjsEarcut: any;
  66875. /**
  66876. * Creates a PolygonMeshBuilder
  66877. * @param name name of the builder
  66878. * @param contours Path of the polygon
  66879. * @param scene scene to add to when creating the mesh
  66880. * @param earcutInjection can be used to inject your own earcut reference
  66881. */
  66882. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66883. /**
  66884. * Adds a whole within the polygon
  66885. * @param hole Array of points defining the hole
  66886. * @returns this
  66887. */
  66888. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66889. /**
  66890. * Creates the polygon
  66891. * @param updatable If the mesh should be updatable
  66892. * @param depth The depth of the mesh created
  66893. * @returns the created mesh
  66894. */
  66895. build(updatable?: boolean, depth?: number): Mesh;
  66896. /**
  66897. * Creates the polygon
  66898. * @param depth The depth of the mesh created
  66899. * @returns the created VertexData
  66900. */
  66901. buildVertexData(depth?: number): VertexData;
  66902. /**
  66903. * Adds a side to the polygon
  66904. * @param positions points that make the polygon
  66905. * @param normals normals of the polygon
  66906. * @param uvs uvs of the polygon
  66907. * @param indices indices of the polygon
  66908. * @param bounds bounds of the polygon
  66909. * @param points points of the polygon
  66910. * @param depth depth of the polygon
  66911. * @param flip flip of the polygon
  66912. */
  66913. private addSide;
  66914. }
  66915. }
  66916. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  66917. import { Scene } from "babylonjs/scene";
  66918. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66919. import { Color4 } from "babylonjs/Maths/math.color";
  66920. import { Mesh } from "babylonjs/Meshes/mesh";
  66921. import { Nullable } from "babylonjs/types";
  66922. /**
  66923. * Class containing static functions to help procedurally build meshes
  66924. */
  66925. export class PolygonBuilder {
  66926. /**
  66927. * Creates a polygon mesh
  66928. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66929. * * 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
  66930. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66933. * * Remember you can only change the shape positions, not their number when updating a polygon
  66934. * @param name defines the name of the mesh
  66935. * @param options defines the options used to create the mesh
  66936. * @param scene defines the hosting scene
  66937. * @param earcutInjection can be used to inject your own earcut reference
  66938. * @returns the polygon mesh
  66939. */
  66940. static CreatePolygon(name: string, options: {
  66941. shape: Vector3[];
  66942. holes?: Vector3[][];
  66943. depth?: number;
  66944. faceUV?: Vector4[];
  66945. faceColors?: Color4[];
  66946. updatable?: boolean;
  66947. sideOrientation?: number;
  66948. frontUVs?: Vector4;
  66949. backUVs?: Vector4;
  66950. wrap?: boolean;
  66951. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66952. /**
  66953. * Creates an extruded polygon mesh, with depth in the Y direction.
  66954. * * 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)
  66955. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66956. * @param name defines the name of the mesh
  66957. * @param options defines the options used to create the mesh
  66958. * @param scene defines the hosting scene
  66959. * @param earcutInjection can be used to inject your own earcut reference
  66960. * @returns the polygon mesh
  66961. */
  66962. static ExtrudePolygon(name: string, options: {
  66963. shape: Vector3[];
  66964. holes?: Vector3[][];
  66965. depth?: number;
  66966. faceUV?: Vector4[];
  66967. faceColors?: Color4[];
  66968. updatable?: boolean;
  66969. sideOrientation?: number;
  66970. frontUVs?: Vector4;
  66971. backUVs?: Vector4;
  66972. wrap?: boolean;
  66973. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66974. }
  66975. }
  66976. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  66977. import { Scene } from "babylonjs/scene";
  66978. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66979. import { Mesh } from "babylonjs/Meshes/mesh";
  66980. import { Nullable } from "babylonjs/types";
  66981. /**
  66982. * Class containing static functions to help procedurally build meshes
  66983. */
  66984. export class LatheBuilder {
  66985. /**
  66986. * Creates lathe mesh.
  66987. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66988. * * 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
  66989. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66990. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66991. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66992. * * 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
  66993. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66994. * * 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
  66995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66999. * @param name defines the name of the mesh
  67000. * @param options defines the options used to create the mesh
  67001. * @param scene defines the hosting scene
  67002. * @returns the lathe mesh
  67003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67004. */
  67005. static CreateLathe(name: string, options: {
  67006. shape: Vector3[];
  67007. radius?: number;
  67008. tessellation?: number;
  67009. clip?: number;
  67010. arc?: number;
  67011. closed?: boolean;
  67012. updatable?: boolean;
  67013. sideOrientation?: number;
  67014. frontUVs?: Vector4;
  67015. backUVs?: Vector4;
  67016. cap?: number;
  67017. invertUV?: boolean;
  67018. }, scene?: Nullable<Scene>): Mesh;
  67019. }
  67020. }
  67021. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67022. import { Nullable } from "babylonjs/types";
  67023. import { Scene } from "babylonjs/scene";
  67024. import { Vector4 } from "babylonjs/Maths/math.vector";
  67025. import { Mesh } from "babylonjs/Meshes/mesh";
  67026. /**
  67027. * Class containing static functions to help procedurally build meshes
  67028. */
  67029. export class TiledPlaneBuilder {
  67030. /**
  67031. * Creates a tiled plane mesh
  67032. * * The parameter `pattern` will, depending on value, do nothing or
  67033. * * * flip (reflect about central vertical) alternate tiles across and up
  67034. * * * flip every tile on alternate rows
  67035. * * * rotate (180 degs) alternate tiles across and up
  67036. * * * rotate every tile on alternate rows
  67037. * * * flip and rotate alternate tiles across and up
  67038. * * * flip and rotate every tile on alternate rows
  67039. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67040. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67043. * * 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)
  67044. * * 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)
  67045. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67046. * @param name defines the name of the mesh
  67047. * @param options defines the options used to create the mesh
  67048. * @param scene defines the hosting scene
  67049. * @returns the box mesh
  67050. */
  67051. static CreateTiledPlane(name: string, options: {
  67052. pattern?: number;
  67053. tileSize?: number;
  67054. tileWidth?: number;
  67055. tileHeight?: number;
  67056. size?: number;
  67057. width?: number;
  67058. height?: number;
  67059. alignHorizontal?: number;
  67060. alignVertical?: number;
  67061. sideOrientation?: number;
  67062. frontUVs?: Vector4;
  67063. backUVs?: Vector4;
  67064. updatable?: boolean;
  67065. }, scene?: Nullable<Scene>): Mesh;
  67066. }
  67067. }
  67068. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67069. import { Nullable } from "babylonjs/types";
  67070. import { Scene } from "babylonjs/scene";
  67071. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67072. import { Mesh } from "babylonjs/Meshes/mesh";
  67073. /**
  67074. * Class containing static functions to help procedurally build meshes
  67075. */
  67076. export class TubeBuilder {
  67077. /**
  67078. * Creates a tube mesh.
  67079. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67080. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67081. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67082. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67083. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67084. * * 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)
  67085. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67086. * * 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
  67087. * * 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
  67088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67092. * @param name defines the name of the mesh
  67093. * @param options defines the options used to create the mesh
  67094. * @param scene defines the hosting scene
  67095. * @returns the tube mesh
  67096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67097. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67098. */
  67099. static CreateTube(name: string, options: {
  67100. path: Vector3[];
  67101. radius?: number;
  67102. tessellation?: number;
  67103. radiusFunction?: {
  67104. (i: number, distance: number): number;
  67105. };
  67106. cap?: number;
  67107. arc?: number;
  67108. updatable?: boolean;
  67109. sideOrientation?: number;
  67110. frontUVs?: Vector4;
  67111. backUVs?: Vector4;
  67112. instance?: Mesh;
  67113. invertUV?: boolean;
  67114. }, scene?: Nullable<Scene>): Mesh;
  67115. }
  67116. }
  67117. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67118. import { Scene } from "babylonjs/scene";
  67119. import { Vector4 } from "babylonjs/Maths/math.vector";
  67120. import { Mesh } from "babylonjs/Meshes/mesh";
  67121. import { Nullable } from "babylonjs/types";
  67122. /**
  67123. * Class containing static functions to help procedurally build meshes
  67124. */
  67125. export class IcoSphereBuilder {
  67126. /**
  67127. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67128. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67129. * * 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`)
  67130. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67131. * * 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
  67132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67135. * @param name defines the name of the mesh
  67136. * @param options defines the options used to create the mesh
  67137. * @param scene defines the hosting scene
  67138. * @returns the icosahedron mesh
  67139. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67140. */
  67141. static CreateIcoSphere(name: string, options: {
  67142. radius?: number;
  67143. radiusX?: number;
  67144. radiusY?: number;
  67145. radiusZ?: number;
  67146. flat?: boolean;
  67147. subdivisions?: number;
  67148. sideOrientation?: number;
  67149. frontUVs?: Vector4;
  67150. backUVs?: Vector4;
  67151. updatable?: boolean;
  67152. }, scene?: Nullable<Scene>): Mesh;
  67153. }
  67154. }
  67155. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67156. import { Vector3 } from "babylonjs/Maths/math.vector";
  67157. import { Mesh } from "babylonjs/Meshes/mesh";
  67158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67159. /**
  67160. * Class containing static functions to help procedurally build meshes
  67161. */
  67162. export class DecalBuilder {
  67163. /**
  67164. * Creates a decal mesh.
  67165. * 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
  67166. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67167. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67168. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67169. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67170. * @param name defines the name of the mesh
  67171. * @param sourceMesh defines the mesh where the decal must be applied
  67172. * @param options defines the options used to create the mesh
  67173. * @param scene defines the hosting scene
  67174. * @returns the decal mesh
  67175. * @see https://doc.babylonjs.com/how_to/decals
  67176. */
  67177. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67178. position?: Vector3;
  67179. normal?: Vector3;
  67180. size?: Vector3;
  67181. angle?: number;
  67182. }): Mesh;
  67183. }
  67184. }
  67185. declare module "babylonjs/Meshes/meshBuilder" {
  67186. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67187. import { Nullable } from "babylonjs/types";
  67188. import { Scene } from "babylonjs/scene";
  67189. import { Mesh } from "babylonjs/Meshes/mesh";
  67190. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67191. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67193. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67194. import { Plane } from "babylonjs/Maths/math.plane";
  67195. /**
  67196. * Class containing static functions to help procedurally build meshes
  67197. */
  67198. export class MeshBuilder {
  67199. /**
  67200. * Creates a box mesh
  67201. * * The parameter `size` sets the size (float) of each box side (default 1)
  67202. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67203. * * 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)
  67204. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67208. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67209. * @param name defines the name of the mesh
  67210. * @param options defines the options used to create the mesh
  67211. * @param scene defines the hosting scene
  67212. * @returns the box mesh
  67213. */
  67214. static CreateBox(name: string, options: {
  67215. size?: number;
  67216. width?: number;
  67217. height?: number;
  67218. depth?: number;
  67219. faceUV?: Vector4[];
  67220. faceColors?: Color4[];
  67221. sideOrientation?: number;
  67222. frontUVs?: Vector4;
  67223. backUVs?: Vector4;
  67224. wrap?: boolean;
  67225. topBaseAt?: number;
  67226. bottomBaseAt?: number;
  67227. updatable?: boolean;
  67228. }, scene?: Nullable<Scene>): Mesh;
  67229. /**
  67230. * Creates a tiled box mesh
  67231. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67233. * @param name defines the name of the mesh
  67234. * @param options defines the options used to create the mesh
  67235. * @param scene defines the hosting scene
  67236. * @returns the tiled box mesh
  67237. */
  67238. static CreateTiledBox(name: string, options: {
  67239. pattern?: number;
  67240. size?: number;
  67241. width?: number;
  67242. height?: number;
  67243. depth: number;
  67244. tileSize?: number;
  67245. tileWidth?: number;
  67246. tileHeight?: number;
  67247. faceUV?: Vector4[];
  67248. faceColors?: Color4[];
  67249. alignHorizontal?: number;
  67250. alignVertical?: number;
  67251. sideOrientation?: number;
  67252. updatable?: boolean;
  67253. }, scene?: Nullable<Scene>): Mesh;
  67254. /**
  67255. * Creates a sphere mesh
  67256. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67257. * * 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`)
  67258. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67259. * * 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
  67260. * * 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)
  67261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67264. * @param name defines the name of the mesh
  67265. * @param options defines the options used to create the mesh
  67266. * @param scene defines the hosting scene
  67267. * @returns the sphere mesh
  67268. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67269. */
  67270. static CreateSphere(name: string, options: {
  67271. segments?: number;
  67272. diameter?: number;
  67273. diameterX?: number;
  67274. diameterY?: number;
  67275. diameterZ?: number;
  67276. arc?: number;
  67277. slice?: number;
  67278. sideOrientation?: number;
  67279. frontUVs?: Vector4;
  67280. backUVs?: Vector4;
  67281. updatable?: boolean;
  67282. }, scene?: Nullable<Scene>): Mesh;
  67283. /**
  67284. * Creates a plane polygonal mesh. By default, this is a disc
  67285. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67286. * * 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
  67287. * * 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
  67288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67291. * @param name defines the name of the mesh
  67292. * @param options defines the options used to create the mesh
  67293. * @param scene defines the hosting scene
  67294. * @returns the plane polygonal mesh
  67295. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67296. */
  67297. static CreateDisc(name: string, options: {
  67298. radius?: number;
  67299. tessellation?: number;
  67300. arc?: number;
  67301. updatable?: boolean;
  67302. sideOrientation?: number;
  67303. frontUVs?: Vector4;
  67304. backUVs?: Vector4;
  67305. }, scene?: Nullable<Scene>): Mesh;
  67306. /**
  67307. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67308. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67309. * * 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`)
  67310. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67311. * * 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
  67312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67315. * @param name defines the name of the mesh
  67316. * @param options defines the options used to create the mesh
  67317. * @param scene defines the hosting scene
  67318. * @returns the icosahedron mesh
  67319. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67320. */
  67321. static CreateIcoSphere(name: string, options: {
  67322. radius?: number;
  67323. radiusX?: number;
  67324. radiusY?: number;
  67325. radiusZ?: number;
  67326. flat?: boolean;
  67327. subdivisions?: number;
  67328. sideOrientation?: number;
  67329. frontUVs?: Vector4;
  67330. backUVs?: Vector4;
  67331. updatable?: boolean;
  67332. }, scene?: Nullable<Scene>): Mesh;
  67333. /**
  67334. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67335. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67336. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67337. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67338. * * 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
  67339. * * 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
  67340. * * 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
  67341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67344. * * 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
  67345. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67346. * * 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
  67347. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67349. * @param name defines the name of the mesh
  67350. * @param options defines the options used to create the mesh
  67351. * @param scene defines the hosting scene
  67352. * @returns the ribbon mesh
  67353. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67354. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67355. */
  67356. static CreateRibbon(name: string, options: {
  67357. pathArray: Vector3[][];
  67358. closeArray?: boolean;
  67359. closePath?: boolean;
  67360. offset?: number;
  67361. updatable?: boolean;
  67362. sideOrientation?: number;
  67363. frontUVs?: Vector4;
  67364. backUVs?: Vector4;
  67365. instance?: Mesh;
  67366. invertUV?: boolean;
  67367. uvs?: Vector2[];
  67368. colors?: Color4[];
  67369. }, scene?: Nullable<Scene>): Mesh;
  67370. /**
  67371. * Creates a cylinder or a cone mesh
  67372. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67373. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67374. * * 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.
  67375. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67376. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67377. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67378. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67379. * * 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).
  67380. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67381. * * 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).
  67382. * * 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
  67383. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67384. * * 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
  67385. * * 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.
  67386. * * If `enclose` is false, a ring surface is one element.
  67387. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67388. * * 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
  67389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67392. * @param name defines the name of the mesh
  67393. * @param options defines the options used to create the mesh
  67394. * @param scene defines the hosting scene
  67395. * @returns the cylinder mesh
  67396. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67397. */
  67398. static CreateCylinder(name: string, options: {
  67399. height?: number;
  67400. diameterTop?: number;
  67401. diameterBottom?: number;
  67402. diameter?: number;
  67403. tessellation?: number;
  67404. subdivisions?: number;
  67405. arc?: number;
  67406. faceColors?: Color4[];
  67407. faceUV?: Vector4[];
  67408. updatable?: boolean;
  67409. hasRings?: boolean;
  67410. enclose?: boolean;
  67411. cap?: number;
  67412. sideOrientation?: number;
  67413. frontUVs?: Vector4;
  67414. backUVs?: Vector4;
  67415. }, scene?: Nullable<Scene>): Mesh;
  67416. /**
  67417. * Creates a torus mesh
  67418. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67419. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67420. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67424. * @param name defines the name of the mesh
  67425. * @param options defines the options used to create the mesh
  67426. * @param scene defines the hosting scene
  67427. * @returns the torus mesh
  67428. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67429. */
  67430. static CreateTorus(name: string, options: {
  67431. diameter?: number;
  67432. thickness?: number;
  67433. tessellation?: number;
  67434. updatable?: boolean;
  67435. sideOrientation?: number;
  67436. frontUVs?: Vector4;
  67437. backUVs?: Vector4;
  67438. }, scene?: Nullable<Scene>): Mesh;
  67439. /**
  67440. * Creates a torus knot mesh
  67441. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67442. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67443. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67444. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67448. * @param name defines the name of the mesh
  67449. * @param options defines the options used to create the mesh
  67450. * @param scene defines the hosting scene
  67451. * @returns the torus knot mesh
  67452. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67453. */
  67454. static CreateTorusKnot(name: string, options: {
  67455. radius?: number;
  67456. tube?: number;
  67457. radialSegments?: number;
  67458. tubularSegments?: number;
  67459. p?: number;
  67460. q?: number;
  67461. updatable?: boolean;
  67462. sideOrientation?: number;
  67463. frontUVs?: Vector4;
  67464. backUVs?: Vector4;
  67465. }, scene?: Nullable<Scene>): Mesh;
  67466. /**
  67467. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67468. * * 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
  67469. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67470. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67471. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67472. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67473. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67474. * * 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
  67475. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67478. * @param name defines the name of the new line system
  67479. * @param options defines the options used to create the line system
  67480. * @param scene defines the hosting scene
  67481. * @returns a new line system mesh
  67482. */
  67483. static CreateLineSystem(name: string, options: {
  67484. lines: Vector3[][];
  67485. updatable?: boolean;
  67486. instance?: Nullable<LinesMesh>;
  67487. colors?: Nullable<Color4[][]>;
  67488. useVertexAlpha?: boolean;
  67489. }, scene: Nullable<Scene>): LinesMesh;
  67490. /**
  67491. * Creates a line mesh
  67492. * 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
  67493. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67494. * * The parameter `points` is an array successive Vector3
  67495. * * 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
  67496. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67497. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67498. * * When updating an instance, remember that only point positions can change, not the number of points
  67499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67501. * @param name defines the name of the new line system
  67502. * @param options defines the options used to create the line system
  67503. * @param scene defines the hosting scene
  67504. * @returns a new line mesh
  67505. */
  67506. static CreateLines(name: string, options: {
  67507. points: Vector3[];
  67508. updatable?: boolean;
  67509. instance?: Nullable<LinesMesh>;
  67510. colors?: Color4[];
  67511. useVertexAlpha?: boolean;
  67512. }, scene?: Nullable<Scene>): LinesMesh;
  67513. /**
  67514. * Creates a dashed line mesh
  67515. * * 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
  67516. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67517. * * The parameter `points` is an array successive Vector3
  67518. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67519. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67520. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67521. * * 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
  67522. * * When updating an instance, remember that only point positions can change, not the number of points
  67523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67524. * @param name defines the name of the mesh
  67525. * @param options defines the options used to create the mesh
  67526. * @param scene defines the hosting scene
  67527. * @returns the dashed line mesh
  67528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67529. */
  67530. static CreateDashedLines(name: string, options: {
  67531. points: Vector3[];
  67532. dashSize?: number;
  67533. gapSize?: number;
  67534. dashNb?: number;
  67535. updatable?: boolean;
  67536. instance?: LinesMesh;
  67537. }, scene?: Nullable<Scene>): LinesMesh;
  67538. /**
  67539. * 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.
  67540. * * 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.
  67541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67542. * * 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.
  67543. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67544. * * 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
  67545. * * 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
  67546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67551. * @param name defines the name of the mesh
  67552. * @param options defines the options used to create the mesh
  67553. * @param scene defines the hosting scene
  67554. * @returns the extruded shape mesh
  67555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67557. */
  67558. static ExtrudeShape(name: string, options: {
  67559. shape: Vector3[];
  67560. path: Vector3[];
  67561. scale?: number;
  67562. rotation?: number;
  67563. cap?: number;
  67564. updatable?: boolean;
  67565. sideOrientation?: number;
  67566. frontUVs?: Vector4;
  67567. backUVs?: Vector4;
  67568. instance?: Mesh;
  67569. invertUV?: boolean;
  67570. }, scene?: Nullable<Scene>): Mesh;
  67571. /**
  67572. * Creates an custom extruded shape mesh.
  67573. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67574. * * 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.
  67575. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67576. * * 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
  67577. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67578. * * 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
  67579. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67580. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67581. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67582. * * 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
  67583. * * 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
  67584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67589. * @param name defines the name of the mesh
  67590. * @param options defines the options used to create the mesh
  67591. * @param scene defines the hosting scene
  67592. * @returns the custom extruded shape mesh
  67593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67596. */
  67597. static ExtrudeShapeCustom(name: string, options: {
  67598. shape: Vector3[];
  67599. path: Vector3[];
  67600. scaleFunction?: any;
  67601. rotationFunction?: any;
  67602. ribbonCloseArray?: boolean;
  67603. ribbonClosePath?: boolean;
  67604. cap?: number;
  67605. updatable?: boolean;
  67606. sideOrientation?: number;
  67607. frontUVs?: Vector4;
  67608. backUVs?: Vector4;
  67609. instance?: Mesh;
  67610. invertUV?: boolean;
  67611. }, scene?: Nullable<Scene>): Mesh;
  67612. /**
  67613. * Creates lathe mesh.
  67614. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67615. * * 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
  67616. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67617. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67618. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67619. * * 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
  67620. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67621. * * 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
  67622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67624. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67626. * @param name defines the name of the mesh
  67627. * @param options defines the options used to create the mesh
  67628. * @param scene defines the hosting scene
  67629. * @returns the lathe mesh
  67630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67631. */
  67632. static CreateLathe(name: string, options: {
  67633. shape: Vector3[];
  67634. radius?: number;
  67635. tessellation?: number;
  67636. clip?: number;
  67637. arc?: number;
  67638. closed?: boolean;
  67639. updatable?: boolean;
  67640. sideOrientation?: number;
  67641. frontUVs?: Vector4;
  67642. backUVs?: Vector4;
  67643. cap?: number;
  67644. invertUV?: boolean;
  67645. }, scene?: Nullable<Scene>): Mesh;
  67646. /**
  67647. * Creates a tiled plane mesh
  67648. * * You can set a limited pattern arrangement with the tiles
  67649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67652. * @param name defines the name of the mesh
  67653. * @param options defines the options used to create the mesh
  67654. * @param scene defines the hosting scene
  67655. * @returns the plane mesh
  67656. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67657. */
  67658. static CreateTiledPlane(name: string, options: {
  67659. pattern?: number;
  67660. tileSize?: number;
  67661. tileWidth?: number;
  67662. tileHeight?: number;
  67663. size?: number;
  67664. width?: number;
  67665. height?: number;
  67666. alignHorizontal?: number;
  67667. alignVertical?: number;
  67668. sideOrientation?: number;
  67669. frontUVs?: Vector4;
  67670. backUVs?: Vector4;
  67671. updatable?: boolean;
  67672. }, scene?: Nullable<Scene>): Mesh;
  67673. /**
  67674. * Creates a plane mesh
  67675. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67676. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67677. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67681. * @param name defines the name of the mesh
  67682. * @param options defines the options used to create the mesh
  67683. * @param scene defines the hosting scene
  67684. * @returns the plane mesh
  67685. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67686. */
  67687. static CreatePlane(name: string, options: {
  67688. size?: number;
  67689. width?: number;
  67690. height?: number;
  67691. sideOrientation?: number;
  67692. frontUVs?: Vector4;
  67693. backUVs?: Vector4;
  67694. updatable?: boolean;
  67695. sourcePlane?: Plane;
  67696. }, scene?: Nullable<Scene>): Mesh;
  67697. /**
  67698. * Creates a ground mesh
  67699. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67700. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67702. * @param name defines the name of the mesh
  67703. * @param options defines the options used to create the mesh
  67704. * @param scene defines the hosting scene
  67705. * @returns the ground mesh
  67706. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67707. */
  67708. static CreateGround(name: string, options: {
  67709. width?: number;
  67710. height?: number;
  67711. subdivisions?: number;
  67712. subdivisionsX?: number;
  67713. subdivisionsY?: number;
  67714. updatable?: boolean;
  67715. }, scene?: Nullable<Scene>): Mesh;
  67716. /**
  67717. * Creates a tiled ground mesh
  67718. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67719. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67720. * * 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
  67721. * * 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
  67722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67723. * @param name defines the name of the mesh
  67724. * @param options defines the options used to create the mesh
  67725. * @param scene defines the hosting scene
  67726. * @returns the tiled ground mesh
  67727. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67728. */
  67729. static CreateTiledGround(name: string, options: {
  67730. xmin: number;
  67731. zmin: number;
  67732. xmax: number;
  67733. zmax: number;
  67734. subdivisions?: {
  67735. w: number;
  67736. h: number;
  67737. };
  67738. precision?: {
  67739. w: number;
  67740. h: number;
  67741. };
  67742. updatable?: boolean;
  67743. }, scene?: Nullable<Scene>): Mesh;
  67744. /**
  67745. * Creates a ground mesh from a height map
  67746. * * The parameter `url` sets the URL of the height map image resource.
  67747. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67748. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67749. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67750. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67751. * * 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.
  67752. * * 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).
  67753. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67755. * @param name defines the name of the mesh
  67756. * @param url defines the url to the height map
  67757. * @param options defines the options used to create the mesh
  67758. * @param scene defines the hosting scene
  67759. * @returns the ground mesh
  67760. * @see https://doc.babylonjs.com/babylon101/height_map
  67761. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67762. */
  67763. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67764. width?: number;
  67765. height?: number;
  67766. subdivisions?: number;
  67767. minHeight?: number;
  67768. maxHeight?: number;
  67769. colorFilter?: Color3;
  67770. alphaFilter?: number;
  67771. updatable?: boolean;
  67772. onReady?: (mesh: GroundMesh) => void;
  67773. }, scene?: Nullable<Scene>): GroundMesh;
  67774. /**
  67775. * Creates a polygon mesh
  67776. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67777. * * 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
  67778. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67781. * * Remember you can only change the shape positions, not their number when updating a polygon
  67782. * @param name defines the name of the mesh
  67783. * @param options defines the options used to create the mesh
  67784. * @param scene defines the hosting scene
  67785. * @param earcutInjection can be used to inject your own earcut reference
  67786. * @returns the polygon mesh
  67787. */
  67788. static CreatePolygon(name: string, options: {
  67789. shape: Vector3[];
  67790. holes?: Vector3[][];
  67791. depth?: number;
  67792. faceUV?: Vector4[];
  67793. faceColors?: Color4[];
  67794. updatable?: boolean;
  67795. sideOrientation?: number;
  67796. frontUVs?: Vector4;
  67797. backUVs?: Vector4;
  67798. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67799. /**
  67800. * Creates an extruded polygon mesh, with depth in the Y direction.
  67801. * * 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)
  67802. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67803. * @param name defines the name of the mesh
  67804. * @param options defines the options used to create the mesh
  67805. * @param scene defines the hosting scene
  67806. * @param earcutInjection can be used to inject your own earcut reference
  67807. * @returns the polygon mesh
  67808. */
  67809. static ExtrudePolygon(name: string, options: {
  67810. shape: Vector3[];
  67811. holes?: Vector3[][];
  67812. depth?: number;
  67813. faceUV?: Vector4[];
  67814. faceColors?: Color4[];
  67815. updatable?: boolean;
  67816. sideOrientation?: number;
  67817. frontUVs?: Vector4;
  67818. backUVs?: Vector4;
  67819. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67820. /**
  67821. * Creates a tube mesh.
  67822. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67823. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67824. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67825. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67826. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67827. * * 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)
  67828. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67829. * * 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
  67830. * * 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
  67831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67833. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67835. * @param name defines the name of the mesh
  67836. * @param options defines the options used to create the mesh
  67837. * @param scene defines the hosting scene
  67838. * @returns the tube mesh
  67839. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67840. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67841. */
  67842. static CreateTube(name: string, options: {
  67843. path: Vector3[];
  67844. radius?: number;
  67845. tessellation?: number;
  67846. radiusFunction?: {
  67847. (i: number, distance: number): number;
  67848. };
  67849. cap?: number;
  67850. arc?: number;
  67851. updatable?: boolean;
  67852. sideOrientation?: number;
  67853. frontUVs?: Vector4;
  67854. backUVs?: Vector4;
  67855. instance?: Mesh;
  67856. invertUV?: boolean;
  67857. }, scene?: Nullable<Scene>): Mesh;
  67858. /**
  67859. * Creates a polyhedron mesh
  67860. * * 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
  67861. * * The parameter `size` (positive float, default 1) sets the polygon size
  67862. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67863. * * 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`
  67864. * * 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
  67865. * * 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)`)
  67866. * * 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
  67867. * * 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
  67868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67871. * @param name defines the name of the mesh
  67872. * @param options defines the options used to create the mesh
  67873. * @param scene defines the hosting scene
  67874. * @returns the polyhedron mesh
  67875. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67876. */
  67877. static CreatePolyhedron(name: string, options: {
  67878. type?: number;
  67879. size?: number;
  67880. sizeX?: number;
  67881. sizeY?: number;
  67882. sizeZ?: number;
  67883. custom?: any;
  67884. faceUV?: Vector4[];
  67885. faceColors?: Color4[];
  67886. flat?: boolean;
  67887. updatable?: boolean;
  67888. sideOrientation?: number;
  67889. frontUVs?: Vector4;
  67890. backUVs?: Vector4;
  67891. }, scene?: Nullable<Scene>): Mesh;
  67892. /**
  67893. * Creates a decal mesh.
  67894. * 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
  67895. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67896. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67897. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67898. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67899. * @param name defines the name of the mesh
  67900. * @param sourceMesh defines the mesh where the decal must be applied
  67901. * @param options defines the options used to create the mesh
  67902. * @param scene defines the hosting scene
  67903. * @returns the decal mesh
  67904. * @see https://doc.babylonjs.com/how_to/decals
  67905. */
  67906. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67907. position?: Vector3;
  67908. normal?: Vector3;
  67909. size?: Vector3;
  67910. angle?: number;
  67911. }): Mesh;
  67912. }
  67913. }
  67914. declare module "babylonjs/Meshes/meshSimplification" {
  67915. import { Mesh } from "babylonjs/Meshes/mesh";
  67916. /**
  67917. * A simplifier interface for future simplification implementations
  67918. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67919. */
  67920. export interface ISimplifier {
  67921. /**
  67922. * Simplification of a given mesh according to the given settings.
  67923. * Since this requires computation, it is assumed that the function runs async.
  67924. * @param settings The settings of the simplification, including quality and distance
  67925. * @param successCallback A callback that will be called after the mesh was simplified.
  67926. * @param errorCallback in case of an error, this callback will be called. optional.
  67927. */
  67928. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67929. }
  67930. /**
  67931. * Expected simplification settings.
  67932. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67934. */
  67935. export interface ISimplificationSettings {
  67936. /**
  67937. * Gets or sets the expected quality
  67938. */
  67939. quality: number;
  67940. /**
  67941. * Gets or sets the distance when this optimized version should be used
  67942. */
  67943. distance: number;
  67944. /**
  67945. * Gets an already optimized mesh
  67946. */
  67947. optimizeMesh?: boolean;
  67948. }
  67949. /**
  67950. * Class used to specify simplification options
  67951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67952. */
  67953. export class SimplificationSettings implements ISimplificationSettings {
  67954. /** expected quality */
  67955. quality: number;
  67956. /** distance when this optimized version should be used */
  67957. distance: number;
  67958. /** already optimized mesh */
  67959. optimizeMesh?: boolean | undefined;
  67960. /**
  67961. * Creates a SimplificationSettings
  67962. * @param quality expected quality
  67963. * @param distance distance when this optimized version should be used
  67964. * @param optimizeMesh already optimized mesh
  67965. */
  67966. constructor(
  67967. /** expected quality */
  67968. quality: number,
  67969. /** distance when this optimized version should be used */
  67970. distance: number,
  67971. /** already optimized mesh */
  67972. optimizeMesh?: boolean | undefined);
  67973. }
  67974. /**
  67975. * Interface used to define a simplification task
  67976. */
  67977. export interface ISimplificationTask {
  67978. /**
  67979. * Array of settings
  67980. */
  67981. settings: Array<ISimplificationSettings>;
  67982. /**
  67983. * Simplification type
  67984. */
  67985. simplificationType: SimplificationType;
  67986. /**
  67987. * Mesh to simplify
  67988. */
  67989. mesh: Mesh;
  67990. /**
  67991. * Callback called on success
  67992. */
  67993. successCallback?: () => void;
  67994. /**
  67995. * Defines if parallel processing can be used
  67996. */
  67997. parallelProcessing: boolean;
  67998. }
  67999. /**
  68000. * Queue used to order the simplification tasks
  68001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68002. */
  68003. export class SimplificationQueue {
  68004. private _simplificationArray;
  68005. /**
  68006. * Gets a boolean indicating that the process is still running
  68007. */
  68008. running: boolean;
  68009. /**
  68010. * Creates a new queue
  68011. */
  68012. constructor();
  68013. /**
  68014. * Adds a new simplification task
  68015. * @param task defines a task to add
  68016. */
  68017. addTask(task: ISimplificationTask): void;
  68018. /**
  68019. * Execute next task
  68020. */
  68021. executeNext(): void;
  68022. /**
  68023. * Execute a simplification task
  68024. * @param task defines the task to run
  68025. */
  68026. runSimplification(task: ISimplificationTask): void;
  68027. private getSimplifier;
  68028. }
  68029. /**
  68030. * The implemented types of simplification
  68031. * At the moment only Quadratic Error Decimation is implemented
  68032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68033. */
  68034. export enum SimplificationType {
  68035. /** Quadratic error decimation */
  68036. QUADRATIC = 0
  68037. }
  68038. /**
  68039. * An implementation of the Quadratic Error simplification algorithm.
  68040. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68041. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68042. * @author RaananW
  68043. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68044. */
  68045. export class QuadraticErrorSimplification implements ISimplifier {
  68046. private _mesh;
  68047. private triangles;
  68048. private vertices;
  68049. private references;
  68050. private _reconstructedMesh;
  68051. /** Gets or sets the number pf sync interations */
  68052. syncIterations: number;
  68053. /** Gets or sets the aggressiveness of the simplifier */
  68054. aggressiveness: number;
  68055. /** Gets or sets the number of allowed iterations for decimation */
  68056. decimationIterations: number;
  68057. /** Gets or sets the espilon to use for bounding box computation */
  68058. boundingBoxEpsilon: number;
  68059. /**
  68060. * Creates a new QuadraticErrorSimplification
  68061. * @param _mesh defines the target mesh
  68062. */
  68063. constructor(_mesh: Mesh);
  68064. /**
  68065. * Simplification of a given mesh according to the given settings.
  68066. * Since this requires computation, it is assumed that the function runs async.
  68067. * @param settings The settings of the simplification, including quality and distance
  68068. * @param successCallback A callback that will be called after the mesh was simplified.
  68069. */
  68070. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68071. private runDecimation;
  68072. private initWithMesh;
  68073. private init;
  68074. private reconstructMesh;
  68075. private initDecimatedMesh;
  68076. private isFlipped;
  68077. private updateTriangles;
  68078. private identifyBorder;
  68079. private updateMesh;
  68080. private vertexError;
  68081. private calculateError;
  68082. }
  68083. }
  68084. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68085. import { Scene } from "babylonjs/scene";
  68086. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68087. import { ISceneComponent } from "babylonjs/sceneComponent";
  68088. module "babylonjs/scene" {
  68089. interface Scene {
  68090. /** @hidden (Backing field) */
  68091. _simplificationQueue: SimplificationQueue;
  68092. /**
  68093. * Gets or sets the simplification queue attached to the scene
  68094. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68095. */
  68096. simplificationQueue: SimplificationQueue;
  68097. }
  68098. }
  68099. module "babylonjs/Meshes/mesh" {
  68100. interface Mesh {
  68101. /**
  68102. * Simplify the mesh according to the given array of settings.
  68103. * Function will return immediately and will simplify async
  68104. * @param settings a collection of simplification settings
  68105. * @param parallelProcessing should all levels calculate parallel or one after the other
  68106. * @param simplificationType the type of simplification to run
  68107. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68108. * @returns the current mesh
  68109. */
  68110. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68111. }
  68112. }
  68113. /**
  68114. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68115. * created in a scene
  68116. */
  68117. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68118. /**
  68119. * The component name helpfull to identify the component in the list of scene components.
  68120. */
  68121. readonly name: string;
  68122. /**
  68123. * The scene the component belongs to.
  68124. */
  68125. scene: Scene;
  68126. /**
  68127. * Creates a new instance of the component for the given scene
  68128. * @param scene Defines the scene to register the component in
  68129. */
  68130. constructor(scene: Scene);
  68131. /**
  68132. * Registers the component in a given scene
  68133. */
  68134. register(): void;
  68135. /**
  68136. * Rebuilds the elements related to this component in case of
  68137. * context lost for instance.
  68138. */
  68139. rebuild(): void;
  68140. /**
  68141. * Disposes the component and the associated ressources
  68142. */
  68143. dispose(): void;
  68144. private _beforeCameraUpdate;
  68145. }
  68146. }
  68147. declare module "babylonjs/Meshes/Builders/index" {
  68148. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68149. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68150. export * from "babylonjs/Meshes/Builders/discBuilder";
  68151. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68152. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68153. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68154. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68155. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68156. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68157. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68158. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68159. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68160. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68161. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68162. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68163. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68164. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68165. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68166. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68167. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68168. }
  68169. declare module "babylonjs/Meshes/index" {
  68170. export * from "babylonjs/Meshes/abstractMesh";
  68171. export * from "babylonjs/Meshes/buffer";
  68172. export * from "babylonjs/Meshes/Compression/index";
  68173. export * from "babylonjs/Meshes/csg";
  68174. export * from "babylonjs/Meshes/geometry";
  68175. export * from "babylonjs/Meshes/groundMesh";
  68176. export * from "babylonjs/Meshes/trailMesh";
  68177. export * from "babylonjs/Meshes/instancedMesh";
  68178. export * from "babylonjs/Meshes/linesMesh";
  68179. export * from "babylonjs/Meshes/mesh";
  68180. export * from "babylonjs/Meshes/mesh.vertexData";
  68181. export * from "babylonjs/Meshes/meshBuilder";
  68182. export * from "babylonjs/Meshes/meshSimplification";
  68183. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68184. export * from "babylonjs/Meshes/polygonMesh";
  68185. export * from "babylonjs/Meshes/subMesh";
  68186. export * from "babylonjs/Meshes/meshLODLevel";
  68187. export * from "babylonjs/Meshes/transformNode";
  68188. export * from "babylonjs/Meshes/Builders/index";
  68189. export * from "babylonjs/Meshes/dataBuffer";
  68190. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68191. }
  68192. declare module "babylonjs/Morph/index" {
  68193. export * from "babylonjs/Morph/morphTarget";
  68194. export * from "babylonjs/Morph/morphTargetManager";
  68195. }
  68196. declare module "babylonjs/Navigation/INavigationEngine" {
  68197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68198. import { Vector3 } from "babylonjs/Maths/math";
  68199. import { Mesh } from "babylonjs/Meshes/mesh";
  68200. import { Scene } from "babylonjs/scene";
  68201. /**
  68202. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68203. */
  68204. export interface INavigationEnginePlugin {
  68205. /**
  68206. * plugin name
  68207. */
  68208. name: string;
  68209. /**
  68210. * Creates a navigation mesh
  68211. * @param meshes array of all the geometry used to compute the navigatio mesh
  68212. * @param parameters bunch of parameters used to filter geometry
  68213. */
  68214. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68215. /**
  68216. * Create a navigation mesh debug mesh
  68217. * @param scene is where the mesh will be added
  68218. * @returns debug display mesh
  68219. */
  68220. createDebugNavMesh(scene: Scene): Mesh;
  68221. /**
  68222. * Get a navigation mesh constrained position, closest to the parameter position
  68223. * @param position world position
  68224. * @returns the closest point to position constrained by the navigation mesh
  68225. */
  68226. getClosestPoint(position: Vector3): Vector3;
  68227. /**
  68228. * Get a navigation mesh constrained position, closest to the parameter position
  68229. * @param position world position
  68230. * @param result output the closest point to position constrained by the navigation mesh
  68231. */
  68232. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68233. /**
  68234. * Get a navigation mesh constrained position, within a particular radius
  68235. * @param position world position
  68236. * @param maxRadius the maximum distance to the constrained world position
  68237. * @returns the closest point to position constrained by the navigation mesh
  68238. */
  68239. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68240. /**
  68241. * Get a navigation mesh constrained position, within a particular radius
  68242. * @param position world position
  68243. * @param maxRadius the maximum distance to the constrained world position
  68244. * @param result output the closest point to position constrained by the navigation mesh
  68245. */
  68246. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68247. /**
  68248. * Compute the final position from a segment made of destination-position
  68249. * @param position world position
  68250. * @param destination world position
  68251. * @returns the resulting point along the navmesh
  68252. */
  68253. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68254. /**
  68255. * Compute the final position from a segment made of destination-position
  68256. * @param position world position
  68257. * @param destination world position
  68258. * @param result output the resulting point along the navmesh
  68259. */
  68260. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68261. /**
  68262. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68263. * @param start world position
  68264. * @param end world position
  68265. * @returns array containing world position composing the path
  68266. */
  68267. computePath(start: Vector3, end: Vector3): Vector3[];
  68268. /**
  68269. * If this plugin is supported
  68270. * @returns true if plugin is supported
  68271. */
  68272. isSupported(): boolean;
  68273. /**
  68274. * Create a new Crowd so you can add agents
  68275. * @param maxAgents the maximum agent count in the crowd
  68276. * @param maxAgentRadius the maximum radius an agent can have
  68277. * @param scene to attach the crowd to
  68278. * @returns the crowd you can add agents to
  68279. */
  68280. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68281. /**
  68282. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68283. * The queries will try to find a solution within those bounds
  68284. * default is (1,1,1)
  68285. * @param extent x,y,z value that define the extent around the queries point of reference
  68286. */
  68287. setDefaultQueryExtent(extent: Vector3): void;
  68288. /**
  68289. * Get the Bounding box extent specified by setDefaultQueryExtent
  68290. * @returns the box extent values
  68291. */
  68292. getDefaultQueryExtent(): Vector3;
  68293. /**
  68294. * build the navmesh from a previously saved state using getNavmeshData
  68295. * @param data the Uint8Array returned by getNavmeshData
  68296. */
  68297. buildFromNavmeshData(data: Uint8Array): void;
  68298. /**
  68299. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68300. * @returns data the Uint8Array that can be saved and reused
  68301. */
  68302. getNavmeshData(): Uint8Array;
  68303. /**
  68304. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68305. * @param result output the box extent values
  68306. */
  68307. getDefaultQueryExtentToRef(result: Vector3): void;
  68308. /**
  68309. * Release all resources
  68310. */
  68311. dispose(): void;
  68312. }
  68313. /**
  68314. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68315. */
  68316. export interface ICrowd {
  68317. /**
  68318. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68319. * You can attach anything to that node. The node position is updated in the scene update tick.
  68320. * @param pos world position that will be constrained by the navigation mesh
  68321. * @param parameters agent parameters
  68322. * @param transform hooked to the agent that will be update by the scene
  68323. * @returns agent index
  68324. */
  68325. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68326. /**
  68327. * Returns the agent position in world space
  68328. * @param index agent index returned by addAgent
  68329. * @returns world space position
  68330. */
  68331. getAgentPosition(index: number): Vector3;
  68332. /**
  68333. * Gets the agent position result in world space
  68334. * @param index agent index returned by addAgent
  68335. * @param result output world space position
  68336. */
  68337. getAgentPositionToRef(index: number, result: Vector3): void;
  68338. /**
  68339. * Gets the agent velocity in world space
  68340. * @param index agent index returned by addAgent
  68341. * @returns world space velocity
  68342. */
  68343. getAgentVelocity(index: number): Vector3;
  68344. /**
  68345. * Gets the agent velocity result in world space
  68346. * @param index agent index returned by addAgent
  68347. * @param result output world space velocity
  68348. */
  68349. getAgentVelocityToRef(index: number, result: Vector3): void;
  68350. /**
  68351. * remove a particular agent previously created
  68352. * @param index agent index returned by addAgent
  68353. */
  68354. removeAgent(index: number): void;
  68355. /**
  68356. * get the list of all agents attached to this crowd
  68357. * @returns list of agent indices
  68358. */
  68359. getAgents(): number[];
  68360. /**
  68361. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68362. * @param deltaTime in seconds
  68363. */
  68364. update(deltaTime: number): void;
  68365. /**
  68366. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68367. * @param index agent index returned by addAgent
  68368. * @param destination targeted world position
  68369. */
  68370. agentGoto(index: number, destination: Vector3): void;
  68371. /**
  68372. * Teleport the agent to a new position
  68373. * @param index agent index returned by addAgent
  68374. * @param destination targeted world position
  68375. */
  68376. agentTeleport(index: number, destination: Vector3): void;
  68377. /**
  68378. * Update agent parameters
  68379. * @param index agent index returned by addAgent
  68380. * @param parameters agent parameters
  68381. */
  68382. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68383. /**
  68384. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68385. * The queries will try to find a solution within those bounds
  68386. * default is (1,1,1)
  68387. * @param extent x,y,z value that define the extent around the queries point of reference
  68388. */
  68389. setDefaultQueryExtent(extent: Vector3): void;
  68390. /**
  68391. * Get the Bounding box extent specified by setDefaultQueryExtent
  68392. * @returns the box extent values
  68393. */
  68394. getDefaultQueryExtent(): Vector3;
  68395. /**
  68396. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68397. * @param result output the box extent values
  68398. */
  68399. getDefaultQueryExtentToRef(result: Vector3): void;
  68400. /**
  68401. * Release all resources
  68402. */
  68403. dispose(): void;
  68404. }
  68405. /**
  68406. * Configures an agent
  68407. */
  68408. export interface IAgentParameters {
  68409. /**
  68410. * Agent radius. [Limit: >= 0]
  68411. */
  68412. radius: number;
  68413. /**
  68414. * Agent height. [Limit: > 0]
  68415. */
  68416. height: number;
  68417. /**
  68418. * Maximum allowed acceleration. [Limit: >= 0]
  68419. */
  68420. maxAcceleration: number;
  68421. /**
  68422. * Maximum allowed speed. [Limit: >= 0]
  68423. */
  68424. maxSpeed: number;
  68425. /**
  68426. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68427. */
  68428. collisionQueryRange: number;
  68429. /**
  68430. * The path visibility optimization range. [Limit: > 0]
  68431. */
  68432. pathOptimizationRange: number;
  68433. /**
  68434. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68435. */
  68436. separationWeight: number;
  68437. }
  68438. /**
  68439. * Configures the navigation mesh creation
  68440. */
  68441. export interface INavMeshParameters {
  68442. /**
  68443. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68444. */
  68445. cs: number;
  68446. /**
  68447. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68448. */
  68449. ch: number;
  68450. /**
  68451. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68452. */
  68453. walkableSlopeAngle: number;
  68454. /**
  68455. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68456. * be considered walkable. [Limit: >= 3] [Units: vx]
  68457. */
  68458. walkableHeight: number;
  68459. /**
  68460. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68461. */
  68462. walkableClimb: number;
  68463. /**
  68464. * The distance to erode/shrink the walkable area of the heightfield away from
  68465. * obstructions. [Limit: >=0] [Units: vx]
  68466. */
  68467. walkableRadius: number;
  68468. /**
  68469. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68470. */
  68471. maxEdgeLen: number;
  68472. /**
  68473. * The maximum distance a simplfied contour's border edges should deviate
  68474. * the original raw contour. [Limit: >=0] [Units: vx]
  68475. */
  68476. maxSimplificationError: number;
  68477. /**
  68478. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68479. */
  68480. minRegionArea: number;
  68481. /**
  68482. * Any regions with a span count smaller than this value will, if possible,
  68483. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68484. */
  68485. mergeRegionArea: number;
  68486. /**
  68487. * The maximum number of vertices allowed for polygons generated during the
  68488. * contour to polygon conversion process. [Limit: >= 3]
  68489. */
  68490. maxVertsPerPoly: number;
  68491. /**
  68492. * Sets the sampling distance to use when generating the detail mesh.
  68493. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68494. */
  68495. detailSampleDist: number;
  68496. /**
  68497. * The maximum distance the detail mesh surface should deviate from heightfield
  68498. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68499. */
  68500. detailSampleMaxError: number;
  68501. }
  68502. }
  68503. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  68504. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  68505. import { Mesh } from "babylonjs/Meshes/mesh";
  68506. import { Scene } from "babylonjs/scene";
  68507. import { Vector3 } from "babylonjs/Maths/math";
  68508. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68509. /**
  68510. * RecastJS navigation plugin
  68511. */
  68512. export class RecastJSPlugin implements INavigationEnginePlugin {
  68513. /**
  68514. * Reference to the Recast library
  68515. */
  68516. bjsRECAST: any;
  68517. /**
  68518. * plugin name
  68519. */
  68520. name: string;
  68521. /**
  68522. * the first navmesh created. We might extend this to support multiple navmeshes
  68523. */
  68524. navMesh: any;
  68525. /**
  68526. * Initializes the recastJS plugin
  68527. * @param recastInjection can be used to inject your own recast reference
  68528. */
  68529. constructor(recastInjection?: any);
  68530. /**
  68531. * Creates a navigation mesh
  68532. * @param meshes array of all the geometry used to compute the navigatio mesh
  68533. * @param parameters bunch of parameters used to filter geometry
  68534. */
  68535. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68536. /**
  68537. * Create a navigation mesh debug mesh
  68538. * @param scene is where the mesh will be added
  68539. * @returns debug display mesh
  68540. */
  68541. createDebugNavMesh(scene: Scene): Mesh;
  68542. /**
  68543. * Get a navigation mesh constrained position, closest to the parameter position
  68544. * @param position world position
  68545. * @returns the closest point to position constrained by the navigation mesh
  68546. */
  68547. getClosestPoint(position: Vector3): Vector3;
  68548. /**
  68549. * Get a navigation mesh constrained position, closest to the parameter position
  68550. * @param position world position
  68551. * @param result output the closest point to position constrained by the navigation mesh
  68552. */
  68553. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68554. /**
  68555. * Get a navigation mesh constrained position, within a particular radius
  68556. * @param position world position
  68557. * @param maxRadius the maximum distance to the constrained world position
  68558. * @returns the closest point to position constrained by the navigation mesh
  68559. */
  68560. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68561. /**
  68562. * Get a navigation mesh constrained position, within a particular radius
  68563. * @param position world position
  68564. * @param maxRadius the maximum distance to the constrained world position
  68565. * @param result output the closest point to position constrained by the navigation mesh
  68566. */
  68567. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68568. /**
  68569. * Compute the final position from a segment made of destination-position
  68570. * @param position world position
  68571. * @param destination world position
  68572. * @returns the resulting point along the navmesh
  68573. */
  68574. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68575. /**
  68576. * Compute the final position from a segment made of destination-position
  68577. * @param position world position
  68578. * @param destination world position
  68579. * @param result output the resulting point along the navmesh
  68580. */
  68581. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68582. /**
  68583. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68584. * @param start world position
  68585. * @param end world position
  68586. * @returns array containing world position composing the path
  68587. */
  68588. computePath(start: Vector3, end: Vector3): Vector3[];
  68589. /**
  68590. * Create a new Crowd so you can add agents
  68591. * @param maxAgents the maximum agent count in the crowd
  68592. * @param maxAgentRadius the maximum radius an agent can have
  68593. * @param scene to attach the crowd to
  68594. * @returns the crowd you can add agents to
  68595. */
  68596. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68597. /**
  68598. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68599. * The queries will try to find a solution within those bounds
  68600. * default is (1,1,1)
  68601. * @param extent x,y,z value that define the extent around the queries point of reference
  68602. */
  68603. setDefaultQueryExtent(extent: Vector3): void;
  68604. /**
  68605. * Get the Bounding box extent specified by setDefaultQueryExtent
  68606. * @returns the box extent values
  68607. */
  68608. getDefaultQueryExtent(): Vector3;
  68609. /**
  68610. * build the navmesh from a previously saved state using getNavmeshData
  68611. * @param data the Uint8Array returned by getNavmeshData
  68612. */
  68613. buildFromNavmeshData(data: Uint8Array): void;
  68614. /**
  68615. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68616. * @returns data the Uint8Array that can be saved and reused
  68617. */
  68618. getNavmeshData(): Uint8Array;
  68619. /**
  68620. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68621. * @param result output the box extent values
  68622. */
  68623. getDefaultQueryExtentToRef(result: Vector3): void;
  68624. /**
  68625. * Disposes
  68626. */
  68627. dispose(): void;
  68628. /**
  68629. * If this plugin is supported
  68630. * @returns true if plugin is supported
  68631. */
  68632. isSupported(): boolean;
  68633. }
  68634. /**
  68635. * Recast detour crowd implementation
  68636. */
  68637. export class RecastJSCrowd implements ICrowd {
  68638. /**
  68639. * Recast/detour plugin
  68640. */
  68641. bjsRECASTPlugin: RecastJSPlugin;
  68642. /**
  68643. * Link to the detour crowd
  68644. */
  68645. recastCrowd: any;
  68646. /**
  68647. * One transform per agent
  68648. */
  68649. transforms: TransformNode[];
  68650. /**
  68651. * All agents created
  68652. */
  68653. agents: number[];
  68654. /**
  68655. * Link to the scene is kept to unregister the crowd from the scene
  68656. */
  68657. private _scene;
  68658. /**
  68659. * Observer for crowd updates
  68660. */
  68661. private _onBeforeAnimationsObserver;
  68662. /**
  68663. * Constructor
  68664. * @param plugin recastJS plugin
  68665. * @param maxAgents the maximum agent count in the crowd
  68666. * @param maxAgentRadius the maximum radius an agent can have
  68667. * @param scene to attach the crowd to
  68668. * @returns the crowd you can add agents to
  68669. */
  68670. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68671. /**
  68672. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68673. * You can attach anything to that node. The node position is updated in the scene update tick.
  68674. * @param pos world position that will be constrained by the navigation mesh
  68675. * @param parameters agent parameters
  68676. * @param transform hooked to the agent that will be update by the scene
  68677. * @returns agent index
  68678. */
  68679. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68680. /**
  68681. * Returns the agent position in world space
  68682. * @param index agent index returned by addAgent
  68683. * @returns world space position
  68684. */
  68685. getAgentPosition(index: number): Vector3;
  68686. /**
  68687. * Returns the agent position result in world space
  68688. * @param index agent index returned by addAgent
  68689. * @param result output world space position
  68690. */
  68691. getAgentPositionToRef(index: number, result: Vector3): void;
  68692. /**
  68693. * Returns the agent velocity in world space
  68694. * @param index agent index returned by addAgent
  68695. * @returns world space velocity
  68696. */
  68697. getAgentVelocity(index: number): Vector3;
  68698. /**
  68699. * Returns the agent velocity result in world space
  68700. * @param index agent index returned by addAgent
  68701. * @param result output world space velocity
  68702. */
  68703. getAgentVelocityToRef(index: number, result: Vector3): void;
  68704. /**
  68705. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68706. * @param index agent index returned by addAgent
  68707. * @param destination targeted world position
  68708. */
  68709. agentGoto(index: number, destination: Vector3): void;
  68710. /**
  68711. * Teleport the agent to a new position
  68712. * @param index agent index returned by addAgent
  68713. * @param destination targeted world position
  68714. */
  68715. agentTeleport(index: number, destination: Vector3): void;
  68716. /**
  68717. * Update agent parameters
  68718. * @param index agent index returned by addAgent
  68719. * @param parameters agent parameters
  68720. */
  68721. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68722. /**
  68723. * remove a particular agent previously created
  68724. * @param index agent index returned by addAgent
  68725. */
  68726. removeAgent(index: number): void;
  68727. /**
  68728. * get the list of all agents attached to this crowd
  68729. * @returns list of agent indices
  68730. */
  68731. getAgents(): number[];
  68732. /**
  68733. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68734. * @param deltaTime in seconds
  68735. */
  68736. update(deltaTime: number): void;
  68737. /**
  68738. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68739. * The queries will try to find a solution within those bounds
  68740. * default is (1,1,1)
  68741. * @param extent x,y,z value that define the extent around the queries point of reference
  68742. */
  68743. setDefaultQueryExtent(extent: Vector3): void;
  68744. /**
  68745. * Get the Bounding box extent specified by setDefaultQueryExtent
  68746. * @returns the box extent values
  68747. */
  68748. getDefaultQueryExtent(): Vector3;
  68749. /**
  68750. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68751. * @param result output the box extent values
  68752. */
  68753. getDefaultQueryExtentToRef(result: Vector3): void;
  68754. /**
  68755. * Release all resources
  68756. */
  68757. dispose(): void;
  68758. }
  68759. }
  68760. declare module "babylonjs/Navigation/Plugins/index" {
  68761. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  68762. }
  68763. declare module "babylonjs/Navigation/index" {
  68764. export * from "babylonjs/Navigation/INavigationEngine";
  68765. export * from "babylonjs/Navigation/Plugins/index";
  68766. }
  68767. declare module "babylonjs/Offline/database" {
  68768. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  68769. /**
  68770. * Class used to enable access to IndexedDB
  68771. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68772. */
  68773. export class Database implements IOfflineProvider {
  68774. private _callbackManifestChecked;
  68775. private _currentSceneUrl;
  68776. private _db;
  68777. private _enableSceneOffline;
  68778. private _enableTexturesOffline;
  68779. private _manifestVersionFound;
  68780. private _mustUpdateRessources;
  68781. private _hasReachedQuota;
  68782. private _isSupported;
  68783. private _idbFactory;
  68784. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68785. private static IsUASupportingBlobStorage;
  68786. /**
  68787. * Gets a boolean indicating if Database storate is enabled (off by default)
  68788. */
  68789. static IDBStorageEnabled: boolean;
  68790. /**
  68791. * Gets a boolean indicating if scene must be saved in the database
  68792. */
  68793. get enableSceneOffline(): boolean;
  68794. /**
  68795. * Gets a boolean indicating if textures must be saved in the database
  68796. */
  68797. get enableTexturesOffline(): boolean;
  68798. /**
  68799. * Creates a new Database
  68800. * @param urlToScene defines the url to load the scene
  68801. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68802. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68803. */
  68804. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68805. private static _ParseURL;
  68806. private static _ReturnFullUrlLocation;
  68807. private _checkManifestFile;
  68808. /**
  68809. * Open the database and make it available
  68810. * @param successCallback defines the callback to call on success
  68811. * @param errorCallback defines the callback to call on error
  68812. */
  68813. open(successCallback: () => void, errorCallback: () => void): void;
  68814. /**
  68815. * Loads an image from the database
  68816. * @param url defines the url to load from
  68817. * @param image defines the target DOM image
  68818. */
  68819. loadImage(url: string, image: HTMLImageElement): void;
  68820. private _loadImageFromDBAsync;
  68821. private _saveImageIntoDBAsync;
  68822. private _checkVersionFromDB;
  68823. private _loadVersionFromDBAsync;
  68824. private _saveVersionIntoDBAsync;
  68825. /**
  68826. * Loads a file from database
  68827. * @param url defines the URL to load from
  68828. * @param sceneLoaded defines a callback to call on success
  68829. * @param progressCallBack defines a callback to call when progress changed
  68830. * @param errorCallback defines a callback to call on error
  68831. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68832. */
  68833. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68834. private _loadFileAsync;
  68835. private _saveFileAsync;
  68836. /**
  68837. * Validates if xhr data is correct
  68838. * @param xhr defines the request to validate
  68839. * @param dataType defines the expected data type
  68840. * @returns true if data is correct
  68841. */
  68842. private static _ValidateXHRData;
  68843. }
  68844. }
  68845. declare module "babylonjs/Offline/index" {
  68846. export * from "babylonjs/Offline/database";
  68847. export * from "babylonjs/Offline/IOfflineProvider";
  68848. }
  68849. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  68850. /** @hidden */
  68851. export var gpuUpdateParticlesPixelShader: {
  68852. name: string;
  68853. shader: string;
  68854. };
  68855. }
  68856. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  68857. /** @hidden */
  68858. export var gpuUpdateParticlesVertexShader: {
  68859. name: string;
  68860. shader: string;
  68861. };
  68862. }
  68863. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  68864. /** @hidden */
  68865. export var clipPlaneFragmentDeclaration2: {
  68866. name: string;
  68867. shader: string;
  68868. };
  68869. }
  68870. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  68871. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  68872. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  68873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68874. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  68875. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  68876. /** @hidden */
  68877. export var gpuRenderParticlesPixelShader: {
  68878. name: string;
  68879. shader: string;
  68880. };
  68881. }
  68882. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  68883. /** @hidden */
  68884. export var clipPlaneVertexDeclaration2: {
  68885. name: string;
  68886. shader: string;
  68887. };
  68888. }
  68889. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  68890. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  68891. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  68892. /** @hidden */
  68893. export var gpuRenderParticlesVertexShader: {
  68894. name: string;
  68895. shader: string;
  68896. };
  68897. }
  68898. declare module "babylonjs/Particles/gpuParticleSystem" {
  68899. import { Nullable } from "babylonjs/types";
  68900. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  68901. import { Observable } from "babylonjs/Misc/observable";
  68902. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68903. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68904. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  68905. import { Scene, IDisposable } from "babylonjs/scene";
  68906. import { Effect } from "babylonjs/Materials/effect";
  68907. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68908. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68909. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  68910. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  68911. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  68912. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  68913. /**
  68914. * This represents a GPU particle system in Babylon
  68915. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68916. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68917. */
  68918. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68919. /**
  68920. * The layer mask we are rendering the particles through.
  68921. */
  68922. layerMask: number;
  68923. private _capacity;
  68924. private _activeCount;
  68925. private _currentActiveCount;
  68926. private _accumulatedCount;
  68927. private _renderEffect;
  68928. private _updateEffect;
  68929. private _buffer0;
  68930. private _buffer1;
  68931. private _spriteBuffer;
  68932. private _updateVAO;
  68933. private _renderVAO;
  68934. private _targetIndex;
  68935. private _sourceBuffer;
  68936. private _targetBuffer;
  68937. private _engine;
  68938. private _currentRenderId;
  68939. private _started;
  68940. private _stopped;
  68941. private _timeDelta;
  68942. private _randomTexture;
  68943. private _randomTexture2;
  68944. private _attributesStrideSize;
  68945. private _updateEffectOptions;
  68946. private _randomTextureSize;
  68947. private _actualFrame;
  68948. private _customEffect;
  68949. private readonly _rawTextureWidth;
  68950. /**
  68951. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68952. */
  68953. static get IsSupported(): boolean;
  68954. /**
  68955. * An event triggered when the system is disposed.
  68956. */
  68957. onDisposeObservable: Observable<IParticleSystem>;
  68958. /**
  68959. * Gets the maximum number of particles active at the same time.
  68960. * @returns The max number of active particles.
  68961. */
  68962. getCapacity(): number;
  68963. /**
  68964. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68965. * to override the particles.
  68966. */
  68967. forceDepthWrite: boolean;
  68968. /**
  68969. * Gets or set the number of active particles
  68970. */
  68971. get activeParticleCount(): number;
  68972. set activeParticleCount(value: number);
  68973. private _preWarmDone;
  68974. /**
  68975. * Specifies if the particles are updated in emitter local space or world space.
  68976. */
  68977. isLocal: boolean;
  68978. /**
  68979. * Is this system ready to be used/rendered
  68980. * @return true if the system is ready
  68981. */
  68982. isReady(): boolean;
  68983. /**
  68984. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68985. * @returns True if it has been started, otherwise false.
  68986. */
  68987. isStarted(): boolean;
  68988. /**
  68989. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68990. * @returns True if it has been stopped, otherwise false.
  68991. */
  68992. isStopped(): boolean;
  68993. /**
  68994. * Gets a boolean indicating that the system is stopping
  68995. * @returns true if the system is currently stopping
  68996. */
  68997. isStopping(): boolean;
  68998. /**
  68999. * Gets the number of particles active at the same time.
  69000. * @returns The number of active particles.
  69001. */
  69002. getActiveCount(): number;
  69003. /**
  69004. * Starts the particle system and begins to emit
  69005. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69006. */
  69007. start(delay?: number): void;
  69008. /**
  69009. * Stops the particle system.
  69010. */
  69011. stop(): void;
  69012. /**
  69013. * Remove all active particles
  69014. */
  69015. reset(): void;
  69016. /**
  69017. * Returns the string "GPUParticleSystem"
  69018. * @returns a string containing the class name
  69019. */
  69020. getClassName(): string;
  69021. /**
  69022. * Gets the custom effect used to render the particles
  69023. * @param blendMode Blend mode for which the effect should be retrieved
  69024. * @returns The effect
  69025. */
  69026. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69027. /**
  69028. * Sets the custom effect used to render the particles
  69029. * @param effect The effect to set
  69030. * @param blendMode Blend mode for which the effect should be set
  69031. */
  69032. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69033. /** @hidden */
  69034. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69035. /**
  69036. * Observable that will be called just before the particles are drawn
  69037. */
  69038. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69039. /**
  69040. * Gets the name of the particle vertex shader
  69041. */
  69042. get vertexShaderName(): string;
  69043. private _colorGradientsTexture;
  69044. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69045. /**
  69046. * Adds a new color gradient
  69047. * @param gradient defines the gradient to use (between 0 and 1)
  69048. * @param color1 defines the color to affect to the specified gradient
  69049. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69050. * @returns the current particle system
  69051. */
  69052. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69053. private _refreshColorGradient;
  69054. /** Force the system to rebuild all gradients that need to be resync */
  69055. forceRefreshGradients(): void;
  69056. /**
  69057. * Remove a specific color gradient
  69058. * @param gradient defines the gradient to remove
  69059. * @returns the current particle system
  69060. */
  69061. removeColorGradient(gradient: number): GPUParticleSystem;
  69062. private _angularSpeedGradientsTexture;
  69063. private _sizeGradientsTexture;
  69064. private _velocityGradientsTexture;
  69065. private _limitVelocityGradientsTexture;
  69066. private _dragGradientsTexture;
  69067. private _addFactorGradient;
  69068. /**
  69069. * Adds a new size gradient
  69070. * @param gradient defines the gradient to use (between 0 and 1)
  69071. * @param factor defines the size factor to affect to the specified gradient
  69072. * @returns the current particle system
  69073. */
  69074. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69075. /**
  69076. * Remove a specific size gradient
  69077. * @param gradient defines the gradient to remove
  69078. * @returns the current particle system
  69079. */
  69080. removeSizeGradient(gradient: number): GPUParticleSystem;
  69081. private _refreshFactorGradient;
  69082. /**
  69083. * Adds a new angular speed gradient
  69084. * @param gradient defines the gradient to use (between 0 and 1)
  69085. * @param factor defines the angular speed to affect to the specified gradient
  69086. * @returns the current particle system
  69087. */
  69088. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69089. /**
  69090. * Remove a specific angular speed gradient
  69091. * @param gradient defines the gradient to remove
  69092. * @returns the current particle system
  69093. */
  69094. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69095. /**
  69096. * Adds a new velocity gradient
  69097. * @param gradient defines the gradient to use (between 0 and 1)
  69098. * @param factor defines the velocity to affect to the specified gradient
  69099. * @returns the current particle system
  69100. */
  69101. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69102. /**
  69103. * Remove a specific velocity gradient
  69104. * @param gradient defines the gradient to remove
  69105. * @returns the current particle system
  69106. */
  69107. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69108. /**
  69109. * Adds a new limit velocity gradient
  69110. * @param gradient defines the gradient to use (between 0 and 1)
  69111. * @param factor defines the limit velocity value to affect to the specified gradient
  69112. * @returns the current particle system
  69113. */
  69114. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69115. /**
  69116. * Remove a specific limit velocity gradient
  69117. * @param gradient defines the gradient to remove
  69118. * @returns the current particle system
  69119. */
  69120. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69121. /**
  69122. * Adds a new drag gradient
  69123. * @param gradient defines the gradient to use (between 0 and 1)
  69124. * @param factor defines the drag value to affect to the specified gradient
  69125. * @returns the current particle system
  69126. */
  69127. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69128. /**
  69129. * Remove a specific drag gradient
  69130. * @param gradient defines the gradient to remove
  69131. * @returns the current particle system
  69132. */
  69133. removeDragGradient(gradient: number): GPUParticleSystem;
  69134. /**
  69135. * Not supported by GPUParticleSystem
  69136. * @param gradient defines the gradient to use (between 0 and 1)
  69137. * @param factor defines the emit rate value to affect to the specified gradient
  69138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69139. * @returns the current particle system
  69140. */
  69141. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69142. /**
  69143. * Not supported by GPUParticleSystem
  69144. * @param gradient defines the gradient to remove
  69145. * @returns the current particle system
  69146. */
  69147. removeEmitRateGradient(gradient: number): IParticleSystem;
  69148. /**
  69149. * Not supported by GPUParticleSystem
  69150. * @param gradient defines the gradient to use (between 0 and 1)
  69151. * @param factor defines the start size value to affect to the specified gradient
  69152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69153. * @returns the current particle system
  69154. */
  69155. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69156. /**
  69157. * Not supported by GPUParticleSystem
  69158. * @param gradient defines the gradient to remove
  69159. * @returns the current particle system
  69160. */
  69161. removeStartSizeGradient(gradient: number): IParticleSystem;
  69162. /**
  69163. * Not supported by GPUParticleSystem
  69164. * @param gradient defines the gradient to use (between 0 and 1)
  69165. * @param min defines the color remap minimal range
  69166. * @param max defines the color remap maximal range
  69167. * @returns the current particle system
  69168. */
  69169. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69170. /**
  69171. * Not supported by GPUParticleSystem
  69172. * @param gradient defines the gradient to remove
  69173. * @returns the current particle system
  69174. */
  69175. removeColorRemapGradient(): IParticleSystem;
  69176. /**
  69177. * Not supported by GPUParticleSystem
  69178. * @param gradient defines the gradient to use (between 0 and 1)
  69179. * @param min defines the alpha remap minimal range
  69180. * @param max defines the alpha remap maximal range
  69181. * @returns the current particle system
  69182. */
  69183. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69184. /**
  69185. * Not supported by GPUParticleSystem
  69186. * @param gradient defines the gradient to remove
  69187. * @returns the current particle system
  69188. */
  69189. removeAlphaRemapGradient(): IParticleSystem;
  69190. /**
  69191. * Not supported by GPUParticleSystem
  69192. * @param gradient defines the gradient to use (between 0 and 1)
  69193. * @param color defines the color to affect to the specified gradient
  69194. * @returns the current particle system
  69195. */
  69196. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69197. /**
  69198. * Not supported by GPUParticleSystem
  69199. * @param gradient defines the gradient to remove
  69200. * @returns the current particle system
  69201. */
  69202. removeRampGradient(): IParticleSystem;
  69203. /**
  69204. * Not supported by GPUParticleSystem
  69205. * @returns the list of ramp gradients
  69206. */
  69207. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69208. /**
  69209. * Not supported by GPUParticleSystem
  69210. * Gets or sets a boolean indicating that ramp gradients must be used
  69211. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69212. */
  69213. get useRampGradients(): boolean;
  69214. set useRampGradients(value: boolean);
  69215. /**
  69216. * Not supported by GPUParticleSystem
  69217. * @param gradient defines the gradient to use (between 0 and 1)
  69218. * @param factor defines the life time factor to affect to the specified gradient
  69219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69220. * @returns the current particle system
  69221. */
  69222. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69223. /**
  69224. * Not supported by GPUParticleSystem
  69225. * @param gradient defines the gradient to remove
  69226. * @returns the current particle system
  69227. */
  69228. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69229. /**
  69230. * Instantiates a GPU particle system.
  69231. * 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.
  69232. * @param name The name of the particle system
  69233. * @param options The options used to create the system
  69234. * @param scene The scene the particle system belongs to
  69235. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69236. * @param customEffect a custom effect used to change the way particles are rendered by default
  69237. */
  69238. constructor(name: string, options: Partial<{
  69239. capacity: number;
  69240. randomTextureSize: number;
  69241. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69242. protected _reset(): void;
  69243. private _createUpdateVAO;
  69244. private _createRenderVAO;
  69245. private _initialize;
  69246. /** @hidden */
  69247. _recreateUpdateEffect(): void;
  69248. private _getEffect;
  69249. /**
  69250. * Fill the defines array according to the current settings of the particle system
  69251. * @param defines Array to be updated
  69252. * @param blendMode blend mode to take into account when updating the array
  69253. */
  69254. fillDefines(defines: Array<string>, blendMode?: number): void;
  69255. /**
  69256. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69257. * @param uniforms Uniforms array to fill
  69258. * @param attributes Attributes array to fill
  69259. * @param samplers Samplers array to fill
  69260. */
  69261. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69262. /** @hidden */
  69263. _recreateRenderEffect(): Effect;
  69264. /**
  69265. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69266. * @param preWarm defines if we are in the pre-warmimg phase
  69267. */
  69268. animate(preWarm?: boolean): void;
  69269. private _createFactorGradientTexture;
  69270. private _createSizeGradientTexture;
  69271. private _createAngularSpeedGradientTexture;
  69272. private _createVelocityGradientTexture;
  69273. private _createLimitVelocityGradientTexture;
  69274. private _createDragGradientTexture;
  69275. private _createColorGradientTexture;
  69276. /**
  69277. * Renders the particle system in its current state
  69278. * @param preWarm defines if the system should only update the particles but not render them
  69279. * @returns the current number of particles
  69280. */
  69281. render(preWarm?: boolean): number;
  69282. /**
  69283. * Rebuilds the particle system
  69284. */
  69285. rebuild(): void;
  69286. private _releaseBuffers;
  69287. private _releaseVAOs;
  69288. /**
  69289. * Disposes the particle system and free the associated resources
  69290. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69291. */
  69292. dispose(disposeTexture?: boolean): void;
  69293. /**
  69294. * Clones the particle system.
  69295. * @param name The name of the cloned object
  69296. * @param newEmitter The new emitter to use
  69297. * @returns the cloned particle system
  69298. */
  69299. clone(name: string, newEmitter: any): GPUParticleSystem;
  69300. /**
  69301. * Serializes the particle system to a JSON object
  69302. * @param serializeTexture defines if the texture must be serialized as well
  69303. * @returns the JSON object
  69304. */
  69305. serialize(serializeTexture?: boolean): any;
  69306. /**
  69307. * Parses a JSON object to create a GPU particle system.
  69308. * @param parsedParticleSystem The JSON object to parse
  69309. * @param scene The scene to create the particle system in
  69310. * @param rootUrl The root url to use to load external dependencies like texture
  69311. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69312. * @returns the parsed GPU particle system
  69313. */
  69314. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69315. }
  69316. }
  69317. declare module "babylonjs/Particles/particleSystemSet" {
  69318. import { Nullable } from "babylonjs/types";
  69319. import { Color3 } from "babylonjs/Maths/math.color";
  69320. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69322. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69323. import { Scene, IDisposable } from "babylonjs/scene";
  69324. /**
  69325. * Represents a set of particle systems working together to create a specific effect
  69326. */
  69327. export class ParticleSystemSet implements IDisposable {
  69328. /**
  69329. * Gets or sets base Assets URL
  69330. */
  69331. static BaseAssetsUrl: string;
  69332. private _emitterCreationOptions;
  69333. private _emitterNode;
  69334. /**
  69335. * Gets the particle system list
  69336. */
  69337. systems: IParticleSystem[];
  69338. /**
  69339. * Gets the emitter node used with this set
  69340. */
  69341. get emitterNode(): Nullable<TransformNode>;
  69342. /**
  69343. * Creates a new emitter mesh as a sphere
  69344. * @param options defines the options used to create the sphere
  69345. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69346. * @param scene defines the hosting scene
  69347. */
  69348. setEmitterAsSphere(options: {
  69349. diameter: number;
  69350. segments: number;
  69351. color: Color3;
  69352. }, renderingGroupId: number, scene: Scene): void;
  69353. /**
  69354. * Starts all particle systems of the set
  69355. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69356. */
  69357. start(emitter?: AbstractMesh): void;
  69358. /**
  69359. * Release all associated resources
  69360. */
  69361. dispose(): void;
  69362. /**
  69363. * Serialize the set into a JSON compatible object
  69364. * @param serializeTexture defines if the texture must be serialized as well
  69365. * @returns a JSON compatible representation of the set
  69366. */
  69367. serialize(serializeTexture?: boolean): any;
  69368. /**
  69369. * Parse a new ParticleSystemSet from a serialized source
  69370. * @param data defines a JSON compatible representation of the set
  69371. * @param scene defines the hosting scene
  69372. * @param gpu defines if we want GPU particles or CPU particles
  69373. * @returns a new ParticleSystemSet
  69374. */
  69375. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69376. }
  69377. }
  69378. declare module "babylonjs/Particles/particleHelper" {
  69379. import { Nullable } from "babylonjs/types";
  69380. import { Scene } from "babylonjs/scene";
  69381. import { Vector3 } from "babylonjs/Maths/math.vector";
  69382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69384. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69385. /**
  69386. * This class is made for on one-liner static method to help creating particle system set.
  69387. */
  69388. export class ParticleHelper {
  69389. /**
  69390. * Gets or sets base Assets URL
  69391. */
  69392. static BaseAssetsUrl: string;
  69393. /** Define the Url to load snippets */
  69394. static SnippetUrl: string;
  69395. /**
  69396. * Create a default particle system that you can tweak
  69397. * @param emitter defines the emitter to use
  69398. * @param capacity defines the system capacity (default is 500 particles)
  69399. * @param scene defines the hosting scene
  69400. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69401. * @returns the new Particle system
  69402. */
  69403. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69404. /**
  69405. * This is the main static method (one-liner) of this helper to create different particle systems
  69406. * @param type This string represents the type to the particle system to create
  69407. * @param scene The scene where the particle system should live
  69408. * @param gpu If the system will use gpu
  69409. * @returns the ParticleSystemSet created
  69410. */
  69411. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69412. /**
  69413. * Static function used to export a particle system to a ParticleSystemSet variable.
  69414. * Please note that the emitter shape is not exported
  69415. * @param systems defines the particle systems to export
  69416. * @returns the created particle system set
  69417. */
  69418. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69419. /**
  69420. * Creates a particle system from a snippet saved in a remote file
  69421. * @param name defines the name of the particle system to create
  69422. * @param url defines the url to load from
  69423. * @param scene defines the hosting scene
  69424. * @param gpu If the system will use gpu
  69425. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69426. * @returns a promise that will resolve to the new particle system
  69427. */
  69428. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69429. /**
  69430. * Creates a particle system from a snippet saved by the particle system editor
  69431. * @param snippetId defines the snippet to load
  69432. * @param scene defines the hosting scene
  69433. * @param gpu If the system will use gpu
  69434. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69435. * @returns a promise that will resolve to the new particle system
  69436. */
  69437. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69438. }
  69439. }
  69440. declare module "babylonjs/Particles/particleSystemComponent" {
  69441. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69442. import { Effect } from "babylonjs/Materials/effect";
  69443. import "babylonjs/Shaders/particles.vertex";
  69444. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69445. module "babylonjs/Engines/engine" {
  69446. interface Engine {
  69447. /**
  69448. * Create an effect to use with particle systems.
  69449. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69450. * the particle system for which you want to create a custom effect in the last parameter
  69451. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69452. * @param uniformsNames defines a list of attribute names
  69453. * @param samplers defines an array of string used to represent textures
  69454. * @param defines defines the string containing the defines to use to compile the shaders
  69455. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69456. * @param onCompiled defines a function to call when the effect creation is successful
  69457. * @param onError defines a function to call when the effect creation has failed
  69458. * @param particleSystem the particle system you want to create the effect for
  69459. * @returns the new Effect
  69460. */
  69461. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69462. }
  69463. }
  69464. module "babylonjs/Meshes/mesh" {
  69465. interface Mesh {
  69466. /**
  69467. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69468. * @returns an array of IParticleSystem
  69469. */
  69470. getEmittedParticleSystems(): IParticleSystem[];
  69471. /**
  69472. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69473. * @returns an array of IParticleSystem
  69474. */
  69475. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69476. }
  69477. }
  69478. /**
  69479. * @hidden
  69480. */
  69481. export var _IDoNeedToBeInTheBuild: number;
  69482. }
  69483. declare module "babylonjs/Particles/pointsCloudSystem" {
  69484. import { Color4 } from "babylonjs/Maths/math";
  69485. import { Mesh } from "babylonjs/Meshes/mesh";
  69486. import { Scene, IDisposable } from "babylonjs/scene";
  69487. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  69488. /** Defines the 4 color options */
  69489. export enum PointColor {
  69490. /** color value */
  69491. Color = 2,
  69492. /** uv value */
  69493. UV = 1,
  69494. /** random value */
  69495. Random = 0,
  69496. /** stated value */
  69497. Stated = 3
  69498. }
  69499. /**
  69500. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69501. * 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.
  69502. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69503. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69504. *
  69505. * Full documentation here : TO BE ENTERED
  69506. */
  69507. export class PointsCloudSystem implements IDisposable {
  69508. /**
  69509. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69510. * Example : var p = SPS.particles[i];
  69511. */
  69512. particles: CloudPoint[];
  69513. /**
  69514. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69515. */
  69516. nbParticles: number;
  69517. /**
  69518. * This a counter for your own usage. It's not set by any SPS functions.
  69519. */
  69520. counter: number;
  69521. /**
  69522. * The PCS name. This name is also given to the underlying mesh.
  69523. */
  69524. name: string;
  69525. /**
  69526. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69527. */
  69528. mesh: Mesh;
  69529. /**
  69530. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69531. * Please read :
  69532. */
  69533. vars: any;
  69534. /**
  69535. * @hidden
  69536. */
  69537. _size: number;
  69538. private _scene;
  69539. private _promises;
  69540. private _positions;
  69541. private _indices;
  69542. private _normals;
  69543. private _colors;
  69544. private _uvs;
  69545. private _indices32;
  69546. private _positions32;
  69547. private _colors32;
  69548. private _uvs32;
  69549. private _updatable;
  69550. private _isVisibilityBoxLocked;
  69551. private _alwaysVisible;
  69552. private _groups;
  69553. private _groupCounter;
  69554. private _computeParticleColor;
  69555. private _computeParticleTexture;
  69556. private _computeParticleRotation;
  69557. private _computeBoundingBox;
  69558. private _isReady;
  69559. /**
  69560. * Creates a PCS (Points Cloud System) object
  69561. * @param name (String) is the PCS name, this will be the underlying mesh name
  69562. * @param pointSize (number) is the size for each point
  69563. * @param scene (Scene) is the scene in which the PCS is added
  69564. * @param options defines the options of the PCS e.g.
  69565. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69566. */
  69567. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69568. updatable?: boolean;
  69569. });
  69570. /**
  69571. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69572. * If no points were added to the PCS, the returned mesh is just a single point.
  69573. * @returns a promise for the created mesh
  69574. */
  69575. buildMeshAsync(): Promise<Mesh>;
  69576. /**
  69577. * @hidden
  69578. */
  69579. private _buildMesh;
  69580. private _addParticle;
  69581. private _randomUnitVector;
  69582. private _getColorIndicesForCoord;
  69583. private _setPointsColorOrUV;
  69584. private _colorFromTexture;
  69585. private _calculateDensity;
  69586. /**
  69587. * Adds points to the PCS in random positions within a unit sphere
  69588. * @param nb (positive integer) the number of particles to be created from this model
  69589. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69590. * @returns the number of groups in the system
  69591. */
  69592. addPoints(nb: number, pointFunction?: any): number;
  69593. /**
  69594. * Adds points to the PCS from the surface of the model shape
  69595. * @param mesh is any Mesh object that will be used as a surface model for the points
  69596. * @param nb (positive integer) the number of particles to be created from this model
  69597. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69598. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69599. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69600. * @returns the number of groups in the system
  69601. */
  69602. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69603. /**
  69604. * Adds points to the PCS inside the model shape
  69605. * @param mesh is any Mesh object that will be used as a surface model for the points
  69606. * @param nb (positive integer) the number of particles to be created from this model
  69607. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69608. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69609. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69610. * @returns the number of groups in the system
  69611. */
  69612. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69613. /**
  69614. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69615. * This method calls `updateParticle()` for each particle of the SPS.
  69616. * For an animated SPS, it is usually called within the render loop.
  69617. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69618. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69619. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69620. * @returns the PCS.
  69621. */
  69622. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69623. /**
  69624. * Disposes the PCS.
  69625. */
  69626. dispose(): void;
  69627. /**
  69628. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69629. * doc :
  69630. * @returns the PCS.
  69631. */
  69632. refreshVisibleSize(): PointsCloudSystem;
  69633. /**
  69634. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69635. * @param size the size (float) of the visibility box
  69636. * note : this doesn't lock the PCS mesh bounding box.
  69637. * doc :
  69638. */
  69639. setVisibilityBox(size: number): void;
  69640. /**
  69641. * Gets whether the PCS is always visible or not
  69642. * doc :
  69643. */
  69644. get isAlwaysVisible(): boolean;
  69645. /**
  69646. * Sets the PCS as always visible or not
  69647. * doc :
  69648. */
  69649. set isAlwaysVisible(val: boolean);
  69650. /**
  69651. * Tells to `setParticles()` to compute the particle rotations or not
  69652. * Default value : false. The PCS is faster when it's set to false
  69653. * Note : particle rotations are only applied to parent particles
  69654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69655. */
  69656. set computeParticleRotation(val: boolean);
  69657. /**
  69658. * Tells to `setParticles()` to compute the particle colors or not.
  69659. * Default value : true. The PCS is faster when it's set to false.
  69660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69661. */
  69662. set computeParticleColor(val: boolean);
  69663. set computeParticleTexture(val: boolean);
  69664. /**
  69665. * Gets if `setParticles()` computes the particle colors or not.
  69666. * Default value : false. The PCS is faster when it's set to false.
  69667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69668. */
  69669. get computeParticleColor(): boolean;
  69670. /**
  69671. * Gets if `setParticles()` computes the particle textures or not.
  69672. * Default value : false. The PCS is faster when it's set to false.
  69673. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69674. */
  69675. get computeParticleTexture(): boolean;
  69676. /**
  69677. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69678. */
  69679. set computeBoundingBox(val: boolean);
  69680. /**
  69681. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69682. */
  69683. get computeBoundingBox(): boolean;
  69684. /**
  69685. * This function does nothing. It may be overwritten to set all the particle first values.
  69686. * The PCS doesn't call this function, you may have to call it by your own.
  69687. * doc :
  69688. */
  69689. initParticles(): void;
  69690. /**
  69691. * This function does nothing. It may be overwritten to recycle a particle
  69692. * The PCS doesn't call this function, you can to call it
  69693. * doc :
  69694. * @param particle The particle to recycle
  69695. * @returns the recycled particle
  69696. */
  69697. recycleParticle(particle: CloudPoint): CloudPoint;
  69698. /**
  69699. * Updates a particle : this function should be overwritten by the user.
  69700. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69701. * doc :
  69702. * @example : just set a particle position or velocity and recycle conditions
  69703. * @param particle The particle to update
  69704. * @returns the updated particle
  69705. */
  69706. updateParticle(particle: CloudPoint): CloudPoint;
  69707. /**
  69708. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69709. * This does nothing and may be overwritten by the user.
  69710. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69711. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69712. * @param update the boolean update value actually passed to setParticles()
  69713. */
  69714. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69715. /**
  69716. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69717. * This will be passed three parameters.
  69718. * This does nothing and may be overwritten by the user.
  69719. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69721. * @param update the boolean update value actually passed to setParticles()
  69722. */
  69723. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69724. }
  69725. }
  69726. declare module "babylonjs/Particles/cloudPoint" {
  69727. import { Nullable } from "babylonjs/types";
  69728. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  69729. import { Mesh } from "babylonjs/Meshes/mesh";
  69730. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  69731. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  69732. /**
  69733. * Represents one particle of a points cloud system.
  69734. */
  69735. export class CloudPoint {
  69736. /**
  69737. * particle global index
  69738. */
  69739. idx: number;
  69740. /**
  69741. * The color of the particle
  69742. */
  69743. color: Nullable<Color4>;
  69744. /**
  69745. * The world space position of the particle.
  69746. */
  69747. position: Vector3;
  69748. /**
  69749. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69750. */
  69751. rotation: Vector3;
  69752. /**
  69753. * The world space rotation quaternion of the particle.
  69754. */
  69755. rotationQuaternion: Nullable<Quaternion>;
  69756. /**
  69757. * The uv of the particle.
  69758. */
  69759. uv: Nullable<Vector2>;
  69760. /**
  69761. * The current speed of the particle.
  69762. */
  69763. velocity: Vector3;
  69764. /**
  69765. * The pivot point in the particle local space.
  69766. */
  69767. pivot: Vector3;
  69768. /**
  69769. * Must the particle be translated from its pivot point in its local space ?
  69770. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69771. * Default : false
  69772. */
  69773. translateFromPivot: boolean;
  69774. /**
  69775. * Index of this particle in the global "positions" array (Internal use)
  69776. * @hidden
  69777. */
  69778. _pos: number;
  69779. /**
  69780. * @hidden Index of this particle in the global "indices" array (Internal use)
  69781. */
  69782. _ind: number;
  69783. /**
  69784. * Group this particle belongs to
  69785. */
  69786. _group: PointsGroup;
  69787. /**
  69788. * Group id of this particle
  69789. */
  69790. groupId: number;
  69791. /**
  69792. * Index of the particle in its group id (Internal use)
  69793. */
  69794. idxInGroup: number;
  69795. /**
  69796. * @hidden Particle BoundingInfo object (Internal use)
  69797. */
  69798. _boundingInfo: BoundingInfo;
  69799. /**
  69800. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69801. */
  69802. _pcs: PointsCloudSystem;
  69803. /**
  69804. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69805. */
  69806. _stillInvisible: boolean;
  69807. /**
  69808. * @hidden Last computed particle rotation matrix
  69809. */
  69810. _rotationMatrix: number[];
  69811. /**
  69812. * Parent particle Id, if any.
  69813. * Default null.
  69814. */
  69815. parentId: Nullable<number>;
  69816. /**
  69817. * @hidden Internal global position in the PCS.
  69818. */
  69819. _globalPosition: Vector3;
  69820. /**
  69821. * Creates a Point Cloud object.
  69822. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69823. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69824. * @param group (PointsGroup) is the group the particle belongs to
  69825. * @param groupId (integer) is the group identifier in the PCS.
  69826. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69827. * @param pcs defines the PCS it is associated to
  69828. */
  69829. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69830. /**
  69831. * get point size
  69832. */
  69833. get size(): Vector3;
  69834. /**
  69835. * Set point size
  69836. */
  69837. set size(scale: Vector3);
  69838. /**
  69839. * Legacy support, changed quaternion to rotationQuaternion
  69840. */
  69841. get quaternion(): Nullable<Quaternion>;
  69842. /**
  69843. * Legacy support, changed quaternion to rotationQuaternion
  69844. */
  69845. set quaternion(q: Nullable<Quaternion>);
  69846. /**
  69847. * Returns a boolean. True if the particle intersects a mesh, else false
  69848. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69849. * @param target is the object (point or mesh) what the intersection is computed against
  69850. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69851. * @returns true if it intersects
  69852. */
  69853. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69854. /**
  69855. * get the rotation matrix of the particle
  69856. * @hidden
  69857. */
  69858. getRotationMatrix(m: Matrix): void;
  69859. }
  69860. /**
  69861. * Represents a group of points in a points cloud system
  69862. * * PCS internal tool, don't use it manually.
  69863. */
  69864. export class PointsGroup {
  69865. /**
  69866. * The group id
  69867. * @hidden
  69868. */
  69869. groupID: number;
  69870. /**
  69871. * image data for group (internal use)
  69872. * @hidden
  69873. */
  69874. _groupImageData: Nullable<ArrayBufferView>;
  69875. /**
  69876. * Image Width (internal use)
  69877. * @hidden
  69878. */
  69879. _groupImgWidth: number;
  69880. /**
  69881. * Image Height (internal use)
  69882. * @hidden
  69883. */
  69884. _groupImgHeight: number;
  69885. /**
  69886. * Custom position function (internal use)
  69887. * @hidden
  69888. */
  69889. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69890. /**
  69891. * density per facet for surface points
  69892. * @hidden
  69893. */
  69894. _groupDensity: number[];
  69895. /**
  69896. * Only when points are colored by texture carries pointer to texture list array
  69897. * @hidden
  69898. */
  69899. _textureNb: number;
  69900. /**
  69901. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69902. * PCS internal tool, don't use it manually.
  69903. * @hidden
  69904. */
  69905. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69906. }
  69907. }
  69908. declare module "babylonjs/Particles/index" {
  69909. export * from "babylonjs/Particles/baseParticleSystem";
  69910. export * from "babylonjs/Particles/EmitterTypes/index";
  69911. export * from "babylonjs/Particles/gpuParticleSystem";
  69912. export * from "babylonjs/Particles/IParticleSystem";
  69913. export * from "babylonjs/Particles/particle";
  69914. export * from "babylonjs/Particles/particleHelper";
  69915. export * from "babylonjs/Particles/particleSystem";
  69916. export * from "babylonjs/Particles/particleSystemComponent";
  69917. export * from "babylonjs/Particles/particleSystemSet";
  69918. export * from "babylonjs/Particles/solidParticle";
  69919. export * from "babylonjs/Particles/solidParticleSystem";
  69920. export * from "babylonjs/Particles/cloudPoint";
  69921. export * from "babylonjs/Particles/pointsCloudSystem";
  69922. export * from "babylonjs/Particles/subEmitter";
  69923. }
  69924. declare module "babylonjs/Physics/physicsEngineComponent" {
  69925. import { Nullable } from "babylonjs/types";
  69926. import { Observable, Observer } from "babylonjs/Misc/observable";
  69927. import { Vector3 } from "babylonjs/Maths/math.vector";
  69928. import { Mesh } from "babylonjs/Meshes/mesh";
  69929. import { ISceneComponent } from "babylonjs/sceneComponent";
  69930. import { Scene } from "babylonjs/scene";
  69931. import { Node } from "babylonjs/node";
  69932. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  69933. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  69934. module "babylonjs/scene" {
  69935. interface Scene {
  69936. /** @hidden (Backing field) */
  69937. _physicsEngine: Nullable<IPhysicsEngine>;
  69938. /** @hidden */
  69939. _physicsTimeAccumulator: number;
  69940. /**
  69941. * Gets the current physics engine
  69942. * @returns a IPhysicsEngine or null if none attached
  69943. */
  69944. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69945. /**
  69946. * Enables physics to the current scene
  69947. * @param gravity defines the scene's gravity for the physics engine
  69948. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69949. * @return a boolean indicating if the physics engine was initialized
  69950. */
  69951. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69952. /**
  69953. * Disables and disposes the physics engine associated with the scene
  69954. */
  69955. disablePhysicsEngine(): void;
  69956. /**
  69957. * Gets a boolean indicating if there is an active physics engine
  69958. * @returns a boolean indicating if there is an active physics engine
  69959. */
  69960. isPhysicsEnabled(): boolean;
  69961. /**
  69962. * Deletes a physics compound impostor
  69963. * @param compound defines the compound to delete
  69964. */
  69965. deleteCompoundImpostor(compound: any): void;
  69966. /**
  69967. * An event triggered when physic simulation is about to be run
  69968. */
  69969. onBeforePhysicsObservable: Observable<Scene>;
  69970. /**
  69971. * An event triggered when physic simulation has been done
  69972. */
  69973. onAfterPhysicsObservable: Observable<Scene>;
  69974. }
  69975. }
  69976. module "babylonjs/Meshes/abstractMesh" {
  69977. interface AbstractMesh {
  69978. /** @hidden */
  69979. _physicsImpostor: Nullable<PhysicsImpostor>;
  69980. /**
  69981. * Gets or sets impostor used for physic simulation
  69982. * @see http://doc.babylonjs.com/features/physics_engine
  69983. */
  69984. physicsImpostor: Nullable<PhysicsImpostor>;
  69985. /**
  69986. * Gets the current physics impostor
  69987. * @see http://doc.babylonjs.com/features/physics_engine
  69988. * @returns a physics impostor or null
  69989. */
  69990. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69991. /** Apply a physic impulse to the mesh
  69992. * @param force defines the force to apply
  69993. * @param contactPoint defines where to apply the force
  69994. * @returns the current mesh
  69995. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  69996. */
  69997. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69998. /**
  69999. * Creates a physic joint between two meshes
  70000. * @param otherMesh defines the other mesh to use
  70001. * @param pivot1 defines the pivot to use on this mesh
  70002. * @param pivot2 defines the pivot to use on the other mesh
  70003. * @param options defines additional options (can be plugin dependent)
  70004. * @returns the current mesh
  70005. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70006. */
  70007. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70008. /** @hidden */
  70009. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70010. }
  70011. }
  70012. /**
  70013. * Defines the physics engine scene component responsible to manage a physics engine
  70014. */
  70015. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70016. /**
  70017. * The component name helpful to identify the component in the list of scene components.
  70018. */
  70019. readonly name: string;
  70020. /**
  70021. * The scene the component belongs to.
  70022. */
  70023. scene: Scene;
  70024. /**
  70025. * Creates a new instance of the component for the given scene
  70026. * @param scene Defines the scene to register the component in
  70027. */
  70028. constructor(scene: Scene);
  70029. /**
  70030. * Registers the component in a given scene
  70031. */
  70032. register(): void;
  70033. /**
  70034. * Rebuilds the elements related to this component in case of
  70035. * context lost for instance.
  70036. */
  70037. rebuild(): void;
  70038. /**
  70039. * Disposes the component and the associated ressources
  70040. */
  70041. dispose(): void;
  70042. }
  70043. }
  70044. declare module "babylonjs/Physics/physicsHelper" {
  70045. import { Nullable } from "babylonjs/types";
  70046. import { Vector3 } from "babylonjs/Maths/math.vector";
  70047. import { Mesh } from "babylonjs/Meshes/mesh";
  70048. import { Scene } from "babylonjs/scene";
  70049. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70050. /**
  70051. * A helper for physics simulations
  70052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70053. */
  70054. export class PhysicsHelper {
  70055. private _scene;
  70056. private _physicsEngine;
  70057. /**
  70058. * Initializes the Physics helper
  70059. * @param scene Babylon.js scene
  70060. */
  70061. constructor(scene: Scene);
  70062. /**
  70063. * Applies a radial explosion impulse
  70064. * @param origin the origin of the explosion
  70065. * @param radiusOrEventOptions the radius or the options of radial explosion
  70066. * @param strength the explosion strength
  70067. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70068. * @returns A physics radial explosion event, or null
  70069. */
  70070. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70071. /**
  70072. * Applies a radial explosion force
  70073. * @param origin the origin of the explosion
  70074. * @param radiusOrEventOptions the radius or the options of radial explosion
  70075. * @param strength the explosion strength
  70076. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70077. * @returns A physics radial explosion event, or null
  70078. */
  70079. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70080. /**
  70081. * Creates a gravitational field
  70082. * @param origin the origin of the explosion
  70083. * @param radiusOrEventOptions the radius or the options of radial explosion
  70084. * @param strength the explosion strength
  70085. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70086. * @returns A physics gravitational field event, or null
  70087. */
  70088. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70089. /**
  70090. * Creates a physics updraft event
  70091. * @param origin the origin of the updraft
  70092. * @param radiusOrEventOptions the radius or the options of the updraft
  70093. * @param strength the strength of the updraft
  70094. * @param height the height of the updraft
  70095. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70096. * @returns A physics updraft event, or null
  70097. */
  70098. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70099. /**
  70100. * Creates a physics vortex event
  70101. * @param origin the of the vortex
  70102. * @param radiusOrEventOptions the radius or the options of the vortex
  70103. * @param strength the strength of the vortex
  70104. * @param height the height of the vortex
  70105. * @returns a Physics vortex event, or null
  70106. * A physics vortex event or null
  70107. */
  70108. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70109. }
  70110. /**
  70111. * Represents a physics radial explosion event
  70112. */
  70113. class PhysicsRadialExplosionEvent {
  70114. private _scene;
  70115. private _options;
  70116. private _sphere;
  70117. private _dataFetched;
  70118. /**
  70119. * Initializes a radial explosioin event
  70120. * @param _scene BabylonJS scene
  70121. * @param _options The options for the vortex event
  70122. */
  70123. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70124. /**
  70125. * Returns the data related to the radial explosion event (sphere).
  70126. * @returns The radial explosion event data
  70127. */
  70128. getData(): PhysicsRadialExplosionEventData;
  70129. /**
  70130. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70131. * @param impostor A physics imposter
  70132. * @param origin the origin of the explosion
  70133. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70134. */
  70135. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70136. /**
  70137. * Triggers affecterd impostors callbacks
  70138. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70139. */
  70140. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70141. /**
  70142. * Disposes the sphere.
  70143. * @param force Specifies if the sphere should be disposed by force
  70144. */
  70145. dispose(force?: boolean): void;
  70146. /*** Helpers ***/
  70147. private _prepareSphere;
  70148. private _intersectsWithSphere;
  70149. }
  70150. /**
  70151. * Represents a gravitational field event
  70152. */
  70153. class PhysicsGravitationalFieldEvent {
  70154. private _physicsHelper;
  70155. private _scene;
  70156. private _origin;
  70157. private _options;
  70158. private _tickCallback;
  70159. private _sphere;
  70160. private _dataFetched;
  70161. /**
  70162. * Initializes the physics gravitational field event
  70163. * @param _physicsHelper A physics helper
  70164. * @param _scene BabylonJS scene
  70165. * @param _origin The origin position of the gravitational field event
  70166. * @param _options The options for the vortex event
  70167. */
  70168. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70169. /**
  70170. * Returns the data related to the gravitational field event (sphere).
  70171. * @returns A gravitational field event
  70172. */
  70173. getData(): PhysicsGravitationalFieldEventData;
  70174. /**
  70175. * Enables the gravitational field.
  70176. */
  70177. enable(): void;
  70178. /**
  70179. * Disables the gravitational field.
  70180. */
  70181. disable(): void;
  70182. /**
  70183. * Disposes the sphere.
  70184. * @param force The force to dispose from the gravitational field event
  70185. */
  70186. dispose(force?: boolean): void;
  70187. private _tick;
  70188. }
  70189. /**
  70190. * Represents a physics updraft event
  70191. */
  70192. class PhysicsUpdraftEvent {
  70193. private _scene;
  70194. private _origin;
  70195. private _options;
  70196. private _physicsEngine;
  70197. private _originTop;
  70198. private _originDirection;
  70199. private _tickCallback;
  70200. private _cylinder;
  70201. private _cylinderPosition;
  70202. private _dataFetched;
  70203. /**
  70204. * Initializes the physics updraft event
  70205. * @param _scene BabylonJS scene
  70206. * @param _origin The origin position of the updraft
  70207. * @param _options The options for the updraft event
  70208. */
  70209. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70210. /**
  70211. * Returns the data related to the updraft event (cylinder).
  70212. * @returns A physics updraft event
  70213. */
  70214. getData(): PhysicsUpdraftEventData;
  70215. /**
  70216. * Enables the updraft.
  70217. */
  70218. enable(): void;
  70219. /**
  70220. * Disables the updraft.
  70221. */
  70222. disable(): void;
  70223. /**
  70224. * Disposes the cylinder.
  70225. * @param force Specifies if the updraft should be disposed by force
  70226. */
  70227. dispose(force?: boolean): void;
  70228. private getImpostorHitData;
  70229. private _tick;
  70230. /*** Helpers ***/
  70231. private _prepareCylinder;
  70232. private _intersectsWithCylinder;
  70233. }
  70234. /**
  70235. * Represents a physics vortex event
  70236. */
  70237. class PhysicsVortexEvent {
  70238. private _scene;
  70239. private _origin;
  70240. private _options;
  70241. private _physicsEngine;
  70242. private _originTop;
  70243. private _tickCallback;
  70244. private _cylinder;
  70245. private _cylinderPosition;
  70246. private _dataFetched;
  70247. /**
  70248. * Initializes the physics vortex event
  70249. * @param _scene The BabylonJS scene
  70250. * @param _origin The origin position of the vortex
  70251. * @param _options The options for the vortex event
  70252. */
  70253. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70254. /**
  70255. * Returns the data related to the vortex event (cylinder).
  70256. * @returns The physics vortex event data
  70257. */
  70258. getData(): PhysicsVortexEventData;
  70259. /**
  70260. * Enables the vortex.
  70261. */
  70262. enable(): void;
  70263. /**
  70264. * Disables the cortex.
  70265. */
  70266. disable(): void;
  70267. /**
  70268. * Disposes the sphere.
  70269. * @param force
  70270. */
  70271. dispose(force?: boolean): void;
  70272. private getImpostorHitData;
  70273. private _tick;
  70274. /*** Helpers ***/
  70275. private _prepareCylinder;
  70276. private _intersectsWithCylinder;
  70277. }
  70278. /**
  70279. * Options fot the radial explosion event
  70280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70281. */
  70282. export class PhysicsRadialExplosionEventOptions {
  70283. /**
  70284. * The radius of the sphere for the radial explosion.
  70285. */
  70286. radius: number;
  70287. /**
  70288. * The strenth of the explosion.
  70289. */
  70290. strength: number;
  70291. /**
  70292. * The strenght of the force in correspondence to the distance of the affected object
  70293. */
  70294. falloff: PhysicsRadialImpulseFalloff;
  70295. /**
  70296. * Sphere options for the radial explosion.
  70297. */
  70298. sphere: {
  70299. segments: number;
  70300. diameter: number;
  70301. };
  70302. /**
  70303. * Sphere options for the radial explosion.
  70304. */
  70305. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70306. }
  70307. /**
  70308. * Options fot the updraft event
  70309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70310. */
  70311. export class PhysicsUpdraftEventOptions {
  70312. /**
  70313. * The radius of the cylinder for the vortex
  70314. */
  70315. radius: number;
  70316. /**
  70317. * The strenth of the updraft.
  70318. */
  70319. strength: number;
  70320. /**
  70321. * The height of the cylinder for the updraft.
  70322. */
  70323. height: number;
  70324. /**
  70325. * The mode for the the updraft.
  70326. */
  70327. updraftMode: PhysicsUpdraftMode;
  70328. }
  70329. /**
  70330. * Options fot the vortex event
  70331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70332. */
  70333. export class PhysicsVortexEventOptions {
  70334. /**
  70335. * The radius of the cylinder for the vortex
  70336. */
  70337. radius: number;
  70338. /**
  70339. * The strenth of the vortex.
  70340. */
  70341. strength: number;
  70342. /**
  70343. * The height of the cylinder for the vortex.
  70344. */
  70345. height: number;
  70346. /**
  70347. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70348. */
  70349. centripetalForceThreshold: number;
  70350. /**
  70351. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70352. */
  70353. centripetalForceMultiplier: number;
  70354. /**
  70355. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70356. */
  70357. centrifugalForceMultiplier: number;
  70358. /**
  70359. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70360. */
  70361. updraftForceMultiplier: number;
  70362. }
  70363. /**
  70364. * The strenght of the force in correspondence to the distance of the affected object
  70365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70366. */
  70367. export enum PhysicsRadialImpulseFalloff {
  70368. /** Defines that impulse is constant in strength across it's whole radius */
  70369. Constant = 0,
  70370. /** Defines that impulse gets weaker if it's further from the origin */
  70371. Linear = 1
  70372. }
  70373. /**
  70374. * The strength of the force in correspondence to the distance of the affected object
  70375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70376. */
  70377. export enum PhysicsUpdraftMode {
  70378. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70379. Center = 0,
  70380. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70381. Perpendicular = 1
  70382. }
  70383. /**
  70384. * Interface for a physics hit data
  70385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70386. */
  70387. export interface PhysicsHitData {
  70388. /**
  70389. * The force applied at the contact point
  70390. */
  70391. force: Vector3;
  70392. /**
  70393. * The contact point
  70394. */
  70395. contactPoint: Vector3;
  70396. /**
  70397. * The distance from the origin to the contact point
  70398. */
  70399. distanceFromOrigin: number;
  70400. }
  70401. /**
  70402. * Interface for radial explosion event data
  70403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70404. */
  70405. export interface PhysicsRadialExplosionEventData {
  70406. /**
  70407. * A sphere used for the radial explosion event
  70408. */
  70409. sphere: Mesh;
  70410. }
  70411. /**
  70412. * Interface for gravitational field event data
  70413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70414. */
  70415. export interface PhysicsGravitationalFieldEventData {
  70416. /**
  70417. * A sphere mesh used for the gravitational field event
  70418. */
  70419. sphere: Mesh;
  70420. }
  70421. /**
  70422. * Interface for updraft event data
  70423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70424. */
  70425. export interface PhysicsUpdraftEventData {
  70426. /**
  70427. * A cylinder used for the updraft event
  70428. */
  70429. cylinder: Mesh;
  70430. }
  70431. /**
  70432. * Interface for vortex event data
  70433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70434. */
  70435. export interface PhysicsVortexEventData {
  70436. /**
  70437. * A cylinder used for the vortex event
  70438. */
  70439. cylinder: Mesh;
  70440. }
  70441. /**
  70442. * Interface for an affected physics impostor
  70443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70444. */
  70445. export interface PhysicsAffectedImpostorWithData {
  70446. /**
  70447. * The impostor affected by the effect
  70448. */
  70449. impostor: PhysicsImpostor;
  70450. /**
  70451. * The data about the hit/horce from the explosion
  70452. */
  70453. hitData: PhysicsHitData;
  70454. }
  70455. }
  70456. declare module "babylonjs/Physics/Plugins/index" {
  70457. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  70458. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  70459. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  70460. }
  70461. declare module "babylonjs/Physics/index" {
  70462. export * from "babylonjs/Physics/IPhysicsEngine";
  70463. export * from "babylonjs/Physics/physicsEngine";
  70464. export * from "babylonjs/Physics/physicsEngineComponent";
  70465. export * from "babylonjs/Physics/physicsHelper";
  70466. export * from "babylonjs/Physics/physicsImpostor";
  70467. export * from "babylonjs/Physics/physicsJoint";
  70468. export * from "babylonjs/Physics/Plugins/index";
  70469. }
  70470. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  70471. /** @hidden */
  70472. export var blackAndWhitePixelShader: {
  70473. name: string;
  70474. shader: string;
  70475. };
  70476. }
  70477. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  70478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70479. import { Camera } from "babylonjs/Cameras/camera";
  70480. import { Engine } from "babylonjs/Engines/engine";
  70481. import "babylonjs/Shaders/blackAndWhite.fragment";
  70482. /**
  70483. * Post process used to render in black and white
  70484. */
  70485. export class BlackAndWhitePostProcess extends PostProcess {
  70486. /**
  70487. * Linear about to convert he result to black and white (default: 1)
  70488. */
  70489. degree: number;
  70490. /**
  70491. * Creates a black and white post process
  70492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70493. * @param name The name of the effect.
  70494. * @param options The required width/height ratio to downsize to before computing the render pass.
  70495. * @param camera The camera to apply the render pass to.
  70496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70497. * @param engine The engine which the post process will be applied. (default: current engine)
  70498. * @param reusable If the post process can be reused on the same frame. (default: false)
  70499. */
  70500. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70501. }
  70502. }
  70503. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  70504. import { Nullable } from "babylonjs/types";
  70505. import { Camera } from "babylonjs/Cameras/camera";
  70506. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70507. import { Engine } from "babylonjs/Engines/engine";
  70508. /**
  70509. * This represents a set of one or more post processes in Babylon.
  70510. * A post process can be used to apply a shader to a texture after it is rendered.
  70511. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70512. */
  70513. export class PostProcessRenderEffect {
  70514. private _postProcesses;
  70515. private _getPostProcesses;
  70516. private _singleInstance;
  70517. private _cameras;
  70518. private _indicesForCamera;
  70519. /**
  70520. * Name of the effect
  70521. * @hidden
  70522. */
  70523. _name: string;
  70524. /**
  70525. * Instantiates a post process render effect.
  70526. * A post process can be used to apply a shader to a texture after it is rendered.
  70527. * @param engine The engine the effect is tied to
  70528. * @param name The name of the effect
  70529. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70530. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70531. */
  70532. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70533. /**
  70534. * Checks if all the post processes in the effect are supported.
  70535. */
  70536. get isSupported(): boolean;
  70537. /**
  70538. * Updates the current state of the effect
  70539. * @hidden
  70540. */
  70541. _update(): void;
  70542. /**
  70543. * Attaches the effect on cameras
  70544. * @param cameras The camera to attach to.
  70545. * @hidden
  70546. */
  70547. _attachCameras(cameras: Camera): void;
  70548. /**
  70549. * Attaches the effect on cameras
  70550. * @param cameras The camera to attach to.
  70551. * @hidden
  70552. */
  70553. _attachCameras(cameras: Camera[]): void;
  70554. /**
  70555. * Detaches the effect on cameras
  70556. * @param cameras The camera to detatch from.
  70557. * @hidden
  70558. */
  70559. _detachCameras(cameras: Camera): void;
  70560. /**
  70561. * Detatches the effect on cameras
  70562. * @param cameras The camera to detatch from.
  70563. * @hidden
  70564. */
  70565. _detachCameras(cameras: Camera[]): void;
  70566. /**
  70567. * Enables the effect on given cameras
  70568. * @param cameras The camera to enable.
  70569. * @hidden
  70570. */
  70571. _enable(cameras: Camera): void;
  70572. /**
  70573. * Enables the effect on given cameras
  70574. * @param cameras The camera to enable.
  70575. * @hidden
  70576. */
  70577. _enable(cameras: Nullable<Camera[]>): void;
  70578. /**
  70579. * Disables the effect on the given cameras
  70580. * @param cameras The camera to disable.
  70581. * @hidden
  70582. */
  70583. _disable(cameras: Camera): void;
  70584. /**
  70585. * Disables the effect on the given cameras
  70586. * @param cameras The camera to disable.
  70587. * @hidden
  70588. */
  70589. _disable(cameras: Nullable<Camera[]>): void;
  70590. /**
  70591. * Gets a list of the post processes contained in the effect.
  70592. * @param camera The camera to get the post processes on.
  70593. * @returns The list of the post processes in the effect.
  70594. */
  70595. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70596. }
  70597. }
  70598. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  70599. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70600. /** @hidden */
  70601. export var extractHighlightsPixelShader: {
  70602. name: string;
  70603. shader: string;
  70604. };
  70605. }
  70606. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  70607. import { Nullable } from "babylonjs/types";
  70608. import { Camera } from "babylonjs/Cameras/camera";
  70609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70610. import { Engine } from "babylonjs/Engines/engine";
  70611. import "babylonjs/Shaders/extractHighlights.fragment";
  70612. /**
  70613. * 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.
  70614. */
  70615. export class ExtractHighlightsPostProcess extends PostProcess {
  70616. /**
  70617. * The luminance threshold, pixels below this value will be set to black.
  70618. */
  70619. threshold: number;
  70620. /** @hidden */
  70621. _exposure: number;
  70622. /**
  70623. * Post process which has the input texture to be used when performing highlight extraction
  70624. * @hidden
  70625. */
  70626. _inputPostProcess: Nullable<PostProcess>;
  70627. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70628. }
  70629. }
  70630. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  70631. /** @hidden */
  70632. export var bloomMergePixelShader: {
  70633. name: string;
  70634. shader: string;
  70635. };
  70636. }
  70637. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  70638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70639. import { Nullable } from "babylonjs/types";
  70640. import { Engine } from "babylonjs/Engines/engine";
  70641. import { Camera } from "babylonjs/Cameras/camera";
  70642. import "babylonjs/Shaders/bloomMerge.fragment";
  70643. /**
  70644. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70645. */
  70646. export class BloomMergePostProcess extends PostProcess {
  70647. /** Weight of the bloom to be added to the original input. */
  70648. weight: number;
  70649. /**
  70650. * Creates a new instance of @see BloomMergePostProcess
  70651. * @param name The name of the effect.
  70652. * @param originalFromInput Post process which's input will be used for the merge.
  70653. * @param blurred Blurred highlights post process which's output will be used.
  70654. * @param weight Weight of the bloom to be added to the original input.
  70655. * @param options The required width/height ratio to downsize to before computing the render pass.
  70656. * @param camera The camera to apply the render pass to.
  70657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70658. * @param engine The engine which the post process will be applied. (default: current engine)
  70659. * @param reusable If the post process can be reused on the same frame. (default: false)
  70660. * @param textureType Type of textures used when performing the post process. (default: 0)
  70661. * @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)
  70662. */
  70663. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70664. /** Weight of the bloom to be added to the original input. */
  70665. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70666. }
  70667. }
  70668. declare module "babylonjs/PostProcesses/bloomEffect" {
  70669. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70670. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70671. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70672. import { Camera } from "babylonjs/Cameras/camera";
  70673. import { Scene } from "babylonjs/scene";
  70674. /**
  70675. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70676. */
  70677. export class BloomEffect extends PostProcessRenderEffect {
  70678. private bloomScale;
  70679. /**
  70680. * @hidden Internal
  70681. */
  70682. _effects: Array<PostProcess>;
  70683. /**
  70684. * @hidden Internal
  70685. */
  70686. _downscale: ExtractHighlightsPostProcess;
  70687. private _blurX;
  70688. private _blurY;
  70689. private _merge;
  70690. /**
  70691. * The luminance threshold to find bright areas of the image to bloom.
  70692. */
  70693. get threshold(): number;
  70694. set threshold(value: number);
  70695. /**
  70696. * The strength of the bloom.
  70697. */
  70698. get weight(): number;
  70699. set weight(value: number);
  70700. /**
  70701. * Specifies the size of the bloom blur kernel, relative to the final output size
  70702. */
  70703. get kernel(): number;
  70704. set kernel(value: number);
  70705. /**
  70706. * Creates a new instance of @see BloomEffect
  70707. * @param scene The scene the effect belongs to.
  70708. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70709. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70710. * @param bloomWeight The the strength of bloom.
  70711. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70712. * @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)
  70713. */
  70714. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70715. /**
  70716. * Disposes each of the internal effects for a given camera.
  70717. * @param camera The camera to dispose the effect on.
  70718. */
  70719. disposeEffects(camera: Camera): void;
  70720. /**
  70721. * @hidden Internal
  70722. */
  70723. _updateEffects(): void;
  70724. /**
  70725. * Internal
  70726. * @returns if all the contained post processes are ready.
  70727. * @hidden
  70728. */
  70729. _isReady(): boolean;
  70730. }
  70731. }
  70732. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  70733. /** @hidden */
  70734. export var chromaticAberrationPixelShader: {
  70735. name: string;
  70736. shader: string;
  70737. };
  70738. }
  70739. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  70740. import { Vector2 } from "babylonjs/Maths/math.vector";
  70741. import { Nullable } from "babylonjs/types";
  70742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70743. import { Camera } from "babylonjs/Cameras/camera";
  70744. import { Engine } from "babylonjs/Engines/engine";
  70745. import "babylonjs/Shaders/chromaticAberration.fragment";
  70746. /**
  70747. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70748. */
  70749. export class ChromaticAberrationPostProcess extends PostProcess {
  70750. /**
  70751. * The amount of seperation of rgb channels (default: 30)
  70752. */
  70753. aberrationAmount: number;
  70754. /**
  70755. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70756. */
  70757. radialIntensity: number;
  70758. /**
  70759. * 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))
  70760. */
  70761. direction: Vector2;
  70762. /**
  70763. * 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))
  70764. */
  70765. centerPosition: Vector2;
  70766. /**
  70767. * Creates a new instance ChromaticAberrationPostProcess
  70768. * @param name The name of the effect.
  70769. * @param screenWidth The width of the screen to apply the effect on.
  70770. * @param screenHeight The height of the screen to apply the effect on.
  70771. * @param options The required width/height ratio to downsize to before computing the render pass.
  70772. * @param camera The camera to apply the render pass to.
  70773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70774. * @param engine The engine which the post process will be applied. (default: current engine)
  70775. * @param reusable If the post process can be reused on the same frame. (default: false)
  70776. * @param textureType Type of textures used when performing the post process. (default: 0)
  70777. * @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)
  70778. */
  70779. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70780. }
  70781. }
  70782. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  70783. /** @hidden */
  70784. export var circleOfConfusionPixelShader: {
  70785. name: string;
  70786. shader: string;
  70787. };
  70788. }
  70789. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  70790. import { Nullable } from "babylonjs/types";
  70791. import { Engine } from "babylonjs/Engines/engine";
  70792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70793. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70794. import { Camera } from "babylonjs/Cameras/camera";
  70795. import "babylonjs/Shaders/circleOfConfusion.fragment";
  70796. /**
  70797. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70798. */
  70799. export class CircleOfConfusionPostProcess extends PostProcess {
  70800. /**
  70801. * 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.
  70802. */
  70803. lensSize: number;
  70804. /**
  70805. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70806. */
  70807. fStop: number;
  70808. /**
  70809. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70810. */
  70811. focusDistance: number;
  70812. /**
  70813. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70814. */
  70815. focalLength: number;
  70816. private _depthTexture;
  70817. /**
  70818. * Creates a new instance CircleOfConfusionPostProcess
  70819. * @param name The name of the effect.
  70820. * @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.
  70821. * @param options The required width/height ratio to downsize to before computing the render pass.
  70822. * @param camera The camera to apply the render pass to.
  70823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70824. * @param engine The engine which the post process will be applied. (default: current engine)
  70825. * @param reusable If the post process can be reused on the same frame. (default: false)
  70826. * @param textureType Type of textures used when performing the post process. (default: 0)
  70827. * @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)
  70828. */
  70829. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70830. /**
  70831. * 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.
  70832. */
  70833. set depthTexture(value: RenderTargetTexture);
  70834. }
  70835. }
  70836. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  70837. /** @hidden */
  70838. export var colorCorrectionPixelShader: {
  70839. name: string;
  70840. shader: string;
  70841. };
  70842. }
  70843. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  70844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70845. import { Engine } from "babylonjs/Engines/engine";
  70846. import { Camera } from "babylonjs/Cameras/camera";
  70847. import "babylonjs/Shaders/colorCorrection.fragment";
  70848. /**
  70849. *
  70850. * This post-process allows the modification of rendered colors by using
  70851. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70852. *
  70853. * The object needs to be provided an url to a texture containing the color
  70854. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70855. * Use an image editing software to tweak the LUT to match your needs.
  70856. *
  70857. * For an example of a color LUT, see here:
  70858. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70859. * For explanations on color grading, see here:
  70860. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70861. *
  70862. */
  70863. export class ColorCorrectionPostProcess extends PostProcess {
  70864. private _colorTableTexture;
  70865. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70866. }
  70867. }
  70868. declare module "babylonjs/Shaders/convolution.fragment" {
  70869. /** @hidden */
  70870. export var convolutionPixelShader: {
  70871. name: string;
  70872. shader: string;
  70873. };
  70874. }
  70875. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  70876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70877. import { Nullable } from "babylonjs/types";
  70878. import { Camera } from "babylonjs/Cameras/camera";
  70879. import { Engine } from "babylonjs/Engines/engine";
  70880. import "babylonjs/Shaders/convolution.fragment";
  70881. /**
  70882. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70883. * input texture to perform effects such as edge detection or sharpening
  70884. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70885. */
  70886. export class ConvolutionPostProcess extends PostProcess {
  70887. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70888. kernel: number[];
  70889. /**
  70890. * Creates a new instance ConvolutionPostProcess
  70891. * @param name The name of the effect.
  70892. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70893. * @param options The required width/height ratio to downsize to before computing the render pass.
  70894. * @param camera The camera to apply the render pass to.
  70895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70896. * @param engine The engine which the post process will be applied. (default: current engine)
  70897. * @param reusable If the post process can be reused on the same frame. (default: false)
  70898. * @param textureType Type of textures used when performing the post process. (default: 0)
  70899. */
  70900. constructor(name: string,
  70901. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70902. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70903. /**
  70904. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70905. */
  70906. static EdgeDetect0Kernel: number[];
  70907. /**
  70908. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70909. */
  70910. static EdgeDetect1Kernel: number[];
  70911. /**
  70912. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70913. */
  70914. static EdgeDetect2Kernel: number[];
  70915. /**
  70916. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70917. */
  70918. static SharpenKernel: number[];
  70919. /**
  70920. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70921. */
  70922. static EmbossKernel: number[];
  70923. /**
  70924. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70925. */
  70926. static GaussianKernel: number[];
  70927. }
  70928. }
  70929. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  70930. import { Nullable } from "babylonjs/types";
  70931. import { Vector2 } from "babylonjs/Maths/math.vector";
  70932. import { Camera } from "babylonjs/Cameras/camera";
  70933. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70934. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70935. import { Engine } from "babylonjs/Engines/engine";
  70936. import { Scene } from "babylonjs/scene";
  70937. /**
  70938. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70939. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70940. * based on samples that have a large difference in distance than the center pixel.
  70941. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70942. */
  70943. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70944. direction: Vector2;
  70945. /**
  70946. * Creates a new instance CircleOfConfusionPostProcess
  70947. * @param name The name of the effect.
  70948. * @param scene The scene the effect belongs to.
  70949. * @param direction The direction the blur should be applied.
  70950. * @param kernel The size of the kernel used to blur.
  70951. * @param options The required width/height ratio to downsize to before computing the render pass.
  70952. * @param camera The camera to apply the render pass to.
  70953. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70954. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70956. * @param engine The engine which the post process will be applied. (default: current engine)
  70957. * @param reusable If the post process can be reused on the same frame. (default: false)
  70958. * @param textureType Type of textures used when performing the post process. (default: 0)
  70959. * @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)
  70960. */
  70961. 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);
  70962. }
  70963. }
  70964. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  70965. /** @hidden */
  70966. export var depthOfFieldMergePixelShader: {
  70967. name: string;
  70968. shader: string;
  70969. };
  70970. }
  70971. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  70972. import { Nullable } from "babylonjs/types";
  70973. import { Camera } from "babylonjs/Cameras/camera";
  70974. import { Effect } from "babylonjs/Materials/effect";
  70975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70976. import { Engine } from "babylonjs/Engines/engine";
  70977. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  70978. /**
  70979. * Options to be set when merging outputs from the default pipeline.
  70980. */
  70981. export class DepthOfFieldMergePostProcessOptions {
  70982. /**
  70983. * The original image to merge on top of
  70984. */
  70985. originalFromInput: PostProcess;
  70986. /**
  70987. * Parameters to perform the merge of the depth of field effect
  70988. */
  70989. depthOfField?: {
  70990. circleOfConfusion: PostProcess;
  70991. blurSteps: Array<PostProcess>;
  70992. };
  70993. /**
  70994. * Parameters to perform the merge of bloom effect
  70995. */
  70996. bloom?: {
  70997. blurred: PostProcess;
  70998. weight: number;
  70999. };
  71000. }
  71001. /**
  71002. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71003. */
  71004. export class DepthOfFieldMergePostProcess extends PostProcess {
  71005. private blurSteps;
  71006. /**
  71007. * Creates a new instance of DepthOfFieldMergePostProcess
  71008. * @param name The name of the effect.
  71009. * @param originalFromInput Post process which's input will be used for the merge.
  71010. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71011. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71012. * @param options The required width/height ratio to downsize to before computing the render pass.
  71013. * @param camera The camera to apply the render pass to.
  71014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71015. * @param engine The engine which the post process will be applied. (default: current engine)
  71016. * @param reusable If the post process can be reused on the same frame. (default: false)
  71017. * @param textureType Type of textures used when performing the post process. (default: 0)
  71018. * @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)
  71019. */
  71020. 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);
  71021. /**
  71022. * Updates the effect with the current post process compile time values and recompiles the shader.
  71023. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71024. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71025. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71026. * @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
  71027. * @param onCompiled Called when the shader has been compiled.
  71028. * @param onError Called if there is an error when compiling a shader.
  71029. */
  71030. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71031. }
  71032. }
  71033. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71034. import { Nullable } from "babylonjs/types";
  71035. import { Camera } from "babylonjs/Cameras/camera";
  71036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71037. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71038. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71039. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71040. import { Scene } from "babylonjs/scene";
  71041. /**
  71042. * Specifies the level of max blur that should be applied when using the depth of field effect
  71043. */
  71044. export enum DepthOfFieldEffectBlurLevel {
  71045. /**
  71046. * Subtle blur
  71047. */
  71048. Low = 0,
  71049. /**
  71050. * Medium blur
  71051. */
  71052. Medium = 1,
  71053. /**
  71054. * Large blur
  71055. */
  71056. High = 2
  71057. }
  71058. /**
  71059. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71060. */
  71061. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71062. private _circleOfConfusion;
  71063. /**
  71064. * @hidden Internal, blurs from high to low
  71065. */
  71066. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71067. private _depthOfFieldBlurY;
  71068. private _dofMerge;
  71069. /**
  71070. * @hidden Internal post processes in depth of field effect
  71071. */
  71072. _effects: Array<PostProcess>;
  71073. /**
  71074. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71075. */
  71076. set focalLength(value: number);
  71077. get focalLength(): number;
  71078. /**
  71079. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71080. */
  71081. set fStop(value: number);
  71082. get fStop(): number;
  71083. /**
  71084. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71085. */
  71086. set focusDistance(value: number);
  71087. get focusDistance(): number;
  71088. /**
  71089. * 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.
  71090. */
  71091. set lensSize(value: number);
  71092. get lensSize(): number;
  71093. /**
  71094. * Creates a new instance DepthOfFieldEffect
  71095. * @param scene The scene the effect belongs to.
  71096. * @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.
  71097. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71098. * @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)
  71099. */
  71100. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71101. /**
  71102. * Get the current class name of the current effet
  71103. * @returns "DepthOfFieldEffect"
  71104. */
  71105. getClassName(): string;
  71106. /**
  71107. * 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.
  71108. */
  71109. set depthTexture(value: RenderTargetTexture);
  71110. /**
  71111. * Disposes each of the internal effects for a given camera.
  71112. * @param camera The camera to dispose the effect on.
  71113. */
  71114. disposeEffects(camera: Camera): void;
  71115. /**
  71116. * @hidden Internal
  71117. */
  71118. _updateEffects(): void;
  71119. /**
  71120. * Internal
  71121. * @returns if all the contained post processes are ready.
  71122. * @hidden
  71123. */
  71124. _isReady(): boolean;
  71125. }
  71126. }
  71127. declare module "babylonjs/Shaders/displayPass.fragment" {
  71128. /** @hidden */
  71129. export var displayPassPixelShader: {
  71130. name: string;
  71131. shader: string;
  71132. };
  71133. }
  71134. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71135. import { Nullable } from "babylonjs/types";
  71136. import { Camera } from "babylonjs/Cameras/camera";
  71137. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71138. import { Engine } from "babylonjs/Engines/engine";
  71139. import "babylonjs/Shaders/displayPass.fragment";
  71140. /**
  71141. * DisplayPassPostProcess which produces an output the same as it's input
  71142. */
  71143. export class DisplayPassPostProcess extends PostProcess {
  71144. /**
  71145. * Creates the DisplayPassPostProcess
  71146. * @param name The name of the effect.
  71147. * @param options The required width/height ratio to downsize to before computing the render pass.
  71148. * @param camera The camera to apply the render pass to.
  71149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71150. * @param engine The engine which the post process will be applied. (default: current engine)
  71151. * @param reusable If the post process can be reused on the same frame. (default: false)
  71152. */
  71153. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71154. }
  71155. }
  71156. declare module "babylonjs/Shaders/filter.fragment" {
  71157. /** @hidden */
  71158. export var filterPixelShader: {
  71159. name: string;
  71160. shader: string;
  71161. };
  71162. }
  71163. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71164. import { Nullable } from "babylonjs/types";
  71165. import { Matrix } from "babylonjs/Maths/math.vector";
  71166. import { Camera } from "babylonjs/Cameras/camera";
  71167. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71168. import { Engine } from "babylonjs/Engines/engine";
  71169. import "babylonjs/Shaders/filter.fragment";
  71170. /**
  71171. * Applies a kernel filter to the image
  71172. */
  71173. export class FilterPostProcess extends PostProcess {
  71174. /** The matrix to be applied to the image */
  71175. kernelMatrix: Matrix;
  71176. /**
  71177. *
  71178. * @param name The name of the effect.
  71179. * @param kernelMatrix The matrix to be applied to the image
  71180. * @param options The required width/height ratio to downsize to before computing the render pass.
  71181. * @param camera The camera to apply the render pass to.
  71182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71183. * @param engine The engine which the post process will be applied. (default: current engine)
  71184. * @param reusable If the post process can be reused on the same frame. (default: false)
  71185. */
  71186. constructor(name: string,
  71187. /** The matrix to be applied to the image */
  71188. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71189. }
  71190. }
  71191. declare module "babylonjs/Shaders/fxaa.fragment" {
  71192. /** @hidden */
  71193. export var fxaaPixelShader: {
  71194. name: string;
  71195. shader: string;
  71196. };
  71197. }
  71198. declare module "babylonjs/Shaders/fxaa.vertex" {
  71199. /** @hidden */
  71200. export var fxaaVertexShader: {
  71201. name: string;
  71202. shader: string;
  71203. };
  71204. }
  71205. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71206. import { Nullable } from "babylonjs/types";
  71207. import { Camera } from "babylonjs/Cameras/camera";
  71208. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71209. import { Engine } from "babylonjs/Engines/engine";
  71210. import "babylonjs/Shaders/fxaa.fragment";
  71211. import "babylonjs/Shaders/fxaa.vertex";
  71212. /**
  71213. * Fxaa post process
  71214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71215. */
  71216. export class FxaaPostProcess extends PostProcess {
  71217. /** @hidden */
  71218. texelWidth: number;
  71219. /** @hidden */
  71220. texelHeight: number;
  71221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71222. private _getDefines;
  71223. }
  71224. }
  71225. declare module "babylonjs/Shaders/grain.fragment" {
  71226. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71227. /** @hidden */
  71228. export var grainPixelShader: {
  71229. name: string;
  71230. shader: string;
  71231. };
  71232. }
  71233. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71234. import { Nullable } from "babylonjs/types";
  71235. import { Camera } from "babylonjs/Cameras/camera";
  71236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71237. import { Engine } from "babylonjs/Engines/engine";
  71238. import "babylonjs/Shaders/grain.fragment";
  71239. /**
  71240. * The GrainPostProcess adds noise to the image at mid luminance levels
  71241. */
  71242. export class GrainPostProcess extends PostProcess {
  71243. /**
  71244. * The intensity of the grain added (default: 30)
  71245. */
  71246. intensity: number;
  71247. /**
  71248. * If the grain should be randomized on every frame
  71249. */
  71250. animated: boolean;
  71251. /**
  71252. * Creates a new instance of @see GrainPostProcess
  71253. * @param name The name of the effect.
  71254. * @param options The required width/height ratio to downsize to before computing the render pass.
  71255. * @param camera The camera to apply the render pass to.
  71256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71257. * @param engine The engine which the post process will be applied. (default: current engine)
  71258. * @param reusable If the post process can be reused on the same frame. (default: false)
  71259. * @param textureType Type of textures used when performing the post process. (default: 0)
  71260. * @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)
  71261. */
  71262. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71263. }
  71264. }
  71265. declare module "babylonjs/Shaders/highlights.fragment" {
  71266. /** @hidden */
  71267. export var highlightsPixelShader: {
  71268. name: string;
  71269. shader: string;
  71270. };
  71271. }
  71272. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71273. import { Nullable } from "babylonjs/types";
  71274. import { Camera } from "babylonjs/Cameras/camera";
  71275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71276. import { Engine } from "babylonjs/Engines/engine";
  71277. import "babylonjs/Shaders/highlights.fragment";
  71278. /**
  71279. * Extracts highlights from the image
  71280. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71281. */
  71282. export class HighlightsPostProcess extends PostProcess {
  71283. /**
  71284. * Extracts highlights from the image
  71285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71286. * @param name The name of the effect.
  71287. * @param options The required width/height ratio to downsize to before computing the render pass.
  71288. * @param camera The camera to apply the render pass to.
  71289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71290. * @param engine The engine which the post process will be applied. (default: current engine)
  71291. * @param reusable If the post process can be reused on the same frame. (default: false)
  71292. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71293. */
  71294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71295. }
  71296. }
  71297. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71298. /** @hidden */
  71299. export var mrtFragmentDeclaration: {
  71300. name: string;
  71301. shader: string;
  71302. };
  71303. }
  71304. declare module "babylonjs/Shaders/geometry.fragment" {
  71305. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71306. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71307. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71308. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71309. /** @hidden */
  71310. export var geometryPixelShader: {
  71311. name: string;
  71312. shader: string;
  71313. };
  71314. }
  71315. declare module "babylonjs/Shaders/geometry.vertex" {
  71316. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71319. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71320. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71322. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71323. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71324. /** @hidden */
  71325. export var geometryVertexShader: {
  71326. name: string;
  71327. shader: string;
  71328. };
  71329. }
  71330. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71331. import { Matrix } from "babylonjs/Maths/math.vector";
  71332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71333. import { Mesh } from "babylonjs/Meshes/mesh";
  71334. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71335. import { Effect } from "babylonjs/Materials/effect";
  71336. import { Scene } from "babylonjs/scene";
  71337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71338. import "babylonjs/Shaders/geometry.fragment";
  71339. import "babylonjs/Shaders/geometry.vertex";
  71340. /** @hidden */
  71341. interface ISavedTransformationMatrix {
  71342. world: Matrix;
  71343. viewProjection: Matrix;
  71344. }
  71345. /**
  71346. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71347. */
  71348. export class GeometryBufferRenderer {
  71349. /**
  71350. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71351. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71352. */
  71353. static readonly POSITION_TEXTURE_TYPE: number;
  71354. /**
  71355. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71356. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71357. */
  71358. static readonly VELOCITY_TEXTURE_TYPE: number;
  71359. /**
  71360. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71361. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71362. */
  71363. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71364. /**
  71365. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71366. * in order to compute objects velocities when enableVelocity is set to "true"
  71367. * @hidden
  71368. */
  71369. _previousTransformationMatrices: {
  71370. [index: number]: ISavedTransformationMatrix;
  71371. };
  71372. /**
  71373. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71374. * in order to compute objects velocities when enableVelocity is set to "true"
  71375. * @hidden
  71376. */
  71377. _previousBonesTransformationMatrices: {
  71378. [index: number]: Float32Array;
  71379. };
  71380. /**
  71381. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71382. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71383. */
  71384. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71385. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71386. renderTransparentMeshes: boolean;
  71387. private _scene;
  71388. private _multiRenderTarget;
  71389. private _ratio;
  71390. private _enablePosition;
  71391. private _enableVelocity;
  71392. private _enableReflectivity;
  71393. private _positionIndex;
  71394. private _velocityIndex;
  71395. private _reflectivityIndex;
  71396. protected _effect: Effect;
  71397. protected _cachedDefines: string;
  71398. /**
  71399. * Set the render list (meshes to be rendered) used in the G buffer.
  71400. */
  71401. set renderList(meshes: Mesh[]);
  71402. /**
  71403. * Gets wether or not G buffer are supported by the running hardware.
  71404. * This requires draw buffer supports
  71405. */
  71406. get isSupported(): boolean;
  71407. /**
  71408. * Returns the index of the given texture type in the G-Buffer textures array
  71409. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  71410. * @returns the index of the given texture type in the G-Buffer textures array
  71411. */
  71412. getTextureIndex(textureType: number): number;
  71413. /**
  71414. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  71415. */
  71416. get enablePosition(): boolean;
  71417. /**
  71418. * Sets whether or not objects positions are enabled for the G buffer.
  71419. */
  71420. set enablePosition(enable: boolean);
  71421. /**
  71422. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  71423. */
  71424. get enableVelocity(): boolean;
  71425. /**
  71426. * Sets wether or not objects velocities are enabled for the G buffer.
  71427. */
  71428. set enableVelocity(enable: boolean);
  71429. /**
  71430. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  71431. */
  71432. get enableReflectivity(): boolean;
  71433. /**
  71434. * Sets wether or not objects roughness are enabled for the G buffer.
  71435. */
  71436. set enableReflectivity(enable: boolean);
  71437. /**
  71438. * Gets the scene associated with the buffer.
  71439. */
  71440. get scene(): Scene;
  71441. /**
  71442. * Gets the ratio used by the buffer during its creation.
  71443. * How big is the buffer related to the main canvas.
  71444. */
  71445. get ratio(): number;
  71446. /** @hidden */
  71447. static _SceneComponentInitialization: (scene: Scene) => void;
  71448. /**
  71449. * Creates a new G Buffer for the scene
  71450. * @param scene The scene the buffer belongs to
  71451. * @param ratio How big is the buffer related to the main canvas.
  71452. */
  71453. constructor(scene: Scene, ratio?: number);
  71454. /**
  71455. * Checks wether everything is ready to render a submesh to the G buffer.
  71456. * @param subMesh the submesh to check readiness for
  71457. * @param useInstances is the mesh drawn using instance or not
  71458. * @returns true if ready otherwise false
  71459. */
  71460. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71461. /**
  71462. * Gets the current underlying G Buffer.
  71463. * @returns the buffer
  71464. */
  71465. getGBuffer(): MultiRenderTarget;
  71466. /**
  71467. * Gets the number of samples used to render the buffer (anti aliasing).
  71468. */
  71469. get samples(): number;
  71470. /**
  71471. * Sets the number of samples used to render the buffer (anti aliasing).
  71472. */
  71473. set samples(value: number);
  71474. /**
  71475. * Disposes the renderer and frees up associated resources.
  71476. */
  71477. dispose(): void;
  71478. protected _createRenderTargets(): void;
  71479. private _copyBonesTransformationMatrices;
  71480. }
  71481. }
  71482. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  71483. import { Nullable } from "babylonjs/types";
  71484. import { Scene } from "babylonjs/scene";
  71485. import { ISceneComponent } from "babylonjs/sceneComponent";
  71486. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  71487. module "babylonjs/scene" {
  71488. interface Scene {
  71489. /** @hidden (Backing field) */
  71490. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71491. /**
  71492. * Gets or Sets the current geometry buffer associated to the scene.
  71493. */
  71494. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71495. /**
  71496. * Enables a GeometryBufferRender and associates it with the scene
  71497. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71498. * @returns the GeometryBufferRenderer
  71499. */
  71500. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71501. /**
  71502. * Disables the GeometryBufferRender associated with the scene
  71503. */
  71504. disableGeometryBufferRenderer(): void;
  71505. }
  71506. }
  71507. /**
  71508. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71509. * in several rendering techniques.
  71510. */
  71511. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71512. /**
  71513. * The component name helpful to identify the component in the list of scene components.
  71514. */
  71515. readonly name: string;
  71516. /**
  71517. * The scene the component belongs to.
  71518. */
  71519. scene: Scene;
  71520. /**
  71521. * Creates a new instance of the component for the given scene
  71522. * @param scene Defines the scene to register the component in
  71523. */
  71524. constructor(scene: Scene);
  71525. /**
  71526. * Registers the component in a given scene
  71527. */
  71528. register(): void;
  71529. /**
  71530. * Rebuilds the elements related to this component in case of
  71531. * context lost for instance.
  71532. */
  71533. rebuild(): void;
  71534. /**
  71535. * Disposes the component and the associated ressources
  71536. */
  71537. dispose(): void;
  71538. private _gatherRenderTargets;
  71539. }
  71540. }
  71541. declare module "babylonjs/Shaders/motionBlur.fragment" {
  71542. /** @hidden */
  71543. export var motionBlurPixelShader: {
  71544. name: string;
  71545. shader: string;
  71546. };
  71547. }
  71548. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  71549. import { Nullable } from "babylonjs/types";
  71550. import { Camera } from "babylonjs/Cameras/camera";
  71551. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71552. import { Scene } from "babylonjs/scene";
  71553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71554. import "babylonjs/Animations/animatable";
  71555. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71556. import "babylonjs/Shaders/motionBlur.fragment";
  71557. import { Engine } from "babylonjs/Engines/engine";
  71558. /**
  71559. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71560. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71561. * As an example, all you have to do is to create the post-process:
  71562. * var mb = new BABYLON.MotionBlurPostProcess(
  71563. * 'mb', // The name of the effect.
  71564. * scene, // The scene containing the objects to blur according to their velocity.
  71565. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71566. * camera // The camera to apply the render pass to.
  71567. * );
  71568. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71569. */
  71570. export class MotionBlurPostProcess extends PostProcess {
  71571. /**
  71572. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71573. */
  71574. motionStrength: number;
  71575. /**
  71576. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71577. */
  71578. get motionBlurSamples(): number;
  71579. /**
  71580. * Sets the number of iterations to be used for motion blur quality
  71581. */
  71582. set motionBlurSamples(samples: number);
  71583. private _motionBlurSamples;
  71584. private _geometryBufferRenderer;
  71585. /**
  71586. * Creates a new instance MotionBlurPostProcess
  71587. * @param name The name of the effect.
  71588. * @param scene The scene containing the objects to blur according to their velocity.
  71589. * @param options The required width/height ratio to downsize to before computing the render pass.
  71590. * @param camera The camera to apply the render pass to.
  71591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71592. * @param engine The engine which the post process will be applied. (default: current engine)
  71593. * @param reusable If the post process can be reused on the same frame. (default: false)
  71594. * @param textureType Type of textures used when performing the post process. (default: 0)
  71595. * @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)
  71596. */
  71597. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71598. /**
  71599. * Excludes the given skinned mesh from computing bones velocities.
  71600. * 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.
  71601. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71602. */
  71603. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71604. /**
  71605. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71606. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71607. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71608. */
  71609. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71610. /**
  71611. * Disposes the post process.
  71612. * @param camera The camera to dispose the post process on.
  71613. */
  71614. dispose(camera?: Camera): void;
  71615. }
  71616. }
  71617. declare module "babylonjs/Shaders/refraction.fragment" {
  71618. /** @hidden */
  71619. export var refractionPixelShader: {
  71620. name: string;
  71621. shader: string;
  71622. };
  71623. }
  71624. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  71625. import { Color3 } from "babylonjs/Maths/math.color";
  71626. import { Camera } from "babylonjs/Cameras/camera";
  71627. import { Texture } from "babylonjs/Materials/Textures/texture";
  71628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71629. import { Engine } from "babylonjs/Engines/engine";
  71630. import "babylonjs/Shaders/refraction.fragment";
  71631. /**
  71632. * Post process which applies a refractin texture
  71633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71634. */
  71635. export class RefractionPostProcess extends PostProcess {
  71636. /** the base color of the refraction (used to taint the rendering) */
  71637. color: Color3;
  71638. /** simulated refraction depth */
  71639. depth: number;
  71640. /** the coefficient of the base color (0 to remove base color tainting) */
  71641. colorLevel: number;
  71642. private _refTexture;
  71643. private _ownRefractionTexture;
  71644. /**
  71645. * Gets or sets the refraction texture
  71646. * Please note that you are responsible for disposing the texture if you set it manually
  71647. */
  71648. get refractionTexture(): Texture;
  71649. set refractionTexture(value: Texture);
  71650. /**
  71651. * Initializes the RefractionPostProcess
  71652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71653. * @param name The name of the effect.
  71654. * @param refractionTextureUrl Url of the refraction texture to use
  71655. * @param color the base color of the refraction (used to taint the rendering)
  71656. * @param depth simulated refraction depth
  71657. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71658. * @param camera The camera to apply the render pass to.
  71659. * @param options The required width/height ratio to downsize to before computing the render pass.
  71660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71661. * @param engine The engine which the post process will be applied. (default: current engine)
  71662. * @param reusable If the post process can be reused on the same frame. (default: false)
  71663. */
  71664. constructor(name: string, refractionTextureUrl: string,
  71665. /** the base color of the refraction (used to taint the rendering) */
  71666. color: Color3,
  71667. /** simulated refraction depth */
  71668. depth: number,
  71669. /** the coefficient of the base color (0 to remove base color tainting) */
  71670. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71671. /**
  71672. * Disposes of the post process
  71673. * @param camera Camera to dispose post process on
  71674. */
  71675. dispose(camera: Camera): void;
  71676. }
  71677. }
  71678. declare module "babylonjs/Shaders/sharpen.fragment" {
  71679. /** @hidden */
  71680. export var sharpenPixelShader: {
  71681. name: string;
  71682. shader: string;
  71683. };
  71684. }
  71685. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  71686. import { Nullable } from "babylonjs/types";
  71687. import { Camera } from "babylonjs/Cameras/camera";
  71688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71689. import "babylonjs/Shaders/sharpen.fragment";
  71690. import { Engine } from "babylonjs/Engines/engine";
  71691. /**
  71692. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71693. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71694. */
  71695. export class SharpenPostProcess extends PostProcess {
  71696. /**
  71697. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71698. */
  71699. colorAmount: number;
  71700. /**
  71701. * How much sharpness should be applied (default: 0.3)
  71702. */
  71703. edgeAmount: number;
  71704. /**
  71705. * Creates a new instance ConvolutionPostProcess
  71706. * @param name The name of the effect.
  71707. * @param options The required width/height ratio to downsize to before computing the render pass.
  71708. * @param camera The camera to apply the render pass to.
  71709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71710. * @param engine The engine which the post process will be applied. (default: current engine)
  71711. * @param reusable If the post process can be reused on the same frame. (default: false)
  71712. * @param textureType Type of textures used when performing the post process. (default: 0)
  71713. * @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)
  71714. */
  71715. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71716. }
  71717. }
  71718. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  71719. import { Nullable } from "babylonjs/types";
  71720. import { Camera } from "babylonjs/Cameras/camera";
  71721. import { Engine } from "babylonjs/Engines/engine";
  71722. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71723. import { IInspectable } from "babylonjs/Misc/iInspectable";
  71724. /**
  71725. * PostProcessRenderPipeline
  71726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71727. */
  71728. export class PostProcessRenderPipeline {
  71729. private engine;
  71730. private _renderEffects;
  71731. private _renderEffectsForIsolatedPass;
  71732. /**
  71733. * List of inspectable custom properties (used by the Inspector)
  71734. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71735. */
  71736. inspectableCustomProperties: IInspectable[];
  71737. /**
  71738. * @hidden
  71739. */
  71740. protected _cameras: Camera[];
  71741. /** @hidden */
  71742. _name: string;
  71743. /**
  71744. * Gets pipeline name
  71745. */
  71746. get name(): string;
  71747. /** Gets the list of attached cameras */
  71748. get cameras(): Camera[];
  71749. /**
  71750. * Initializes a PostProcessRenderPipeline
  71751. * @param engine engine to add the pipeline to
  71752. * @param name name of the pipeline
  71753. */
  71754. constructor(engine: Engine, name: string);
  71755. /**
  71756. * Gets the class name
  71757. * @returns "PostProcessRenderPipeline"
  71758. */
  71759. getClassName(): string;
  71760. /**
  71761. * If all the render effects in the pipeline are supported
  71762. */
  71763. get isSupported(): boolean;
  71764. /**
  71765. * Adds an effect to the pipeline
  71766. * @param renderEffect the effect to add
  71767. */
  71768. addEffect(renderEffect: PostProcessRenderEffect): void;
  71769. /** @hidden */
  71770. _rebuild(): void;
  71771. /** @hidden */
  71772. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71773. /** @hidden */
  71774. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71775. /** @hidden */
  71776. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71777. /** @hidden */
  71778. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71779. /** @hidden */
  71780. _attachCameras(cameras: Camera, unique: boolean): void;
  71781. /** @hidden */
  71782. _attachCameras(cameras: Camera[], unique: boolean): void;
  71783. /** @hidden */
  71784. _detachCameras(cameras: Camera): void;
  71785. /** @hidden */
  71786. _detachCameras(cameras: Nullable<Camera[]>): void;
  71787. /** @hidden */
  71788. _update(): void;
  71789. /** @hidden */
  71790. _reset(): void;
  71791. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71792. /**
  71793. * Disposes of the pipeline
  71794. */
  71795. dispose(): void;
  71796. }
  71797. }
  71798. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  71799. import { Camera } from "babylonjs/Cameras/camera";
  71800. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71801. /**
  71802. * PostProcessRenderPipelineManager class
  71803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71804. */
  71805. export class PostProcessRenderPipelineManager {
  71806. private _renderPipelines;
  71807. /**
  71808. * Initializes a PostProcessRenderPipelineManager
  71809. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71810. */
  71811. constructor();
  71812. /**
  71813. * Gets the list of supported render pipelines
  71814. */
  71815. get supportedPipelines(): PostProcessRenderPipeline[];
  71816. /**
  71817. * Adds a pipeline to the manager
  71818. * @param renderPipeline The pipeline to add
  71819. */
  71820. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71821. /**
  71822. * Attaches a camera to the pipeline
  71823. * @param renderPipelineName The name of the pipeline to attach to
  71824. * @param cameras the camera to attach
  71825. * @param unique if the camera can be attached multiple times to the pipeline
  71826. */
  71827. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71828. /**
  71829. * Detaches a camera from the pipeline
  71830. * @param renderPipelineName The name of the pipeline to detach from
  71831. * @param cameras the camera to detach
  71832. */
  71833. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71834. /**
  71835. * Enables an effect by name on a pipeline
  71836. * @param renderPipelineName the name of the pipeline to enable the effect in
  71837. * @param renderEffectName the name of the effect to enable
  71838. * @param cameras the cameras that the effect should be enabled on
  71839. */
  71840. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71841. /**
  71842. * Disables an effect by name on a pipeline
  71843. * @param renderPipelineName the name of the pipeline to disable the effect in
  71844. * @param renderEffectName the name of the effect to disable
  71845. * @param cameras the cameras that the effect should be disabled on
  71846. */
  71847. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71848. /**
  71849. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71850. */
  71851. update(): void;
  71852. /** @hidden */
  71853. _rebuild(): void;
  71854. /**
  71855. * Disposes of the manager and pipelines
  71856. */
  71857. dispose(): void;
  71858. }
  71859. }
  71860. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  71861. import { ISceneComponent } from "babylonjs/sceneComponent";
  71862. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  71863. import { Scene } from "babylonjs/scene";
  71864. module "babylonjs/scene" {
  71865. interface Scene {
  71866. /** @hidden (Backing field) */
  71867. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71868. /**
  71869. * Gets the postprocess render pipeline manager
  71870. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71871. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71872. */
  71873. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71874. }
  71875. }
  71876. /**
  71877. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71878. */
  71879. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71880. /**
  71881. * The component name helpfull to identify the component in the list of scene components.
  71882. */
  71883. readonly name: string;
  71884. /**
  71885. * The scene the component belongs to.
  71886. */
  71887. scene: Scene;
  71888. /**
  71889. * Creates a new instance of the component for the given scene
  71890. * @param scene Defines the scene to register the component in
  71891. */
  71892. constructor(scene: Scene);
  71893. /**
  71894. * Registers the component in a given scene
  71895. */
  71896. register(): void;
  71897. /**
  71898. * Rebuilds the elements related to this component in case of
  71899. * context lost for instance.
  71900. */
  71901. rebuild(): void;
  71902. /**
  71903. * Disposes the component and the associated ressources
  71904. */
  71905. dispose(): void;
  71906. private _gatherRenderTargets;
  71907. }
  71908. }
  71909. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  71910. import { Nullable } from "babylonjs/types";
  71911. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71912. import { Camera } from "babylonjs/Cameras/camera";
  71913. import { IDisposable } from "babylonjs/scene";
  71914. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  71915. import { Scene } from "babylonjs/scene";
  71916. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  71917. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  71918. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  71919. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  71920. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71921. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71922. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  71923. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71924. import { Animation } from "babylonjs/Animations/animation";
  71925. /**
  71926. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71927. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71928. */
  71929. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71930. private _scene;
  71931. private _camerasToBeAttached;
  71932. /**
  71933. * ID of the sharpen post process,
  71934. */
  71935. private readonly SharpenPostProcessId;
  71936. /**
  71937. * @ignore
  71938. * ID of the image processing post process;
  71939. */
  71940. readonly ImageProcessingPostProcessId: string;
  71941. /**
  71942. * @ignore
  71943. * ID of the Fast Approximate Anti-Aliasing post process;
  71944. */
  71945. readonly FxaaPostProcessId: string;
  71946. /**
  71947. * ID of the chromatic aberration post process,
  71948. */
  71949. private readonly ChromaticAberrationPostProcessId;
  71950. /**
  71951. * ID of the grain post process
  71952. */
  71953. private readonly GrainPostProcessId;
  71954. /**
  71955. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71956. */
  71957. sharpen: SharpenPostProcess;
  71958. private _sharpenEffect;
  71959. private bloom;
  71960. /**
  71961. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71962. */
  71963. depthOfField: DepthOfFieldEffect;
  71964. /**
  71965. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71966. */
  71967. fxaa: FxaaPostProcess;
  71968. /**
  71969. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71970. */
  71971. imageProcessing: ImageProcessingPostProcess;
  71972. /**
  71973. * Chromatic aberration post process which will shift rgb colors in the image
  71974. */
  71975. chromaticAberration: ChromaticAberrationPostProcess;
  71976. private _chromaticAberrationEffect;
  71977. /**
  71978. * Grain post process which add noise to the image
  71979. */
  71980. grain: GrainPostProcess;
  71981. private _grainEffect;
  71982. /**
  71983. * Glow post process which adds a glow to emissive areas of the image
  71984. */
  71985. private _glowLayer;
  71986. /**
  71987. * Animations which can be used to tweak settings over a period of time
  71988. */
  71989. animations: Animation[];
  71990. private _imageProcessingConfigurationObserver;
  71991. private _sharpenEnabled;
  71992. private _bloomEnabled;
  71993. private _depthOfFieldEnabled;
  71994. private _depthOfFieldBlurLevel;
  71995. private _fxaaEnabled;
  71996. private _imageProcessingEnabled;
  71997. private _defaultPipelineTextureType;
  71998. private _bloomScale;
  71999. private _chromaticAberrationEnabled;
  72000. private _grainEnabled;
  72001. private _buildAllowed;
  72002. /**
  72003. * Gets active scene
  72004. */
  72005. get scene(): Scene;
  72006. /**
  72007. * Enable or disable the sharpen process from the pipeline
  72008. */
  72009. set sharpenEnabled(enabled: boolean);
  72010. get sharpenEnabled(): boolean;
  72011. private _resizeObserver;
  72012. private _hardwareScaleLevel;
  72013. private _bloomKernel;
  72014. /**
  72015. * Specifies the size of the bloom blur kernel, relative to the final output size
  72016. */
  72017. get bloomKernel(): number;
  72018. set bloomKernel(value: number);
  72019. /**
  72020. * Specifies the weight of the bloom in the final rendering
  72021. */
  72022. private _bloomWeight;
  72023. /**
  72024. * Specifies the luma threshold for the area that will be blurred by the bloom
  72025. */
  72026. private _bloomThreshold;
  72027. private _hdr;
  72028. /**
  72029. * The strength of the bloom.
  72030. */
  72031. set bloomWeight(value: number);
  72032. get bloomWeight(): number;
  72033. /**
  72034. * The strength of the bloom.
  72035. */
  72036. set bloomThreshold(value: number);
  72037. get bloomThreshold(): number;
  72038. /**
  72039. * The scale of the bloom, lower value will provide better performance.
  72040. */
  72041. set bloomScale(value: number);
  72042. get bloomScale(): number;
  72043. /**
  72044. * Enable or disable the bloom from the pipeline
  72045. */
  72046. set bloomEnabled(enabled: boolean);
  72047. get bloomEnabled(): boolean;
  72048. private _rebuildBloom;
  72049. /**
  72050. * If the depth of field is enabled.
  72051. */
  72052. get depthOfFieldEnabled(): boolean;
  72053. set depthOfFieldEnabled(enabled: boolean);
  72054. /**
  72055. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72056. */
  72057. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72058. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72059. /**
  72060. * If the anti aliasing is enabled.
  72061. */
  72062. set fxaaEnabled(enabled: boolean);
  72063. get fxaaEnabled(): boolean;
  72064. private _samples;
  72065. /**
  72066. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72067. */
  72068. set samples(sampleCount: number);
  72069. get samples(): number;
  72070. /**
  72071. * If image processing is enabled.
  72072. */
  72073. set imageProcessingEnabled(enabled: boolean);
  72074. get imageProcessingEnabled(): boolean;
  72075. /**
  72076. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72077. */
  72078. set glowLayerEnabled(enabled: boolean);
  72079. get glowLayerEnabled(): boolean;
  72080. /**
  72081. * Gets the glow layer (or null if not defined)
  72082. */
  72083. get glowLayer(): Nullable<GlowLayer>;
  72084. /**
  72085. * Enable or disable the chromaticAberration process from the pipeline
  72086. */
  72087. set chromaticAberrationEnabled(enabled: boolean);
  72088. get chromaticAberrationEnabled(): boolean;
  72089. /**
  72090. * Enable or disable the grain process from the pipeline
  72091. */
  72092. set grainEnabled(enabled: boolean);
  72093. get grainEnabled(): boolean;
  72094. /**
  72095. * @constructor
  72096. * @param name - The rendering pipeline name (default: "")
  72097. * @param hdr - If high dynamic range textures should be used (default: true)
  72098. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72099. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72100. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72101. */
  72102. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72103. /**
  72104. * Get the class name
  72105. * @returns "DefaultRenderingPipeline"
  72106. */
  72107. getClassName(): string;
  72108. /**
  72109. * Force the compilation of the entire pipeline.
  72110. */
  72111. prepare(): void;
  72112. private _hasCleared;
  72113. private _prevPostProcess;
  72114. private _prevPrevPostProcess;
  72115. private _setAutoClearAndTextureSharing;
  72116. private _depthOfFieldSceneObserver;
  72117. private _buildPipeline;
  72118. private _disposePostProcesses;
  72119. /**
  72120. * Adds a camera to the pipeline
  72121. * @param camera the camera to be added
  72122. */
  72123. addCamera(camera: Camera): void;
  72124. /**
  72125. * Removes a camera from the pipeline
  72126. * @param camera the camera to remove
  72127. */
  72128. removeCamera(camera: Camera): void;
  72129. /**
  72130. * Dispose of the pipeline and stop all post processes
  72131. */
  72132. dispose(): void;
  72133. /**
  72134. * Serialize the rendering pipeline (Used when exporting)
  72135. * @returns the serialized object
  72136. */
  72137. serialize(): any;
  72138. /**
  72139. * Parse the serialized pipeline
  72140. * @param source Source pipeline.
  72141. * @param scene The scene to load the pipeline to.
  72142. * @param rootUrl The URL of the serialized pipeline.
  72143. * @returns An instantiated pipeline from the serialized object.
  72144. */
  72145. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72146. }
  72147. }
  72148. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72149. /** @hidden */
  72150. export var lensHighlightsPixelShader: {
  72151. name: string;
  72152. shader: string;
  72153. };
  72154. }
  72155. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72156. /** @hidden */
  72157. export var depthOfFieldPixelShader: {
  72158. name: string;
  72159. shader: string;
  72160. };
  72161. }
  72162. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72163. import { Camera } from "babylonjs/Cameras/camera";
  72164. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72165. import { Scene } from "babylonjs/scene";
  72166. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72167. import "babylonjs/Shaders/chromaticAberration.fragment";
  72168. import "babylonjs/Shaders/lensHighlights.fragment";
  72169. import "babylonjs/Shaders/depthOfField.fragment";
  72170. /**
  72171. * BABYLON.JS Chromatic Aberration GLSL Shader
  72172. * Author: Olivier Guyot
  72173. * Separates very slightly R, G and B colors on the edges of the screen
  72174. * Inspired by Francois Tarlier & Martins Upitis
  72175. */
  72176. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72177. /**
  72178. * @ignore
  72179. * The chromatic aberration PostProcess id in the pipeline
  72180. */
  72181. LensChromaticAberrationEffect: string;
  72182. /**
  72183. * @ignore
  72184. * The highlights enhancing PostProcess id in the pipeline
  72185. */
  72186. HighlightsEnhancingEffect: string;
  72187. /**
  72188. * @ignore
  72189. * The depth-of-field PostProcess id in the pipeline
  72190. */
  72191. LensDepthOfFieldEffect: string;
  72192. private _scene;
  72193. private _depthTexture;
  72194. private _grainTexture;
  72195. private _chromaticAberrationPostProcess;
  72196. private _highlightsPostProcess;
  72197. private _depthOfFieldPostProcess;
  72198. private _edgeBlur;
  72199. private _grainAmount;
  72200. private _chromaticAberration;
  72201. private _distortion;
  72202. private _highlightsGain;
  72203. private _highlightsThreshold;
  72204. private _dofDistance;
  72205. private _dofAperture;
  72206. private _dofDarken;
  72207. private _dofPentagon;
  72208. private _blurNoise;
  72209. /**
  72210. * @constructor
  72211. *
  72212. * Effect parameters are as follow:
  72213. * {
  72214. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72215. * edge_blur: number; // from 0 to x (1 for realism)
  72216. * distortion: number; // from 0 to x (1 for realism)
  72217. * grain_amount: number; // from 0 to 1
  72218. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72219. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72220. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72221. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72222. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72223. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72224. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72225. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72226. * }
  72227. * Note: if an effect parameter is unset, effect is disabled
  72228. *
  72229. * @param name The rendering pipeline name
  72230. * @param parameters - An object containing all parameters (see above)
  72231. * @param scene The scene linked to this pipeline
  72232. * @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)
  72233. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72234. */
  72235. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72236. /**
  72237. * Get the class name
  72238. * @returns "LensRenderingPipeline"
  72239. */
  72240. getClassName(): string;
  72241. /**
  72242. * Gets associated scene
  72243. */
  72244. get scene(): Scene;
  72245. /**
  72246. * Gets or sets the edge blur
  72247. */
  72248. get edgeBlur(): number;
  72249. set edgeBlur(value: number);
  72250. /**
  72251. * Gets or sets the grain amount
  72252. */
  72253. get grainAmount(): number;
  72254. set grainAmount(value: number);
  72255. /**
  72256. * Gets or sets the chromatic aberration amount
  72257. */
  72258. get chromaticAberration(): number;
  72259. set chromaticAberration(value: number);
  72260. /**
  72261. * Gets or sets the depth of field aperture
  72262. */
  72263. get dofAperture(): number;
  72264. set dofAperture(value: number);
  72265. /**
  72266. * Gets or sets the edge distortion
  72267. */
  72268. get edgeDistortion(): number;
  72269. set edgeDistortion(value: number);
  72270. /**
  72271. * Gets or sets the depth of field distortion
  72272. */
  72273. get dofDistortion(): number;
  72274. set dofDistortion(value: number);
  72275. /**
  72276. * Gets or sets the darken out of focus amount
  72277. */
  72278. get darkenOutOfFocus(): number;
  72279. set darkenOutOfFocus(value: number);
  72280. /**
  72281. * Gets or sets a boolean indicating if blur noise is enabled
  72282. */
  72283. get blurNoise(): boolean;
  72284. set blurNoise(value: boolean);
  72285. /**
  72286. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72287. */
  72288. get pentagonBokeh(): boolean;
  72289. set pentagonBokeh(value: boolean);
  72290. /**
  72291. * Gets or sets the highlight grain amount
  72292. */
  72293. get highlightsGain(): number;
  72294. set highlightsGain(value: number);
  72295. /**
  72296. * Gets or sets the highlight threshold
  72297. */
  72298. get highlightsThreshold(): number;
  72299. set highlightsThreshold(value: number);
  72300. /**
  72301. * Sets the amount of blur at the edges
  72302. * @param amount blur amount
  72303. */
  72304. setEdgeBlur(amount: number): void;
  72305. /**
  72306. * Sets edge blur to 0
  72307. */
  72308. disableEdgeBlur(): void;
  72309. /**
  72310. * Sets the amout of grain
  72311. * @param amount Amount of grain
  72312. */
  72313. setGrainAmount(amount: number): void;
  72314. /**
  72315. * Set grain amount to 0
  72316. */
  72317. disableGrain(): void;
  72318. /**
  72319. * Sets the chromatic aberration amount
  72320. * @param amount amount of chromatic aberration
  72321. */
  72322. setChromaticAberration(amount: number): void;
  72323. /**
  72324. * Sets chromatic aberration amount to 0
  72325. */
  72326. disableChromaticAberration(): void;
  72327. /**
  72328. * Sets the EdgeDistortion amount
  72329. * @param amount amount of EdgeDistortion
  72330. */
  72331. setEdgeDistortion(amount: number): void;
  72332. /**
  72333. * Sets edge distortion to 0
  72334. */
  72335. disableEdgeDistortion(): void;
  72336. /**
  72337. * Sets the FocusDistance amount
  72338. * @param amount amount of FocusDistance
  72339. */
  72340. setFocusDistance(amount: number): void;
  72341. /**
  72342. * Disables depth of field
  72343. */
  72344. disableDepthOfField(): void;
  72345. /**
  72346. * Sets the Aperture amount
  72347. * @param amount amount of Aperture
  72348. */
  72349. setAperture(amount: number): void;
  72350. /**
  72351. * Sets the DarkenOutOfFocus amount
  72352. * @param amount amount of DarkenOutOfFocus
  72353. */
  72354. setDarkenOutOfFocus(amount: number): void;
  72355. private _pentagonBokehIsEnabled;
  72356. /**
  72357. * Creates a pentagon bokeh effect
  72358. */
  72359. enablePentagonBokeh(): void;
  72360. /**
  72361. * Disables the pentagon bokeh effect
  72362. */
  72363. disablePentagonBokeh(): void;
  72364. /**
  72365. * Enables noise blur
  72366. */
  72367. enableNoiseBlur(): void;
  72368. /**
  72369. * Disables noise blur
  72370. */
  72371. disableNoiseBlur(): void;
  72372. /**
  72373. * Sets the HighlightsGain amount
  72374. * @param amount amount of HighlightsGain
  72375. */
  72376. setHighlightsGain(amount: number): void;
  72377. /**
  72378. * Sets the HighlightsThreshold amount
  72379. * @param amount amount of HighlightsThreshold
  72380. */
  72381. setHighlightsThreshold(amount: number): void;
  72382. /**
  72383. * Disables highlights
  72384. */
  72385. disableHighlights(): void;
  72386. /**
  72387. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72388. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72389. */
  72390. dispose(disableDepthRender?: boolean): void;
  72391. private _createChromaticAberrationPostProcess;
  72392. private _createHighlightsPostProcess;
  72393. private _createDepthOfFieldPostProcess;
  72394. private _createGrainTexture;
  72395. }
  72396. }
  72397. declare module "babylonjs/Shaders/ssao2.fragment" {
  72398. /** @hidden */
  72399. export var ssao2PixelShader: {
  72400. name: string;
  72401. shader: string;
  72402. };
  72403. }
  72404. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  72405. /** @hidden */
  72406. export var ssaoCombinePixelShader: {
  72407. name: string;
  72408. shader: string;
  72409. };
  72410. }
  72411. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  72412. import { Camera } from "babylonjs/Cameras/camera";
  72413. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72414. import { Scene } from "babylonjs/scene";
  72415. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72416. import "babylonjs/Shaders/ssao2.fragment";
  72417. import "babylonjs/Shaders/ssaoCombine.fragment";
  72418. /**
  72419. * Render pipeline to produce ssao effect
  72420. */
  72421. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72422. /**
  72423. * @ignore
  72424. * The PassPostProcess id in the pipeline that contains the original scene color
  72425. */
  72426. SSAOOriginalSceneColorEffect: string;
  72427. /**
  72428. * @ignore
  72429. * The SSAO PostProcess id in the pipeline
  72430. */
  72431. SSAORenderEffect: string;
  72432. /**
  72433. * @ignore
  72434. * The horizontal blur PostProcess id in the pipeline
  72435. */
  72436. SSAOBlurHRenderEffect: string;
  72437. /**
  72438. * @ignore
  72439. * The vertical blur PostProcess id in the pipeline
  72440. */
  72441. SSAOBlurVRenderEffect: string;
  72442. /**
  72443. * @ignore
  72444. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72445. */
  72446. SSAOCombineRenderEffect: string;
  72447. /**
  72448. * The output strength of the SSAO post-process. Default value is 1.0.
  72449. */
  72450. totalStrength: number;
  72451. /**
  72452. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72453. */
  72454. maxZ: number;
  72455. /**
  72456. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72457. */
  72458. minZAspect: number;
  72459. private _samples;
  72460. /**
  72461. * Number of samples used for the SSAO calculations. Default value is 8
  72462. */
  72463. set samples(n: number);
  72464. get samples(): number;
  72465. private _textureSamples;
  72466. /**
  72467. * Number of samples to use for antialiasing
  72468. */
  72469. set textureSamples(n: number);
  72470. get textureSamples(): number;
  72471. /**
  72472. * Ratio object used for SSAO ratio and blur ratio
  72473. */
  72474. private _ratio;
  72475. /**
  72476. * Dynamically generated sphere sampler.
  72477. */
  72478. private _sampleSphere;
  72479. /**
  72480. * Blur filter offsets
  72481. */
  72482. private _samplerOffsets;
  72483. private _expensiveBlur;
  72484. /**
  72485. * If bilateral blur should be used
  72486. */
  72487. set expensiveBlur(b: boolean);
  72488. get expensiveBlur(): boolean;
  72489. /**
  72490. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72491. */
  72492. radius: number;
  72493. /**
  72494. * The base color of the SSAO post-process
  72495. * The final result is "base + ssao" between [0, 1]
  72496. */
  72497. base: number;
  72498. /**
  72499. * Support test.
  72500. */
  72501. static get IsSupported(): boolean;
  72502. private _scene;
  72503. private _depthTexture;
  72504. private _normalTexture;
  72505. private _randomTexture;
  72506. private _originalColorPostProcess;
  72507. private _ssaoPostProcess;
  72508. private _blurHPostProcess;
  72509. private _blurVPostProcess;
  72510. private _ssaoCombinePostProcess;
  72511. /**
  72512. * Gets active scene
  72513. */
  72514. get scene(): Scene;
  72515. /**
  72516. * @constructor
  72517. * @param name The rendering pipeline name
  72518. * @param scene The scene linked to this pipeline
  72519. * @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 }
  72520. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72521. */
  72522. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72523. /**
  72524. * Get the class name
  72525. * @returns "SSAO2RenderingPipeline"
  72526. */
  72527. getClassName(): string;
  72528. /**
  72529. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72530. */
  72531. dispose(disableGeometryBufferRenderer?: boolean): void;
  72532. private _createBlurPostProcess;
  72533. /** @hidden */
  72534. _rebuild(): void;
  72535. private _bits;
  72536. private _radicalInverse_VdC;
  72537. private _hammersley;
  72538. private _hemisphereSample_uniform;
  72539. private _generateHemisphere;
  72540. private _createSSAOPostProcess;
  72541. private _createSSAOCombinePostProcess;
  72542. private _createRandomTexture;
  72543. /**
  72544. * Serialize the rendering pipeline (Used when exporting)
  72545. * @returns the serialized object
  72546. */
  72547. serialize(): any;
  72548. /**
  72549. * Parse the serialized pipeline
  72550. * @param source Source pipeline.
  72551. * @param scene The scene to load the pipeline to.
  72552. * @param rootUrl The URL of the serialized pipeline.
  72553. * @returns An instantiated pipeline from the serialized object.
  72554. */
  72555. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72556. }
  72557. }
  72558. declare module "babylonjs/Shaders/ssao.fragment" {
  72559. /** @hidden */
  72560. export var ssaoPixelShader: {
  72561. name: string;
  72562. shader: string;
  72563. };
  72564. }
  72565. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  72566. import { Camera } from "babylonjs/Cameras/camera";
  72567. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72568. import { Scene } from "babylonjs/scene";
  72569. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72570. import "babylonjs/Shaders/ssao.fragment";
  72571. import "babylonjs/Shaders/ssaoCombine.fragment";
  72572. /**
  72573. * Render pipeline to produce ssao effect
  72574. */
  72575. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72576. /**
  72577. * @ignore
  72578. * The PassPostProcess id in the pipeline that contains the original scene color
  72579. */
  72580. SSAOOriginalSceneColorEffect: string;
  72581. /**
  72582. * @ignore
  72583. * The SSAO PostProcess id in the pipeline
  72584. */
  72585. SSAORenderEffect: string;
  72586. /**
  72587. * @ignore
  72588. * The horizontal blur PostProcess id in the pipeline
  72589. */
  72590. SSAOBlurHRenderEffect: string;
  72591. /**
  72592. * @ignore
  72593. * The vertical blur PostProcess id in the pipeline
  72594. */
  72595. SSAOBlurVRenderEffect: string;
  72596. /**
  72597. * @ignore
  72598. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72599. */
  72600. SSAOCombineRenderEffect: string;
  72601. /**
  72602. * The output strength of the SSAO post-process. Default value is 1.0.
  72603. */
  72604. totalStrength: number;
  72605. /**
  72606. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72607. */
  72608. radius: number;
  72609. /**
  72610. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72611. * Must not be equal to fallOff and superior to fallOff.
  72612. * Default value is 0.0075
  72613. */
  72614. area: number;
  72615. /**
  72616. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72617. * Must not be equal to area and inferior to area.
  72618. * Default value is 0.000001
  72619. */
  72620. fallOff: number;
  72621. /**
  72622. * The base color of the SSAO post-process
  72623. * The final result is "base + ssao" between [0, 1]
  72624. */
  72625. base: number;
  72626. private _scene;
  72627. private _depthTexture;
  72628. private _randomTexture;
  72629. private _originalColorPostProcess;
  72630. private _ssaoPostProcess;
  72631. private _blurHPostProcess;
  72632. private _blurVPostProcess;
  72633. private _ssaoCombinePostProcess;
  72634. private _firstUpdate;
  72635. /**
  72636. * Gets active scene
  72637. */
  72638. get scene(): Scene;
  72639. /**
  72640. * @constructor
  72641. * @param name - The rendering pipeline name
  72642. * @param scene - The scene linked to this pipeline
  72643. * @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 }
  72644. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72645. */
  72646. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72647. /**
  72648. * Get the class name
  72649. * @returns "SSAORenderingPipeline"
  72650. */
  72651. getClassName(): string;
  72652. /**
  72653. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72654. */
  72655. dispose(disableDepthRender?: boolean): void;
  72656. private _createBlurPostProcess;
  72657. /** @hidden */
  72658. _rebuild(): void;
  72659. private _createSSAOPostProcess;
  72660. private _createSSAOCombinePostProcess;
  72661. private _createRandomTexture;
  72662. }
  72663. }
  72664. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  72665. /** @hidden */
  72666. export var screenSpaceReflectionPixelShader: {
  72667. name: string;
  72668. shader: string;
  72669. };
  72670. }
  72671. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  72672. import { Nullable } from "babylonjs/types";
  72673. import { Camera } from "babylonjs/Cameras/camera";
  72674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72675. import { Scene } from "babylonjs/scene";
  72676. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  72677. import { Engine } from "babylonjs/Engines/engine";
  72678. /**
  72679. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72680. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72681. */
  72682. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72683. /**
  72684. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72685. */
  72686. threshold: number;
  72687. /**
  72688. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72689. */
  72690. strength: number;
  72691. /**
  72692. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72693. */
  72694. reflectionSpecularFalloffExponent: number;
  72695. /**
  72696. * 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]
  72697. */
  72698. step: number;
  72699. /**
  72700. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72701. */
  72702. roughnessFactor: number;
  72703. private _geometryBufferRenderer;
  72704. private _enableSmoothReflections;
  72705. private _reflectionSamples;
  72706. private _smoothSteps;
  72707. /**
  72708. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72709. * @param name The name of the effect.
  72710. * @param scene The scene containing the objects to calculate reflections.
  72711. * @param options The required width/height ratio to downsize to before computing the render pass.
  72712. * @param camera The camera to apply the render pass to.
  72713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72714. * @param engine The engine which the post process will be applied. (default: current engine)
  72715. * @param reusable If the post process can be reused on the same frame. (default: false)
  72716. * @param textureType Type of textures used when performing the post process. (default: 0)
  72717. * @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)
  72718. */
  72719. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72720. /**
  72721. * Gets wether or not smoothing reflections is enabled.
  72722. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72723. */
  72724. get enableSmoothReflections(): boolean;
  72725. /**
  72726. * Sets wether or not smoothing reflections is enabled.
  72727. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72728. */
  72729. set enableSmoothReflections(enabled: boolean);
  72730. /**
  72731. * Gets the number of samples taken while computing reflections. More samples count is high,
  72732. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72733. */
  72734. get reflectionSamples(): number;
  72735. /**
  72736. * Sets the number of samples taken while computing reflections. More samples count is high,
  72737. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72738. */
  72739. set reflectionSamples(samples: number);
  72740. /**
  72741. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72742. * more the post-process will require GPU power and can generate a drop in FPS.
  72743. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72744. */
  72745. get smoothSteps(): number;
  72746. set smoothSteps(steps: number);
  72747. private _updateEffectDefines;
  72748. }
  72749. }
  72750. declare module "babylonjs/Shaders/standard.fragment" {
  72751. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  72752. /** @hidden */
  72753. export var standardPixelShader: {
  72754. name: string;
  72755. shader: string;
  72756. };
  72757. }
  72758. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  72759. import { Nullable } from "babylonjs/types";
  72760. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72761. import { Camera } from "babylonjs/Cameras/camera";
  72762. import { Texture } from "babylonjs/Materials/Textures/texture";
  72763. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72764. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72765. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72766. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72767. import { IDisposable } from "babylonjs/scene";
  72768. import { SpotLight } from "babylonjs/Lights/spotLight";
  72769. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  72770. import { Scene } from "babylonjs/scene";
  72771. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72772. import { Animation } from "babylonjs/Animations/animation";
  72773. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72774. import "babylonjs/Shaders/standard.fragment";
  72775. /**
  72776. * Standard rendering pipeline
  72777. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72778. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72779. */
  72780. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72781. /**
  72782. * Public members
  72783. */
  72784. /**
  72785. * Post-process which contains the original scene color before the pipeline applies all the effects
  72786. */
  72787. originalPostProcess: Nullable<PostProcess>;
  72788. /**
  72789. * Post-process used to down scale an image x4
  72790. */
  72791. downSampleX4PostProcess: Nullable<PostProcess>;
  72792. /**
  72793. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72794. */
  72795. brightPassPostProcess: Nullable<PostProcess>;
  72796. /**
  72797. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72798. */
  72799. blurHPostProcesses: PostProcess[];
  72800. /**
  72801. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72802. */
  72803. blurVPostProcesses: PostProcess[];
  72804. /**
  72805. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72806. */
  72807. textureAdderPostProcess: Nullable<PostProcess>;
  72808. /**
  72809. * Post-process used to create volumetric lighting effect
  72810. */
  72811. volumetricLightPostProcess: Nullable<PostProcess>;
  72812. /**
  72813. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72814. */
  72815. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72816. /**
  72817. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72818. */
  72819. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72820. /**
  72821. * Post-process used to merge the volumetric light effect and the real scene color
  72822. */
  72823. volumetricLightMergePostProces: Nullable<PostProcess>;
  72824. /**
  72825. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72826. */
  72827. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72828. /**
  72829. * Base post-process used to calculate the average luminance of the final image for HDR
  72830. */
  72831. luminancePostProcess: Nullable<PostProcess>;
  72832. /**
  72833. * Post-processes used to create down sample post-processes in order to get
  72834. * the average luminance of the final image for HDR
  72835. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72836. */
  72837. luminanceDownSamplePostProcesses: PostProcess[];
  72838. /**
  72839. * Post-process used to create a HDR effect (light adaptation)
  72840. */
  72841. hdrPostProcess: Nullable<PostProcess>;
  72842. /**
  72843. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72844. */
  72845. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72846. /**
  72847. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72848. */
  72849. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72850. /**
  72851. * Post-process used to merge the final HDR post-process and the real scene color
  72852. */
  72853. hdrFinalPostProcess: Nullable<PostProcess>;
  72854. /**
  72855. * Post-process used to create a lens flare effect
  72856. */
  72857. lensFlarePostProcess: Nullable<PostProcess>;
  72858. /**
  72859. * Post-process that merges the result of the lens flare post-process and the real scene color
  72860. */
  72861. lensFlareComposePostProcess: Nullable<PostProcess>;
  72862. /**
  72863. * Post-process used to create a motion blur effect
  72864. */
  72865. motionBlurPostProcess: Nullable<PostProcess>;
  72866. /**
  72867. * Post-process used to create a depth of field effect
  72868. */
  72869. depthOfFieldPostProcess: Nullable<PostProcess>;
  72870. /**
  72871. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72872. */
  72873. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72874. /**
  72875. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72876. */
  72877. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72878. /**
  72879. * Represents the brightness threshold in order to configure the illuminated surfaces
  72880. */
  72881. brightThreshold: number;
  72882. /**
  72883. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72884. */
  72885. blurWidth: number;
  72886. /**
  72887. * Sets if the blur for highlighted surfaces must be only horizontal
  72888. */
  72889. horizontalBlur: boolean;
  72890. /**
  72891. * Gets the overall exposure used by the pipeline
  72892. */
  72893. get exposure(): number;
  72894. /**
  72895. * Sets the overall exposure used by the pipeline
  72896. */
  72897. set exposure(value: number);
  72898. /**
  72899. * Texture used typically to simulate "dirty" on camera lens
  72900. */
  72901. lensTexture: Nullable<Texture>;
  72902. /**
  72903. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72904. */
  72905. volumetricLightCoefficient: number;
  72906. /**
  72907. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72908. */
  72909. volumetricLightPower: number;
  72910. /**
  72911. * Used the set the blur intensity to smooth the volumetric lights
  72912. */
  72913. volumetricLightBlurScale: number;
  72914. /**
  72915. * Light (spot or directional) used to generate the volumetric lights rays
  72916. * The source light must have a shadow generate so the pipeline can get its
  72917. * depth map
  72918. */
  72919. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72920. /**
  72921. * For eye adaptation, represents the minimum luminance the eye can see
  72922. */
  72923. hdrMinimumLuminance: number;
  72924. /**
  72925. * For eye adaptation, represents the decrease luminance speed
  72926. */
  72927. hdrDecreaseRate: number;
  72928. /**
  72929. * For eye adaptation, represents the increase luminance speed
  72930. */
  72931. hdrIncreaseRate: number;
  72932. /**
  72933. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72934. */
  72935. get hdrAutoExposure(): boolean;
  72936. /**
  72937. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72938. */
  72939. set hdrAutoExposure(value: boolean);
  72940. /**
  72941. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72942. */
  72943. lensColorTexture: Nullable<Texture>;
  72944. /**
  72945. * The overall strengh for the lens flare effect
  72946. */
  72947. lensFlareStrength: number;
  72948. /**
  72949. * Dispersion coefficient for lens flare ghosts
  72950. */
  72951. lensFlareGhostDispersal: number;
  72952. /**
  72953. * Main lens flare halo width
  72954. */
  72955. lensFlareHaloWidth: number;
  72956. /**
  72957. * Based on the lens distortion effect, defines how much the lens flare result
  72958. * is distorted
  72959. */
  72960. lensFlareDistortionStrength: number;
  72961. /**
  72962. * Configures the blur intensity used for for lens flare (halo)
  72963. */
  72964. lensFlareBlurWidth: number;
  72965. /**
  72966. * Lens star texture must be used to simulate rays on the flares and is available
  72967. * in the documentation
  72968. */
  72969. lensStarTexture: Nullable<Texture>;
  72970. /**
  72971. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72972. * flare effect by taking account of the dirt texture
  72973. */
  72974. lensFlareDirtTexture: Nullable<Texture>;
  72975. /**
  72976. * Represents the focal length for the depth of field effect
  72977. */
  72978. depthOfFieldDistance: number;
  72979. /**
  72980. * Represents the blur intensity for the blurred part of the depth of field effect
  72981. */
  72982. depthOfFieldBlurWidth: number;
  72983. /**
  72984. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72985. */
  72986. get motionStrength(): number;
  72987. /**
  72988. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72989. */
  72990. set motionStrength(strength: number);
  72991. /**
  72992. * Gets wether or not the motion blur post-process is object based or screen based.
  72993. */
  72994. get objectBasedMotionBlur(): boolean;
  72995. /**
  72996. * Sets wether or not the motion blur post-process should be object based or screen based
  72997. */
  72998. set objectBasedMotionBlur(value: boolean);
  72999. /**
  73000. * List of animations for the pipeline (IAnimatable implementation)
  73001. */
  73002. animations: Animation[];
  73003. /**
  73004. * Private members
  73005. */
  73006. private _scene;
  73007. private _currentDepthOfFieldSource;
  73008. private _basePostProcess;
  73009. private _fixedExposure;
  73010. private _currentExposure;
  73011. private _hdrAutoExposure;
  73012. private _hdrCurrentLuminance;
  73013. private _motionStrength;
  73014. private _isObjectBasedMotionBlur;
  73015. private _floatTextureType;
  73016. private _camerasToBeAttached;
  73017. private _ratio;
  73018. private _bloomEnabled;
  73019. private _depthOfFieldEnabled;
  73020. private _vlsEnabled;
  73021. private _lensFlareEnabled;
  73022. private _hdrEnabled;
  73023. private _motionBlurEnabled;
  73024. private _fxaaEnabled;
  73025. private _screenSpaceReflectionsEnabled;
  73026. private _motionBlurSamples;
  73027. private _volumetricLightStepsCount;
  73028. private _samples;
  73029. /**
  73030. * @ignore
  73031. * Specifies if the bloom pipeline is enabled
  73032. */
  73033. get BloomEnabled(): boolean;
  73034. set BloomEnabled(enabled: boolean);
  73035. /**
  73036. * @ignore
  73037. * Specifies if the depth of field pipeline is enabed
  73038. */
  73039. get DepthOfFieldEnabled(): boolean;
  73040. set DepthOfFieldEnabled(enabled: boolean);
  73041. /**
  73042. * @ignore
  73043. * Specifies if the lens flare pipeline is enabed
  73044. */
  73045. get LensFlareEnabled(): boolean;
  73046. set LensFlareEnabled(enabled: boolean);
  73047. /**
  73048. * @ignore
  73049. * Specifies if the HDR pipeline is enabled
  73050. */
  73051. get HDREnabled(): boolean;
  73052. set HDREnabled(enabled: boolean);
  73053. /**
  73054. * @ignore
  73055. * Specifies if the volumetric lights scattering effect is enabled
  73056. */
  73057. get VLSEnabled(): boolean;
  73058. set VLSEnabled(enabled: boolean);
  73059. /**
  73060. * @ignore
  73061. * Specifies if the motion blur effect is enabled
  73062. */
  73063. get MotionBlurEnabled(): boolean;
  73064. set MotionBlurEnabled(enabled: boolean);
  73065. /**
  73066. * Specifies if anti-aliasing is enabled
  73067. */
  73068. get fxaaEnabled(): boolean;
  73069. set fxaaEnabled(enabled: boolean);
  73070. /**
  73071. * Specifies if screen space reflections are enabled.
  73072. */
  73073. get screenSpaceReflectionsEnabled(): boolean;
  73074. set screenSpaceReflectionsEnabled(enabled: boolean);
  73075. /**
  73076. * Specifies the number of steps used to calculate the volumetric lights
  73077. * Typically in interval [50, 200]
  73078. */
  73079. get volumetricLightStepsCount(): number;
  73080. set volumetricLightStepsCount(count: number);
  73081. /**
  73082. * Specifies the number of samples used for the motion blur effect
  73083. * Typically in interval [16, 64]
  73084. */
  73085. get motionBlurSamples(): number;
  73086. set motionBlurSamples(samples: number);
  73087. /**
  73088. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73089. */
  73090. get samples(): number;
  73091. set samples(sampleCount: number);
  73092. /**
  73093. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73094. * @constructor
  73095. * @param name The rendering pipeline name
  73096. * @param scene The scene linked to this pipeline
  73097. * @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)
  73098. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73099. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73100. */
  73101. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73102. private _buildPipeline;
  73103. private _createDownSampleX4PostProcess;
  73104. private _createBrightPassPostProcess;
  73105. private _createBlurPostProcesses;
  73106. private _createTextureAdderPostProcess;
  73107. private _createVolumetricLightPostProcess;
  73108. private _createLuminancePostProcesses;
  73109. private _createHdrPostProcess;
  73110. private _createLensFlarePostProcess;
  73111. private _createDepthOfFieldPostProcess;
  73112. private _createMotionBlurPostProcess;
  73113. private _getDepthTexture;
  73114. private _disposePostProcesses;
  73115. /**
  73116. * Dispose of the pipeline and stop all post processes
  73117. */
  73118. dispose(): void;
  73119. /**
  73120. * Serialize the rendering pipeline (Used when exporting)
  73121. * @returns the serialized object
  73122. */
  73123. serialize(): any;
  73124. /**
  73125. * Parse the serialized pipeline
  73126. * @param source Source pipeline.
  73127. * @param scene The scene to load the pipeline to.
  73128. * @param rootUrl The URL of the serialized pipeline.
  73129. * @returns An instantiated pipeline from the serialized object.
  73130. */
  73131. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73132. /**
  73133. * Luminance steps
  73134. */
  73135. static LuminanceSteps: number;
  73136. }
  73137. }
  73138. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73139. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73140. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73141. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73142. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73143. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73144. }
  73145. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73146. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73147. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73148. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73149. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73150. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73151. }
  73152. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73153. /** @hidden */
  73154. export var stereoscopicInterlacePixelShader: {
  73155. name: string;
  73156. shader: string;
  73157. };
  73158. }
  73159. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73160. import { Camera } from "babylonjs/Cameras/camera";
  73161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73162. import { Engine } from "babylonjs/Engines/engine";
  73163. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73164. /**
  73165. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73166. */
  73167. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73168. private _stepSize;
  73169. private _passedProcess;
  73170. /**
  73171. * Initializes a StereoscopicInterlacePostProcessI
  73172. * @param name The name of the effect.
  73173. * @param rigCameras The rig cameras to be appled to the post process
  73174. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73175. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73177. * @param engine The engine which the post process will be applied. (default: current engine)
  73178. * @param reusable If the post process can be reused on the same frame. (default: false)
  73179. */
  73180. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73181. }
  73182. /**
  73183. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73184. */
  73185. export class StereoscopicInterlacePostProcess extends PostProcess {
  73186. private _stepSize;
  73187. private _passedProcess;
  73188. /**
  73189. * Initializes a StereoscopicInterlacePostProcess
  73190. * @param name The name of the effect.
  73191. * @param rigCameras The rig cameras to be appled to the post process
  73192. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73194. * @param engine The engine which the post process will be applied. (default: current engine)
  73195. * @param reusable If the post process can be reused on the same frame. (default: false)
  73196. */
  73197. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73198. }
  73199. }
  73200. declare module "babylonjs/Shaders/tonemap.fragment" {
  73201. /** @hidden */
  73202. export var tonemapPixelShader: {
  73203. name: string;
  73204. shader: string;
  73205. };
  73206. }
  73207. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73208. import { Camera } from "babylonjs/Cameras/camera";
  73209. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73210. import "babylonjs/Shaders/tonemap.fragment";
  73211. import { Engine } from "babylonjs/Engines/engine";
  73212. /** Defines operator used for tonemapping */
  73213. export enum TonemappingOperator {
  73214. /** Hable */
  73215. Hable = 0,
  73216. /** Reinhard */
  73217. Reinhard = 1,
  73218. /** HejiDawson */
  73219. HejiDawson = 2,
  73220. /** Photographic */
  73221. Photographic = 3
  73222. }
  73223. /**
  73224. * Defines a post process to apply tone mapping
  73225. */
  73226. export class TonemapPostProcess extends PostProcess {
  73227. private _operator;
  73228. /** Defines the required exposure adjustement */
  73229. exposureAdjustment: number;
  73230. /**
  73231. * Creates a new TonemapPostProcess
  73232. * @param name defines the name of the postprocess
  73233. * @param _operator defines the operator to use
  73234. * @param exposureAdjustment defines the required exposure adjustement
  73235. * @param camera defines the camera to use (can be null)
  73236. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73237. * @param engine defines the hosting engine (can be ignore if camera is set)
  73238. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73239. */
  73240. constructor(name: string, _operator: TonemappingOperator,
  73241. /** Defines the required exposure adjustement */
  73242. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73243. }
  73244. }
  73245. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73246. /** @hidden */
  73247. export var volumetricLightScatteringPixelShader: {
  73248. name: string;
  73249. shader: string;
  73250. };
  73251. }
  73252. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73253. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73257. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73258. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73259. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73260. /** @hidden */
  73261. export var volumetricLightScatteringPassVertexShader: {
  73262. name: string;
  73263. shader: string;
  73264. };
  73265. }
  73266. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73267. /** @hidden */
  73268. export var volumetricLightScatteringPassPixelShader: {
  73269. name: string;
  73270. shader: string;
  73271. };
  73272. }
  73273. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73274. import { Vector3 } from "babylonjs/Maths/math.vector";
  73275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73276. import { Mesh } from "babylonjs/Meshes/mesh";
  73277. import { Camera } from "babylonjs/Cameras/camera";
  73278. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73279. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73280. import { Scene } from "babylonjs/scene";
  73281. import "babylonjs/Meshes/Builders/planeBuilder";
  73282. import "babylonjs/Shaders/depth.vertex";
  73283. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73284. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73285. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73286. import { Engine } from "babylonjs/Engines/engine";
  73287. /**
  73288. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73289. */
  73290. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73291. private _volumetricLightScatteringPass;
  73292. private _volumetricLightScatteringRTT;
  73293. private _viewPort;
  73294. private _screenCoordinates;
  73295. private _cachedDefines;
  73296. /**
  73297. * If not undefined, the mesh position is computed from the attached node position
  73298. */
  73299. attachedNode: {
  73300. position: Vector3;
  73301. };
  73302. /**
  73303. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73304. */
  73305. customMeshPosition: Vector3;
  73306. /**
  73307. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73308. */
  73309. useCustomMeshPosition: boolean;
  73310. /**
  73311. * If the post-process should inverse the light scattering direction
  73312. */
  73313. invert: boolean;
  73314. /**
  73315. * The internal mesh used by the post-process
  73316. */
  73317. mesh: Mesh;
  73318. /**
  73319. * @hidden
  73320. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73321. */
  73322. get useDiffuseColor(): boolean;
  73323. set useDiffuseColor(useDiffuseColor: boolean);
  73324. /**
  73325. * Array containing the excluded meshes not rendered in the internal pass
  73326. */
  73327. excludedMeshes: AbstractMesh[];
  73328. /**
  73329. * Controls the overall intensity of the post-process
  73330. */
  73331. exposure: number;
  73332. /**
  73333. * Dissipates each sample's contribution in range [0, 1]
  73334. */
  73335. decay: number;
  73336. /**
  73337. * Controls the overall intensity of each sample
  73338. */
  73339. weight: number;
  73340. /**
  73341. * Controls the density of each sample
  73342. */
  73343. density: number;
  73344. /**
  73345. * @constructor
  73346. * @param name The post-process name
  73347. * @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)
  73348. * @param camera The camera that the post-process will be attached to
  73349. * @param mesh The mesh used to create the light scattering
  73350. * @param samples The post-process quality, default 100
  73351. * @param samplingModeThe post-process filtering mode
  73352. * @param engine The babylon engine
  73353. * @param reusable If the post-process is reusable
  73354. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73355. */
  73356. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73357. /**
  73358. * Returns the string "VolumetricLightScatteringPostProcess"
  73359. * @returns "VolumetricLightScatteringPostProcess"
  73360. */
  73361. getClassName(): string;
  73362. private _isReady;
  73363. /**
  73364. * Sets the new light position for light scattering effect
  73365. * @param position The new custom light position
  73366. */
  73367. setCustomMeshPosition(position: Vector3): void;
  73368. /**
  73369. * Returns the light position for light scattering effect
  73370. * @return Vector3 The custom light position
  73371. */
  73372. getCustomMeshPosition(): Vector3;
  73373. /**
  73374. * Disposes the internal assets and detaches the post-process from the camera
  73375. */
  73376. dispose(camera: Camera): void;
  73377. /**
  73378. * Returns the render target texture used by the post-process
  73379. * @return the render target texture used by the post-process
  73380. */
  73381. getPass(): RenderTargetTexture;
  73382. private _meshExcluded;
  73383. private _createPass;
  73384. private _updateMeshScreenCoordinates;
  73385. /**
  73386. * Creates a default mesh for the Volumeric Light Scattering post-process
  73387. * @param name The mesh name
  73388. * @param scene The scene where to create the mesh
  73389. * @return the default mesh
  73390. */
  73391. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73392. }
  73393. }
  73394. declare module "babylonjs/PostProcesses/index" {
  73395. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73396. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73397. export * from "babylonjs/PostProcesses/bloomEffect";
  73398. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73399. export * from "babylonjs/PostProcesses/blurPostProcess";
  73400. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73401. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73402. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  73403. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  73404. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73405. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  73406. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  73407. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  73408. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73409. export * from "babylonjs/PostProcesses/filterPostProcess";
  73410. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  73411. export * from "babylonjs/PostProcesses/grainPostProcess";
  73412. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  73413. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73414. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  73415. export * from "babylonjs/PostProcesses/passPostProcess";
  73416. export * from "babylonjs/PostProcesses/postProcess";
  73417. export * from "babylonjs/PostProcesses/postProcessManager";
  73418. export * from "babylonjs/PostProcesses/refractionPostProcess";
  73419. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  73420. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  73421. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  73422. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  73423. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  73424. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  73425. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  73426. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73427. }
  73428. declare module "babylonjs/Probes/index" {
  73429. export * from "babylonjs/Probes/reflectionProbe";
  73430. }
  73431. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  73432. import { Scene } from "babylonjs/scene";
  73433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73434. import { SmartArray } from "babylonjs/Misc/smartArray";
  73435. import { ISceneComponent } from "babylonjs/sceneComponent";
  73436. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  73437. import "babylonjs/Meshes/Builders/boxBuilder";
  73438. import "babylonjs/Shaders/color.fragment";
  73439. import "babylonjs/Shaders/color.vertex";
  73440. import { Color3 } from "babylonjs/Maths/math.color";
  73441. import { Observable } from "babylonjs/Misc/observable";
  73442. module "babylonjs/scene" {
  73443. interface Scene {
  73444. /** @hidden (Backing field) */
  73445. _boundingBoxRenderer: BoundingBoxRenderer;
  73446. /** @hidden (Backing field) */
  73447. _forceShowBoundingBoxes: boolean;
  73448. /**
  73449. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73450. */
  73451. forceShowBoundingBoxes: boolean;
  73452. /**
  73453. * Gets the bounding box renderer associated with the scene
  73454. * @returns a BoundingBoxRenderer
  73455. */
  73456. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73457. }
  73458. }
  73459. module "babylonjs/Meshes/abstractMesh" {
  73460. interface AbstractMesh {
  73461. /** @hidden (Backing field) */
  73462. _showBoundingBox: boolean;
  73463. /**
  73464. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73465. */
  73466. showBoundingBox: boolean;
  73467. }
  73468. }
  73469. /**
  73470. * Component responsible of rendering the bounding box of the meshes in a scene.
  73471. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73472. */
  73473. export class BoundingBoxRenderer implements ISceneComponent {
  73474. /**
  73475. * The component name helpfull to identify the component in the list of scene components.
  73476. */
  73477. readonly name: string;
  73478. /**
  73479. * The scene the component belongs to.
  73480. */
  73481. scene: Scene;
  73482. /**
  73483. * Color of the bounding box lines placed in front of an object
  73484. */
  73485. frontColor: Color3;
  73486. /**
  73487. * Color of the bounding box lines placed behind an object
  73488. */
  73489. backColor: Color3;
  73490. /**
  73491. * Defines if the renderer should show the back lines or not
  73492. */
  73493. showBackLines: boolean;
  73494. /**
  73495. * Observable raised before rendering a bounding box
  73496. */
  73497. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73498. /**
  73499. * Observable raised after rendering a bounding box
  73500. */
  73501. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73502. /**
  73503. * @hidden
  73504. */
  73505. renderList: SmartArray<BoundingBox>;
  73506. private _colorShader;
  73507. private _vertexBuffers;
  73508. private _indexBuffer;
  73509. private _fillIndexBuffer;
  73510. private _fillIndexData;
  73511. /**
  73512. * Instantiates a new bounding box renderer in a scene.
  73513. * @param scene the scene the renderer renders in
  73514. */
  73515. constructor(scene: Scene);
  73516. /**
  73517. * Registers the component in a given scene
  73518. */
  73519. register(): void;
  73520. private _evaluateSubMesh;
  73521. private _activeMesh;
  73522. private _prepareRessources;
  73523. private _createIndexBuffer;
  73524. /**
  73525. * Rebuilds the elements related to this component in case of
  73526. * context lost for instance.
  73527. */
  73528. rebuild(): void;
  73529. /**
  73530. * @hidden
  73531. */
  73532. reset(): void;
  73533. /**
  73534. * Render the bounding boxes of a specific rendering group
  73535. * @param renderingGroupId defines the rendering group to render
  73536. */
  73537. render(renderingGroupId: number): void;
  73538. /**
  73539. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73540. * @param mesh Define the mesh to render the occlusion bounding box for
  73541. */
  73542. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73543. /**
  73544. * Dispose and release the resources attached to this renderer.
  73545. */
  73546. dispose(): void;
  73547. }
  73548. }
  73549. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  73550. import { Nullable } from "babylonjs/types";
  73551. import { Scene } from "babylonjs/scene";
  73552. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  73553. import { Camera } from "babylonjs/Cameras/camera";
  73554. import { ISceneComponent } from "babylonjs/sceneComponent";
  73555. module "babylonjs/scene" {
  73556. interface Scene {
  73557. /** @hidden (Backing field) */
  73558. _depthRenderer: {
  73559. [id: string]: DepthRenderer;
  73560. };
  73561. /**
  73562. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73563. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73564. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73565. * @returns the created depth renderer
  73566. */
  73567. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  73568. /**
  73569. * Disables a depth renderer for a given camera
  73570. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73571. */
  73572. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73573. }
  73574. }
  73575. /**
  73576. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73577. * in several rendering techniques.
  73578. */
  73579. export class DepthRendererSceneComponent implements ISceneComponent {
  73580. /**
  73581. * The component name helpfull to identify the component in the list of scene components.
  73582. */
  73583. readonly name: string;
  73584. /**
  73585. * The scene the component belongs to.
  73586. */
  73587. scene: Scene;
  73588. /**
  73589. * Creates a new instance of the component for the given scene
  73590. * @param scene Defines the scene to register the component in
  73591. */
  73592. constructor(scene: Scene);
  73593. /**
  73594. * Registers the component in a given scene
  73595. */
  73596. register(): void;
  73597. /**
  73598. * Rebuilds the elements related to this component in case of
  73599. * context lost for instance.
  73600. */
  73601. rebuild(): void;
  73602. /**
  73603. * Disposes the component and the associated ressources
  73604. */
  73605. dispose(): void;
  73606. private _gatherRenderTargets;
  73607. private _gatherActiveCameraRenderTargets;
  73608. }
  73609. }
  73610. declare module "babylonjs/Shaders/outline.fragment" {
  73611. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73612. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  73613. /** @hidden */
  73614. export var outlinePixelShader: {
  73615. name: string;
  73616. shader: string;
  73617. };
  73618. }
  73619. declare module "babylonjs/Shaders/outline.vertex" {
  73620. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73621. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73622. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73623. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73624. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73625. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73626. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73627. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73628. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  73629. /** @hidden */
  73630. export var outlineVertexShader: {
  73631. name: string;
  73632. shader: string;
  73633. };
  73634. }
  73635. declare module "babylonjs/Rendering/outlineRenderer" {
  73636. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73637. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  73638. import { Scene } from "babylonjs/scene";
  73639. import { ISceneComponent } from "babylonjs/sceneComponent";
  73640. import "babylonjs/Shaders/outline.fragment";
  73641. import "babylonjs/Shaders/outline.vertex";
  73642. module "babylonjs/scene" {
  73643. interface Scene {
  73644. /** @hidden */
  73645. _outlineRenderer: OutlineRenderer;
  73646. /**
  73647. * Gets the outline renderer associated with the scene
  73648. * @returns a OutlineRenderer
  73649. */
  73650. getOutlineRenderer(): OutlineRenderer;
  73651. }
  73652. }
  73653. module "babylonjs/Meshes/abstractMesh" {
  73654. interface AbstractMesh {
  73655. /** @hidden (Backing field) */
  73656. _renderOutline: boolean;
  73657. /**
  73658. * Gets or sets a boolean indicating if the outline must be rendered as well
  73659. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73660. */
  73661. renderOutline: boolean;
  73662. /** @hidden (Backing field) */
  73663. _renderOverlay: boolean;
  73664. /**
  73665. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73666. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73667. */
  73668. renderOverlay: boolean;
  73669. }
  73670. }
  73671. /**
  73672. * This class is responsible to draw bothe outline/overlay of meshes.
  73673. * It should not be used directly but through the available method on mesh.
  73674. */
  73675. export class OutlineRenderer implements ISceneComponent {
  73676. /**
  73677. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73678. */
  73679. private static _StencilReference;
  73680. /**
  73681. * The name of the component. Each component must have a unique name.
  73682. */
  73683. name: string;
  73684. /**
  73685. * The scene the component belongs to.
  73686. */
  73687. scene: Scene;
  73688. /**
  73689. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73690. */
  73691. zOffset: number;
  73692. private _engine;
  73693. private _effect;
  73694. private _cachedDefines;
  73695. private _savedDepthWrite;
  73696. /**
  73697. * Instantiates a new outline renderer. (There could be only one per scene).
  73698. * @param scene Defines the scene it belongs to
  73699. */
  73700. constructor(scene: Scene);
  73701. /**
  73702. * Register the component to one instance of a scene.
  73703. */
  73704. register(): void;
  73705. /**
  73706. * Rebuilds the elements related to this component in case of
  73707. * context lost for instance.
  73708. */
  73709. rebuild(): void;
  73710. /**
  73711. * Disposes the component and the associated ressources.
  73712. */
  73713. dispose(): void;
  73714. /**
  73715. * Renders the outline in the canvas.
  73716. * @param subMesh Defines the sumesh to render
  73717. * @param batch Defines the batch of meshes in case of instances
  73718. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73719. */
  73720. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73721. /**
  73722. * Returns whether or not the outline renderer is ready for a given submesh.
  73723. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73724. * @param subMesh Defines the submesh to check readyness for
  73725. * @param useInstances Defines wheter wee are trying to render instances or not
  73726. * @returns true if ready otherwise false
  73727. */
  73728. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73729. private _beforeRenderingMesh;
  73730. private _afterRenderingMesh;
  73731. }
  73732. }
  73733. declare module "babylonjs/Rendering/index" {
  73734. export * from "babylonjs/Rendering/boundingBoxRenderer";
  73735. export * from "babylonjs/Rendering/depthRenderer";
  73736. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  73737. export * from "babylonjs/Rendering/edgesRenderer";
  73738. export * from "babylonjs/Rendering/geometryBufferRenderer";
  73739. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73740. export * from "babylonjs/Rendering/outlineRenderer";
  73741. export * from "babylonjs/Rendering/renderingGroup";
  73742. export * from "babylonjs/Rendering/renderingManager";
  73743. export * from "babylonjs/Rendering/utilityLayerRenderer";
  73744. }
  73745. declare module "babylonjs/Sprites/ISprites" {
  73746. /**
  73747. * Defines the basic options interface of a Sprite Frame Source Size.
  73748. */
  73749. export interface ISpriteJSONSpriteSourceSize {
  73750. /**
  73751. * number of the original width of the Frame
  73752. */
  73753. w: number;
  73754. /**
  73755. * number of the original height of the Frame
  73756. */
  73757. h: number;
  73758. }
  73759. /**
  73760. * Defines the basic options interface of a Sprite Frame Data.
  73761. */
  73762. export interface ISpriteJSONSpriteFrameData {
  73763. /**
  73764. * number of the x offset of the Frame
  73765. */
  73766. x: number;
  73767. /**
  73768. * number of the y offset of the Frame
  73769. */
  73770. y: number;
  73771. /**
  73772. * number of the width of the Frame
  73773. */
  73774. w: number;
  73775. /**
  73776. * number of the height of the Frame
  73777. */
  73778. h: number;
  73779. }
  73780. /**
  73781. * Defines the basic options interface of a JSON Sprite.
  73782. */
  73783. export interface ISpriteJSONSprite {
  73784. /**
  73785. * string name of the Frame
  73786. */
  73787. filename: string;
  73788. /**
  73789. * ISpriteJSONSpriteFrame basic object of the frame data
  73790. */
  73791. frame: ISpriteJSONSpriteFrameData;
  73792. /**
  73793. * boolean to flag is the frame was rotated.
  73794. */
  73795. rotated: boolean;
  73796. /**
  73797. * boolean to flag is the frame was trimmed.
  73798. */
  73799. trimmed: boolean;
  73800. /**
  73801. * ISpriteJSONSpriteFrame basic object of the source data
  73802. */
  73803. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73804. /**
  73805. * ISpriteJSONSpriteFrame basic object of the source data
  73806. */
  73807. sourceSize: ISpriteJSONSpriteSourceSize;
  73808. }
  73809. /**
  73810. * Defines the basic options interface of a JSON atlas.
  73811. */
  73812. export interface ISpriteJSONAtlas {
  73813. /**
  73814. * Array of objects that contain the frame data.
  73815. */
  73816. frames: Array<ISpriteJSONSprite>;
  73817. /**
  73818. * object basic object containing the sprite meta data.
  73819. */
  73820. meta?: object;
  73821. }
  73822. }
  73823. declare module "babylonjs/Shaders/spriteMap.fragment" {
  73824. /** @hidden */
  73825. export var spriteMapPixelShader: {
  73826. name: string;
  73827. shader: string;
  73828. };
  73829. }
  73830. declare module "babylonjs/Shaders/spriteMap.vertex" {
  73831. /** @hidden */
  73832. export var spriteMapVertexShader: {
  73833. name: string;
  73834. shader: string;
  73835. };
  73836. }
  73837. declare module "babylonjs/Sprites/spriteMap" {
  73838. import { IDisposable, Scene } from "babylonjs/scene";
  73839. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  73840. import { Texture } from "babylonjs/Materials/Textures/texture";
  73841. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  73842. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  73843. import "babylonjs/Meshes/Builders/planeBuilder";
  73844. import "babylonjs/Shaders/spriteMap.fragment";
  73845. import "babylonjs/Shaders/spriteMap.vertex";
  73846. /**
  73847. * Defines the basic options interface of a SpriteMap
  73848. */
  73849. export interface ISpriteMapOptions {
  73850. /**
  73851. * Vector2 of the number of cells in the grid.
  73852. */
  73853. stageSize?: Vector2;
  73854. /**
  73855. * Vector2 of the size of the output plane in World Units.
  73856. */
  73857. outputSize?: Vector2;
  73858. /**
  73859. * Vector3 of the position of the output plane in World Units.
  73860. */
  73861. outputPosition?: Vector3;
  73862. /**
  73863. * Vector3 of the rotation of the output plane.
  73864. */
  73865. outputRotation?: Vector3;
  73866. /**
  73867. * number of layers that the system will reserve in resources.
  73868. */
  73869. layerCount?: number;
  73870. /**
  73871. * number of max animation frames a single cell will reserve in resources.
  73872. */
  73873. maxAnimationFrames?: number;
  73874. /**
  73875. * number cell index of the base tile when the system compiles.
  73876. */
  73877. baseTile?: number;
  73878. /**
  73879. * boolean flip the sprite after its been repositioned by the framing data.
  73880. */
  73881. flipU?: boolean;
  73882. /**
  73883. * Vector3 scalar of the global RGB values of the SpriteMap.
  73884. */
  73885. colorMultiply?: Vector3;
  73886. }
  73887. /**
  73888. * Defines the IDisposable interface in order to be cleanable from resources.
  73889. */
  73890. export interface ISpriteMap extends IDisposable {
  73891. /**
  73892. * String name of the SpriteMap.
  73893. */
  73894. name: string;
  73895. /**
  73896. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73897. */
  73898. atlasJSON: ISpriteJSONAtlas;
  73899. /**
  73900. * Texture of the SpriteMap.
  73901. */
  73902. spriteSheet: Texture;
  73903. /**
  73904. * The parameters to initialize the SpriteMap with.
  73905. */
  73906. options: ISpriteMapOptions;
  73907. }
  73908. /**
  73909. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73910. */
  73911. export class SpriteMap implements ISpriteMap {
  73912. /** The Name of the spriteMap */
  73913. name: string;
  73914. /** The JSON file with the frame and meta data */
  73915. atlasJSON: ISpriteJSONAtlas;
  73916. /** The systems Sprite Sheet Texture */
  73917. spriteSheet: Texture;
  73918. /** Arguments passed with the Constructor */
  73919. options: ISpriteMapOptions;
  73920. /** Public Sprite Storage array, parsed from atlasJSON */
  73921. sprites: Array<ISpriteJSONSprite>;
  73922. /** Returns the Number of Sprites in the System */
  73923. get spriteCount(): number;
  73924. /** Returns the Position of Output Plane*/
  73925. get position(): Vector3;
  73926. /** Returns the Position of Output Plane*/
  73927. set position(v: Vector3);
  73928. /** Returns the Rotation of Output Plane*/
  73929. get rotation(): Vector3;
  73930. /** Returns the Rotation of Output Plane*/
  73931. set rotation(v: Vector3);
  73932. /** Sets the AnimationMap*/
  73933. get animationMap(): RawTexture;
  73934. /** Sets the AnimationMap*/
  73935. set animationMap(v: RawTexture);
  73936. /** Scene that the SpriteMap was created in */
  73937. private _scene;
  73938. /** Texture Buffer of Float32 that holds tile frame data*/
  73939. private _frameMap;
  73940. /** Texture Buffers of Float32 that holds tileMap data*/
  73941. private _tileMaps;
  73942. /** Texture Buffer of Float32 that holds Animation Data*/
  73943. private _animationMap;
  73944. /** Custom ShaderMaterial Central to the System*/
  73945. private _material;
  73946. /** Custom ShaderMaterial Central to the System*/
  73947. private _output;
  73948. /** Systems Time Ticker*/
  73949. private _time;
  73950. /**
  73951. * Creates a new SpriteMap
  73952. * @param name defines the SpriteMaps Name
  73953. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73954. * @param spriteSheet is the Texture that the Sprites are on.
  73955. * @param options a basic deployment configuration
  73956. * @param scene The Scene that the map is deployed on
  73957. */
  73958. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73959. /**
  73960. * Returns tileID location
  73961. * @returns Vector2 the cell position ID
  73962. */
  73963. getTileID(): Vector2;
  73964. /**
  73965. * Gets the UV location of the mouse over the SpriteMap.
  73966. * @returns Vector2 the UV position of the mouse interaction
  73967. */
  73968. getMousePosition(): Vector2;
  73969. /**
  73970. * Creates the "frame" texture Buffer
  73971. * -------------------------------------
  73972. * Structure of frames
  73973. * "filename": "Falling-Water-2.png",
  73974. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73975. * "rotated": true,
  73976. * "trimmed": true,
  73977. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73978. * "sourceSize": {"w":32,"h":32}
  73979. * @returns RawTexture of the frameMap
  73980. */
  73981. private _createFrameBuffer;
  73982. /**
  73983. * Creates the tileMap texture Buffer
  73984. * @param buffer normally and array of numbers, or a false to generate from scratch
  73985. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73986. * @returns RawTexture of the tileMap
  73987. */
  73988. private _createTileBuffer;
  73989. /**
  73990. * Modifies the data of the tileMaps
  73991. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73992. * @param pos is the iVector2 Coordinates of the Tile
  73993. * @param tile The SpriteIndex of the new Tile
  73994. */
  73995. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73996. /**
  73997. * Creates the animationMap texture Buffer
  73998. * @param buffer normally and array of numbers, or a false to generate from scratch
  73999. * @returns RawTexture of the animationMap
  74000. */
  74001. private _createTileAnimationBuffer;
  74002. /**
  74003. * Modifies the data of the animationMap
  74004. * @param cellID is the Index of the Sprite
  74005. * @param _frame is the target Animation frame
  74006. * @param toCell is the Target Index of the next frame of the animation
  74007. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74008. * @param speed is a global scalar of the time variable on the map.
  74009. */
  74010. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74011. /**
  74012. * Exports the .tilemaps file
  74013. */
  74014. saveTileMaps(): void;
  74015. /**
  74016. * Imports the .tilemaps file
  74017. * @param url of the .tilemaps file
  74018. */
  74019. loadTileMaps(url: string): void;
  74020. /**
  74021. * Release associated resources
  74022. */
  74023. dispose(): void;
  74024. }
  74025. }
  74026. declare module "babylonjs/Sprites/spritePackedManager" {
  74027. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74028. import { Scene } from "babylonjs/scene";
  74029. /**
  74030. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74031. * @see http://doc.babylonjs.com/babylon101/sprites
  74032. */
  74033. export class SpritePackedManager extends SpriteManager {
  74034. /** defines the packed manager's name */
  74035. name: string;
  74036. /**
  74037. * Creates a new sprite manager from a packed sprite sheet
  74038. * @param name defines the manager's name
  74039. * @param imgUrl defines the sprite sheet url
  74040. * @param capacity defines the maximum allowed number of sprites
  74041. * @param scene defines the hosting scene
  74042. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74043. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74044. * @param samplingMode defines the smapling mode to use with spritesheet
  74045. * @param fromPacked set to true; do not alter
  74046. */
  74047. constructor(
  74048. /** defines the packed manager's name */
  74049. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74050. }
  74051. }
  74052. declare module "babylonjs/Sprites/index" {
  74053. export * from "babylonjs/Sprites/sprite";
  74054. export * from "babylonjs/Sprites/ISprites";
  74055. export * from "babylonjs/Sprites/spriteManager";
  74056. export * from "babylonjs/Sprites/spriteMap";
  74057. export * from "babylonjs/Sprites/spritePackedManager";
  74058. export * from "babylonjs/Sprites/spriteSceneComponent";
  74059. }
  74060. declare module "babylonjs/States/index" {
  74061. export * from "babylonjs/States/alphaCullingState";
  74062. export * from "babylonjs/States/depthCullingState";
  74063. export * from "babylonjs/States/stencilState";
  74064. }
  74065. declare module "babylonjs/Misc/assetsManager" {
  74066. import { Scene } from "babylonjs/scene";
  74067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74068. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74069. import { Skeleton } from "babylonjs/Bones/skeleton";
  74070. import { Observable } from "babylonjs/Misc/observable";
  74071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74072. import { Texture } from "babylonjs/Materials/Textures/texture";
  74073. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74074. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74075. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74076. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74077. /**
  74078. * Defines the list of states available for a task inside a AssetsManager
  74079. */
  74080. export enum AssetTaskState {
  74081. /**
  74082. * Initialization
  74083. */
  74084. INIT = 0,
  74085. /**
  74086. * Running
  74087. */
  74088. RUNNING = 1,
  74089. /**
  74090. * Done
  74091. */
  74092. DONE = 2,
  74093. /**
  74094. * Error
  74095. */
  74096. ERROR = 3
  74097. }
  74098. /**
  74099. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74100. */
  74101. export abstract class AbstractAssetTask {
  74102. /**
  74103. * Task name
  74104. */ name: string;
  74105. /**
  74106. * Callback called when the task is successful
  74107. */
  74108. onSuccess: (task: any) => void;
  74109. /**
  74110. * Callback called when the task is not successful
  74111. */
  74112. onError: (task: any, message?: string, exception?: any) => void;
  74113. /**
  74114. * Creates a new AssetsManager
  74115. * @param name defines the name of the task
  74116. */
  74117. constructor(
  74118. /**
  74119. * Task name
  74120. */ name: string);
  74121. private _isCompleted;
  74122. private _taskState;
  74123. private _errorObject;
  74124. /**
  74125. * Get if the task is completed
  74126. */
  74127. get isCompleted(): boolean;
  74128. /**
  74129. * Gets the current state of the task
  74130. */
  74131. get taskState(): AssetTaskState;
  74132. /**
  74133. * Gets the current error object (if task is in error)
  74134. */
  74135. get errorObject(): {
  74136. message?: string;
  74137. exception?: any;
  74138. };
  74139. /**
  74140. * Internal only
  74141. * @hidden
  74142. */
  74143. _setErrorObject(message?: string, exception?: any): void;
  74144. /**
  74145. * Execute the current task
  74146. * @param scene defines the scene where you want your assets to be loaded
  74147. * @param onSuccess is a callback called when the task is successfully executed
  74148. * @param onError is a callback called if an error occurs
  74149. */
  74150. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74151. /**
  74152. * Execute the current task
  74153. * @param scene defines the scene where you want your assets to be loaded
  74154. * @param onSuccess is a callback called when the task is successfully executed
  74155. * @param onError is a callback called if an error occurs
  74156. */
  74157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74158. /**
  74159. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74160. * This can be used with failed tasks that have the reason for failure fixed.
  74161. */
  74162. reset(): void;
  74163. private onErrorCallback;
  74164. private onDoneCallback;
  74165. }
  74166. /**
  74167. * Define the interface used by progress events raised during assets loading
  74168. */
  74169. export interface IAssetsProgressEvent {
  74170. /**
  74171. * Defines the number of remaining tasks to process
  74172. */
  74173. remainingCount: number;
  74174. /**
  74175. * Defines the total number of tasks
  74176. */
  74177. totalCount: number;
  74178. /**
  74179. * Defines the task that was just processed
  74180. */
  74181. task: AbstractAssetTask;
  74182. }
  74183. /**
  74184. * Class used to share progress information about assets loading
  74185. */
  74186. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74187. /**
  74188. * Defines the number of remaining tasks to process
  74189. */
  74190. remainingCount: number;
  74191. /**
  74192. * Defines the total number of tasks
  74193. */
  74194. totalCount: number;
  74195. /**
  74196. * Defines the task that was just processed
  74197. */
  74198. task: AbstractAssetTask;
  74199. /**
  74200. * Creates a AssetsProgressEvent
  74201. * @param remainingCount defines the number of remaining tasks to process
  74202. * @param totalCount defines the total number of tasks
  74203. * @param task defines the task that was just processed
  74204. */
  74205. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74206. }
  74207. /**
  74208. * Define a task used by AssetsManager to load meshes
  74209. */
  74210. export class MeshAssetTask extends AbstractAssetTask {
  74211. /**
  74212. * Defines the name of the task
  74213. */
  74214. name: string;
  74215. /**
  74216. * Defines the list of mesh's names you want to load
  74217. */
  74218. meshesNames: any;
  74219. /**
  74220. * Defines the root url to use as a base to load your meshes and associated resources
  74221. */
  74222. rootUrl: string;
  74223. /**
  74224. * Defines the filename or File of the scene to load from
  74225. */
  74226. sceneFilename: string | File;
  74227. /**
  74228. * Gets the list of loaded meshes
  74229. */
  74230. loadedMeshes: Array<AbstractMesh>;
  74231. /**
  74232. * Gets the list of loaded particle systems
  74233. */
  74234. loadedParticleSystems: Array<IParticleSystem>;
  74235. /**
  74236. * Gets the list of loaded skeletons
  74237. */
  74238. loadedSkeletons: Array<Skeleton>;
  74239. /**
  74240. * Gets the list of loaded animation groups
  74241. */
  74242. loadedAnimationGroups: Array<AnimationGroup>;
  74243. /**
  74244. * Callback called when the task is successful
  74245. */
  74246. onSuccess: (task: MeshAssetTask) => void;
  74247. /**
  74248. * Callback called when the task is successful
  74249. */
  74250. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74251. /**
  74252. * Creates a new MeshAssetTask
  74253. * @param name defines the name of the task
  74254. * @param meshesNames defines the list of mesh's names you want to load
  74255. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74256. * @param sceneFilename defines the filename or File of the scene to load from
  74257. */
  74258. constructor(
  74259. /**
  74260. * Defines the name of the task
  74261. */
  74262. name: string,
  74263. /**
  74264. * Defines the list of mesh's names you want to load
  74265. */
  74266. meshesNames: any,
  74267. /**
  74268. * Defines the root url to use as a base to load your meshes and associated resources
  74269. */
  74270. rootUrl: string,
  74271. /**
  74272. * Defines the filename or File of the scene to load from
  74273. */
  74274. sceneFilename: string | File);
  74275. /**
  74276. * Execute the current task
  74277. * @param scene defines the scene where you want your assets to be loaded
  74278. * @param onSuccess is a callback called when the task is successfully executed
  74279. * @param onError is a callback called if an error occurs
  74280. */
  74281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74282. }
  74283. /**
  74284. * Define a task used by AssetsManager to load text content
  74285. */
  74286. export class TextFileAssetTask extends AbstractAssetTask {
  74287. /**
  74288. * Defines the name of the task
  74289. */
  74290. name: string;
  74291. /**
  74292. * Defines the location of the file to load
  74293. */
  74294. url: string;
  74295. /**
  74296. * Gets the loaded text string
  74297. */
  74298. text: string;
  74299. /**
  74300. * Callback called when the task is successful
  74301. */
  74302. onSuccess: (task: TextFileAssetTask) => void;
  74303. /**
  74304. * Callback called when the task is successful
  74305. */
  74306. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74307. /**
  74308. * Creates a new TextFileAssetTask object
  74309. * @param name defines the name of the task
  74310. * @param url defines the location of the file to load
  74311. */
  74312. constructor(
  74313. /**
  74314. * Defines the name of the task
  74315. */
  74316. name: string,
  74317. /**
  74318. * Defines the location of the file to load
  74319. */
  74320. url: string);
  74321. /**
  74322. * Execute the current task
  74323. * @param scene defines the scene where you want your assets to be loaded
  74324. * @param onSuccess is a callback called when the task is successfully executed
  74325. * @param onError is a callback called if an error occurs
  74326. */
  74327. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74328. }
  74329. /**
  74330. * Define a task used by AssetsManager to load binary data
  74331. */
  74332. export class BinaryFileAssetTask extends AbstractAssetTask {
  74333. /**
  74334. * Defines the name of the task
  74335. */
  74336. name: string;
  74337. /**
  74338. * Defines the location of the file to load
  74339. */
  74340. url: string;
  74341. /**
  74342. * Gets the lodaded data (as an array buffer)
  74343. */
  74344. data: ArrayBuffer;
  74345. /**
  74346. * Callback called when the task is successful
  74347. */
  74348. onSuccess: (task: BinaryFileAssetTask) => void;
  74349. /**
  74350. * Callback called when the task is successful
  74351. */
  74352. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74353. /**
  74354. * Creates a new BinaryFileAssetTask object
  74355. * @param name defines the name of the new task
  74356. * @param url defines the location of the file to load
  74357. */
  74358. constructor(
  74359. /**
  74360. * Defines the name of the task
  74361. */
  74362. name: string,
  74363. /**
  74364. * Defines the location of the file to load
  74365. */
  74366. url: string);
  74367. /**
  74368. * Execute the current task
  74369. * @param scene defines the scene where you want your assets to be loaded
  74370. * @param onSuccess is a callback called when the task is successfully executed
  74371. * @param onError is a callback called if an error occurs
  74372. */
  74373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74374. }
  74375. /**
  74376. * Define a task used by AssetsManager to load images
  74377. */
  74378. export class ImageAssetTask extends AbstractAssetTask {
  74379. /**
  74380. * Defines the name of the task
  74381. */
  74382. name: string;
  74383. /**
  74384. * Defines the location of the image to load
  74385. */
  74386. url: string;
  74387. /**
  74388. * Gets the loaded images
  74389. */
  74390. image: HTMLImageElement;
  74391. /**
  74392. * Callback called when the task is successful
  74393. */
  74394. onSuccess: (task: ImageAssetTask) => void;
  74395. /**
  74396. * Callback called when the task is successful
  74397. */
  74398. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74399. /**
  74400. * Creates a new ImageAssetTask
  74401. * @param name defines the name of the task
  74402. * @param url defines the location of the image to load
  74403. */
  74404. constructor(
  74405. /**
  74406. * Defines the name of the task
  74407. */
  74408. name: string,
  74409. /**
  74410. * Defines the location of the image to load
  74411. */
  74412. url: string);
  74413. /**
  74414. * Execute the current task
  74415. * @param scene defines the scene where you want your assets to be loaded
  74416. * @param onSuccess is a callback called when the task is successfully executed
  74417. * @param onError is a callback called if an error occurs
  74418. */
  74419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74420. }
  74421. /**
  74422. * Defines the interface used by texture loading tasks
  74423. */
  74424. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74425. /**
  74426. * Gets the loaded texture
  74427. */
  74428. texture: TEX;
  74429. }
  74430. /**
  74431. * Define a task used by AssetsManager to load 2D textures
  74432. */
  74433. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74434. /**
  74435. * Defines the name of the task
  74436. */
  74437. name: string;
  74438. /**
  74439. * Defines the location of the file to load
  74440. */
  74441. url: string;
  74442. /**
  74443. * Defines if mipmap should not be generated (default is false)
  74444. */
  74445. noMipmap?: boolean | undefined;
  74446. /**
  74447. * Defines if texture must be inverted on Y axis (default is true)
  74448. */
  74449. invertY: boolean;
  74450. /**
  74451. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74452. */
  74453. samplingMode: number;
  74454. /**
  74455. * Gets the loaded texture
  74456. */
  74457. texture: Texture;
  74458. /**
  74459. * Callback called when the task is successful
  74460. */
  74461. onSuccess: (task: TextureAssetTask) => void;
  74462. /**
  74463. * Callback called when the task is successful
  74464. */
  74465. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74466. /**
  74467. * Creates a new TextureAssetTask object
  74468. * @param name defines the name of the task
  74469. * @param url defines the location of the file to load
  74470. * @param noMipmap defines if mipmap should not be generated (default is false)
  74471. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74472. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74473. */
  74474. constructor(
  74475. /**
  74476. * Defines the name of the task
  74477. */
  74478. name: string,
  74479. /**
  74480. * Defines the location of the file to load
  74481. */
  74482. url: string,
  74483. /**
  74484. * Defines if mipmap should not be generated (default is false)
  74485. */
  74486. noMipmap?: boolean | undefined,
  74487. /**
  74488. * Defines if texture must be inverted on Y axis (default is true)
  74489. */
  74490. invertY?: boolean,
  74491. /**
  74492. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74493. */
  74494. samplingMode?: number);
  74495. /**
  74496. * Execute the current task
  74497. * @param scene defines the scene where you want your assets to be loaded
  74498. * @param onSuccess is a callback called when the task is successfully executed
  74499. * @param onError is a callback called if an error occurs
  74500. */
  74501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74502. }
  74503. /**
  74504. * Define a task used by AssetsManager to load cube textures
  74505. */
  74506. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74507. /**
  74508. * Defines the name of the task
  74509. */
  74510. name: string;
  74511. /**
  74512. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74513. */
  74514. url: string;
  74515. /**
  74516. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74517. */
  74518. extensions?: string[] | undefined;
  74519. /**
  74520. * Defines if mipmaps should not be generated (default is false)
  74521. */
  74522. noMipmap?: boolean | undefined;
  74523. /**
  74524. * Defines the explicit list of files (undefined by default)
  74525. */
  74526. files?: string[] | undefined;
  74527. /**
  74528. * Gets the loaded texture
  74529. */
  74530. texture: CubeTexture;
  74531. /**
  74532. * Callback called when the task is successful
  74533. */
  74534. onSuccess: (task: CubeTextureAssetTask) => void;
  74535. /**
  74536. * Callback called when the task is successful
  74537. */
  74538. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74539. /**
  74540. * Creates a new CubeTextureAssetTask
  74541. * @param name defines the name of the task
  74542. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74543. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74544. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74545. * @param files defines the explicit list of files (undefined by default)
  74546. */
  74547. constructor(
  74548. /**
  74549. * Defines the name of the task
  74550. */
  74551. name: string,
  74552. /**
  74553. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74554. */
  74555. url: string,
  74556. /**
  74557. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74558. */
  74559. extensions?: string[] | undefined,
  74560. /**
  74561. * Defines if mipmaps should not be generated (default is false)
  74562. */
  74563. noMipmap?: boolean | undefined,
  74564. /**
  74565. * Defines the explicit list of files (undefined by default)
  74566. */
  74567. files?: string[] | undefined);
  74568. /**
  74569. * Execute the current task
  74570. * @param scene defines the scene where you want your assets to be loaded
  74571. * @param onSuccess is a callback called when the task is successfully executed
  74572. * @param onError is a callback called if an error occurs
  74573. */
  74574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74575. }
  74576. /**
  74577. * Define a task used by AssetsManager to load HDR cube textures
  74578. */
  74579. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74580. /**
  74581. * Defines the name of the task
  74582. */
  74583. name: string;
  74584. /**
  74585. * Defines the location of the file to load
  74586. */
  74587. url: string;
  74588. /**
  74589. * Defines the desired size (the more it increases the longer the generation will be)
  74590. */
  74591. size: number;
  74592. /**
  74593. * Defines if mipmaps should not be generated (default is false)
  74594. */
  74595. noMipmap: boolean;
  74596. /**
  74597. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74598. */
  74599. generateHarmonics: boolean;
  74600. /**
  74601. * 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)
  74602. */
  74603. gammaSpace: boolean;
  74604. /**
  74605. * Internal Use Only
  74606. */
  74607. reserved: boolean;
  74608. /**
  74609. * Gets the loaded texture
  74610. */
  74611. texture: HDRCubeTexture;
  74612. /**
  74613. * Callback called when the task is successful
  74614. */
  74615. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74616. /**
  74617. * Callback called when the task is successful
  74618. */
  74619. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74620. /**
  74621. * Creates a new HDRCubeTextureAssetTask object
  74622. * @param name defines the name of the task
  74623. * @param url defines the location of the file to load
  74624. * @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.
  74625. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74626. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74627. * @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)
  74628. * @param reserved Internal use only
  74629. */
  74630. constructor(
  74631. /**
  74632. * Defines the name of the task
  74633. */
  74634. name: string,
  74635. /**
  74636. * Defines the location of the file to load
  74637. */
  74638. url: string,
  74639. /**
  74640. * Defines the desired size (the more it increases the longer the generation will be)
  74641. */
  74642. size: number,
  74643. /**
  74644. * Defines if mipmaps should not be generated (default is false)
  74645. */
  74646. noMipmap?: boolean,
  74647. /**
  74648. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74649. */
  74650. generateHarmonics?: boolean,
  74651. /**
  74652. * 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)
  74653. */
  74654. gammaSpace?: boolean,
  74655. /**
  74656. * Internal Use Only
  74657. */
  74658. reserved?: boolean);
  74659. /**
  74660. * Execute the current task
  74661. * @param scene defines the scene where you want your assets to be loaded
  74662. * @param onSuccess is a callback called when the task is successfully executed
  74663. * @param onError is a callback called if an error occurs
  74664. */
  74665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74666. }
  74667. /**
  74668. * Define a task used by AssetsManager to load Equirectangular cube textures
  74669. */
  74670. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74671. /**
  74672. * Defines the name of the task
  74673. */
  74674. name: string;
  74675. /**
  74676. * Defines the location of the file to load
  74677. */
  74678. url: string;
  74679. /**
  74680. * Defines the desired size (the more it increases the longer the generation will be)
  74681. */
  74682. size: number;
  74683. /**
  74684. * Defines if mipmaps should not be generated (default is false)
  74685. */
  74686. noMipmap: boolean;
  74687. /**
  74688. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74689. * but the standard material would require them in Gamma space) (default is true)
  74690. */
  74691. gammaSpace: boolean;
  74692. /**
  74693. * Gets the loaded texture
  74694. */
  74695. texture: EquiRectangularCubeTexture;
  74696. /**
  74697. * Callback called when the task is successful
  74698. */
  74699. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74700. /**
  74701. * Callback called when the task is successful
  74702. */
  74703. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74704. /**
  74705. * Creates a new EquiRectangularCubeTextureAssetTask object
  74706. * @param name defines the name of the task
  74707. * @param url defines the location of the file to load
  74708. * @param size defines the desired size (the more it increases the longer the generation will be)
  74709. * If the size is omitted this implies you are using a preprocessed cubemap.
  74710. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74711. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74712. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74713. * (default is true)
  74714. */
  74715. constructor(
  74716. /**
  74717. * Defines the name of the task
  74718. */
  74719. name: string,
  74720. /**
  74721. * Defines the location of the file to load
  74722. */
  74723. url: string,
  74724. /**
  74725. * Defines the desired size (the more it increases the longer the generation will be)
  74726. */
  74727. size: number,
  74728. /**
  74729. * Defines if mipmaps should not be generated (default is false)
  74730. */
  74731. noMipmap?: boolean,
  74732. /**
  74733. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74734. * but the standard material would require them in Gamma space) (default is true)
  74735. */
  74736. gammaSpace?: boolean);
  74737. /**
  74738. * Execute the current task
  74739. * @param scene defines the scene where you want your assets to be loaded
  74740. * @param onSuccess is a callback called when the task is successfully executed
  74741. * @param onError is a callback called if an error occurs
  74742. */
  74743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74744. }
  74745. /**
  74746. * This class can be used to easily import assets into a scene
  74747. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74748. */
  74749. export class AssetsManager {
  74750. private _scene;
  74751. private _isLoading;
  74752. protected _tasks: AbstractAssetTask[];
  74753. protected _waitingTasksCount: number;
  74754. protected _totalTasksCount: number;
  74755. /**
  74756. * Callback called when all tasks are processed
  74757. */
  74758. onFinish: (tasks: AbstractAssetTask[]) => void;
  74759. /**
  74760. * Callback called when a task is successful
  74761. */
  74762. onTaskSuccess: (task: AbstractAssetTask) => void;
  74763. /**
  74764. * Callback called when a task had an error
  74765. */
  74766. onTaskError: (task: AbstractAssetTask) => void;
  74767. /**
  74768. * Callback called when a task is done (whatever the result is)
  74769. */
  74770. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74771. /**
  74772. * Observable called when all tasks are processed
  74773. */
  74774. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74775. /**
  74776. * Observable called when a task had an error
  74777. */
  74778. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74779. /**
  74780. * Observable called when all tasks were executed
  74781. */
  74782. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74783. /**
  74784. * Observable called when a task is done (whatever the result is)
  74785. */
  74786. onProgressObservable: Observable<IAssetsProgressEvent>;
  74787. /**
  74788. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74789. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74790. */
  74791. useDefaultLoadingScreen: boolean;
  74792. /**
  74793. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74794. * when all assets have been downloaded.
  74795. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74796. */
  74797. autoHideLoadingUI: boolean;
  74798. /**
  74799. * Creates a new AssetsManager
  74800. * @param scene defines the scene to work on
  74801. */
  74802. constructor(scene: Scene);
  74803. /**
  74804. * Add a MeshAssetTask to the list of active tasks
  74805. * @param taskName defines the name of the new task
  74806. * @param meshesNames defines the name of meshes to load
  74807. * @param rootUrl defines the root url to use to locate files
  74808. * @param sceneFilename defines the filename of the scene file
  74809. * @returns a new MeshAssetTask object
  74810. */
  74811. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74812. /**
  74813. * Add a TextFileAssetTask to the list of active tasks
  74814. * @param taskName defines the name of the new task
  74815. * @param url defines the url of the file to load
  74816. * @returns a new TextFileAssetTask object
  74817. */
  74818. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74819. /**
  74820. * Add a BinaryFileAssetTask to the list of active tasks
  74821. * @param taskName defines the name of the new task
  74822. * @param url defines the url of the file to load
  74823. * @returns a new BinaryFileAssetTask object
  74824. */
  74825. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74826. /**
  74827. * Add a ImageAssetTask to the list of active tasks
  74828. * @param taskName defines the name of the new task
  74829. * @param url defines the url of the file to load
  74830. * @returns a new ImageAssetTask object
  74831. */
  74832. addImageTask(taskName: string, url: string): ImageAssetTask;
  74833. /**
  74834. * Add a TextureAssetTask to the list of active tasks
  74835. * @param taskName defines the name of the new task
  74836. * @param url defines the url of the file to load
  74837. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74838. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74839. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74840. * @returns a new TextureAssetTask object
  74841. */
  74842. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74843. /**
  74844. * Add a CubeTextureAssetTask to the list of active tasks
  74845. * @param taskName defines the name of the new task
  74846. * @param url defines the url of the file to load
  74847. * @param extensions defines the extension to use to load the cube map (can be null)
  74848. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74849. * @param files defines the list of files to load (can be null)
  74850. * @returns a new CubeTextureAssetTask object
  74851. */
  74852. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74853. /**
  74854. *
  74855. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74856. * @param taskName defines the name of the new task
  74857. * @param url defines the url of the file to load
  74858. * @param size defines the size you want for the cubemap (can be null)
  74859. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74860. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74861. * @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)
  74862. * @param reserved Internal use only
  74863. * @returns a new HDRCubeTextureAssetTask object
  74864. */
  74865. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74866. /**
  74867. *
  74868. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74869. * @param taskName defines the name of the new task
  74870. * @param url defines the url of the file to load
  74871. * @param size defines the size you want for the cubemap (can be null)
  74872. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74873. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74874. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74875. * @returns a new EquiRectangularCubeTextureAssetTask object
  74876. */
  74877. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74878. /**
  74879. * Remove a task from the assets manager.
  74880. * @param task the task to remove
  74881. */
  74882. removeTask(task: AbstractAssetTask): void;
  74883. private _decreaseWaitingTasksCount;
  74884. private _runTask;
  74885. /**
  74886. * Reset the AssetsManager and remove all tasks
  74887. * @return the current instance of the AssetsManager
  74888. */
  74889. reset(): AssetsManager;
  74890. /**
  74891. * Start the loading process
  74892. * @return the current instance of the AssetsManager
  74893. */
  74894. load(): AssetsManager;
  74895. /**
  74896. * Start the loading process as an async operation
  74897. * @return a promise returning the list of failed tasks
  74898. */
  74899. loadAsync(): Promise<void>;
  74900. }
  74901. }
  74902. declare module "babylonjs/Misc/deferred" {
  74903. /**
  74904. * Wrapper class for promise with external resolve and reject.
  74905. */
  74906. export class Deferred<T> {
  74907. /**
  74908. * The promise associated with this deferred object.
  74909. */
  74910. readonly promise: Promise<T>;
  74911. private _resolve;
  74912. private _reject;
  74913. /**
  74914. * The resolve method of the promise associated with this deferred object.
  74915. */
  74916. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74917. /**
  74918. * The reject method of the promise associated with this deferred object.
  74919. */
  74920. get reject(): (reason?: any) => void;
  74921. /**
  74922. * Constructor for this deferred object.
  74923. */
  74924. constructor();
  74925. }
  74926. }
  74927. declare module "babylonjs/Misc/meshExploder" {
  74928. import { Mesh } from "babylonjs/Meshes/mesh";
  74929. /**
  74930. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74931. */
  74932. export class MeshExploder {
  74933. private _centerMesh;
  74934. private _meshes;
  74935. private _meshesOrigins;
  74936. private _toCenterVectors;
  74937. private _scaledDirection;
  74938. private _newPosition;
  74939. private _centerPosition;
  74940. /**
  74941. * Explodes meshes from a center mesh.
  74942. * @param meshes The meshes to explode.
  74943. * @param centerMesh The mesh to be center of explosion.
  74944. */
  74945. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74946. private _setCenterMesh;
  74947. /**
  74948. * Get class name
  74949. * @returns "MeshExploder"
  74950. */
  74951. getClassName(): string;
  74952. /**
  74953. * "Exploded meshes"
  74954. * @returns Array of meshes with the centerMesh at index 0.
  74955. */
  74956. getMeshes(): Array<Mesh>;
  74957. /**
  74958. * Explodes meshes giving a specific direction
  74959. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74960. */
  74961. explode(direction?: number): void;
  74962. }
  74963. }
  74964. declare module "babylonjs/Misc/filesInput" {
  74965. import { Engine } from "babylonjs/Engines/engine";
  74966. import { Scene } from "babylonjs/scene";
  74967. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  74968. /**
  74969. * Class used to help managing file picking and drag'n'drop
  74970. */
  74971. export class FilesInput {
  74972. /**
  74973. * List of files ready to be loaded
  74974. */
  74975. static get FilesToLoad(): {
  74976. [key: string]: File;
  74977. };
  74978. /**
  74979. * Callback called when a file is processed
  74980. */
  74981. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  74982. private _engine;
  74983. private _currentScene;
  74984. private _sceneLoadedCallback;
  74985. private _progressCallback;
  74986. private _additionalRenderLoopLogicCallback;
  74987. private _textureLoadingCallback;
  74988. private _startingProcessingFilesCallback;
  74989. private _onReloadCallback;
  74990. private _errorCallback;
  74991. private _elementToMonitor;
  74992. private _sceneFileToLoad;
  74993. private _filesToLoad;
  74994. /**
  74995. * Creates a new FilesInput
  74996. * @param engine defines the rendering engine
  74997. * @param scene defines the hosting scene
  74998. * @param sceneLoadedCallback callback called when scene is loaded
  74999. * @param progressCallback callback called to track progress
  75000. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75001. * @param textureLoadingCallback callback called when a texture is loading
  75002. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75003. * @param onReloadCallback callback called when a reload is requested
  75004. * @param errorCallback callback call if an error occurs
  75005. */
  75006. 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);
  75007. private _dragEnterHandler;
  75008. private _dragOverHandler;
  75009. private _dropHandler;
  75010. /**
  75011. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75012. * @param elementToMonitor defines the DOM element to track
  75013. */
  75014. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75015. /**
  75016. * Release all associated resources
  75017. */
  75018. dispose(): void;
  75019. private renderFunction;
  75020. private drag;
  75021. private drop;
  75022. private _traverseFolder;
  75023. private _processFiles;
  75024. /**
  75025. * Load files from a drop event
  75026. * @param event defines the drop event to use as source
  75027. */
  75028. loadFiles(event: any): void;
  75029. private _processReload;
  75030. /**
  75031. * Reload the current scene from the loaded files
  75032. */
  75033. reload(): void;
  75034. }
  75035. }
  75036. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75037. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75038. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75039. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75040. }
  75041. declare module "babylonjs/Misc/sceneOptimizer" {
  75042. import { Scene, IDisposable } from "babylonjs/scene";
  75043. import { Observable } from "babylonjs/Misc/observable";
  75044. /**
  75045. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75046. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75047. */
  75048. export class SceneOptimization {
  75049. /**
  75050. * Defines the priority of this optimization (0 by default which means first in the list)
  75051. */
  75052. priority: number;
  75053. /**
  75054. * Gets a string describing the action executed by the current optimization
  75055. * @returns description string
  75056. */
  75057. getDescription(): string;
  75058. /**
  75059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75060. * @param scene defines the current scene where to apply this optimization
  75061. * @param optimizer defines the current optimizer
  75062. * @returns true if everything that can be done was applied
  75063. */
  75064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75065. /**
  75066. * Creates the SceneOptimization object
  75067. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75068. * @param desc defines the description associated with the optimization
  75069. */
  75070. constructor(
  75071. /**
  75072. * Defines the priority of this optimization (0 by default which means first in the list)
  75073. */
  75074. priority?: number);
  75075. }
  75076. /**
  75077. * Defines an optimization used to reduce the size of render target textures
  75078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75079. */
  75080. export class TextureOptimization extends SceneOptimization {
  75081. /**
  75082. * Defines the priority of this optimization (0 by default which means first in the list)
  75083. */
  75084. priority: number;
  75085. /**
  75086. * 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
  75087. */
  75088. maximumSize: number;
  75089. /**
  75090. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75091. */
  75092. step: number;
  75093. /**
  75094. * Gets a string describing the action executed by the current optimization
  75095. * @returns description string
  75096. */
  75097. getDescription(): string;
  75098. /**
  75099. * Creates the TextureOptimization object
  75100. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75101. * @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
  75102. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75103. */
  75104. constructor(
  75105. /**
  75106. * Defines the priority of this optimization (0 by default which means first in the list)
  75107. */
  75108. priority?: number,
  75109. /**
  75110. * 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
  75111. */
  75112. maximumSize?: number,
  75113. /**
  75114. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75115. */
  75116. step?: number);
  75117. /**
  75118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75119. * @param scene defines the current scene where to apply this optimization
  75120. * @param optimizer defines the current optimizer
  75121. * @returns true if everything that can be done was applied
  75122. */
  75123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75124. }
  75125. /**
  75126. * Defines an optimization used to increase or decrease the rendering resolution
  75127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75128. */
  75129. export class HardwareScalingOptimization extends SceneOptimization {
  75130. /**
  75131. * Defines the priority of this optimization (0 by default which means first in the list)
  75132. */
  75133. priority: number;
  75134. /**
  75135. * Defines the maximum scale to use (2 by default)
  75136. */
  75137. maximumScale: number;
  75138. /**
  75139. * Defines the step to use between two passes (0.5 by default)
  75140. */
  75141. step: number;
  75142. private _currentScale;
  75143. private _directionOffset;
  75144. /**
  75145. * Gets a string describing the action executed by the current optimization
  75146. * @return description string
  75147. */
  75148. getDescription(): string;
  75149. /**
  75150. * Creates the HardwareScalingOptimization object
  75151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75152. * @param maximumScale defines the maximum scale to use (2 by default)
  75153. * @param step defines the step to use between two passes (0.5 by default)
  75154. */
  75155. constructor(
  75156. /**
  75157. * Defines the priority of this optimization (0 by default which means first in the list)
  75158. */
  75159. priority?: number,
  75160. /**
  75161. * Defines the maximum scale to use (2 by default)
  75162. */
  75163. maximumScale?: number,
  75164. /**
  75165. * Defines the step to use between two passes (0.5 by default)
  75166. */
  75167. step?: number);
  75168. /**
  75169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75170. * @param scene defines the current scene where to apply this optimization
  75171. * @param optimizer defines the current optimizer
  75172. * @returns true if everything that can be done was applied
  75173. */
  75174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75175. }
  75176. /**
  75177. * Defines an optimization used to remove shadows
  75178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75179. */
  75180. export class ShadowsOptimization extends SceneOptimization {
  75181. /**
  75182. * Gets a string describing the action executed by the current optimization
  75183. * @return description string
  75184. */
  75185. getDescription(): string;
  75186. /**
  75187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75188. * @param scene defines the current scene where to apply this optimization
  75189. * @param optimizer defines the current optimizer
  75190. * @returns true if everything that can be done was applied
  75191. */
  75192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75193. }
  75194. /**
  75195. * Defines an optimization used to turn post-processes off
  75196. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75197. */
  75198. export class PostProcessesOptimization extends SceneOptimization {
  75199. /**
  75200. * Gets a string describing the action executed by the current optimization
  75201. * @return description string
  75202. */
  75203. getDescription(): string;
  75204. /**
  75205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75206. * @param scene defines the current scene where to apply this optimization
  75207. * @param optimizer defines the current optimizer
  75208. * @returns true if everything that can be done was applied
  75209. */
  75210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75211. }
  75212. /**
  75213. * Defines an optimization used to turn lens flares off
  75214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75215. */
  75216. export class LensFlaresOptimization extends SceneOptimization {
  75217. /**
  75218. * Gets a string describing the action executed by the current optimization
  75219. * @return description string
  75220. */
  75221. getDescription(): string;
  75222. /**
  75223. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75224. * @param scene defines the current scene where to apply this optimization
  75225. * @param optimizer defines the current optimizer
  75226. * @returns true if everything that can be done was applied
  75227. */
  75228. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75229. }
  75230. /**
  75231. * Defines an optimization based on user defined callback.
  75232. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75233. */
  75234. export class CustomOptimization extends SceneOptimization {
  75235. /**
  75236. * Callback called to apply the custom optimization.
  75237. */
  75238. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75239. /**
  75240. * Callback called to get custom description
  75241. */
  75242. onGetDescription: () => string;
  75243. /**
  75244. * Gets a string describing the action executed by the current optimization
  75245. * @returns description string
  75246. */
  75247. getDescription(): string;
  75248. /**
  75249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75250. * @param scene defines the current scene where to apply this optimization
  75251. * @param optimizer defines the current optimizer
  75252. * @returns true if everything that can be done was applied
  75253. */
  75254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75255. }
  75256. /**
  75257. * Defines an optimization used to turn particles off
  75258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75259. */
  75260. export class ParticlesOptimization extends SceneOptimization {
  75261. /**
  75262. * Gets a string describing the action executed by the current optimization
  75263. * @return description string
  75264. */
  75265. getDescription(): string;
  75266. /**
  75267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75268. * @param scene defines the current scene where to apply this optimization
  75269. * @param optimizer defines the current optimizer
  75270. * @returns true if everything that can be done was applied
  75271. */
  75272. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75273. }
  75274. /**
  75275. * Defines an optimization used to turn render targets off
  75276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75277. */
  75278. export class RenderTargetsOptimization extends SceneOptimization {
  75279. /**
  75280. * Gets a string describing the action executed by the current optimization
  75281. * @return description string
  75282. */
  75283. getDescription(): string;
  75284. /**
  75285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75286. * @param scene defines the current scene where to apply this optimization
  75287. * @param optimizer defines the current optimizer
  75288. * @returns true if everything that can be done was applied
  75289. */
  75290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75291. }
  75292. /**
  75293. * Defines an optimization used to merge meshes with compatible materials
  75294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75295. */
  75296. export class MergeMeshesOptimization extends SceneOptimization {
  75297. private static _UpdateSelectionTree;
  75298. /**
  75299. * Gets or sets a boolean which defines if optimization octree has to be updated
  75300. */
  75301. static get UpdateSelectionTree(): boolean;
  75302. /**
  75303. * Gets or sets a boolean which defines if optimization octree has to be updated
  75304. */
  75305. static set UpdateSelectionTree(value: boolean);
  75306. /**
  75307. * Gets a string describing the action executed by the current optimization
  75308. * @return description string
  75309. */
  75310. getDescription(): string;
  75311. private _canBeMerged;
  75312. /**
  75313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75314. * @param scene defines the current scene where to apply this optimization
  75315. * @param optimizer defines the current optimizer
  75316. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75317. * @returns true if everything that can be done was applied
  75318. */
  75319. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75320. }
  75321. /**
  75322. * Defines a list of options used by SceneOptimizer
  75323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75324. */
  75325. export class SceneOptimizerOptions {
  75326. /**
  75327. * Defines the target frame rate to reach (60 by default)
  75328. */
  75329. targetFrameRate: number;
  75330. /**
  75331. * Defines the interval between two checkes (2000ms by default)
  75332. */
  75333. trackerDuration: number;
  75334. /**
  75335. * Gets the list of optimizations to apply
  75336. */
  75337. optimizations: SceneOptimization[];
  75338. /**
  75339. * Creates a new list of options used by SceneOptimizer
  75340. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75341. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75342. */
  75343. constructor(
  75344. /**
  75345. * Defines the target frame rate to reach (60 by default)
  75346. */
  75347. targetFrameRate?: number,
  75348. /**
  75349. * Defines the interval between two checkes (2000ms by default)
  75350. */
  75351. trackerDuration?: number);
  75352. /**
  75353. * Add a new optimization
  75354. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75355. * @returns the current SceneOptimizerOptions
  75356. */
  75357. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75358. /**
  75359. * Add a new custom optimization
  75360. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75361. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75362. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75363. * @returns the current SceneOptimizerOptions
  75364. */
  75365. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75366. /**
  75367. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75368. * @param targetFrameRate defines the target frame rate (60 by default)
  75369. * @returns a SceneOptimizerOptions object
  75370. */
  75371. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75372. /**
  75373. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75374. * @param targetFrameRate defines the target frame rate (60 by default)
  75375. * @returns a SceneOptimizerOptions object
  75376. */
  75377. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75378. /**
  75379. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75380. * @param targetFrameRate defines the target frame rate (60 by default)
  75381. * @returns a SceneOptimizerOptions object
  75382. */
  75383. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75384. }
  75385. /**
  75386. * Class used to run optimizations in order to reach a target frame rate
  75387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75388. */
  75389. export class SceneOptimizer implements IDisposable {
  75390. private _isRunning;
  75391. private _options;
  75392. private _scene;
  75393. private _currentPriorityLevel;
  75394. private _targetFrameRate;
  75395. private _trackerDuration;
  75396. private _currentFrameRate;
  75397. private _sceneDisposeObserver;
  75398. private _improvementMode;
  75399. /**
  75400. * Defines an observable called when the optimizer reaches the target frame rate
  75401. */
  75402. onSuccessObservable: Observable<SceneOptimizer>;
  75403. /**
  75404. * Defines an observable called when the optimizer enables an optimization
  75405. */
  75406. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75407. /**
  75408. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75409. */
  75410. onFailureObservable: Observable<SceneOptimizer>;
  75411. /**
  75412. * Gets a boolean indicating if the optimizer is in improvement mode
  75413. */
  75414. get isInImprovementMode(): boolean;
  75415. /**
  75416. * Gets the current priority level (0 at start)
  75417. */
  75418. get currentPriorityLevel(): number;
  75419. /**
  75420. * Gets the current frame rate checked by the SceneOptimizer
  75421. */
  75422. get currentFrameRate(): number;
  75423. /**
  75424. * Gets or sets the current target frame rate (60 by default)
  75425. */
  75426. get targetFrameRate(): number;
  75427. /**
  75428. * Gets or sets the current target frame rate (60 by default)
  75429. */
  75430. set targetFrameRate(value: number);
  75431. /**
  75432. * Gets or sets the current interval between two checks (every 2000ms by default)
  75433. */
  75434. get trackerDuration(): number;
  75435. /**
  75436. * Gets or sets the current interval between two checks (every 2000ms by default)
  75437. */
  75438. set trackerDuration(value: number);
  75439. /**
  75440. * Gets the list of active optimizations
  75441. */
  75442. get optimizations(): SceneOptimization[];
  75443. /**
  75444. * Creates a new SceneOptimizer
  75445. * @param scene defines the scene to work on
  75446. * @param options defines the options to use with the SceneOptimizer
  75447. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75448. * @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)
  75449. */
  75450. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75451. /**
  75452. * Stops the current optimizer
  75453. */
  75454. stop(): void;
  75455. /**
  75456. * Reset the optimizer to initial step (current priority level = 0)
  75457. */
  75458. reset(): void;
  75459. /**
  75460. * Start the optimizer. By default it will try to reach a specific framerate
  75461. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75462. */
  75463. start(): void;
  75464. private _checkCurrentState;
  75465. /**
  75466. * Release all resources
  75467. */
  75468. dispose(): void;
  75469. /**
  75470. * Helper function to create a SceneOptimizer with one single line of code
  75471. * @param scene defines the scene to work on
  75472. * @param options defines the options to use with the SceneOptimizer
  75473. * @param onSuccess defines a callback to call on success
  75474. * @param onFailure defines a callback to call on failure
  75475. * @returns the new SceneOptimizer object
  75476. */
  75477. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75478. }
  75479. }
  75480. declare module "babylonjs/Misc/sceneSerializer" {
  75481. import { Scene } from "babylonjs/scene";
  75482. /**
  75483. * Class used to serialize a scene into a string
  75484. */
  75485. export class SceneSerializer {
  75486. /**
  75487. * Clear cache used by a previous serialization
  75488. */
  75489. static ClearCache(): void;
  75490. /**
  75491. * Serialize a scene into a JSON compatible object
  75492. * @param scene defines the scene to serialize
  75493. * @returns a JSON compatible object
  75494. */
  75495. static Serialize(scene: Scene): any;
  75496. /**
  75497. * Serialize a mesh into a JSON compatible object
  75498. * @param toSerialize defines the mesh to serialize
  75499. * @param withParents defines if parents must be serialized as well
  75500. * @param withChildren defines if children must be serialized as well
  75501. * @returns a JSON compatible object
  75502. */
  75503. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75504. }
  75505. }
  75506. declare module "babylonjs/Misc/textureTools" {
  75507. import { Texture } from "babylonjs/Materials/Textures/texture";
  75508. /**
  75509. * Class used to host texture specific utilities
  75510. */
  75511. export class TextureTools {
  75512. /**
  75513. * Uses the GPU to create a copy texture rescaled at a given size
  75514. * @param texture Texture to copy from
  75515. * @param width defines the desired width
  75516. * @param height defines the desired height
  75517. * @param useBilinearMode defines if bilinear mode has to be used
  75518. * @return the generated texture
  75519. */
  75520. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75521. }
  75522. }
  75523. declare module "babylonjs/Misc/videoRecorder" {
  75524. import { Nullable } from "babylonjs/types";
  75525. import { Engine } from "babylonjs/Engines/engine";
  75526. /**
  75527. * This represents the different options available for the video capture.
  75528. */
  75529. export interface VideoRecorderOptions {
  75530. /** Defines the mime type of the video. */
  75531. mimeType: string;
  75532. /** Defines the FPS the video should be recorded at. */
  75533. fps: number;
  75534. /** Defines the chunk size for the recording data. */
  75535. recordChunckSize: number;
  75536. /** The audio tracks to attach to the recording. */
  75537. audioTracks?: MediaStreamTrack[];
  75538. }
  75539. /**
  75540. * This can help with recording videos from BabylonJS.
  75541. * This is based on the available WebRTC functionalities of the browser.
  75542. *
  75543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  75544. */
  75545. export class VideoRecorder {
  75546. private static readonly _defaultOptions;
  75547. /**
  75548. * Returns whether or not the VideoRecorder is available in your browser.
  75549. * @param engine Defines the Babylon Engine.
  75550. * @returns true if supported otherwise false.
  75551. */
  75552. static IsSupported(engine: Engine): boolean;
  75553. private readonly _options;
  75554. private _canvas;
  75555. private _mediaRecorder;
  75556. private _recordedChunks;
  75557. private _fileName;
  75558. private _resolve;
  75559. private _reject;
  75560. /**
  75561. * True when a recording is already in progress.
  75562. */
  75563. get isRecording(): boolean;
  75564. /**
  75565. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75566. * @param engine Defines the BabylonJS Engine you wish to record.
  75567. * @param options Defines options that can be used to customize the capture.
  75568. */
  75569. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75570. /**
  75571. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75572. */
  75573. stopRecording(): void;
  75574. /**
  75575. * Starts recording the canvas for a max duration specified in parameters.
  75576. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75577. * If null no automatic download will start and you can rely on the promise to get the data back.
  75578. * @param maxDuration Defines the maximum recording time in seconds.
  75579. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75580. * @return A promise callback at the end of the recording with the video data in Blob.
  75581. */
  75582. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75583. /**
  75584. * Releases internal resources used during the recording.
  75585. */
  75586. dispose(): void;
  75587. private _handleDataAvailable;
  75588. private _handleError;
  75589. private _handleStop;
  75590. }
  75591. }
  75592. declare module "babylonjs/Misc/screenshotTools" {
  75593. import { Camera } from "babylonjs/Cameras/camera";
  75594. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  75595. import { Engine } from "babylonjs/Engines/engine";
  75596. /**
  75597. * Class containing a set of static utilities functions for screenshots
  75598. */
  75599. export class ScreenshotTools {
  75600. /**
  75601. * Captures a screenshot of the current rendering
  75602. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75603. * @param engine defines the rendering engine
  75604. * @param camera defines the source camera
  75605. * @param size This parameter can be set to a single number or to an object with the
  75606. * following (optional) properties: precision, width, height. If a single number is passed,
  75607. * it will be used for both width and height. If an object is passed, the screenshot size
  75608. * will be derived from the parameters. The precision property is a multiplier allowing
  75609. * rendering at a higher or lower resolution
  75610. * @param successCallback defines the callback receives a single parameter which contains the
  75611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75612. * src parameter of an <img> to display it
  75613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75614. * Check your browser for supported MIME types
  75615. */
  75616. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75617. /**
  75618. * Captures a screenshot of the current rendering
  75619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75620. * @param engine defines the rendering engine
  75621. * @param camera defines the source camera
  75622. * @param size This parameter can be set to a single number or to an object with the
  75623. * following (optional) properties: precision, width, height. If a single number is passed,
  75624. * it will be used for both width and height. If an object is passed, the screenshot size
  75625. * will be derived from the parameters. The precision property is a multiplier allowing
  75626. * rendering at a higher or lower resolution
  75627. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75628. * Check your browser for supported MIME types
  75629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75630. * to the src parameter of an <img> to display it
  75631. */
  75632. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75633. /**
  75634. * Generates an image screenshot from the specified camera.
  75635. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75636. * @param engine The engine to use for rendering
  75637. * @param camera The camera to use for rendering
  75638. * @param size This parameter can be set to a single number or to an object with the
  75639. * following (optional) properties: precision, width, height. If a single number is passed,
  75640. * it will be used for both width and height. If an object is passed, the screenshot size
  75641. * will be derived from the parameters. The precision property is a multiplier allowing
  75642. * rendering at a higher or lower resolution
  75643. * @param successCallback The callback receives a single parameter which contains the
  75644. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75645. * src parameter of an <img> to display it
  75646. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75647. * Check your browser for supported MIME types
  75648. * @param samples Texture samples (default: 1)
  75649. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75650. * @param fileName A name for for the downloaded file.
  75651. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75652. */
  75653. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  75654. /**
  75655. * Generates an image screenshot from the specified camera.
  75656. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75657. * @param engine The engine to use for rendering
  75658. * @param camera The camera to use for rendering
  75659. * @param size This parameter can be set to a single number or to an object with the
  75660. * following (optional) properties: precision, width, height. If a single number is passed,
  75661. * it will be used for both width and height. If an object is passed, the screenshot size
  75662. * will be derived from the parameters. The precision property is a multiplier allowing
  75663. * rendering at a higher or lower resolution
  75664. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75665. * Check your browser for supported MIME types
  75666. * @param samples Texture samples (default: 1)
  75667. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75668. * @param fileName A name for for the downloaded file.
  75669. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75670. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75671. * to the src parameter of an <img> to display it
  75672. */
  75673. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75674. /**
  75675. * Gets height and width for screenshot size
  75676. * @private
  75677. */
  75678. private static _getScreenshotSize;
  75679. }
  75680. }
  75681. declare module "babylonjs/Misc/dataReader" {
  75682. /**
  75683. * Interface for a data buffer
  75684. */
  75685. export interface IDataBuffer {
  75686. /**
  75687. * Reads bytes from the data buffer.
  75688. * @param byteOffset The byte offset to read
  75689. * @param byteLength The byte length to read
  75690. * @returns A promise that resolves when the bytes are read
  75691. */
  75692. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75693. /**
  75694. * The byte length of the buffer.
  75695. */
  75696. readonly byteLength: number;
  75697. }
  75698. /**
  75699. * Utility class for reading from a data buffer
  75700. */
  75701. export class DataReader {
  75702. /**
  75703. * The data buffer associated with this data reader.
  75704. */
  75705. readonly buffer: IDataBuffer;
  75706. /**
  75707. * The current byte offset from the beginning of the data buffer.
  75708. */
  75709. byteOffset: number;
  75710. private _dataView;
  75711. private _dataByteOffset;
  75712. /**
  75713. * Constructor
  75714. * @param buffer The buffer to read
  75715. */
  75716. constructor(buffer: IDataBuffer);
  75717. /**
  75718. * Loads the given byte length.
  75719. * @param byteLength The byte length to load
  75720. * @returns A promise that resolves when the load is complete
  75721. */
  75722. loadAsync(byteLength: number): Promise<void>;
  75723. /**
  75724. * Read a unsigned 32-bit integer from the currently loaded data range.
  75725. * @returns The 32-bit integer read
  75726. */
  75727. readUint32(): number;
  75728. /**
  75729. * Read a byte array from the currently loaded data range.
  75730. * @param byteLength The byte length to read
  75731. * @returns The byte array read
  75732. */
  75733. readUint8Array(byteLength: number): Uint8Array;
  75734. /**
  75735. * Read a string from the currently loaded data range.
  75736. * @param byteLength The byte length to read
  75737. * @returns The string read
  75738. */
  75739. readString(byteLength: number): string;
  75740. /**
  75741. * Skips the given byte length the currently loaded data range.
  75742. * @param byteLength The byte length to skip
  75743. */
  75744. skipBytes(byteLength: number): void;
  75745. }
  75746. }
  75747. declare module "babylonjs/Misc/dataStorage" {
  75748. /**
  75749. * Class for storing data to local storage if available or in-memory storage otherwise
  75750. */
  75751. export class DataStorage {
  75752. private static _Storage;
  75753. private static _GetStorage;
  75754. /**
  75755. * Reads a string from the data storage
  75756. * @param key The key to read
  75757. * @param defaultValue The value if the key doesn't exist
  75758. * @returns The string value
  75759. */
  75760. static ReadString(key: string, defaultValue: string): string;
  75761. /**
  75762. * Writes a string to the data storage
  75763. * @param key The key to write
  75764. * @param value The value to write
  75765. */
  75766. static WriteString(key: string, value: string): void;
  75767. /**
  75768. * Reads a boolean from the data storage
  75769. * @param key The key to read
  75770. * @param defaultValue The value if the key doesn't exist
  75771. * @returns The boolean value
  75772. */
  75773. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75774. /**
  75775. * Writes a boolean to the data storage
  75776. * @param key The key to write
  75777. * @param value The value to write
  75778. */
  75779. static WriteBoolean(key: string, value: boolean): void;
  75780. /**
  75781. * Reads a number from the data storage
  75782. * @param key The key to read
  75783. * @param defaultValue The value if the key doesn't exist
  75784. * @returns The number value
  75785. */
  75786. static ReadNumber(key: string, defaultValue: number): number;
  75787. /**
  75788. * Writes a number to the data storage
  75789. * @param key The key to write
  75790. * @param value The value to write
  75791. */
  75792. static WriteNumber(key: string, value: number): void;
  75793. }
  75794. }
  75795. declare module "babylonjs/Misc/index" {
  75796. export * from "babylonjs/Misc/andOrNotEvaluator";
  75797. export * from "babylonjs/Misc/assetsManager";
  75798. export * from "babylonjs/Misc/basis";
  75799. export * from "babylonjs/Misc/dds";
  75800. export * from "babylonjs/Misc/decorators";
  75801. export * from "babylonjs/Misc/deferred";
  75802. export * from "babylonjs/Misc/environmentTextureTools";
  75803. export * from "babylonjs/Misc/meshExploder";
  75804. export * from "babylonjs/Misc/filesInput";
  75805. export * from "babylonjs/Misc/HighDynamicRange/index";
  75806. export * from "babylonjs/Misc/khronosTextureContainer";
  75807. export * from "babylonjs/Misc/observable";
  75808. export * from "babylonjs/Misc/performanceMonitor";
  75809. export * from "babylonjs/Misc/promise";
  75810. export * from "babylonjs/Misc/sceneOptimizer";
  75811. export * from "babylonjs/Misc/sceneSerializer";
  75812. export * from "babylonjs/Misc/smartArray";
  75813. export * from "babylonjs/Misc/stringDictionary";
  75814. export * from "babylonjs/Misc/tags";
  75815. export * from "babylonjs/Misc/textureTools";
  75816. export * from "babylonjs/Misc/tga";
  75817. export * from "babylonjs/Misc/tools";
  75818. export * from "babylonjs/Misc/videoRecorder";
  75819. export * from "babylonjs/Misc/virtualJoystick";
  75820. export * from "babylonjs/Misc/workerPool";
  75821. export * from "babylonjs/Misc/logger";
  75822. export * from "babylonjs/Misc/typeStore";
  75823. export * from "babylonjs/Misc/filesInputStore";
  75824. export * from "babylonjs/Misc/deepCopier";
  75825. export * from "babylonjs/Misc/pivotTools";
  75826. export * from "babylonjs/Misc/precisionDate";
  75827. export * from "babylonjs/Misc/screenshotTools";
  75828. export * from "babylonjs/Misc/typeStore";
  75829. export * from "babylonjs/Misc/webRequest";
  75830. export * from "babylonjs/Misc/iInspectable";
  75831. export * from "babylonjs/Misc/brdfTextureTools";
  75832. export * from "babylonjs/Misc/rgbdTextureTools";
  75833. export * from "babylonjs/Misc/gradients";
  75834. export * from "babylonjs/Misc/perfCounter";
  75835. export * from "babylonjs/Misc/fileRequest";
  75836. export * from "babylonjs/Misc/customAnimationFrameRequester";
  75837. export * from "babylonjs/Misc/retryStrategy";
  75838. export * from "babylonjs/Misc/interfaces/screenshotSize";
  75839. export * from "babylonjs/Misc/canvasGenerator";
  75840. export * from "babylonjs/Misc/fileTools";
  75841. export * from "babylonjs/Misc/stringTools";
  75842. export * from "babylonjs/Misc/dataReader";
  75843. export * from "babylonjs/Misc/minMaxReducer";
  75844. export * from "babylonjs/Misc/depthReducer";
  75845. export * from "babylonjs/Misc/dataStorage";
  75846. }
  75847. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  75848. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75849. import { Observable } from "babylonjs/Misc/observable";
  75850. import { Matrix } from "babylonjs/Maths/math.vector";
  75851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75852. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75853. /**
  75854. * Options used for hit testing
  75855. */
  75856. export interface IWebXRLegacyHitTestOptions {
  75857. /**
  75858. * Only test when user interacted with the scene. Default - hit test every frame
  75859. */
  75860. testOnPointerDownOnly?: boolean;
  75861. /**
  75862. * The node to use to transform the local results to world coordinates
  75863. */
  75864. worldParentNode?: TransformNode;
  75865. }
  75866. /**
  75867. * Interface defining the babylon result of raycasting/hit-test
  75868. */
  75869. export interface IWebXRLegacyHitResult {
  75870. /**
  75871. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75872. */
  75873. transformationMatrix: Matrix;
  75874. /**
  75875. * The native hit test result
  75876. */
  75877. xrHitResult: XRHitResult | XRHitTestResult;
  75878. }
  75879. /**
  75880. * The currently-working hit-test module.
  75881. * Hit test (or Ray-casting) is used to interact with the real world.
  75882. * For further information read here - https://github.com/immersive-web/hit-test
  75883. */
  75884. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  75885. /**
  75886. * options to use when constructing this feature
  75887. */
  75888. readonly options: IWebXRLegacyHitTestOptions;
  75889. private _direction;
  75890. private _mat;
  75891. private _onSelectEnabled;
  75892. private _origin;
  75893. /**
  75894. * The module's name
  75895. */
  75896. static readonly Name: string;
  75897. /**
  75898. * The (Babylon) version of this module.
  75899. * This is an integer representing the implementation version.
  75900. * This number does not correspond to the WebXR specs version
  75901. */
  75902. static readonly Version: number;
  75903. /**
  75904. * Populated with the last native XR Hit Results
  75905. */
  75906. lastNativeXRHitResults: XRHitResult[];
  75907. /**
  75908. * Triggered when new babylon (transformed) hit test results are available
  75909. */
  75910. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75911. /**
  75912. * Creates a new instance of the (legacy version) hit test feature
  75913. * @param _xrSessionManager an instance of WebXRSessionManager
  75914. * @param options options to use when constructing this feature
  75915. */
  75916. constructor(_xrSessionManager: WebXRSessionManager,
  75917. /**
  75918. * options to use when constructing this feature
  75919. */
  75920. options?: IWebXRLegacyHitTestOptions);
  75921. /**
  75922. * execute a hit test with an XR Ray
  75923. *
  75924. * @param xrSession a native xrSession that will execute this hit test
  75925. * @param xrRay the ray (position and direction) to use for ray-casting
  75926. * @param referenceSpace native XR reference space to use for the hit-test
  75927. * @param filter filter function that will filter the results
  75928. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75929. */
  75930. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75931. /**
  75932. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75933. * @param event the (select) event to use to select with
  75934. * @param referenceSpace the reference space to use for this hit test
  75935. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75936. */
  75937. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75938. /**
  75939. * attach this feature
  75940. * Will usually be called by the features manager
  75941. *
  75942. * @returns true if successful.
  75943. */
  75944. attach(): boolean;
  75945. /**
  75946. * detach this feature.
  75947. * Will usually be called by the features manager
  75948. *
  75949. * @returns true if successful.
  75950. */
  75951. detach(): boolean;
  75952. /**
  75953. * Dispose this feature and all of the resources attached
  75954. */
  75955. dispose(): void;
  75956. protected _onXRFrame(frame: XRFrame): void;
  75957. private _onHitTestResults;
  75958. private _onSelect;
  75959. }
  75960. }
  75961. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  75962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75963. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75964. import { Observable } from "babylonjs/Misc/observable";
  75965. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  75966. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75967. /**
  75968. * Options used in the plane detector module
  75969. */
  75970. export interface IWebXRPlaneDetectorOptions {
  75971. /**
  75972. * The node to use to transform the local results to world coordinates
  75973. */
  75974. worldParentNode?: TransformNode;
  75975. }
  75976. /**
  75977. * A babylon interface for a WebXR plane.
  75978. * A Plane is actually a polygon, built from N points in space
  75979. *
  75980. * Supported in chrome 79, not supported in canary 81 ATM
  75981. */
  75982. export interface IWebXRPlane {
  75983. /**
  75984. * a babylon-assigned ID for this polygon
  75985. */
  75986. id: number;
  75987. /**
  75988. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75989. */
  75990. polygonDefinition: Array<Vector3>;
  75991. /**
  75992. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75993. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75994. */
  75995. transformationMatrix: Matrix;
  75996. /**
  75997. * the native xr-plane object
  75998. */
  75999. xrPlane: XRPlane;
  76000. }
  76001. /**
  76002. * The plane detector is used to detect planes in the real world when in AR
  76003. * For more information see https://github.com/immersive-web/real-world-geometry/
  76004. */
  76005. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76006. private _options;
  76007. private _detectedPlanes;
  76008. private _enabled;
  76009. private _lastFrameDetected;
  76010. /**
  76011. * The module's name
  76012. */
  76013. static readonly Name: string;
  76014. /**
  76015. * The (Babylon) version of this module.
  76016. * This is an integer representing the implementation version.
  76017. * This number does not correspond to the WebXR specs version
  76018. */
  76019. static readonly Version: number;
  76020. /**
  76021. * Observers registered here will be executed when a new plane was added to the session
  76022. */
  76023. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76024. /**
  76025. * Observers registered here will be executed when a plane is no longer detected in the session
  76026. */
  76027. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76028. /**
  76029. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76030. * This can execute N times every frame
  76031. */
  76032. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76033. /**
  76034. * construct a new Plane Detector
  76035. * @param _xrSessionManager an instance of xr Session manager
  76036. * @param _options configuration to use when constructing this feature
  76037. */
  76038. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76039. /**
  76040. * Dispose this feature and all of the resources attached
  76041. */
  76042. dispose(): void;
  76043. protected _onXRFrame(frame: XRFrame): void;
  76044. private _init;
  76045. private _updatePlaneWithXRPlane;
  76046. /**
  76047. * avoiding using Array.find for global support.
  76048. * @param xrPlane the plane to find in the array
  76049. */
  76050. private findIndexInPlaneArray;
  76051. }
  76052. }
  76053. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76054. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76055. import { Observable } from "babylonjs/Misc/observable";
  76056. import { Matrix } from "babylonjs/Maths/math.vector";
  76057. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76058. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  76059. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76060. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76061. /**
  76062. * Configuration options of the anchor system
  76063. */
  76064. export interface IWebXRAnchorSystemOptions {
  76065. /**
  76066. * Should a new anchor be added every time a select event is triggered
  76067. */
  76068. addAnchorOnSelect?: boolean;
  76069. /**
  76070. * should the anchor system use plane detection.
  76071. * If set to true, the plane-detection feature should be set using setPlaneDetector
  76072. */
  76073. usePlaneDetection?: boolean;
  76074. /**
  76075. * a node that will be used to convert local to world coordinates
  76076. */
  76077. worldParentNode?: TransformNode;
  76078. }
  76079. /**
  76080. * A babylon container for an XR Anchor
  76081. */
  76082. export interface IWebXRAnchor {
  76083. /**
  76084. * A babylon-assigned ID for this anchor
  76085. */
  76086. id: number;
  76087. /**
  76088. * Transformation matrix to apply to an object attached to this anchor
  76089. */
  76090. transformationMatrix: Matrix;
  76091. /**
  76092. * The native anchor object
  76093. */
  76094. xrAnchor: XRAnchor;
  76095. }
  76096. /**
  76097. * An implementation of the anchor system of WebXR.
  76098. * Note that the current documented implementation is not available in any browser. Future implementations
  76099. * will use the frame to create an anchor and not the session or a detected plane
  76100. * For further information see https://github.com/immersive-web/anchors/
  76101. */
  76102. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76103. private _options;
  76104. private _enabled;
  76105. private _hitTestModule;
  76106. private _lastFrameDetected;
  76107. private _onSelect;
  76108. private _planeDetector;
  76109. private _trackedAnchors;
  76110. /**
  76111. * The module's name
  76112. */
  76113. static readonly Name: string;
  76114. /**
  76115. * The (Babylon) version of this module.
  76116. * This is an integer representing the implementation version.
  76117. * This number does not correspond to the WebXR specs version
  76118. */
  76119. static readonly Version: number;
  76120. /**
  76121. * Observers registered here will be executed when a new anchor was added to the session
  76122. */
  76123. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76124. /**
  76125. * Observers registered here will be executed when an anchor was removed from the session
  76126. */
  76127. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76128. /**
  76129. * Observers registered here will be executed when an existing anchor updates
  76130. * This can execute N times every frame
  76131. */
  76132. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76133. /**
  76134. * constructs a new anchor system
  76135. * @param _xrSessionManager an instance of WebXRSessionManager
  76136. * @param _options configuration object for this feature
  76137. */
  76138. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76139. /**
  76140. * Add anchor at a specific XR point.
  76141. *
  76142. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  76143. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  76144. * @returns a promise the fulfills when the anchor was created
  76145. */
  76146. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  76147. /**
  76148. * attach this feature
  76149. * Will usually be called by the features manager
  76150. *
  76151. * @returns true if successful.
  76152. */
  76153. attach(): boolean;
  76154. /**
  76155. * detach this feature.
  76156. * Will usually be called by the features manager
  76157. *
  76158. * @returns true if successful.
  76159. */
  76160. detach(): boolean;
  76161. /**
  76162. * Dispose this feature and all of the resources attached
  76163. */
  76164. dispose(): void;
  76165. /**
  76166. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  76167. * @param hitTestModule the hit-test module to use.
  76168. */
  76169. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  76170. /**
  76171. * set the plane detector to use in order to create anchors from frames
  76172. * @param planeDetector the plane-detector module to use
  76173. * @param enable enable plane-anchors. default is true
  76174. */
  76175. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  76176. protected _onXRFrame(frame: XRFrame): void;
  76177. /**
  76178. * avoiding using Array.find for global support.
  76179. * @param xrAnchor the plane to find in the array
  76180. */
  76181. private _findIndexInAnchorArray;
  76182. private _updateAnchorWithXRFrame;
  76183. }
  76184. }
  76185. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76186. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76188. import { Observable } from "babylonjs/Misc/observable";
  76189. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76190. /**
  76191. * Options interface for the background remover plugin
  76192. */
  76193. export interface IWebXRBackgroundRemoverOptions {
  76194. /**
  76195. * Further background meshes to disable when entering AR
  76196. */
  76197. backgroundMeshes?: AbstractMesh[];
  76198. /**
  76199. * flags to configure the removal of the environment helper.
  76200. * If not set, the entire background will be removed. If set, flags should be set as well.
  76201. */
  76202. environmentHelperRemovalFlags?: {
  76203. /**
  76204. * Should the skybox be removed (default false)
  76205. */
  76206. skyBox?: boolean;
  76207. /**
  76208. * Should the ground be removed (default false)
  76209. */
  76210. ground?: boolean;
  76211. };
  76212. /**
  76213. * don't disable the environment helper
  76214. */
  76215. ignoreEnvironmentHelper?: boolean;
  76216. }
  76217. /**
  76218. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76219. */
  76220. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76221. /**
  76222. * read-only options to be used in this module
  76223. */
  76224. readonly options: IWebXRBackgroundRemoverOptions;
  76225. /**
  76226. * The module's name
  76227. */
  76228. static readonly Name: string;
  76229. /**
  76230. * The (Babylon) version of this module.
  76231. * This is an integer representing the implementation version.
  76232. * This number does not correspond to the WebXR specs version
  76233. */
  76234. static readonly Version: number;
  76235. /**
  76236. * registered observers will be triggered when the background state changes
  76237. */
  76238. onBackgroundStateChangedObservable: Observable<boolean>;
  76239. /**
  76240. * constructs a new background remover module
  76241. * @param _xrSessionManager the session manager for this module
  76242. * @param options read-only options to be used in this module
  76243. */
  76244. constructor(_xrSessionManager: WebXRSessionManager,
  76245. /**
  76246. * read-only options to be used in this module
  76247. */
  76248. options?: IWebXRBackgroundRemoverOptions);
  76249. /**
  76250. * attach this feature
  76251. * Will usually be called by the features manager
  76252. *
  76253. * @returns true if successful.
  76254. */
  76255. attach(): boolean;
  76256. /**
  76257. * detach this feature.
  76258. * Will usually be called by the features manager
  76259. *
  76260. * @returns true if successful.
  76261. */
  76262. detach(): boolean;
  76263. /**
  76264. * Dispose this feature and all of the resources attached
  76265. */
  76266. dispose(): void;
  76267. protected _onXRFrame(_xrFrame: XRFrame): void;
  76268. private _setBackgroundState;
  76269. }
  76270. }
  76271. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  76272. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76273. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  76274. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76275. import { WebXRInput } from "babylonjs/XR/webXRInput";
  76276. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76277. import { Nullable } from "babylonjs/types";
  76278. /**
  76279. * Options for the controller physics feature
  76280. */
  76281. export class IWebXRControllerPhysicsOptions {
  76282. /**
  76283. * Should the headset get its own impostor
  76284. */
  76285. enableHeadsetImpostor?: boolean;
  76286. /**
  76287. * Optional parameters for the headset impostor
  76288. */
  76289. headsetImpostorParams?: {
  76290. /**
  76291. * The type of impostor to create. Default is sphere
  76292. */
  76293. impostorType: number;
  76294. /**
  76295. * the size of the impostor. Defaults to 10cm
  76296. */
  76297. impostorSize?: number | {
  76298. width: number;
  76299. height: number;
  76300. depth: number;
  76301. };
  76302. /**
  76303. * Friction definitions
  76304. */
  76305. friction?: number;
  76306. /**
  76307. * Restitution
  76308. */
  76309. restitution?: number;
  76310. };
  76311. /**
  76312. * The physics properties of the future impostors
  76313. */
  76314. physicsProperties?: {
  76315. /**
  76316. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76317. * Note that this requires a physics engine that supports mesh impostors!
  76318. */
  76319. useControllerMesh?: boolean;
  76320. /**
  76321. * The type of impostor to create. Default is sphere
  76322. */
  76323. impostorType?: number;
  76324. /**
  76325. * the size of the impostor. Defaults to 10cm
  76326. */
  76327. impostorSize?: number | {
  76328. width: number;
  76329. height: number;
  76330. depth: number;
  76331. };
  76332. /**
  76333. * Friction definitions
  76334. */
  76335. friction?: number;
  76336. /**
  76337. * Restitution
  76338. */
  76339. restitution?: number;
  76340. };
  76341. /**
  76342. * the xr input to use with this pointer selection
  76343. */
  76344. xrInput: WebXRInput;
  76345. }
  76346. /**
  76347. * Add physics impostor to your webxr controllers,
  76348. * including naive calculation of their linear and angular velocity
  76349. */
  76350. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76351. private readonly _options;
  76352. private _attachController;
  76353. private _controllers;
  76354. private _debugMode;
  76355. private _delta;
  76356. private _headsetImpostor?;
  76357. private _headsetMesh?;
  76358. private _lastTimestamp;
  76359. private _tmpQuaternion;
  76360. private _tmpVector;
  76361. /**
  76362. * The module's name
  76363. */
  76364. static readonly Name: string;
  76365. /**
  76366. * The (Babylon) version of this module.
  76367. * This is an integer representing the implementation version.
  76368. * This number does not correspond to the webxr specs version
  76369. */
  76370. static readonly Version: number;
  76371. /**
  76372. * Construct a new Controller Physics Feature
  76373. * @param _xrSessionManager the corresponding xr session manager
  76374. * @param _options options to create this feature with
  76375. */
  76376. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76377. /**
  76378. * @hidden
  76379. * enable debugging - will show console outputs and the impostor mesh
  76380. */
  76381. _enablePhysicsDebug(): void;
  76382. /**
  76383. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76384. * @param xrController the controller to add
  76385. */
  76386. addController(xrController: WebXRInputSource): void;
  76387. /**
  76388. * attach this feature
  76389. * Will usually be called by the features manager
  76390. *
  76391. * @returns true if successful.
  76392. */
  76393. attach(): boolean;
  76394. /**
  76395. * detach this feature.
  76396. * Will usually be called by the features manager
  76397. *
  76398. * @returns true if successful.
  76399. */
  76400. detach(): boolean;
  76401. /**
  76402. * Get the headset impostor, if enabled
  76403. * @returns the impostor
  76404. */
  76405. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76406. /**
  76407. * Get the physics impostor of a specific controller.
  76408. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76409. * @param controller the controller or the controller id of which to get the impostor
  76410. * @returns the impostor or null
  76411. */
  76412. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76413. /**
  76414. * Update the physics properties provided in the constructor
  76415. * @param newProperties the new properties object
  76416. */
  76417. setPhysicsProperties(newProperties: {
  76418. impostorType?: number;
  76419. impostorSize?: number | {
  76420. width: number;
  76421. height: number;
  76422. depth: number;
  76423. };
  76424. friction?: number;
  76425. restitution?: number;
  76426. }): void;
  76427. protected _onXRFrame(_xrFrame: any): void;
  76428. private _detachController;
  76429. }
  76430. }
  76431. declare module "babylonjs/XR/features/WebXRHitTest" {
  76432. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76433. import { Observable } from "babylonjs/Misc/observable";
  76434. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76435. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76436. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76437. /**
  76438. * Options used for hit testing (version 2)
  76439. */
  76440. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76441. /**
  76442. * Do not create a permanent hit test. Will usually be used when only
  76443. * transient inputs are needed.
  76444. */
  76445. disablePermanentHitTest?: boolean;
  76446. /**
  76447. * Enable transient (for example touch-based) hit test inspections
  76448. */
  76449. enableTransientHitTest?: boolean;
  76450. /**
  76451. * Offset ray for the permanent hit test
  76452. */
  76453. offsetRay?: Vector3;
  76454. /**
  76455. * Offset ray for the transient hit test
  76456. */
  76457. transientOffsetRay?: Vector3;
  76458. /**
  76459. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76460. */
  76461. useReferenceSpace?: boolean;
  76462. }
  76463. /**
  76464. * Interface defining the babylon result of hit-test
  76465. */
  76466. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76467. /**
  76468. * The input source that generated this hit test (if transient)
  76469. */
  76470. inputSource?: XRInputSource;
  76471. /**
  76472. * Is this a transient hit test
  76473. */
  76474. isTransient?: boolean;
  76475. /**
  76476. * Position of the hit test result
  76477. */
  76478. position: Vector3;
  76479. /**
  76480. * Rotation of the hit test result
  76481. */
  76482. rotationQuaternion: Quaternion;
  76483. }
  76484. /**
  76485. * The currently-working hit-test module.
  76486. * Hit test (or Ray-casting) is used to interact with the real world.
  76487. * For further information read here - https://github.com/immersive-web/hit-test
  76488. *
  76489. * Tested on chrome (mobile) 80.
  76490. */
  76491. export class WebXRHitTest extends WebXRAbstractFeature {
  76492. /**
  76493. * options to use when constructing this feature
  76494. */
  76495. readonly options: IWebXRHitTestOptions;
  76496. private _tmpMat;
  76497. private _tmpPos;
  76498. private _tmpQuat;
  76499. private _transientXrHitTestSource;
  76500. private _xrHitTestSource;
  76501. private initHitTestSource;
  76502. /**
  76503. * The module's name
  76504. */
  76505. static readonly Name: string;
  76506. /**
  76507. * The (Babylon) version of this module.
  76508. * This is an integer representing the implementation version.
  76509. * This number does not correspond to the WebXR specs version
  76510. */
  76511. static readonly Version: number;
  76512. /**
  76513. * When set to true, each hit test will have its own position/rotation objects
  76514. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76515. * the developers will clone them or copy them as they see fit.
  76516. */
  76517. autoCloneTransformation: boolean;
  76518. /**
  76519. * Populated with the last native XR Hit Results
  76520. */
  76521. lastNativeXRHitResults: XRHitResult[];
  76522. /**
  76523. * Triggered when new babylon (transformed) hit test results are available
  76524. */
  76525. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76526. /**
  76527. * Use this to temporarily pause hit test checks.
  76528. */
  76529. paused: boolean;
  76530. /**
  76531. * Creates a new instance of the hit test feature
  76532. * @param _xrSessionManager an instance of WebXRSessionManager
  76533. * @param options options to use when constructing this feature
  76534. */
  76535. constructor(_xrSessionManager: WebXRSessionManager,
  76536. /**
  76537. * options to use when constructing this feature
  76538. */
  76539. options?: IWebXRHitTestOptions);
  76540. /**
  76541. * attach this feature
  76542. * Will usually be called by the features manager
  76543. *
  76544. * @returns true if successful.
  76545. */
  76546. attach(): boolean;
  76547. /**
  76548. * detach this feature.
  76549. * Will usually be called by the features manager
  76550. *
  76551. * @returns true if successful.
  76552. */
  76553. detach(): boolean;
  76554. /**
  76555. * Dispose this feature and all of the resources attached
  76556. */
  76557. dispose(): void;
  76558. protected _onXRFrame(frame: XRFrame): void;
  76559. private _processWebXRHitTestResult;
  76560. }
  76561. }
  76562. declare module "babylonjs/XR/features/index" {
  76563. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  76564. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  76565. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  76566. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  76567. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  76568. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  76569. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  76570. export * from "babylonjs/XR/features/WebXRHitTest";
  76571. }
  76572. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  76573. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76575. import { Scene } from "babylonjs/scene";
  76576. /**
  76577. * The motion controller class for all microsoft mixed reality controllers
  76578. */
  76579. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76580. protected readonly _mapping: {
  76581. defaultButton: {
  76582. valueNodeName: string;
  76583. unpressedNodeName: string;
  76584. pressedNodeName: string;
  76585. };
  76586. defaultAxis: {
  76587. valueNodeName: string;
  76588. minNodeName: string;
  76589. maxNodeName: string;
  76590. };
  76591. buttons: {
  76592. "xr-standard-trigger": {
  76593. rootNodeName: string;
  76594. componentProperty: string;
  76595. states: string[];
  76596. };
  76597. "xr-standard-squeeze": {
  76598. rootNodeName: string;
  76599. componentProperty: string;
  76600. states: string[];
  76601. };
  76602. "xr-standard-touchpad": {
  76603. rootNodeName: string;
  76604. labelAnchorNodeName: string;
  76605. touchPointNodeName: string;
  76606. };
  76607. "xr-standard-thumbstick": {
  76608. rootNodeName: string;
  76609. componentProperty: string;
  76610. states: string[];
  76611. };
  76612. };
  76613. axes: {
  76614. "xr-standard-touchpad": {
  76615. "x-axis": {
  76616. rootNodeName: string;
  76617. };
  76618. "y-axis": {
  76619. rootNodeName: string;
  76620. };
  76621. };
  76622. "xr-standard-thumbstick": {
  76623. "x-axis": {
  76624. rootNodeName: string;
  76625. };
  76626. "y-axis": {
  76627. rootNodeName: string;
  76628. };
  76629. };
  76630. };
  76631. };
  76632. /**
  76633. * The base url used to load the left and right controller models
  76634. */
  76635. static MODEL_BASE_URL: string;
  76636. /**
  76637. * The name of the left controller model file
  76638. */
  76639. static MODEL_LEFT_FILENAME: string;
  76640. /**
  76641. * The name of the right controller model file
  76642. */
  76643. static MODEL_RIGHT_FILENAME: string;
  76644. profileId: string;
  76645. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76646. protected _getFilenameAndPath(): {
  76647. filename: string;
  76648. path: string;
  76649. };
  76650. protected _getModelLoadingConstraints(): boolean;
  76651. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76652. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76653. protected _updateModel(): void;
  76654. }
  76655. }
  76656. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  76657. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76659. import { Scene } from "babylonjs/scene";
  76660. /**
  76661. * The motion controller class for oculus touch (quest, rift).
  76662. * This class supports legacy mapping as well the standard xr mapping
  76663. */
  76664. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76665. private _forceLegacyControllers;
  76666. private _modelRootNode;
  76667. /**
  76668. * The base url used to load the left and right controller models
  76669. */
  76670. static MODEL_BASE_URL: string;
  76671. /**
  76672. * The name of the left controller model file
  76673. */
  76674. static MODEL_LEFT_FILENAME: string;
  76675. /**
  76676. * The name of the right controller model file
  76677. */
  76678. static MODEL_RIGHT_FILENAME: string;
  76679. /**
  76680. * Base Url for the Quest controller model.
  76681. */
  76682. static QUEST_MODEL_BASE_URL: string;
  76683. profileId: string;
  76684. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76685. protected _getFilenameAndPath(): {
  76686. filename: string;
  76687. path: string;
  76688. };
  76689. protected _getModelLoadingConstraints(): boolean;
  76690. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76691. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76692. protected _updateModel(): void;
  76693. /**
  76694. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76695. * between the touch and touch 2.
  76696. */
  76697. private _isQuest;
  76698. }
  76699. }
  76700. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  76701. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76702. import { Scene } from "babylonjs/scene";
  76703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76704. /**
  76705. * The motion controller class for the standard HTC-Vive controllers
  76706. */
  76707. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76708. private _modelRootNode;
  76709. /**
  76710. * The base url used to load the left and right controller models
  76711. */
  76712. static MODEL_BASE_URL: string;
  76713. /**
  76714. * File name for the controller model.
  76715. */
  76716. static MODEL_FILENAME: string;
  76717. profileId: string;
  76718. /**
  76719. * Create a new Vive motion controller object
  76720. * @param scene the scene to use to create this controller
  76721. * @param gamepadObject the corresponding gamepad object
  76722. * @param handedness the handedness of the controller
  76723. */
  76724. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76725. protected _getFilenameAndPath(): {
  76726. filename: string;
  76727. path: string;
  76728. };
  76729. protected _getModelLoadingConstraints(): boolean;
  76730. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76731. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76732. protected _updateModel(): void;
  76733. }
  76734. }
  76735. declare module "babylonjs/XR/motionController/index" {
  76736. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76737. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  76738. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  76739. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  76740. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  76741. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  76742. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  76743. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  76744. }
  76745. declare module "babylonjs/XR/index" {
  76746. export * from "babylonjs/XR/webXRCamera";
  76747. export * from "babylonjs/XR/webXREnterExitUI";
  76748. export * from "babylonjs/XR/webXRExperienceHelper";
  76749. export * from "babylonjs/XR/webXRInput";
  76750. export * from "babylonjs/XR/webXRInputSource";
  76751. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  76752. export * from "babylonjs/XR/webXRTypes";
  76753. export * from "babylonjs/XR/webXRSessionManager";
  76754. export * from "babylonjs/XR/webXRDefaultExperience";
  76755. export * from "babylonjs/XR/webXRFeaturesManager";
  76756. export * from "babylonjs/XR/features/index";
  76757. export * from "babylonjs/XR/motionController/index";
  76758. }
  76759. declare module "babylonjs/index" {
  76760. export * from "babylonjs/abstractScene";
  76761. export * from "babylonjs/Actions/index";
  76762. export * from "babylonjs/Animations/index";
  76763. export * from "babylonjs/assetContainer";
  76764. export * from "babylonjs/Audio/index";
  76765. export * from "babylonjs/Behaviors/index";
  76766. export * from "babylonjs/Bones/index";
  76767. export * from "babylonjs/Cameras/index";
  76768. export * from "babylonjs/Collisions/index";
  76769. export * from "babylonjs/Culling/index";
  76770. export * from "babylonjs/Debug/index";
  76771. export * from "babylonjs/DeviceInput/index";
  76772. export * from "babylonjs/Engines/index";
  76773. export * from "babylonjs/Events/index";
  76774. export * from "babylonjs/Gamepads/index";
  76775. export * from "babylonjs/Gizmos/index";
  76776. export * from "babylonjs/Helpers/index";
  76777. export * from "babylonjs/Instrumentation/index";
  76778. export * from "babylonjs/Layers/index";
  76779. export * from "babylonjs/LensFlares/index";
  76780. export * from "babylonjs/Lights/index";
  76781. export * from "babylonjs/Loading/index";
  76782. export * from "babylonjs/Materials/index";
  76783. export * from "babylonjs/Maths/index";
  76784. export * from "babylonjs/Meshes/index";
  76785. export * from "babylonjs/Morph/index";
  76786. export * from "babylonjs/Navigation/index";
  76787. export * from "babylonjs/node";
  76788. export * from "babylonjs/Offline/index";
  76789. export * from "babylonjs/Particles/index";
  76790. export * from "babylonjs/Physics/index";
  76791. export * from "babylonjs/PostProcesses/index";
  76792. export * from "babylonjs/Probes/index";
  76793. export * from "babylonjs/Rendering/index";
  76794. export * from "babylonjs/scene";
  76795. export * from "babylonjs/sceneComponent";
  76796. export * from "babylonjs/Sprites/index";
  76797. export * from "babylonjs/States/index";
  76798. export * from "babylonjs/Misc/index";
  76799. export * from "babylonjs/XR/index";
  76800. export * from "babylonjs/types";
  76801. }
  76802. declare module "babylonjs/Animations/pathCursor" {
  76803. import { Vector3 } from "babylonjs/Maths/math.vector";
  76804. import { Path2 } from "babylonjs/Maths/math.path";
  76805. /**
  76806. * A cursor which tracks a point on a path
  76807. */
  76808. export class PathCursor {
  76809. private path;
  76810. /**
  76811. * Stores path cursor callbacks for when an onchange event is triggered
  76812. */
  76813. private _onchange;
  76814. /**
  76815. * The value of the path cursor
  76816. */
  76817. value: number;
  76818. /**
  76819. * The animation array of the path cursor
  76820. */
  76821. animations: Animation[];
  76822. /**
  76823. * Initializes the path cursor
  76824. * @param path The path to track
  76825. */
  76826. constructor(path: Path2);
  76827. /**
  76828. * Gets the cursor point on the path
  76829. * @returns A point on the path cursor at the cursor location
  76830. */
  76831. getPoint(): Vector3;
  76832. /**
  76833. * Moves the cursor ahead by the step amount
  76834. * @param step The amount to move the cursor forward
  76835. * @returns This path cursor
  76836. */
  76837. moveAhead(step?: number): PathCursor;
  76838. /**
  76839. * Moves the cursor behind by the step amount
  76840. * @param step The amount to move the cursor back
  76841. * @returns This path cursor
  76842. */
  76843. moveBack(step?: number): PathCursor;
  76844. /**
  76845. * Moves the cursor by the step amount
  76846. * If the step amount is greater than one, an exception is thrown
  76847. * @param step The amount to move the cursor
  76848. * @returns This path cursor
  76849. */
  76850. move(step: number): PathCursor;
  76851. /**
  76852. * Ensures that the value is limited between zero and one
  76853. * @returns This path cursor
  76854. */
  76855. private ensureLimits;
  76856. /**
  76857. * Runs onchange callbacks on change (used by the animation engine)
  76858. * @returns This path cursor
  76859. */
  76860. private raiseOnChange;
  76861. /**
  76862. * Executes a function on change
  76863. * @param f A path cursor onchange callback
  76864. * @returns This path cursor
  76865. */
  76866. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76867. }
  76868. }
  76869. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  76870. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  76871. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  76872. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  76873. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  76874. }
  76875. declare module "babylonjs/Engines/Processors/Expressions/index" {
  76876. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  76877. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  76878. }
  76879. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  76880. /** @hidden */
  76881. export class ShaderCodeInliner {
  76882. static readonly InlineToken: string;
  76883. static readonly RegexpFindFunctionNameAndType: RegExp;
  76884. private _sourceCode;
  76885. private _functionDescr;
  76886. private _numMaxIterations;
  76887. debug: boolean;
  76888. get code(): string;
  76889. constructor(sourceCode: string, numMaxIterations?: number);
  76890. processCode(): void;
  76891. private _collectFunctions;
  76892. private _processInlining;
  76893. private _extractBetweenMarkers;
  76894. private _skipWhitespaces;
  76895. private _removeComments;
  76896. private _replaceFunctionCallsByCode;
  76897. private _findBackward;
  76898. private _escapeRegExp;
  76899. private _replaceNames;
  76900. }
  76901. }
  76902. declare module "babylonjs/Engines/Processors/index" {
  76903. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  76904. export * from "babylonjs/Engines/Processors/Expressions/index";
  76905. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  76906. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  76907. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  76908. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  76909. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  76910. export * from "babylonjs/Engines/Processors/shaderProcessor";
  76911. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  76912. }
  76913. declare module "babylonjs/Legacy/legacy" {
  76914. import * as Babylon from "babylonjs/index";
  76915. export * from "babylonjs/index";
  76916. }
  76917. declare module "babylonjs/Shaders/blur.fragment" {
  76918. /** @hidden */
  76919. export var blurPixelShader: {
  76920. name: string;
  76921. shader: string;
  76922. };
  76923. }
  76924. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  76925. /** @hidden */
  76926. export var pointCloudVertexDeclaration: {
  76927. name: string;
  76928. shader: string;
  76929. };
  76930. }
  76931. declare module "babylonjs" {
  76932. export * from "babylonjs/Legacy/legacy";
  76933. }
  76934. declare module BABYLON {
  76935. /** Alias type for value that can be null */
  76936. export type Nullable<T> = T | null;
  76937. /**
  76938. * Alias type for number that are floats
  76939. * @ignorenaming
  76940. */
  76941. export type float = number;
  76942. /**
  76943. * Alias type for number that are doubles.
  76944. * @ignorenaming
  76945. */
  76946. export type double = number;
  76947. /**
  76948. * Alias type for number that are integer
  76949. * @ignorenaming
  76950. */
  76951. export type int = number;
  76952. /** Alias type for number array or Float32Array */
  76953. export type FloatArray = number[] | Float32Array;
  76954. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  76955. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  76956. /**
  76957. * Alias for types that can be used by a Buffer or VertexBuffer.
  76958. */
  76959. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  76960. /**
  76961. * Alias type for primitive types
  76962. * @ignorenaming
  76963. */
  76964. type Primitive = undefined | null | boolean | string | number | Function;
  76965. /**
  76966. * Type modifier to make all the properties of an object Readonly
  76967. */
  76968. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  76969. /**
  76970. * Type modifier to make all the properties of an object Readonly recursively
  76971. */
  76972. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  76973. /**
  76974. * Type modifier to make object properties readonly.
  76975. */
  76976. export type DeepImmutableObject<T> = {
  76977. readonly [K in keyof T]: DeepImmutable<T[K]>;
  76978. };
  76979. /** @hidden */
  76980. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  76981. }
  76982. }
  76983. declare module BABYLON {
  76984. /**
  76985. * A class serves as a medium between the observable and its observers
  76986. */
  76987. export class EventState {
  76988. /**
  76989. * Create a new EventState
  76990. * @param mask defines the mask associated with this state
  76991. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  76992. * @param target defines the original target of the state
  76993. * @param currentTarget defines the current target of the state
  76994. */
  76995. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  76996. /**
  76997. * Initialize the current event state
  76998. * @param mask defines the mask associated with this state
  76999. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77000. * @param target defines the original target of the state
  77001. * @param currentTarget defines the current target of the state
  77002. * @returns the current event state
  77003. */
  77004. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77005. /**
  77006. * An Observer can set this property to true to prevent subsequent observers of being notified
  77007. */
  77008. skipNextObservers: boolean;
  77009. /**
  77010. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77011. */
  77012. mask: number;
  77013. /**
  77014. * The object that originally notified the event
  77015. */
  77016. target?: any;
  77017. /**
  77018. * The current object in the bubbling phase
  77019. */
  77020. currentTarget?: any;
  77021. /**
  77022. * This will be populated with the return value of the last function that was executed.
  77023. * If it is the first function in the callback chain it will be the event data.
  77024. */
  77025. lastReturnValue?: any;
  77026. }
  77027. /**
  77028. * Represent an Observer registered to a given Observable object.
  77029. */
  77030. export class Observer<T> {
  77031. /**
  77032. * Defines the callback to call when the observer is notified
  77033. */
  77034. callback: (eventData: T, eventState: EventState) => void;
  77035. /**
  77036. * Defines the mask of the observer (used to filter notifications)
  77037. */
  77038. mask: number;
  77039. /**
  77040. * Defines the current scope used to restore the JS context
  77041. */
  77042. scope: any;
  77043. /** @hidden */
  77044. _willBeUnregistered: boolean;
  77045. /**
  77046. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77047. */
  77048. unregisterOnNextCall: boolean;
  77049. /**
  77050. * Creates a new observer
  77051. * @param callback defines the callback to call when the observer is notified
  77052. * @param mask defines the mask of the observer (used to filter notifications)
  77053. * @param scope defines the current scope used to restore the JS context
  77054. */
  77055. constructor(
  77056. /**
  77057. * Defines the callback to call when the observer is notified
  77058. */
  77059. callback: (eventData: T, eventState: EventState) => void,
  77060. /**
  77061. * Defines the mask of the observer (used to filter notifications)
  77062. */
  77063. mask: number,
  77064. /**
  77065. * Defines the current scope used to restore the JS context
  77066. */
  77067. scope?: any);
  77068. }
  77069. /**
  77070. * Represent a list of observers registered to multiple Observables object.
  77071. */
  77072. export class MultiObserver<T> {
  77073. private _observers;
  77074. private _observables;
  77075. /**
  77076. * Release associated resources
  77077. */
  77078. dispose(): void;
  77079. /**
  77080. * Raise a callback when one of the observable will notify
  77081. * @param observables defines a list of observables to watch
  77082. * @param callback defines the callback to call on notification
  77083. * @param mask defines the mask used to filter notifications
  77084. * @param scope defines the current scope used to restore the JS context
  77085. * @returns the new MultiObserver
  77086. */
  77087. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77088. }
  77089. /**
  77090. * The Observable class is a simple implementation of the Observable pattern.
  77091. *
  77092. * 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.
  77093. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77094. * 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).
  77095. * 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.
  77096. */
  77097. export class Observable<T> {
  77098. private _observers;
  77099. private _eventState;
  77100. private _onObserverAdded;
  77101. /**
  77102. * Gets the list of observers
  77103. */
  77104. get observers(): Array<Observer<T>>;
  77105. /**
  77106. * Creates a new observable
  77107. * @param onObserverAdded defines a callback to call when a new observer is added
  77108. */
  77109. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77110. /**
  77111. * Create a new Observer with the specified callback
  77112. * @param callback the callback that will be executed for that Observer
  77113. * @param mask the mask used to filter observers
  77114. * @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.
  77115. * @param scope optional scope for the callback to be called from
  77116. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77117. * @returns the new observer created for the callback
  77118. */
  77119. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77120. /**
  77121. * Create a new Observer with the specified callback and unregisters after the next notification
  77122. * @param callback the callback that will be executed for that Observer
  77123. * @returns the new observer created for the callback
  77124. */
  77125. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77126. /**
  77127. * Remove an Observer from the Observable object
  77128. * @param observer the instance of the Observer to remove
  77129. * @returns false if it doesn't belong to this Observable
  77130. */
  77131. remove(observer: Nullable<Observer<T>>): boolean;
  77132. /**
  77133. * Remove a callback from the Observable object
  77134. * @param callback the callback to remove
  77135. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77136. * @returns false if it doesn't belong to this Observable
  77137. */
  77138. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77139. private _deferUnregister;
  77140. private _remove;
  77141. /**
  77142. * Moves the observable to the top of the observer list making it get called first when notified
  77143. * @param observer the observer to move
  77144. */
  77145. makeObserverTopPriority(observer: Observer<T>): void;
  77146. /**
  77147. * Moves the observable to the bottom of the observer list making it get called last when notified
  77148. * @param observer the observer to move
  77149. */
  77150. makeObserverBottomPriority(observer: Observer<T>): void;
  77151. /**
  77152. * Notify all Observers by calling their respective callback with the given data
  77153. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77154. * @param eventData defines the data to send to all observers
  77155. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77156. * @param target defines the original target of the state
  77157. * @param currentTarget defines the current target of the state
  77158. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77159. */
  77160. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77161. /**
  77162. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77163. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77164. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77165. * and it is crucial that all callbacks will be executed.
  77166. * The order of the callbacks is kept, callbacks are not executed parallel.
  77167. *
  77168. * @param eventData The data to be sent to each callback
  77169. * @param mask is used to filter observers defaults to -1
  77170. * @param target defines the callback target (see EventState)
  77171. * @param currentTarget defines he current object in the bubbling phase
  77172. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77173. */
  77174. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77175. /**
  77176. * Notify a specific observer
  77177. * @param observer defines the observer to notify
  77178. * @param eventData defines the data to be sent to each callback
  77179. * @param mask is used to filter observers defaults to -1
  77180. */
  77181. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77182. /**
  77183. * Gets a boolean indicating if the observable has at least one observer
  77184. * @returns true is the Observable has at least one Observer registered
  77185. */
  77186. hasObservers(): boolean;
  77187. /**
  77188. * Clear the list of observers
  77189. */
  77190. clear(): void;
  77191. /**
  77192. * Clone the current observable
  77193. * @returns a new observable
  77194. */
  77195. clone(): Observable<T>;
  77196. /**
  77197. * Does this observable handles observer registered with a given mask
  77198. * @param mask defines the mask to be tested
  77199. * @return whether or not one observer registered with the given mask is handeled
  77200. **/
  77201. hasSpecificMask(mask?: number): boolean;
  77202. }
  77203. }
  77204. declare module BABYLON {
  77205. /**
  77206. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77207. * Babylon.js
  77208. */
  77209. export class DomManagement {
  77210. /**
  77211. * Checks if the window object exists
  77212. * @returns true if the window object exists
  77213. */
  77214. static IsWindowObjectExist(): boolean;
  77215. /**
  77216. * Checks if the navigator object exists
  77217. * @returns true if the navigator object exists
  77218. */
  77219. static IsNavigatorAvailable(): boolean;
  77220. /**
  77221. * Check if the document object exists
  77222. * @returns true if the document object exists
  77223. */
  77224. static IsDocumentAvailable(): boolean;
  77225. /**
  77226. * Extracts text content from a DOM element hierarchy
  77227. * @param element defines the root element
  77228. * @returns a string
  77229. */
  77230. static GetDOMTextContent(element: HTMLElement): string;
  77231. }
  77232. }
  77233. declare module BABYLON {
  77234. /**
  77235. * Logger used througouht the application to allow configuration of
  77236. * the log level required for the messages.
  77237. */
  77238. export class Logger {
  77239. /**
  77240. * No log
  77241. */
  77242. static readonly NoneLogLevel: number;
  77243. /**
  77244. * Only message logs
  77245. */
  77246. static readonly MessageLogLevel: number;
  77247. /**
  77248. * Only warning logs
  77249. */
  77250. static readonly WarningLogLevel: number;
  77251. /**
  77252. * Only error logs
  77253. */
  77254. static readonly ErrorLogLevel: number;
  77255. /**
  77256. * All logs
  77257. */
  77258. static readonly AllLogLevel: number;
  77259. private static _LogCache;
  77260. /**
  77261. * Gets a value indicating the number of loading errors
  77262. * @ignorenaming
  77263. */
  77264. static errorsCount: number;
  77265. /**
  77266. * Callback called when a new log is added
  77267. */
  77268. static OnNewCacheEntry: (entry: string) => void;
  77269. private static _AddLogEntry;
  77270. private static _FormatMessage;
  77271. private static _LogDisabled;
  77272. private static _LogEnabled;
  77273. private static _WarnDisabled;
  77274. private static _WarnEnabled;
  77275. private static _ErrorDisabled;
  77276. private static _ErrorEnabled;
  77277. /**
  77278. * Log a message to the console
  77279. */
  77280. static Log: (message: string) => void;
  77281. /**
  77282. * Write a warning message to the console
  77283. */
  77284. static Warn: (message: string) => void;
  77285. /**
  77286. * Write an error message to the console
  77287. */
  77288. static Error: (message: string) => void;
  77289. /**
  77290. * Gets current log cache (list of logs)
  77291. */
  77292. static get LogCache(): string;
  77293. /**
  77294. * Clears the log cache
  77295. */
  77296. static ClearLogCache(): void;
  77297. /**
  77298. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77299. */
  77300. static set LogLevels(level: number);
  77301. }
  77302. }
  77303. declare module BABYLON {
  77304. /** @hidden */
  77305. export class _TypeStore {
  77306. /** @hidden */
  77307. static RegisteredTypes: {
  77308. [key: string]: Object;
  77309. };
  77310. /** @hidden */
  77311. static GetClass(fqdn: string): any;
  77312. }
  77313. }
  77314. declare module BABYLON {
  77315. /**
  77316. * Helper to manipulate strings
  77317. */
  77318. export class StringTools {
  77319. /**
  77320. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77321. * @param str Source string
  77322. * @param suffix Suffix to search for in the source string
  77323. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77324. */
  77325. static EndsWith(str: string, suffix: string): boolean;
  77326. /**
  77327. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77328. * @param str Source string
  77329. * @param suffix Suffix to search for in the source string
  77330. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77331. */
  77332. static StartsWith(str: string, suffix: string): boolean;
  77333. /**
  77334. * Decodes a buffer into a string
  77335. * @param buffer The buffer to decode
  77336. * @returns The decoded string
  77337. */
  77338. static Decode(buffer: Uint8Array | Uint16Array): string;
  77339. /**
  77340. * Encode a buffer to a base64 string
  77341. * @param buffer defines the buffer to encode
  77342. * @returns the encoded string
  77343. */
  77344. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77345. /**
  77346. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77347. * @param num the number to convert and pad
  77348. * @param length the expected length of the string
  77349. * @returns the padded string
  77350. */
  77351. static PadNumber(num: number, length: number): string;
  77352. }
  77353. }
  77354. declare module BABYLON {
  77355. /**
  77356. * Class containing a set of static utilities functions for deep copy.
  77357. */
  77358. export class DeepCopier {
  77359. /**
  77360. * Tries to copy an object by duplicating every property
  77361. * @param source defines the source object
  77362. * @param destination defines the target object
  77363. * @param doNotCopyList defines a list of properties to avoid
  77364. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77365. */
  77366. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77367. }
  77368. }
  77369. declare module BABYLON {
  77370. /**
  77371. * Class containing a set of static utilities functions for precision date
  77372. */
  77373. export class PrecisionDate {
  77374. /**
  77375. * Gets either window.performance.now() if supported or Date.now() else
  77376. */
  77377. static get Now(): number;
  77378. }
  77379. }
  77380. declare module BABYLON {
  77381. /** @hidden */
  77382. export class _DevTools {
  77383. static WarnImport(name: string): string;
  77384. }
  77385. }
  77386. declare module BABYLON {
  77387. /**
  77388. * Interface used to define the mechanism to get data from the network
  77389. */
  77390. export interface IWebRequest {
  77391. /**
  77392. * Returns client's response url
  77393. */
  77394. responseURL: string;
  77395. /**
  77396. * Returns client's status
  77397. */
  77398. status: number;
  77399. /**
  77400. * Returns client's status as a text
  77401. */
  77402. statusText: string;
  77403. }
  77404. }
  77405. declare module BABYLON {
  77406. /**
  77407. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  77408. */
  77409. export class WebRequest implements IWebRequest {
  77410. private _xhr;
  77411. /**
  77412. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  77413. * i.e. when loading files, where the server/service expects an Authorization header
  77414. */
  77415. static CustomRequestHeaders: {
  77416. [key: string]: string;
  77417. };
  77418. /**
  77419. * Add callback functions in this array to update all the requests before they get sent to the network
  77420. */
  77421. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  77422. private _injectCustomRequestHeaders;
  77423. /**
  77424. * Gets or sets a function to be called when loading progress changes
  77425. */
  77426. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  77427. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  77428. /**
  77429. * Returns client's state
  77430. */
  77431. get readyState(): number;
  77432. /**
  77433. * Returns client's status
  77434. */
  77435. get status(): number;
  77436. /**
  77437. * Returns client's status as a text
  77438. */
  77439. get statusText(): string;
  77440. /**
  77441. * Returns client's response
  77442. */
  77443. get response(): any;
  77444. /**
  77445. * Returns client's response url
  77446. */
  77447. get responseURL(): string;
  77448. /**
  77449. * Returns client's response as text
  77450. */
  77451. get responseText(): string;
  77452. /**
  77453. * Gets or sets the expected response type
  77454. */
  77455. get responseType(): XMLHttpRequestResponseType;
  77456. set responseType(value: XMLHttpRequestResponseType);
  77457. /** @hidden */
  77458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  77459. /** @hidden */
  77460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  77461. /**
  77462. * Cancels any network activity
  77463. */
  77464. abort(): void;
  77465. /**
  77466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  77467. * @param body defines an optional request body
  77468. */
  77469. send(body?: Document | BodyInit | null): void;
  77470. /**
  77471. * Sets the request method, request URL
  77472. * @param method defines the method to use (GET, POST, etc..)
  77473. * @param url defines the url to connect with
  77474. */
  77475. open(method: string, url: string): void;
  77476. /**
  77477. * Sets the value of a request header.
  77478. * @param name The name of the header whose value is to be set
  77479. * @param value The value to set as the body of the header
  77480. */
  77481. setRequestHeader(name: string, value: string): void;
  77482. /**
  77483. * Get the string containing the text of a particular header's value.
  77484. * @param name The name of the header
  77485. * @returns The string containing the text of the given header name
  77486. */
  77487. getResponseHeader(name: string): Nullable<string>;
  77488. }
  77489. }
  77490. declare module BABYLON {
  77491. /**
  77492. * File request interface
  77493. */
  77494. export interface IFileRequest {
  77495. /**
  77496. * Raised when the request is complete (success or error).
  77497. */
  77498. onCompleteObservable: Observable<IFileRequest>;
  77499. /**
  77500. * Aborts the request for a file.
  77501. */
  77502. abort: () => void;
  77503. }
  77504. }
  77505. declare module BABYLON {
  77506. /**
  77507. * Define options used to create a render target texture
  77508. */
  77509. export class RenderTargetCreationOptions {
  77510. /**
  77511. * Specifies is mipmaps must be generated
  77512. */
  77513. generateMipMaps?: boolean;
  77514. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  77515. generateDepthBuffer?: boolean;
  77516. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  77517. generateStencilBuffer?: boolean;
  77518. /** Defines texture type (int by default) */
  77519. type?: number;
  77520. /** Defines sampling mode (trilinear by default) */
  77521. samplingMode?: number;
  77522. /** Defines format (RGBA by default) */
  77523. format?: number;
  77524. }
  77525. }
  77526. declare module BABYLON {
  77527. /** Defines the cross module used constants to avoid circular dependncies */
  77528. export class Constants {
  77529. /** Defines that alpha blending is disabled */
  77530. static readonly ALPHA_DISABLE: number;
  77531. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  77532. static readonly ALPHA_ADD: number;
  77533. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  77534. static readonly ALPHA_COMBINE: number;
  77535. /** Defines that alpha blending is DEST - SRC * DEST */
  77536. static readonly ALPHA_SUBTRACT: number;
  77537. /** Defines that alpha blending is SRC * DEST */
  77538. static readonly ALPHA_MULTIPLY: number;
  77539. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  77540. static readonly ALPHA_MAXIMIZED: number;
  77541. /** Defines that alpha blending is SRC + DEST */
  77542. static readonly ALPHA_ONEONE: number;
  77543. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  77544. static readonly ALPHA_PREMULTIPLIED: number;
  77545. /**
  77546. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  77547. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  77548. */
  77549. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  77550. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  77551. static readonly ALPHA_INTERPOLATE: number;
  77552. /**
  77553. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  77554. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  77555. */
  77556. static readonly ALPHA_SCREENMODE: number;
  77557. /**
  77558. * Defines that alpha blending is SRC + DST
  77559. * Alpha will be set to SRC ALPHA + DST ALPHA
  77560. */
  77561. static readonly ALPHA_ONEONE_ONEONE: number;
  77562. /**
  77563. * Defines that alpha blending is SRC * DST ALPHA + DST
  77564. * Alpha will be set to 0
  77565. */
  77566. static readonly ALPHA_ALPHATOCOLOR: number;
  77567. /**
  77568. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77569. */
  77570. static readonly ALPHA_REVERSEONEMINUS: number;
  77571. /**
  77572. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  77573. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  77574. */
  77575. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  77576. /**
  77577. * Defines that alpha blending is SRC + DST
  77578. * Alpha will be set to SRC ALPHA
  77579. */
  77580. static readonly ALPHA_ONEONE_ONEZERO: number;
  77581. /**
  77582. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77583. * Alpha will be set to DST ALPHA
  77584. */
  77585. static readonly ALPHA_EXCLUSION: number;
  77586. /** Defines that alpha blending equation a SUM */
  77587. static readonly ALPHA_EQUATION_ADD: number;
  77588. /** Defines that alpha blending equation a SUBSTRACTION */
  77589. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  77590. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  77591. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  77592. /** Defines that alpha blending equation a MAX operation */
  77593. static readonly ALPHA_EQUATION_MAX: number;
  77594. /** Defines that alpha blending equation a MIN operation */
  77595. static readonly ALPHA_EQUATION_MIN: number;
  77596. /**
  77597. * Defines that alpha blending equation a DARKEN operation:
  77598. * It takes the min of the src and sums the alpha channels.
  77599. */
  77600. static readonly ALPHA_EQUATION_DARKEN: number;
  77601. /** Defines that the ressource is not delayed*/
  77602. static readonly DELAYLOADSTATE_NONE: number;
  77603. /** Defines that the ressource was successfully delay loaded */
  77604. static readonly DELAYLOADSTATE_LOADED: number;
  77605. /** Defines that the ressource is currently delay loading */
  77606. static readonly DELAYLOADSTATE_LOADING: number;
  77607. /** Defines that the ressource is delayed and has not started loading */
  77608. static readonly DELAYLOADSTATE_NOTLOADED: number;
  77609. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  77610. static readonly NEVER: number;
  77611. /** 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 */
  77612. static readonly ALWAYS: number;
  77613. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  77614. static readonly LESS: number;
  77615. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  77616. static readonly EQUAL: number;
  77617. /** 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 */
  77618. static readonly LEQUAL: number;
  77619. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  77620. static readonly GREATER: number;
  77621. /** 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 */
  77622. static readonly GEQUAL: number;
  77623. /** 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 */
  77624. static readonly NOTEQUAL: number;
  77625. /** Passed to stencilOperation to specify that stencil value must be kept */
  77626. static readonly KEEP: number;
  77627. /** Passed to stencilOperation to specify that stencil value must be replaced */
  77628. static readonly REPLACE: number;
  77629. /** Passed to stencilOperation to specify that stencil value must be incremented */
  77630. static readonly INCR: number;
  77631. /** Passed to stencilOperation to specify that stencil value must be decremented */
  77632. static readonly DECR: number;
  77633. /** Passed to stencilOperation to specify that stencil value must be inverted */
  77634. static readonly INVERT: number;
  77635. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  77636. static readonly INCR_WRAP: number;
  77637. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  77638. static readonly DECR_WRAP: number;
  77639. /** Texture is not repeating outside of 0..1 UVs */
  77640. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  77641. /** Texture is repeating outside of 0..1 UVs */
  77642. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  77643. /** Texture is repeating and mirrored */
  77644. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  77645. /** ALPHA */
  77646. static readonly TEXTUREFORMAT_ALPHA: number;
  77647. /** LUMINANCE */
  77648. static readonly TEXTUREFORMAT_LUMINANCE: number;
  77649. /** LUMINANCE_ALPHA */
  77650. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  77651. /** RGB */
  77652. static readonly TEXTUREFORMAT_RGB: number;
  77653. /** RGBA */
  77654. static readonly TEXTUREFORMAT_RGBA: number;
  77655. /** RED */
  77656. static readonly TEXTUREFORMAT_RED: number;
  77657. /** RED (2nd reference) */
  77658. static readonly TEXTUREFORMAT_R: number;
  77659. /** RG */
  77660. static readonly TEXTUREFORMAT_RG: number;
  77661. /** RED_INTEGER */
  77662. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  77663. /** RED_INTEGER (2nd reference) */
  77664. static readonly TEXTUREFORMAT_R_INTEGER: number;
  77665. /** RG_INTEGER */
  77666. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  77667. /** RGB_INTEGER */
  77668. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  77669. /** RGBA_INTEGER */
  77670. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  77671. /** UNSIGNED_BYTE */
  77672. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  77673. /** UNSIGNED_BYTE (2nd reference) */
  77674. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  77675. /** FLOAT */
  77676. static readonly TEXTURETYPE_FLOAT: number;
  77677. /** HALF_FLOAT */
  77678. static readonly TEXTURETYPE_HALF_FLOAT: number;
  77679. /** BYTE */
  77680. static readonly TEXTURETYPE_BYTE: number;
  77681. /** SHORT */
  77682. static readonly TEXTURETYPE_SHORT: number;
  77683. /** UNSIGNED_SHORT */
  77684. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  77685. /** INT */
  77686. static readonly TEXTURETYPE_INT: number;
  77687. /** UNSIGNED_INT */
  77688. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  77689. /** UNSIGNED_SHORT_4_4_4_4 */
  77690. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  77691. /** UNSIGNED_SHORT_5_5_5_1 */
  77692. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  77693. /** UNSIGNED_SHORT_5_6_5 */
  77694. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  77695. /** UNSIGNED_INT_2_10_10_10_REV */
  77696. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  77697. /** UNSIGNED_INT_24_8 */
  77698. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  77699. /** UNSIGNED_INT_10F_11F_11F_REV */
  77700. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  77701. /** UNSIGNED_INT_5_9_9_9_REV */
  77702. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  77703. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  77704. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77705. /** nearest is mag = nearest and min = nearest and no mip */
  77706. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  77707. /** mag = nearest and min = nearest and mip = none */
  77708. static readonly TEXTURE_NEAREST_NEAREST: number;
  77709. /** Bilinear is mag = linear and min = linear and no mip */
  77710. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  77711. /** mag = linear and min = linear and mip = none */
  77712. static readonly TEXTURE_LINEAR_LINEAR: number;
  77713. /** Trilinear is mag = linear and min = linear and mip = linear */
  77714. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  77715. /** Trilinear is mag = linear and min = linear and mip = linear */
  77716. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  77717. /** mag = nearest and min = nearest and mip = nearest */
  77718. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  77719. /** mag = nearest and min = linear and mip = nearest */
  77720. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  77721. /** mag = nearest and min = linear and mip = linear */
  77722. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  77723. /** mag = nearest and min = linear and mip = none */
  77724. static readonly TEXTURE_NEAREST_LINEAR: number;
  77725. /** nearest is mag = nearest and min = nearest and mip = linear */
  77726. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  77727. /** mag = linear and min = nearest and mip = nearest */
  77728. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  77729. /** mag = linear and min = nearest and mip = linear */
  77730. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  77731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  77733. /** mag = linear and min = nearest and mip = none */
  77734. static readonly TEXTURE_LINEAR_NEAREST: number;
  77735. /** Explicit coordinates mode */
  77736. static readonly TEXTURE_EXPLICIT_MODE: number;
  77737. /** Spherical coordinates mode */
  77738. static readonly TEXTURE_SPHERICAL_MODE: number;
  77739. /** Planar coordinates mode */
  77740. static readonly TEXTURE_PLANAR_MODE: number;
  77741. /** Cubic coordinates mode */
  77742. static readonly TEXTURE_CUBIC_MODE: number;
  77743. /** Projection coordinates mode */
  77744. static readonly TEXTURE_PROJECTION_MODE: number;
  77745. /** Skybox coordinates mode */
  77746. static readonly TEXTURE_SKYBOX_MODE: number;
  77747. /** Inverse Cubic coordinates mode */
  77748. static readonly TEXTURE_INVCUBIC_MODE: number;
  77749. /** Equirectangular coordinates mode */
  77750. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  77751. /** Equirectangular Fixed coordinates mode */
  77752. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  77753. /** Equirectangular Fixed Mirrored coordinates mode */
  77754. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77755. /** Offline (baking) quality for texture filtering */
  77756. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  77757. /** High quality for texture filtering */
  77758. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  77759. /** Medium quality for texture filtering */
  77760. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  77761. /** Low quality for texture filtering */
  77762. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  77763. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  77764. static readonly SCALEMODE_FLOOR: number;
  77765. /** Defines that texture rescaling will look for the nearest power of 2 size */
  77766. static readonly SCALEMODE_NEAREST: number;
  77767. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  77768. static readonly SCALEMODE_CEILING: number;
  77769. /**
  77770. * The dirty texture flag value
  77771. */
  77772. static readonly MATERIAL_TextureDirtyFlag: number;
  77773. /**
  77774. * The dirty light flag value
  77775. */
  77776. static readonly MATERIAL_LightDirtyFlag: number;
  77777. /**
  77778. * The dirty fresnel flag value
  77779. */
  77780. static readonly MATERIAL_FresnelDirtyFlag: number;
  77781. /**
  77782. * The dirty attribute flag value
  77783. */
  77784. static readonly MATERIAL_AttributesDirtyFlag: number;
  77785. /**
  77786. * The dirty misc flag value
  77787. */
  77788. static readonly MATERIAL_MiscDirtyFlag: number;
  77789. /**
  77790. * The all dirty flag value
  77791. */
  77792. static readonly MATERIAL_AllDirtyFlag: number;
  77793. /**
  77794. * Returns the triangle fill mode
  77795. */
  77796. static readonly MATERIAL_TriangleFillMode: number;
  77797. /**
  77798. * Returns the wireframe mode
  77799. */
  77800. static readonly MATERIAL_WireFrameFillMode: number;
  77801. /**
  77802. * Returns the point fill mode
  77803. */
  77804. static readonly MATERIAL_PointFillMode: number;
  77805. /**
  77806. * Returns the point list draw mode
  77807. */
  77808. static readonly MATERIAL_PointListDrawMode: number;
  77809. /**
  77810. * Returns the line list draw mode
  77811. */
  77812. static readonly MATERIAL_LineListDrawMode: number;
  77813. /**
  77814. * Returns the line loop draw mode
  77815. */
  77816. static readonly MATERIAL_LineLoopDrawMode: number;
  77817. /**
  77818. * Returns the line strip draw mode
  77819. */
  77820. static readonly MATERIAL_LineStripDrawMode: number;
  77821. /**
  77822. * Returns the triangle strip draw mode
  77823. */
  77824. static readonly MATERIAL_TriangleStripDrawMode: number;
  77825. /**
  77826. * Returns the triangle fan draw mode
  77827. */
  77828. static readonly MATERIAL_TriangleFanDrawMode: number;
  77829. /**
  77830. * Stores the clock-wise side orientation
  77831. */
  77832. static readonly MATERIAL_ClockWiseSideOrientation: number;
  77833. /**
  77834. * Stores the counter clock-wise side orientation
  77835. */
  77836. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  77837. /**
  77838. * Nothing
  77839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77840. */
  77841. static readonly ACTION_NothingTrigger: number;
  77842. /**
  77843. * On pick
  77844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77845. */
  77846. static readonly ACTION_OnPickTrigger: number;
  77847. /**
  77848. * On left pick
  77849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77850. */
  77851. static readonly ACTION_OnLeftPickTrigger: number;
  77852. /**
  77853. * On right pick
  77854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77855. */
  77856. static readonly ACTION_OnRightPickTrigger: number;
  77857. /**
  77858. * On center pick
  77859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77860. */
  77861. static readonly ACTION_OnCenterPickTrigger: number;
  77862. /**
  77863. * On pick down
  77864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77865. */
  77866. static readonly ACTION_OnPickDownTrigger: number;
  77867. /**
  77868. * On double pick
  77869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77870. */
  77871. static readonly ACTION_OnDoublePickTrigger: number;
  77872. /**
  77873. * On pick up
  77874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77875. */
  77876. static readonly ACTION_OnPickUpTrigger: number;
  77877. /**
  77878. * On pick out.
  77879. * This trigger will only be raised if you also declared a OnPickDown
  77880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77881. */
  77882. static readonly ACTION_OnPickOutTrigger: number;
  77883. /**
  77884. * On long press
  77885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77886. */
  77887. static readonly ACTION_OnLongPressTrigger: number;
  77888. /**
  77889. * On pointer over
  77890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77891. */
  77892. static readonly ACTION_OnPointerOverTrigger: number;
  77893. /**
  77894. * On pointer out
  77895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77896. */
  77897. static readonly ACTION_OnPointerOutTrigger: number;
  77898. /**
  77899. * On every frame
  77900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77901. */
  77902. static readonly ACTION_OnEveryFrameTrigger: number;
  77903. /**
  77904. * On intersection enter
  77905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77906. */
  77907. static readonly ACTION_OnIntersectionEnterTrigger: number;
  77908. /**
  77909. * On intersection exit
  77910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77911. */
  77912. static readonly ACTION_OnIntersectionExitTrigger: number;
  77913. /**
  77914. * On key down
  77915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77916. */
  77917. static readonly ACTION_OnKeyDownTrigger: number;
  77918. /**
  77919. * On key up
  77920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77921. */
  77922. static readonly ACTION_OnKeyUpTrigger: number;
  77923. /**
  77924. * Billboard mode will only apply to Y axis
  77925. */
  77926. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  77927. /**
  77928. * Billboard mode will apply to all axes
  77929. */
  77930. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  77931. /**
  77932. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  77933. */
  77934. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  77935. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  77936. * Test order :
  77937. * Is the bounding sphere outside the frustum ?
  77938. * If not, are the bounding box vertices outside the frustum ?
  77939. * It not, then the cullable object is in the frustum.
  77940. */
  77941. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  77942. /** Culling strategy : Bounding Sphere Only.
  77943. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  77944. * It's also less accurate than the standard because some not visible objects can still be selected.
  77945. * Test : is the bounding sphere outside the frustum ?
  77946. * If not, then the cullable object is in the frustum.
  77947. */
  77948. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  77949. /** Culling strategy : Optimistic Inclusion.
  77950. * This in an inclusion test first, then the standard exclusion test.
  77951. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  77952. * 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.
  77953. * Anyway, it's as accurate as the standard strategy.
  77954. * Test :
  77955. * Is the cullable object bounding sphere center in the frustum ?
  77956. * If not, apply the default culling strategy.
  77957. */
  77958. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  77959. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  77960. * This in an inclusion test first, then the bounding sphere only exclusion test.
  77961. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  77962. * 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.
  77963. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  77964. * Test :
  77965. * Is the cullable object bounding sphere center in the frustum ?
  77966. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  77967. */
  77968. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  77969. /**
  77970. * No logging while loading
  77971. */
  77972. static readonly SCENELOADER_NO_LOGGING: number;
  77973. /**
  77974. * Minimal logging while loading
  77975. */
  77976. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  77977. /**
  77978. * Summary logging while loading
  77979. */
  77980. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  77981. /**
  77982. * Detailled logging while loading
  77983. */
  77984. static readonly SCENELOADER_DETAILED_LOGGING: number;
  77985. }
  77986. }
  77987. declare module BABYLON {
  77988. /**
  77989. * This represents the required contract to create a new type of texture loader.
  77990. */
  77991. export interface IInternalTextureLoader {
  77992. /**
  77993. * Defines wether the loader supports cascade loading the different faces.
  77994. */
  77995. supportCascades: boolean;
  77996. /**
  77997. * This returns if the loader support the current file information.
  77998. * @param extension defines the file extension of the file being loaded
  77999. * @returns true if the loader can load the specified file
  78000. */
  78001. canLoad(extension: string): boolean;
  78002. /**
  78003. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78004. * @param data contains the texture data
  78005. * @param texture defines the BabylonJS internal texture
  78006. * @param createPolynomials will be true if polynomials have been requested
  78007. * @param onLoad defines the callback to trigger once the texture is ready
  78008. * @param onError defines the callback to trigger in case of error
  78009. */
  78010. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78011. /**
  78012. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78013. * @param data contains the texture data
  78014. * @param texture defines the BabylonJS internal texture
  78015. * @param callback defines the method to call once ready to upload
  78016. */
  78017. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78018. }
  78019. }
  78020. declare module BABYLON {
  78021. /**
  78022. * Class used to store and describe the pipeline context associated with an effect
  78023. */
  78024. export interface IPipelineContext {
  78025. /**
  78026. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78027. */
  78028. isAsync: boolean;
  78029. /**
  78030. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78031. */
  78032. isReady: boolean;
  78033. /** @hidden */
  78034. _getVertexShaderCode(): string | null;
  78035. /** @hidden */
  78036. _getFragmentShaderCode(): string | null;
  78037. /** @hidden */
  78038. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78039. }
  78040. }
  78041. declare module BABYLON {
  78042. /**
  78043. * Class used to store gfx data (like WebGLBuffer)
  78044. */
  78045. export class DataBuffer {
  78046. /**
  78047. * Gets or sets the number of objects referencing this buffer
  78048. */
  78049. references: number;
  78050. /** Gets or sets the size of the underlying buffer */
  78051. capacity: number;
  78052. /**
  78053. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78054. */
  78055. is32Bits: boolean;
  78056. /**
  78057. * Gets the underlying buffer
  78058. */
  78059. get underlyingResource(): any;
  78060. }
  78061. }
  78062. declare module BABYLON {
  78063. /** @hidden */
  78064. export interface IShaderProcessor {
  78065. attributeProcessor?: (attribute: string) => string;
  78066. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78067. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78068. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78069. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78070. lineProcessor?: (line: string, isFragment: boolean) => string;
  78071. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78072. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78073. }
  78074. }
  78075. declare module BABYLON {
  78076. /** @hidden */
  78077. export interface ProcessingOptions {
  78078. defines: string[];
  78079. indexParameters: any;
  78080. isFragment: boolean;
  78081. shouldUseHighPrecisionShader: boolean;
  78082. supportsUniformBuffers: boolean;
  78083. shadersRepository: string;
  78084. includesShadersStore: {
  78085. [key: string]: string;
  78086. };
  78087. processor?: IShaderProcessor;
  78088. version: string;
  78089. platformName: string;
  78090. lookForClosingBracketForUniformBuffer?: boolean;
  78091. }
  78092. }
  78093. declare module BABYLON {
  78094. /** @hidden */
  78095. export class ShaderCodeNode {
  78096. line: string;
  78097. children: ShaderCodeNode[];
  78098. additionalDefineKey?: string;
  78099. additionalDefineValue?: string;
  78100. isValid(preprocessors: {
  78101. [key: string]: string;
  78102. }): boolean;
  78103. process(preprocessors: {
  78104. [key: string]: string;
  78105. }, options: ProcessingOptions): string;
  78106. }
  78107. }
  78108. declare module BABYLON {
  78109. /** @hidden */
  78110. export class ShaderCodeCursor {
  78111. private _lines;
  78112. lineIndex: number;
  78113. get currentLine(): string;
  78114. get canRead(): boolean;
  78115. set lines(value: string[]);
  78116. }
  78117. }
  78118. declare module BABYLON {
  78119. /** @hidden */
  78120. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78121. process(preprocessors: {
  78122. [key: string]: string;
  78123. }, options: ProcessingOptions): string;
  78124. }
  78125. }
  78126. declare module BABYLON {
  78127. /** @hidden */
  78128. export class ShaderDefineExpression {
  78129. isTrue(preprocessors: {
  78130. [key: string]: string;
  78131. }): boolean;
  78132. private static _OperatorPriority;
  78133. private static _Stack;
  78134. static postfixToInfix(postfix: string[]): string;
  78135. static infixToPostfix(infix: string): string[];
  78136. }
  78137. }
  78138. declare module BABYLON {
  78139. /** @hidden */
  78140. export class ShaderCodeTestNode extends ShaderCodeNode {
  78141. testExpression: ShaderDefineExpression;
  78142. isValid(preprocessors: {
  78143. [key: string]: string;
  78144. }): boolean;
  78145. }
  78146. }
  78147. declare module BABYLON {
  78148. /** @hidden */
  78149. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78150. define: string;
  78151. not: boolean;
  78152. constructor(define: string, not?: boolean);
  78153. isTrue(preprocessors: {
  78154. [key: string]: string;
  78155. }): boolean;
  78156. }
  78157. }
  78158. declare module BABYLON {
  78159. /** @hidden */
  78160. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78161. leftOperand: ShaderDefineExpression;
  78162. rightOperand: ShaderDefineExpression;
  78163. isTrue(preprocessors: {
  78164. [key: string]: string;
  78165. }): boolean;
  78166. }
  78167. }
  78168. declare module BABYLON {
  78169. /** @hidden */
  78170. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78171. leftOperand: ShaderDefineExpression;
  78172. rightOperand: ShaderDefineExpression;
  78173. isTrue(preprocessors: {
  78174. [key: string]: string;
  78175. }): boolean;
  78176. }
  78177. }
  78178. declare module BABYLON {
  78179. /** @hidden */
  78180. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78181. define: string;
  78182. operand: string;
  78183. testValue: string;
  78184. constructor(define: string, operand: string, testValue: string);
  78185. isTrue(preprocessors: {
  78186. [key: string]: string;
  78187. }): boolean;
  78188. }
  78189. }
  78190. declare module BABYLON {
  78191. /**
  78192. * Class used to enable access to offline support
  78193. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78194. */
  78195. export interface IOfflineProvider {
  78196. /**
  78197. * Gets a boolean indicating if scene must be saved in the database
  78198. */
  78199. enableSceneOffline: boolean;
  78200. /**
  78201. * Gets a boolean indicating if textures must be saved in the database
  78202. */
  78203. enableTexturesOffline: boolean;
  78204. /**
  78205. * Open the offline support and make it available
  78206. * @param successCallback defines the callback to call on success
  78207. * @param errorCallback defines the callback to call on error
  78208. */
  78209. open(successCallback: () => void, errorCallback: () => void): void;
  78210. /**
  78211. * Loads an image from the offline support
  78212. * @param url defines the url to load from
  78213. * @param image defines the target DOM image
  78214. */
  78215. loadImage(url: string, image: HTMLImageElement): void;
  78216. /**
  78217. * Loads a file from offline support
  78218. * @param url defines the URL to load from
  78219. * @param sceneLoaded defines a callback to call on success
  78220. * @param progressCallBack defines a callback to call when progress changed
  78221. * @param errorCallback defines a callback to call on error
  78222. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78223. */
  78224. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78225. }
  78226. }
  78227. declare module BABYLON {
  78228. /**
  78229. * Class used to help managing file picking and drag'n'drop
  78230. * File Storage
  78231. */
  78232. export class FilesInputStore {
  78233. /**
  78234. * List of files ready to be loaded
  78235. */
  78236. static FilesToLoad: {
  78237. [key: string]: File;
  78238. };
  78239. }
  78240. }
  78241. declare module BABYLON {
  78242. /**
  78243. * Class used to define a retry strategy when error happens while loading assets
  78244. */
  78245. export class RetryStrategy {
  78246. /**
  78247. * Function used to defines an exponential back off strategy
  78248. * @param maxRetries defines the maximum number of retries (3 by default)
  78249. * @param baseInterval defines the interval between retries
  78250. * @returns the strategy function to use
  78251. */
  78252. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78253. }
  78254. }
  78255. declare module BABYLON {
  78256. /**
  78257. * @ignore
  78258. * Application error to support additional information when loading a file
  78259. */
  78260. export abstract class BaseError extends Error {
  78261. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78262. }
  78263. }
  78264. declare module BABYLON {
  78265. /** @ignore */
  78266. export class LoadFileError extends BaseError {
  78267. request?: WebRequest;
  78268. file?: File;
  78269. /**
  78270. * Creates a new LoadFileError
  78271. * @param message defines the message of the error
  78272. * @param request defines the optional web request
  78273. * @param file defines the optional file
  78274. */
  78275. constructor(message: string, object?: WebRequest | File);
  78276. }
  78277. /** @ignore */
  78278. export class RequestFileError extends BaseError {
  78279. request: WebRequest;
  78280. /**
  78281. * Creates a new LoadFileError
  78282. * @param message defines the message of the error
  78283. * @param request defines the optional web request
  78284. */
  78285. constructor(message: string, request: WebRequest);
  78286. }
  78287. /** @ignore */
  78288. export class ReadFileError extends BaseError {
  78289. file: File;
  78290. /**
  78291. * Creates a new ReadFileError
  78292. * @param message defines the message of the error
  78293. * @param file defines the optional file
  78294. */
  78295. constructor(message: string, file: File);
  78296. }
  78297. /**
  78298. * @hidden
  78299. */
  78300. export class FileTools {
  78301. /**
  78302. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78303. */
  78304. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78305. /**
  78306. * Gets or sets the base URL to use to load assets
  78307. */
  78308. static BaseUrl: string;
  78309. /**
  78310. * Default behaviour for cors in the application.
  78311. * It can be a string if the expected behavior is identical in the entire app.
  78312. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78313. */
  78314. static CorsBehavior: string | ((url: string | string[]) => string);
  78315. /**
  78316. * Gets or sets a function used to pre-process url before using them to load assets
  78317. */
  78318. static PreprocessUrl: (url: string) => string;
  78319. /**
  78320. * Removes unwanted characters from an url
  78321. * @param url defines the url to clean
  78322. * @returns the cleaned url
  78323. */
  78324. private static _CleanUrl;
  78325. /**
  78326. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78327. * @param url define the url we are trying
  78328. * @param element define the dom element where to configure the cors policy
  78329. */
  78330. static SetCorsBehavior(url: string | string[], element: {
  78331. crossOrigin: string | null;
  78332. }): void;
  78333. /**
  78334. * Loads an image as an HTMLImageElement.
  78335. * @param input url string, ArrayBuffer, or Blob to load
  78336. * @param onLoad callback called when the image successfully loads
  78337. * @param onError callback called when the image fails to load
  78338. * @param offlineProvider offline provider for caching
  78339. * @param mimeType optional mime type
  78340. * @returns the HTMLImageElement of the loaded image
  78341. */
  78342. 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>;
  78343. /**
  78344. * Reads a file from a File object
  78345. * @param file defines the file to load
  78346. * @param onSuccess defines the callback to call when data is loaded
  78347. * @param onProgress defines the callback to call during loading process
  78348. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78349. * @param onError defines the callback to call when an error occurs
  78350. * @returns a file request object
  78351. */
  78352. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78353. /**
  78354. * Loads a file from a url
  78355. * @param url url to load
  78356. * @param onSuccess callback called when the file successfully loads
  78357. * @param onProgress callback called while file is loading (if the server supports this mode)
  78358. * @param offlineProvider defines the offline provider for caching
  78359. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78360. * @param onError callback called when the file fails to load
  78361. * @returns a file request object
  78362. */
  78363. 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;
  78364. /**
  78365. * Loads a file
  78366. * @param url url to load
  78367. * @param onSuccess callback called when the file successfully loads
  78368. * @param onProgress callback called while file is loading (if the server supports this mode)
  78369. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78370. * @param onError callback called when the file fails to load
  78371. * @param onOpened callback called when the web request is opened
  78372. * @returns a file request object
  78373. */
  78374. 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;
  78375. /**
  78376. * Checks if the loaded document was accessed via `file:`-Protocol.
  78377. * @returns boolean
  78378. */
  78379. static IsFileURL(): boolean;
  78380. }
  78381. }
  78382. declare module BABYLON {
  78383. /** @hidden */
  78384. export class ShaderProcessor {
  78385. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78386. private static _ProcessPrecision;
  78387. private static _ExtractOperation;
  78388. private static _BuildSubExpression;
  78389. private static _BuildExpression;
  78390. private static _MoveCursorWithinIf;
  78391. private static _MoveCursor;
  78392. private static _EvaluatePreProcessors;
  78393. private static _PreparePreProcessors;
  78394. private static _ProcessShaderConversion;
  78395. private static _ProcessIncludes;
  78396. /**
  78397. * Loads a file from a url
  78398. * @param url url to load
  78399. * @param onSuccess callback called when the file successfully loads
  78400. * @param onProgress callback called while file is loading (if the server supports this mode)
  78401. * @param offlineProvider defines the offline provider for caching
  78402. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78403. * @param onError callback called when the file fails to load
  78404. * @returns a file request object
  78405. * @hidden
  78406. */
  78407. 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;
  78408. }
  78409. }
  78410. declare module BABYLON {
  78411. /**
  78412. * @hidden
  78413. */
  78414. export interface IColor4Like {
  78415. r: float;
  78416. g: float;
  78417. b: float;
  78418. a: float;
  78419. }
  78420. /**
  78421. * @hidden
  78422. */
  78423. export interface IColor3Like {
  78424. r: float;
  78425. g: float;
  78426. b: float;
  78427. }
  78428. /**
  78429. * @hidden
  78430. */
  78431. export interface IVector4Like {
  78432. x: float;
  78433. y: float;
  78434. z: float;
  78435. w: float;
  78436. }
  78437. /**
  78438. * @hidden
  78439. */
  78440. export interface IVector3Like {
  78441. x: float;
  78442. y: float;
  78443. z: float;
  78444. }
  78445. /**
  78446. * @hidden
  78447. */
  78448. export interface IVector2Like {
  78449. x: float;
  78450. y: float;
  78451. }
  78452. /**
  78453. * @hidden
  78454. */
  78455. export interface IMatrixLike {
  78456. toArray(): DeepImmutable<Float32Array>;
  78457. updateFlag: int;
  78458. }
  78459. /**
  78460. * @hidden
  78461. */
  78462. export interface IViewportLike {
  78463. x: float;
  78464. y: float;
  78465. width: float;
  78466. height: float;
  78467. }
  78468. /**
  78469. * @hidden
  78470. */
  78471. export interface IPlaneLike {
  78472. normal: IVector3Like;
  78473. d: float;
  78474. normalize(): void;
  78475. }
  78476. }
  78477. declare module BABYLON {
  78478. /**
  78479. * Interface used to define common properties for effect fallbacks
  78480. */
  78481. export interface IEffectFallbacks {
  78482. /**
  78483. * Removes the defines that should be removed when falling back.
  78484. * @param currentDefines defines the current define statements for the shader.
  78485. * @param effect defines the current effect we try to compile
  78486. * @returns The resulting defines with defines of the current rank removed.
  78487. */
  78488. reduce(currentDefines: string, effect: Effect): string;
  78489. /**
  78490. * Removes the fallback from the bound mesh.
  78491. */
  78492. unBindMesh(): void;
  78493. /**
  78494. * Checks to see if more fallbacks are still availible.
  78495. */
  78496. hasMoreFallbacks: boolean;
  78497. }
  78498. }
  78499. declare module BABYLON {
  78500. /**
  78501. * Class used to evalaute queries containing `and` and `or` operators
  78502. */
  78503. export class AndOrNotEvaluator {
  78504. /**
  78505. * Evaluate a query
  78506. * @param query defines the query to evaluate
  78507. * @param evaluateCallback defines the callback used to filter result
  78508. * @returns true if the query matches
  78509. */
  78510. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  78511. private static _HandleParenthesisContent;
  78512. private static _SimplifyNegation;
  78513. }
  78514. }
  78515. declare module BABYLON {
  78516. /**
  78517. * Class used to store custom tags
  78518. */
  78519. export class Tags {
  78520. /**
  78521. * Adds support for tags on the given object
  78522. * @param obj defines the object to use
  78523. */
  78524. static EnableFor(obj: any): void;
  78525. /**
  78526. * Removes tags support
  78527. * @param obj defines the object to use
  78528. */
  78529. static DisableFor(obj: any): void;
  78530. /**
  78531. * Gets a boolean indicating if the given object has tags
  78532. * @param obj defines the object to use
  78533. * @returns a boolean
  78534. */
  78535. static HasTags(obj: any): boolean;
  78536. /**
  78537. * Gets the tags available on a given object
  78538. * @param obj defines the object to use
  78539. * @param asString defines if the tags must be returned as a string instead of an array of strings
  78540. * @returns the tags
  78541. */
  78542. static GetTags(obj: any, asString?: boolean): any;
  78543. /**
  78544. * Adds tags to an object
  78545. * @param obj defines the object to use
  78546. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  78547. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  78548. */
  78549. static AddTagsTo(obj: any, tagsString: string): void;
  78550. /**
  78551. * @hidden
  78552. */
  78553. static _AddTagTo(obj: any, tag: string): void;
  78554. /**
  78555. * Removes specific tags from a specific object
  78556. * @param obj defines the object to use
  78557. * @param tagsString defines the tags to remove
  78558. */
  78559. static RemoveTagsFrom(obj: any, tagsString: string): void;
  78560. /**
  78561. * @hidden
  78562. */
  78563. static _RemoveTagFrom(obj: any, tag: string): void;
  78564. /**
  78565. * Defines if tags hosted on an object match a given query
  78566. * @param obj defines the object to use
  78567. * @param tagsQuery defines the tag query
  78568. * @returns a boolean
  78569. */
  78570. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  78571. }
  78572. }
  78573. declare module BABYLON {
  78574. /**
  78575. * Scalar computation library
  78576. */
  78577. export class Scalar {
  78578. /**
  78579. * Two pi constants convenient for computation.
  78580. */
  78581. static TwoPi: number;
  78582. /**
  78583. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78584. * @param a number
  78585. * @param b number
  78586. * @param epsilon (default = 1.401298E-45)
  78587. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78588. */
  78589. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  78590. /**
  78591. * Returns a string : the upper case translation of the number i to hexadecimal.
  78592. * @param i number
  78593. * @returns the upper case translation of the number i to hexadecimal.
  78594. */
  78595. static ToHex(i: number): string;
  78596. /**
  78597. * Returns -1 if value is negative and +1 is value is positive.
  78598. * @param value the value
  78599. * @returns the value itself if it's equal to zero.
  78600. */
  78601. static Sign(value: number): number;
  78602. /**
  78603. * Returns the value itself if it's between min and max.
  78604. * Returns min if the value is lower than min.
  78605. * Returns max if the value is greater than max.
  78606. * @param value the value to clmap
  78607. * @param min the min value to clamp to (default: 0)
  78608. * @param max the max value to clamp to (default: 1)
  78609. * @returns the clamped value
  78610. */
  78611. static Clamp(value: number, min?: number, max?: number): number;
  78612. /**
  78613. * the log2 of value.
  78614. * @param value the value to compute log2 of
  78615. * @returns the log2 of value.
  78616. */
  78617. static Log2(value: number): number;
  78618. /**
  78619. * Loops the value, so that it is never larger than length and never smaller than 0.
  78620. *
  78621. * This is similar to the modulo operator but it works with floating point numbers.
  78622. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  78623. * With t = 5 and length = 2.5, the result would be 0.0.
  78624. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  78625. * @param value the value
  78626. * @param length the length
  78627. * @returns the looped value
  78628. */
  78629. static Repeat(value: number, length: number): number;
  78630. /**
  78631. * Normalize the value between 0.0 and 1.0 using min and max values
  78632. * @param value value to normalize
  78633. * @param min max to normalize between
  78634. * @param max min to normalize between
  78635. * @returns the normalized value
  78636. */
  78637. static Normalize(value: number, min: number, max: number): number;
  78638. /**
  78639. * Denormalize the value from 0.0 and 1.0 using min and max values
  78640. * @param normalized value to denormalize
  78641. * @param min max to denormalize between
  78642. * @param max min to denormalize between
  78643. * @returns the denormalized value
  78644. */
  78645. static Denormalize(normalized: number, min: number, max: number): number;
  78646. /**
  78647. * Calculates the shortest difference between two given angles given in degrees.
  78648. * @param current current angle in degrees
  78649. * @param target target angle in degrees
  78650. * @returns the delta
  78651. */
  78652. static DeltaAngle(current: number, target: number): number;
  78653. /**
  78654. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  78655. * @param tx value
  78656. * @param length length
  78657. * @returns The returned value will move back and forth between 0 and length
  78658. */
  78659. static PingPong(tx: number, length: number): number;
  78660. /**
  78661. * Interpolates between min and max with smoothing at the limits.
  78662. *
  78663. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  78664. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  78665. * @param from from
  78666. * @param to to
  78667. * @param tx value
  78668. * @returns the smooth stepped value
  78669. */
  78670. static SmoothStep(from: number, to: number, tx: number): number;
  78671. /**
  78672. * Moves a value current towards target.
  78673. *
  78674. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  78675. * Negative values of maxDelta pushes the value away from target.
  78676. * @param current current value
  78677. * @param target target value
  78678. * @param maxDelta max distance to move
  78679. * @returns resulting value
  78680. */
  78681. static MoveTowards(current: number, target: number, maxDelta: number): number;
  78682. /**
  78683. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78684. *
  78685. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  78686. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  78687. * @param current current value
  78688. * @param target target value
  78689. * @param maxDelta max distance to move
  78690. * @returns resulting angle
  78691. */
  78692. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  78693. /**
  78694. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  78695. * @param start start value
  78696. * @param end target value
  78697. * @param amount amount to lerp between
  78698. * @returns the lerped value
  78699. */
  78700. static Lerp(start: number, end: number, amount: number): number;
  78701. /**
  78702. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78703. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  78704. * @param start start value
  78705. * @param end target value
  78706. * @param amount amount to lerp between
  78707. * @returns the lerped value
  78708. */
  78709. static LerpAngle(start: number, end: number, amount: number): number;
  78710. /**
  78711. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  78712. * @param a start value
  78713. * @param b target value
  78714. * @param value value between a and b
  78715. * @returns the inverseLerp value
  78716. */
  78717. static InverseLerp(a: number, b: number, value: number): number;
  78718. /**
  78719. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  78720. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  78721. * @param value1 spline value
  78722. * @param tangent1 spline value
  78723. * @param value2 spline value
  78724. * @param tangent2 spline value
  78725. * @param amount input value
  78726. * @returns hermite result
  78727. */
  78728. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  78729. /**
  78730. * Returns a random float number between and min and max values
  78731. * @param min min value of random
  78732. * @param max max value of random
  78733. * @returns random value
  78734. */
  78735. static RandomRange(min: number, max: number): number;
  78736. /**
  78737. * This function returns percentage of a number in a given range.
  78738. *
  78739. * RangeToPercent(40,20,60) will return 0.5 (50%)
  78740. * RangeToPercent(34,0,100) will return 0.34 (34%)
  78741. * @param number to convert to percentage
  78742. * @param min min range
  78743. * @param max max range
  78744. * @returns the percentage
  78745. */
  78746. static RangeToPercent(number: number, min: number, max: number): number;
  78747. /**
  78748. * This function returns number that corresponds to the percentage in a given range.
  78749. *
  78750. * PercentToRange(0.34,0,100) will return 34.
  78751. * @param percent to convert to number
  78752. * @param min min range
  78753. * @param max max range
  78754. * @returns the number
  78755. */
  78756. static PercentToRange(percent: number, min: number, max: number): number;
  78757. /**
  78758. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  78759. * @param angle The angle to normalize in radian.
  78760. * @return The converted angle.
  78761. */
  78762. static NormalizeRadians(angle: number): number;
  78763. }
  78764. }
  78765. declare module BABYLON {
  78766. /**
  78767. * Constant used to convert a value to gamma space
  78768. * @ignorenaming
  78769. */
  78770. export const ToGammaSpace: number;
  78771. /**
  78772. * Constant used to convert a value to linear space
  78773. * @ignorenaming
  78774. */
  78775. export const ToLinearSpace = 2.2;
  78776. /**
  78777. * Constant used to define the minimal number value in Babylon.js
  78778. * @ignorenaming
  78779. */
  78780. let Epsilon: number;
  78781. }
  78782. declare module BABYLON {
  78783. /**
  78784. * Class used to represent a viewport on screen
  78785. */
  78786. export class Viewport {
  78787. /** viewport left coordinate */
  78788. x: number;
  78789. /** viewport top coordinate */
  78790. y: number;
  78791. /**viewport width */
  78792. width: number;
  78793. /** viewport height */
  78794. height: number;
  78795. /**
  78796. * Creates a Viewport object located at (x, y) and sized (width, height)
  78797. * @param x defines viewport left coordinate
  78798. * @param y defines viewport top coordinate
  78799. * @param width defines the viewport width
  78800. * @param height defines the viewport height
  78801. */
  78802. constructor(
  78803. /** viewport left coordinate */
  78804. x: number,
  78805. /** viewport top coordinate */
  78806. y: number,
  78807. /**viewport width */
  78808. width: number,
  78809. /** viewport height */
  78810. height: number);
  78811. /**
  78812. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  78813. * @param renderWidth defines the rendering width
  78814. * @param renderHeight defines the rendering height
  78815. * @returns a new Viewport
  78816. */
  78817. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  78818. /**
  78819. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  78820. * @param renderWidth defines the rendering width
  78821. * @param renderHeight defines the rendering height
  78822. * @param ref defines the target viewport
  78823. * @returns the current viewport
  78824. */
  78825. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  78826. /**
  78827. * Returns a new Viewport copied from the current one
  78828. * @returns a new Viewport
  78829. */
  78830. clone(): Viewport;
  78831. }
  78832. }
  78833. declare module BABYLON {
  78834. /**
  78835. * Class containing a set of static utilities functions for arrays.
  78836. */
  78837. export class ArrayTools {
  78838. /**
  78839. * Returns an array of the given size filled with element built from the given constructor and the paramters
  78840. * @param size the number of element to construct and put in the array
  78841. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  78842. * @returns a new array filled with new objects
  78843. */
  78844. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  78845. }
  78846. }
  78847. declare module BABYLON {
  78848. /**
  78849. * Represens a plane by the equation ax + by + cz + d = 0
  78850. */
  78851. export class Plane {
  78852. private static _TmpMatrix;
  78853. /**
  78854. * Normal of the plane (a,b,c)
  78855. */
  78856. normal: Vector3;
  78857. /**
  78858. * d component of the plane
  78859. */
  78860. d: number;
  78861. /**
  78862. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  78863. * @param a a component of the plane
  78864. * @param b b component of the plane
  78865. * @param c c component of the plane
  78866. * @param d d component of the plane
  78867. */
  78868. constructor(a: number, b: number, c: number, d: number);
  78869. /**
  78870. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  78871. */
  78872. asArray(): number[];
  78873. /**
  78874. * @returns a new plane copied from the current Plane.
  78875. */
  78876. clone(): Plane;
  78877. /**
  78878. * @returns the string "Plane".
  78879. */
  78880. getClassName(): string;
  78881. /**
  78882. * @returns the Plane hash code.
  78883. */
  78884. getHashCode(): number;
  78885. /**
  78886. * Normalize the current Plane in place.
  78887. * @returns the updated Plane.
  78888. */
  78889. normalize(): Plane;
  78890. /**
  78891. * Applies a transformation the plane and returns the result
  78892. * @param transformation the transformation matrix to be applied to the plane
  78893. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  78894. */
  78895. transform(transformation: DeepImmutable<Matrix>): Plane;
  78896. /**
  78897. * Compute the dot product between the point and the plane normal
  78898. * @param point point to calculate the dot product with
  78899. * @returns the dot product (float) of the point coordinates and the plane normal.
  78900. */
  78901. dotCoordinate(point: DeepImmutable<Vector3>): number;
  78902. /**
  78903. * Updates the current Plane from the plane defined by the three given points.
  78904. * @param point1 one of the points used to contruct the plane
  78905. * @param point2 one of the points used to contruct the plane
  78906. * @param point3 one of the points used to contruct the plane
  78907. * @returns the updated Plane.
  78908. */
  78909. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78910. /**
  78911. * Checks if the plane is facing a given direction
  78912. * @param direction the direction to check if the plane is facing
  78913. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78914. * @returns True is the vector "direction" is the same side than the plane normal.
  78915. */
  78916. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  78917. /**
  78918. * Calculates the distance to a point
  78919. * @param point point to calculate distance to
  78920. * @returns the signed distance (float) from the given point to the Plane.
  78921. */
  78922. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  78923. /**
  78924. * Creates a plane from an array
  78925. * @param array the array to create a plane from
  78926. * @returns a new Plane from the given array.
  78927. */
  78928. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  78929. /**
  78930. * Creates a plane from three points
  78931. * @param point1 point used to create the plane
  78932. * @param point2 point used to create the plane
  78933. * @param point3 point used to create the plane
  78934. * @returns a new Plane defined by the three given points.
  78935. */
  78936. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78937. /**
  78938. * Creates a plane from an origin point and a normal
  78939. * @param origin origin of the plane to be constructed
  78940. * @param normal normal of the plane to be constructed
  78941. * @returns a new Plane the normal vector to this plane at the given origin point.
  78942. * Note : the vector "normal" is updated because normalized.
  78943. */
  78944. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78945. /**
  78946. * Calculates the distance from a plane and a point
  78947. * @param origin origin of the plane to be constructed
  78948. * @param normal normal of the plane to be constructed
  78949. * @param point point to calculate distance to
  78950. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78951. */
  78952. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  78953. }
  78954. }
  78955. declare module BABYLON {
  78956. /**
  78957. * Class representing a vector containing 2 coordinates
  78958. */
  78959. export class Vector2 {
  78960. /** defines the first coordinate */
  78961. x: number;
  78962. /** defines the second coordinate */
  78963. y: number;
  78964. /**
  78965. * Creates a new Vector2 from the given x and y coordinates
  78966. * @param x defines the first coordinate
  78967. * @param y defines the second coordinate
  78968. */
  78969. constructor(
  78970. /** defines the first coordinate */
  78971. x?: number,
  78972. /** defines the second coordinate */
  78973. y?: number);
  78974. /**
  78975. * Gets a string with the Vector2 coordinates
  78976. * @returns a string with the Vector2 coordinates
  78977. */
  78978. toString(): string;
  78979. /**
  78980. * Gets class name
  78981. * @returns the string "Vector2"
  78982. */
  78983. getClassName(): string;
  78984. /**
  78985. * Gets current vector hash code
  78986. * @returns the Vector2 hash code as a number
  78987. */
  78988. getHashCode(): number;
  78989. /**
  78990. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  78991. * @param array defines the source array
  78992. * @param index defines the offset in source array
  78993. * @returns the current Vector2
  78994. */
  78995. toArray(array: FloatArray, index?: number): Vector2;
  78996. /**
  78997. * Copy the current vector to an array
  78998. * @returns a new array with 2 elements: the Vector2 coordinates.
  78999. */
  79000. asArray(): number[];
  79001. /**
  79002. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79003. * @param source defines the source Vector2
  79004. * @returns the current updated Vector2
  79005. */
  79006. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79007. /**
  79008. * Sets the Vector2 coordinates with the given floats
  79009. * @param x defines the first coordinate
  79010. * @param y defines the second coordinate
  79011. * @returns the current updated Vector2
  79012. */
  79013. copyFromFloats(x: number, y: number): Vector2;
  79014. /**
  79015. * Sets the Vector2 coordinates with the given floats
  79016. * @param x defines the first coordinate
  79017. * @param y defines the second coordinate
  79018. * @returns the current updated Vector2
  79019. */
  79020. set(x: number, y: number): Vector2;
  79021. /**
  79022. * Add another vector with the current one
  79023. * @param otherVector defines the other vector
  79024. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79025. */
  79026. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79027. /**
  79028. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79029. * @param otherVector defines the other vector
  79030. * @param result defines the target vector
  79031. * @returns the unmodified current Vector2
  79032. */
  79033. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79034. /**
  79035. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79036. * @param otherVector defines the other vector
  79037. * @returns the current updated Vector2
  79038. */
  79039. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79040. /**
  79041. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79042. * @param otherVector defines the other vector
  79043. * @returns a new Vector2
  79044. */
  79045. addVector3(otherVector: Vector3): Vector2;
  79046. /**
  79047. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79048. * @param otherVector defines the other vector
  79049. * @returns a new Vector2
  79050. */
  79051. subtract(otherVector: Vector2): Vector2;
  79052. /**
  79053. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79054. * @param otherVector defines the other vector
  79055. * @param result defines the target vector
  79056. * @returns the unmodified current Vector2
  79057. */
  79058. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79059. /**
  79060. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79061. * @param otherVector defines the other vector
  79062. * @returns the current updated Vector2
  79063. */
  79064. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79065. /**
  79066. * Multiplies in place the current Vector2 coordinates by the given ones
  79067. * @param otherVector defines the other vector
  79068. * @returns the current updated Vector2
  79069. */
  79070. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79071. /**
  79072. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79073. * @param otherVector defines the other vector
  79074. * @returns a new Vector2
  79075. */
  79076. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79077. /**
  79078. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79079. * @param otherVector defines the other vector
  79080. * @param result defines the target vector
  79081. * @returns the unmodified current Vector2
  79082. */
  79083. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79084. /**
  79085. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79086. * @param x defines the first coordinate
  79087. * @param y defines the second coordinate
  79088. * @returns a new Vector2
  79089. */
  79090. multiplyByFloats(x: number, y: number): Vector2;
  79091. /**
  79092. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79093. * @param otherVector defines the other vector
  79094. * @returns a new Vector2
  79095. */
  79096. divide(otherVector: Vector2): Vector2;
  79097. /**
  79098. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79099. * @param otherVector defines the other vector
  79100. * @param result defines the target vector
  79101. * @returns the unmodified current Vector2
  79102. */
  79103. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79104. /**
  79105. * Divides the current Vector2 coordinates by the given ones
  79106. * @param otherVector defines the other vector
  79107. * @returns the current updated Vector2
  79108. */
  79109. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79110. /**
  79111. * Gets a new Vector2 with current Vector2 negated coordinates
  79112. * @returns a new Vector2
  79113. */
  79114. negate(): Vector2;
  79115. /**
  79116. * Negate this vector in place
  79117. * @returns this
  79118. */
  79119. negateInPlace(): Vector2;
  79120. /**
  79121. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79122. * @param result defines the Vector3 object where to store the result
  79123. * @returns the current Vector2
  79124. */
  79125. negateToRef(result: Vector2): Vector2;
  79126. /**
  79127. * Multiply the Vector2 coordinates by scale
  79128. * @param scale defines the scaling factor
  79129. * @returns the current updated Vector2
  79130. */
  79131. scaleInPlace(scale: number): Vector2;
  79132. /**
  79133. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79134. * @param scale defines the scaling factor
  79135. * @returns a new Vector2
  79136. */
  79137. scale(scale: number): Vector2;
  79138. /**
  79139. * Scale the current Vector2 values by a factor to a given Vector2
  79140. * @param scale defines the scale factor
  79141. * @param result defines the Vector2 object where to store the result
  79142. * @returns the unmodified current Vector2
  79143. */
  79144. scaleToRef(scale: number, result: Vector2): Vector2;
  79145. /**
  79146. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79147. * @param scale defines the scale factor
  79148. * @param result defines the Vector2 object where to store the result
  79149. * @returns the unmodified current Vector2
  79150. */
  79151. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79152. /**
  79153. * Gets a boolean if two vectors are equals
  79154. * @param otherVector defines the other vector
  79155. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79156. */
  79157. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79158. /**
  79159. * Gets a boolean if two vectors are equals (using an epsilon value)
  79160. * @param otherVector defines the other vector
  79161. * @param epsilon defines the minimal distance to consider equality
  79162. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79163. */
  79164. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79165. /**
  79166. * Gets a new Vector2 from current Vector2 floored values
  79167. * @returns a new Vector2
  79168. */
  79169. floor(): Vector2;
  79170. /**
  79171. * Gets a new Vector2 from current Vector2 floored values
  79172. * @returns a new Vector2
  79173. */
  79174. fract(): Vector2;
  79175. /**
  79176. * Gets the length of the vector
  79177. * @returns the vector length (float)
  79178. */
  79179. length(): number;
  79180. /**
  79181. * Gets the vector squared length
  79182. * @returns the vector squared length (float)
  79183. */
  79184. lengthSquared(): number;
  79185. /**
  79186. * Normalize the vector
  79187. * @returns the current updated Vector2
  79188. */
  79189. normalize(): Vector2;
  79190. /**
  79191. * Gets a new Vector2 copied from the Vector2
  79192. * @returns a new Vector2
  79193. */
  79194. clone(): Vector2;
  79195. /**
  79196. * Gets a new Vector2(0, 0)
  79197. * @returns a new Vector2
  79198. */
  79199. static Zero(): Vector2;
  79200. /**
  79201. * Gets a new Vector2(1, 1)
  79202. * @returns a new Vector2
  79203. */
  79204. static One(): Vector2;
  79205. /**
  79206. * Gets a new Vector2 set from the given index element of the given array
  79207. * @param array defines the data source
  79208. * @param offset defines the offset in the data source
  79209. * @returns a new Vector2
  79210. */
  79211. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79212. /**
  79213. * Sets "result" from the given index element of the given array
  79214. * @param array defines the data source
  79215. * @param offset defines the offset in the data source
  79216. * @param result defines the target vector
  79217. */
  79218. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79219. /**
  79220. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79221. * @param value1 defines 1st point of control
  79222. * @param value2 defines 2nd point of control
  79223. * @param value3 defines 3rd point of control
  79224. * @param value4 defines 4th point of control
  79225. * @param amount defines the interpolation factor
  79226. * @returns a new Vector2
  79227. */
  79228. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79229. /**
  79230. * 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".
  79231. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79232. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79233. * @param value defines the value to clamp
  79234. * @param min defines the lower limit
  79235. * @param max defines the upper limit
  79236. * @returns a new Vector2
  79237. */
  79238. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79239. /**
  79240. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79241. * @param value1 defines the 1st control point
  79242. * @param tangent1 defines the outgoing tangent
  79243. * @param value2 defines the 2nd control point
  79244. * @param tangent2 defines the incoming tangent
  79245. * @param amount defines the interpolation factor
  79246. * @returns a new Vector2
  79247. */
  79248. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79249. /**
  79250. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79251. * @param start defines the start vector
  79252. * @param end defines the end vector
  79253. * @param amount defines the interpolation factor
  79254. * @returns a new Vector2
  79255. */
  79256. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79257. /**
  79258. * Gets the dot product of the vector "left" and the vector "right"
  79259. * @param left defines first vector
  79260. * @param right defines second vector
  79261. * @returns the dot product (float)
  79262. */
  79263. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79264. /**
  79265. * Returns a new Vector2 equal to the normalized given vector
  79266. * @param vector defines the vector to normalize
  79267. * @returns a new Vector2
  79268. */
  79269. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79270. /**
  79271. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79272. * @param left defines 1st vector
  79273. * @param right defines 2nd vector
  79274. * @returns a new Vector2
  79275. */
  79276. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79277. /**
  79278. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79279. * @param left defines 1st vector
  79280. * @param right defines 2nd vector
  79281. * @returns a new Vector2
  79282. */
  79283. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79284. /**
  79285. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79286. * @param vector defines the vector to transform
  79287. * @param transformation defines the matrix to apply
  79288. * @returns a new Vector2
  79289. */
  79290. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79291. /**
  79292. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79293. * @param vector defines the vector to transform
  79294. * @param transformation defines the matrix to apply
  79295. * @param result defines the target vector
  79296. */
  79297. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79298. /**
  79299. * Determines if a given vector is included in a triangle
  79300. * @param p defines the vector to test
  79301. * @param p0 defines 1st triangle point
  79302. * @param p1 defines 2nd triangle point
  79303. * @param p2 defines 3rd triangle point
  79304. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79305. */
  79306. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79307. /**
  79308. * Gets the distance between the vectors "value1" and "value2"
  79309. * @param value1 defines first vector
  79310. * @param value2 defines second vector
  79311. * @returns the distance between vectors
  79312. */
  79313. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79314. /**
  79315. * Returns the squared distance between the vectors "value1" and "value2"
  79316. * @param value1 defines first vector
  79317. * @param value2 defines second vector
  79318. * @returns the squared distance between vectors
  79319. */
  79320. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79321. /**
  79322. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79323. * @param value1 defines first vector
  79324. * @param value2 defines second vector
  79325. * @returns a new Vector2
  79326. */
  79327. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79328. /**
  79329. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79330. * @param p defines the middle point
  79331. * @param segA defines one point of the segment
  79332. * @param segB defines the other point of the segment
  79333. * @returns the shortest distance
  79334. */
  79335. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79336. }
  79337. /**
  79338. * Class used to store (x,y,z) vector representation
  79339. * A Vector3 is the main object used in 3D geometry
  79340. * It can represent etiher the coordinates of a point the space, either a direction
  79341. * Reminder: js uses a left handed forward facing system
  79342. */
  79343. export class Vector3 {
  79344. /**
  79345. * Defines the first coordinates (on X axis)
  79346. */
  79347. x: number;
  79348. /**
  79349. * Defines the second coordinates (on Y axis)
  79350. */
  79351. y: number;
  79352. /**
  79353. * Defines the third coordinates (on Z axis)
  79354. */
  79355. z: number;
  79356. private static _UpReadOnly;
  79357. private static _ZeroReadOnly;
  79358. /**
  79359. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79360. * @param x defines the first coordinates (on X axis)
  79361. * @param y defines the second coordinates (on Y axis)
  79362. * @param z defines the third coordinates (on Z axis)
  79363. */
  79364. constructor(
  79365. /**
  79366. * Defines the first coordinates (on X axis)
  79367. */
  79368. x?: number,
  79369. /**
  79370. * Defines the second coordinates (on Y axis)
  79371. */
  79372. y?: number,
  79373. /**
  79374. * Defines the third coordinates (on Z axis)
  79375. */
  79376. z?: number);
  79377. /**
  79378. * Creates a string representation of the Vector3
  79379. * @returns a string with the Vector3 coordinates.
  79380. */
  79381. toString(): string;
  79382. /**
  79383. * Gets the class name
  79384. * @returns the string "Vector3"
  79385. */
  79386. getClassName(): string;
  79387. /**
  79388. * Creates the Vector3 hash code
  79389. * @returns a number which tends to be unique between Vector3 instances
  79390. */
  79391. getHashCode(): number;
  79392. /**
  79393. * Creates an array containing three elements : the coordinates of the Vector3
  79394. * @returns a new array of numbers
  79395. */
  79396. asArray(): number[];
  79397. /**
  79398. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79399. * @param array defines the destination array
  79400. * @param index defines the offset in the destination array
  79401. * @returns the current Vector3
  79402. */
  79403. toArray(array: FloatArray, index?: number): Vector3;
  79404. /**
  79405. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  79406. * @returns a new Quaternion object, computed from the Vector3 coordinates
  79407. */
  79408. toQuaternion(): Quaternion;
  79409. /**
  79410. * Adds the given vector to the current Vector3
  79411. * @param otherVector defines the second operand
  79412. * @returns the current updated Vector3
  79413. */
  79414. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79415. /**
  79416. * Adds the given coordinates to the current Vector3
  79417. * @param x defines the x coordinate of the operand
  79418. * @param y defines the y coordinate of the operand
  79419. * @param z defines the z coordinate of the operand
  79420. * @returns the current updated Vector3
  79421. */
  79422. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79423. /**
  79424. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  79425. * @param otherVector defines the second operand
  79426. * @returns the resulting Vector3
  79427. */
  79428. add(otherVector: DeepImmutable<Vector3>): Vector3;
  79429. /**
  79430. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  79431. * @param otherVector defines the second operand
  79432. * @param result defines the Vector3 object where to store the result
  79433. * @returns the current Vector3
  79434. */
  79435. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79436. /**
  79437. * Subtract the given vector from the current Vector3
  79438. * @param otherVector defines the second operand
  79439. * @returns the current updated Vector3
  79440. */
  79441. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79442. /**
  79443. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  79444. * @param otherVector defines the second operand
  79445. * @returns the resulting Vector3
  79446. */
  79447. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  79448. /**
  79449. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  79450. * @param otherVector defines the second operand
  79451. * @param result defines the Vector3 object where to store the result
  79452. * @returns the current Vector3
  79453. */
  79454. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79455. /**
  79456. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  79457. * @param x defines the x coordinate of the operand
  79458. * @param y defines the y coordinate of the operand
  79459. * @param z defines the z coordinate of the operand
  79460. * @returns the resulting Vector3
  79461. */
  79462. subtractFromFloats(x: number, y: number, z: number): Vector3;
  79463. /**
  79464. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  79465. * @param x defines the x coordinate of the operand
  79466. * @param y defines the y coordinate of the operand
  79467. * @param z defines the z coordinate of the operand
  79468. * @param result defines the Vector3 object where to store the result
  79469. * @returns the current Vector3
  79470. */
  79471. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  79472. /**
  79473. * Gets a new Vector3 set with the current Vector3 negated coordinates
  79474. * @returns a new Vector3
  79475. */
  79476. negate(): Vector3;
  79477. /**
  79478. * Negate this vector in place
  79479. * @returns this
  79480. */
  79481. negateInPlace(): Vector3;
  79482. /**
  79483. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  79484. * @param result defines the Vector3 object where to store the result
  79485. * @returns the current Vector3
  79486. */
  79487. negateToRef(result: Vector3): Vector3;
  79488. /**
  79489. * Multiplies the Vector3 coordinates by the float "scale"
  79490. * @param scale defines the multiplier factor
  79491. * @returns the current updated Vector3
  79492. */
  79493. scaleInPlace(scale: number): Vector3;
  79494. /**
  79495. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  79496. * @param scale defines the multiplier factor
  79497. * @returns a new Vector3
  79498. */
  79499. scale(scale: number): Vector3;
  79500. /**
  79501. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  79502. * @param scale defines the multiplier factor
  79503. * @param result defines the Vector3 object where to store the result
  79504. * @returns the current Vector3
  79505. */
  79506. scaleToRef(scale: number, result: Vector3): Vector3;
  79507. /**
  79508. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  79509. * @param scale defines the scale factor
  79510. * @param result defines the Vector3 object where to store the result
  79511. * @returns the unmodified current Vector3
  79512. */
  79513. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  79514. /**
  79515. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79516. * @param origin defines the origin of the projection ray
  79517. * @param plane defines the plane to project to
  79518. * @returns the projected vector3
  79519. */
  79520. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  79521. /**
  79522. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79523. * @param origin defines the origin of the projection ray
  79524. * @param plane defines the plane to project to
  79525. * @param result defines the Vector3 where to store the result
  79526. */
  79527. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  79528. /**
  79529. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  79530. * @param otherVector defines the second operand
  79531. * @returns true if both vectors are equals
  79532. */
  79533. equals(otherVector: DeepImmutable<Vector3>): boolean;
  79534. /**
  79535. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  79536. * @param otherVector defines the second operand
  79537. * @param epsilon defines the minimal distance to define values as equals
  79538. * @returns true if both vectors are distant less than epsilon
  79539. */
  79540. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  79541. /**
  79542. * Returns true if the current Vector3 coordinates equals the given floats
  79543. * @param x defines the x coordinate of the operand
  79544. * @param y defines the y coordinate of the operand
  79545. * @param z defines the z coordinate of the operand
  79546. * @returns true if both vectors are equals
  79547. */
  79548. equalsToFloats(x: number, y: number, z: number): boolean;
  79549. /**
  79550. * Multiplies the current Vector3 coordinates by the given ones
  79551. * @param otherVector defines the second operand
  79552. * @returns the current updated Vector3
  79553. */
  79554. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79555. /**
  79556. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  79557. * @param otherVector defines the second operand
  79558. * @returns the new Vector3
  79559. */
  79560. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  79561. /**
  79562. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  79563. * @param otherVector defines the second operand
  79564. * @param result defines the Vector3 object where to store the result
  79565. * @returns the current Vector3
  79566. */
  79567. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79568. /**
  79569. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  79570. * @param x defines the x coordinate of the operand
  79571. * @param y defines the y coordinate of the operand
  79572. * @param z defines the z coordinate of the operand
  79573. * @returns the new Vector3
  79574. */
  79575. multiplyByFloats(x: number, y: number, z: number): Vector3;
  79576. /**
  79577. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  79578. * @param otherVector defines the second operand
  79579. * @returns the new Vector3
  79580. */
  79581. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  79582. /**
  79583. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  79584. * @param otherVector defines the second operand
  79585. * @param result defines the Vector3 object where to store the result
  79586. * @returns the current Vector3
  79587. */
  79588. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79589. /**
  79590. * Divides the current Vector3 coordinates by the given ones.
  79591. * @param otherVector defines the second operand
  79592. * @returns the current updated Vector3
  79593. */
  79594. divideInPlace(otherVector: Vector3): Vector3;
  79595. /**
  79596. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  79597. * @param other defines the second operand
  79598. * @returns the current updated Vector3
  79599. */
  79600. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79601. /**
  79602. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  79603. * @param other defines the second operand
  79604. * @returns the current updated Vector3
  79605. */
  79606. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79607. /**
  79608. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  79609. * @param x defines the x coordinate of the operand
  79610. * @param y defines the y coordinate of the operand
  79611. * @param z defines the z coordinate of the operand
  79612. * @returns the current updated Vector3
  79613. */
  79614. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79615. /**
  79616. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  79617. * @param x defines the x coordinate of the operand
  79618. * @param y defines the y coordinate of the operand
  79619. * @param z defines the z coordinate of the operand
  79620. * @returns the current updated Vector3
  79621. */
  79622. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79623. /**
  79624. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  79625. * Check if is non uniform within a certain amount of decimal places to account for this
  79626. * @param epsilon the amount the values can differ
  79627. * @returns if the the vector is non uniform to a certain number of decimal places
  79628. */
  79629. isNonUniformWithinEpsilon(epsilon: number): boolean;
  79630. /**
  79631. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  79632. */
  79633. get isNonUniform(): boolean;
  79634. /**
  79635. * Gets a new Vector3 from current Vector3 floored values
  79636. * @returns a new Vector3
  79637. */
  79638. floor(): Vector3;
  79639. /**
  79640. * Gets a new Vector3 from current Vector3 floored values
  79641. * @returns a new Vector3
  79642. */
  79643. fract(): Vector3;
  79644. /**
  79645. * Gets the length of the Vector3
  79646. * @returns the length of the Vector3
  79647. */
  79648. length(): number;
  79649. /**
  79650. * Gets the squared length of the Vector3
  79651. * @returns squared length of the Vector3
  79652. */
  79653. lengthSquared(): number;
  79654. /**
  79655. * Normalize the current Vector3.
  79656. * Please note that this is an in place operation.
  79657. * @returns the current updated Vector3
  79658. */
  79659. normalize(): Vector3;
  79660. /**
  79661. * Reorders the x y z properties of the vector in place
  79662. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  79663. * @returns the current updated vector
  79664. */
  79665. reorderInPlace(order: string): this;
  79666. /**
  79667. * Rotates the vector around 0,0,0 by a quaternion
  79668. * @param quaternion the rotation quaternion
  79669. * @param result vector to store the result
  79670. * @returns the resulting vector
  79671. */
  79672. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  79673. /**
  79674. * Rotates a vector around a given point
  79675. * @param quaternion the rotation quaternion
  79676. * @param point the point to rotate around
  79677. * @param result vector to store the result
  79678. * @returns the resulting vector
  79679. */
  79680. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  79681. /**
  79682. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  79683. * The cross product is then orthogonal to both current and "other"
  79684. * @param other defines the right operand
  79685. * @returns the cross product
  79686. */
  79687. cross(other: Vector3): Vector3;
  79688. /**
  79689. * Normalize the current Vector3 with the given input length.
  79690. * Please note that this is an in place operation.
  79691. * @param len the length of the vector
  79692. * @returns the current updated Vector3
  79693. */
  79694. normalizeFromLength(len: number): Vector3;
  79695. /**
  79696. * Normalize the current Vector3 to a new vector
  79697. * @returns the new Vector3
  79698. */
  79699. normalizeToNew(): Vector3;
  79700. /**
  79701. * Normalize the current Vector3 to the reference
  79702. * @param reference define the Vector3 to update
  79703. * @returns the updated Vector3
  79704. */
  79705. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  79706. /**
  79707. * Creates a new Vector3 copied from the current Vector3
  79708. * @returns the new Vector3
  79709. */
  79710. clone(): Vector3;
  79711. /**
  79712. * Copies the given vector coordinates to the current Vector3 ones
  79713. * @param source defines the source Vector3
  79714. * @returns the current updated Vector3
  79715. */
  79716. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  79717. /**
  79718. * Copies the given floats to the current Vector3 coordinates
  79719. * @param x defines the x coordinate of the operand
  79720. * @param y defines the y coordinate of the operand
  79721. * @param z defines the z coordinate of the operand
  79722. * @returns the current updated Vector3
  79723. */
  79724. copyFromFloats(x: number, y: number, z: number): Vector3;
  79725. /**
  79726. * Copies the given floats to the current Vector3 coordinates
  79727. * @param x defines the x coordinate of the operand
  79728. * @param y defines the y coordinate of the operand
  79729. * @param z defines the z coordinate of the operand
  79730. * @returns the current updated Vector3
  79731. */
  79732. set(x: number, y: number, z: number): Vector3;
  79733. /**
  79734. * Copies the given float to the current Vector3 coordinates
  79735. * @param v defines the x, y and z coordinates of the operand
  79736. * @returns the current updated Vector3
  79737. */
  79738. setAll(v: number): Vector3;
  79739. /**
  79740. * Get the clip factor between two vectors
  79741. * @param vector0 defines the first operand
  79742. * @param vector1 defines the second operand
  79743. * @param axis defines the axis to use
  79744. * @param size defines the size along the axis
  79745. * @returns the clip factor
  79746. */
  79747. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  79748. /**
  79749. * Get angle between two vectors
  79750. * @param vector0 angle between vector0 and vector1
  79751. * @param vector1 angle between vector0 and vector1
  79752. * @param normal direction of the normal
  79753. * @return the angle between vector0 and vector1
  79754. */
  79755. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  79756. /**
  79757. * Returns a new Vector3 set from the index "offset" of the given array
  79758. * @param array defines the source array
  79759. * @param offset defines the offset in the source array
  79760. * @returns the new Vector3
  79761. */
  79762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  79763. /**
  79764. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  79765. * @param array defines the source array
  79766. * @param offset defines the offset in the source array
  79767. * @returns the new Vector3
  79768. * @deprecated Please use FromArray instead.
  79769. */
  79770. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  79771. /**
  79772. * Sets the given vector "result" with the element values from the index "offset" of the given array
  79773. * @param array defines the source array
  79774. * @param offset defines the offset in the source array
  79775. * @param result defines the Vector3 where to store the result
  79776. */
  79777. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  79778. /**
  79779. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  79780. * @param array defines the source array
  79781. * @param offset defines the offset in the source array
  79782. * @param result defines the Vector3 where to store the result
  79783. * @deprecated Please use FromArrayToRef instead.
  79784. */
  79785. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  79786. /**
  79787. * Sets the given vector "result" with the given floats.
  79788. * @param x defines the x coordinate of the source
  79789. * @param y defines the y coordinate of the source
  79790. * @param z defines the z coordinate of the source
  79791. * @param result defines the Vector3 where to store the result
  79792. */
  79793. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  79794. /**
  79795. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  79796. * @returns a new empty Vector3
  79797. */
  79798. static Zero(): Vector3;
  79799. /**
  79800. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  79801. * @returns a new unit Vector3
  79802. */
  79803. static One(): Vector3;
  79804. /**
  79805. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  79806. * @returns a new up Vector3
  79807. */
  79808. static Up(): Vector3;
  79809. /**
  79810. * Gets a up Vector3 that must not be updated
  79811. */
  79812. static get UpReadOnly(): DeepImmutable<Vector3>;
  79813. /**
  79814. * Gets a zero Vector3 that must not be updated
  79815. */
  79816. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  79817. /**
  79818. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  79819. * @returns a new down Vector3
  79820. */
  79821. static Down(): Vector3;
  79822. /**
  79823. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  79824. * @param rightHandedSystem is the scene right-handed (negative z)
  79825. * @returns a new forward Vector3
  79826. */
  79827. static Forward(rightHandedSystem?: boolean): Vector3;
  79828. /**
  79829. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  79830. * @param rightHandedSystem is the scene right-handed (negative-z)
  79831. * @returns a new forward Vector3
  79832. */
  79833. static Backward(rightHandedSystem?: boolean): Vector3;
  79834. /**
  79835. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  79836. * @returns a new right Vector3
  79837. */
  79838. static Right(): Vector3;
  79839. /**
  79840. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  79841. * @returns a new left Vector3
  79842. */
  79843. static Left(): Vector3;
  79844. /**
  79845. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  79846. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  79847. * @param vector defines the Vector3 to transform
  79848. * @param transformation defines the transformation matrix
  79849. * @returns the transformed Vector3
  79850. */
  79851. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  79852. /**
  79853. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  79854. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  79855. * @param vector defines the Vector3 to transform
  79856. * @param transformation defines the transformation matrix
  79857. * @param result defines the Vector3 where to store the result
  79858. */
  79859. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79860. /**
  79861. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  79862. * This method computes tranformed coordinates only, not transformed direction vectors
  79863. * @param x define the x coordinate of the source vector
  79864. * @param y define the y coordinate of the source vector
  79865. * @param z define the z coordinate of the source vector
  79866. * @param transformation defines the transformation matrix
  79867. * @param result defines the Vector3 where to store the result
  79868. */
  79869. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79870. /**
  79871. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  79872. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  79873. * @param vector defines the Vector3 to transform
  79874. * @param transformation defines the transformation matrix
  79875. * @returns the new Vector3
  79876. */
  79877. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  79878. /**
  79879. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  79880. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  79881. * @param vector defines the Vector3 to transform
  79882. * @param transformation defines the transformation matrix
  79883. * @param result defines the Vector3 where to store the result
  79884. */
  79885. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79886. /**
  79887. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  79888. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  79889. * @param x define the x coordinate of the source vector
  79890. * @param y define the y coordinate of the source vector
  79891. * @param z define the z coordinate of the source vector
  79892. * @param transformation defines the transformation matrix
  79893. * @param result defines the Vector3 where to store the result
  79894. */
  79895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79896. /**
  79897. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  79898. * @param value1 defines the first control point
  79899. * @param value2 defines the second control point
  79900. * @param value3 defines the third control point
  79901. * @param value4 defines the fourth control point
  79902. * @param amount defines the amount on the spline to use
  79903. * @returns the new Vector3
  79904. */
  79905. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  79906. /**
  79907. * 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"
  79908. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  79909. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  79910. * @param value defines the current value
  79911. * @param min defines the lower range value
  79912. * @param max defines the upper range value
  79913. * @returns the new Vector3
  79914. */
  79915. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  79916. /**
  79917. * 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"
  79918. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  79919. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  79920. * @param value defines the current value
  79921. * @param min defines the lower range value
  79922. * @param max defines the upper range value
  79923. * @param result defines the Vector3 where to store the result
  79924. */
  79925. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  79926. /**
  79927. * Checks if a given vector is inside a specific range
  79928. * @param v defines the vector to test
  79929. * @param min defines the minimum range
  79930. * @param max defines the maximum range
  79931. */
  79932. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  79933. /**
  79934. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  79935. * @param value1 defines the first control point
  79936. * @param tangent1 defines the first tangent vector
  79937. * @param value2 defines the second control point
  79938. * @param tangent2 defines the second tangent vector
  79939. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  79940. * @returns the new Vector3
  79941. */
  79942. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  79943. /**
  79944. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  79945. * @param start defines the start value
  79946. * @param end defines the end value
  79947. * @param amount max defines amount between both (between 0 and 1)
  79948. * @returns the new Vector3
  79949. */
  79950. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  79951. /**
  79952. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  79953. * @param start defines the start value
  79954. * @param end defines the end value
  79955. * @param amount max defines amount between both (between 0 and 1)
  79956. * @param result defines the Vector3 where to store the result
  79957. */
  79958. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  79959. /**
  79960. * Returns the dot product (float) between the vectors "left" and "right"
  79961. * @param left defines the left operand
  79962. * @param right defines the right operand
  79963. * @returns the dot product
  79964. */
  79965. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  79966. /**
  79967. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  79968. * The cross product is then orthogonal to both "left" and "right"
  79969. * @param left defines the left operand
  79970. * @param right defines the right operand
  79971. * @returns the cross product
  79972. */
  79973. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  79974. /**
  79975. * Sets the given vector "result" with the cross product of "left" and "right"
  79976. * The cross product is then orthogonal to both "left" and "right"
  79977. * @param left defines the left operand
  79978. * @param right defines the right operand
  79979. * @param result defines the Vector3 where to store the result
  79980. */
  79981. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  79982. /**
  79983. * Returns a new Vector3 as the normalization of the given vector
  79984. * @param vector defines the Vector3 to normalize
  79985. * @returns the new Vector3
  79986. */
  79987. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  79988. /**
  79989. * Sets the given vector "result" with the normalization of the given first vector
  79990. * @param vector defines the Vector3 to normalize
  79991. * @param result defines the Vector3 where to store the result
  79992. */
  79993. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  79994. /**
  79995. * Project a Vector3 onto screen space
  79996. * @param vector defines the Vector3 to project
  79997. * @param world defines the world matrix to use
  79998. * @param transform defines the transform (view x projection) matrix to use
  79999. * @param viewport defines the screen viewport to use
  80000. * @returns the new Vector3
  80001. */
  80002. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80003. /** @hidden */
  80004. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80005. /**
  80006. * Unproject from screen space to object space
  80007. * @param source defines the screen space Vector3 to use
  80008. * @param viewportWidth defines the current width of the viewport
  80009. * @param viewportHeight defines the current height of the viewport
  80010. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80011. * @param transform defines the transform (view x projection) matrix to use
  80012. * @returns the new Vector3
  80013. */
  80014. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80015. /**
  80016. * Unproject from screen space to object space
  80017. * @param source defines the screen space Vector3 to use
  80018. * @param viewportWidth defines the current width of the viewport
  80019. * @param viewportHeight defines the current height of the viewport
  80020. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80021. * @param view defines the view matrix to use
  80022. * @param projection defines the projection matrix to use
  80023. * @returns the new Vector3
  80024. */
  80025. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80026. /**
  80027. * Unproject from screen space to object space
  80028. * @param source defines the screen space Vector3 to use
  80029. * @param viewportWidth defines the current width of the viewport
  80030. * @param viewportHeight defines the current height of the viewport
  80031. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80032. * @param view defines the view matrix to use
  80033. * @param projection defines the projection matrix to use
  80034. * @param result defines the Vector3 where to store the result
  80035. */
  80036. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80037. /**
  80038. * Unproject from screen space to object space
  80039. * @param sourceX defines the screen space x coordinate to use
  80040. * @param sourceY defines the screen space y coordinate to use
  80041. * @param sourceZ defines the screen space z coordinate to use
  80042. * @param viewportWidth defines the current width of the viewport
  80043. * @param viewportHeight defines the current height of the viewport
  80044. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80045. * @param view defines the view matrix to use
  80046. * @param projection defines the projection matrix to use
  80047. * @param result defines the Vector3 where to store the result
  80048. */
  80049. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80050. /**
  80051. * Gets the minimal coordinate values between two Vector3
  80052. * @param left defines the first operand
  80053. * @param right defines the second operand
  80054. * @returns the new Vector3
  80055. */
  80056. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80057. /**
  80058. * Gets the maximal coordinate values between two Vector3
  80059. * @param left defines the first operand
  80060. * @param right defines the second operand
  80061. * @returns the new Vector3
  80062. */
  80063. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80064. /**
  80065. * Returns the distance between the vectors "value1" and "value2"
  80066. * @param value1 defines the first operand
  80067. * @param value2 defines the second operand
  80068. * @returns the distance
  80069. */
  80070. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80071. /**
  80072. * Returns the squared distance between the vectors "value1" and "value2"
  80073. * @param value1 defines the first operand
  80074. * @param value2 defines the second operand
  80075. * @returns the squared distance
  80076. */
  80077. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80078. /**
  80079. * Returns a new Vector3 located at the center between "value1" and "value2"
  80080. * @param value1 defines the first operand
  80081. * @param value2 defines the second operand
  80082. * @returns the new Vector3
  80083. */
  80084. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80085. /**
  80086. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80087. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80088. * to something in order to rotate it from its local system to the given target system
  80089. * Note: axis1, axis2 and axis3 are normalized during this operation
  80090. * @param axis1 defines the first axis
  80091. * @param axis2 defines the second axis
  80092. * @param axis3 defines the third axis
  80093. * @returns a new Vector3
  80094. */
  80095. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80096. /**
  80097. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80098. * @param axis1 defines the first axis
  80099. * @param axis2 defines the second axis
  80100. * @param axis3 defines the third axis
  80101. * @param ref defines the Vector3 where to store the result
  80102. */
  80103. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80104. }
  80105. /**
  80106. * Vector4 class created for EulerAngle class conversion to Quaternion
  80107. */
  80108. export class Vector4 {
  80109. /** x value of the vector */
  80110. x: number;
  80111. /** y value of the vector */
  80112. y: number;
  80113. /** z value of the vector */
  80114. z: number;
  80115. /** w value of the vector */
  80116. w: number;
  80117. /**
  80118. * Creates a Vector4 object from the given floats.
  80119. * @param x x value of the vector
  80120. * @param y y value of the vector
  80121. * @param z z value of the vector
  80122. * @param w w value of the vector
  80123. */
  80124. constructor(
  80125. /** x value of the vector */
  80126. x: number,
  80127. /** y value of the vector */
  80128. y: number,
  80129. /** z value of the vector */
  80130. z: number,
  80131. /** w value of the vector */
  80132. w: number);
  80133. /**
  80134. * Returns the string with the Vector4 coordinates.
  80135. * @returns a string containing all the vector values
  80136. */
  80137. toString(): string;
  80138. /**
  80139. * Returns the string "Vector4".
  80140. * @returns "Vector4"
  80141. */
  80142. getClassName(): string;
  80143. /**
  80144. * Returns the Vector4 hash code.
  80145. * @returns a unique hash code
  80146. */
  80147. getHashCode(): number;
  80148. /**
  80149. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80150. * @returns the resulting array
  80151. */
  80152. asArray(): number[];
  80153. /**
  80154. * Populates the given array from the given index with the Vector4 coordinates.
  80155. * @param array array to populate
  80156. * @param index index of the array to start at (default: 0)
  80157. * @returns the Vector4.
  80158. */
  80159. toArray(array: FloatArray, index?: number): Vector4;
  80160. /**
  80161. * Adds the given vector to the current Vector4.
  80162. * @param otherVector the vector to add
  80163. * @returns the updated Vector4.
  80164. */
  80165. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80166. /**
  80167. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80168. * @param otherVector the vector to add
  80169. * @returns the resulting vector
  80170. */
  80171. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80172. /**
  80173. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80174. * @param otherVector the vector to add
  80175. * @param result the vector to store the result
  80176. * @returns the current Vector4.
  80177. */
  80178. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80179. /**
  80180. * Subtract in place the given vector from the current Vector4.
  80181. * @param otherVector the vector to subtract
  80182. * @returns the updated Vector4.
  80183. */
  80184. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80185. /**
  80186. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80187. * @param otherVector the vector to add
  80188. * @returns the new vector with the result
  80189. */
  80190. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80191. /**
  80192. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80193. * @param otherVector the vector to subtract
  80194. * @param result the vector to store the result
  80195. * @returns the current Vector4.
  80196. */
  80197. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80198. /**
  80199. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80200. */
  80201. /**
  80202. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80203. * @param x value to subtract
  80204. * @param y value to subtract
  80205. * @param z value to subtract
  80206. * @param w value to subtract
  80207. * @returns new vector containing the result
  80208. */
  80209. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80210. /**
  80211. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80212. * @param x value to subtract
  80213. * @param y value to subtract
  80214. * @param z value to subtract
  80215. * @param w value to subtract
  80216. * @param result the vector to store the result in
  80217. * @returns the current Vector4.
  80218. */
  80219. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80220. /**
  80221. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80222. * @returns a new vector with the negated values
  80223. */
  80224. negate(): Vector4;
  80225. /**
  80226. * Negate this vector in place
  80227. * @returns this
  80228. */
  80229. negateInPlace(): Vector4;
  80230. /**
  80231. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80232. * @param result defines the Vector3 object where to store the result
  80233. * @returns the current Vector4
  80234. */
  80235. negateToRef(result: Vector4): Vector4;
  80236. /**
  80237. * Multiplies the current Vector4 coordinates by scale (float).
  80238. * @param scale the number to scale with
  80239. * @returns the updated Vector4.
  80240. */
  80241. scaleInPlace(scale: number): Vector4;
  80242. /**
  80243. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80244. * @param scale the number to scale with
  80245. * @returns a new vector with the result
  80246. */
  80247. scale(scale: number): Vector4;
  80248. /**
  80249. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80250. * @param scale the number to scale with
  80251. * @param result a vector to store the result in
  80252. * @returns the current Vector4.
  80253. */
  80254. scaleToRef(scale: number, result: Vector4): Vector4;
  80255. /**
  80256. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80257. * @param scale defines the scale factor
  80258. * @param result defines the Vector4 object where to store the result
  80259. * @returns the unmodified current Vector4
  80260. */
  80261. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80262. /**
  80263. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80264. * @param otherVector the vector to compare against
  80265. * @returns true if they are equal
  80266. */
  80267. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80268. /**
  80269. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80270. * @param otherVector vector to compare against
  80271. * @param epsilon (Default: very small number)
  80272. * @returns true if they are equal
  80273. */
  80274. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80275. /**
  80276. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80277. * @param x x value to compare against
  80278. * @param y y value to compare against
  80279. * @param z z value to compare against
  80280. * @param w w value to compare against
  80281. * @returns true if equal
  80282. */
  80283. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80284. /**
  80285. * Multiplies in place the current Vector4 by the given one.
  80286. * @param otherVector vector to multiple with
  80287. * @returns the updated Vector4.
  80288. */
  80289. multiplyInPlace(otherVector: Vector4): Vector4;
  80290. /**
  80291. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80292. * @param otherVector vector to multiple with
  80293. * @returns resulting new vector
  80294. */
  80295. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80296. /**
  80297. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80298. * @param otherVector vector to multiple with
  80299. * @param result vector to store the result
  80300. * @returns the current Vector4.
  80301. */
  80302. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80303. /**
  80304. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80305. * @param x x value multiply with
  80306. * @param y y value multiply with
  80307. * @param z z value multiply with
  80308. * @param w w value multiply with
  80309. * @returns resulting new vector
  80310. */
  80311. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80312. /**
  80313. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80314. * @param otherVector vector to devide with
  80315. * @returns resulting new vector
  80316. */
  80317. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80318. /**
  80319. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80320. * @param otherVector vector to devide with
  80321. * @param result vector to store the result
  80322. * @returns the current Vector4.
  80323. */
  80324. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80325. /**
  80326. * Divides the current Vector3 coordinates by the given ones.
  80327. * @param otherVector vector to devide with
  80328. * @returns the updated Vector3.
  80329. */
  80330. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80331. /**
  80332. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80333. * @param other defines the second operand
  80334. * @returns the current updated Vector4
  80335. */
  80336. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80337. /**
  80338. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80339. * @param other defines the second operand
  80340. * @returns the current updated Vector4
  80341. */
  80342. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80343. /**
  80344. * Gets a new Vector4 from current Vector4 floored values
  80345. * @returns a new Vector4
  80346. */
  80347. floor(): Vector4;
  80348. /**
  80349. * Gets a new Vector4 from current Vector3 floored values
  80350. * @returns a new Vector4
  80351. */
  80352. fract(): Vector4;
  80353. /**
  80354. * Returns the Vector4 length (float).
  80355. * @returns the length
  80356. */
  80357. length(): number;
  80358. /**
  80359. * Returns the Vector4 squared length (float).
  80360. * @returns the length squared
  80361. */
  80362. lengthSquared(): number;
  80363. /**
  80364. * Normalizes in place the Vector4.
  80365. * @returns the updated Vector4.
  80366. */
  80367. normalize(): Vector4;
  80368. /**
  80369. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80370. * @returns this converted to a new vector3
  80371. */
  80372. toVector3(): Vector3;
  80373. /**
  80374. * Returns a new Vector4 copied from the current one.
  80375. * @returns the new cloned vector
  80376. */
  80377. clone(): Vector4;
  80378. /**
  80379. * Updates the current Vector4 with the given one coordinates.
  80380. * @param source the source vector to copy from
  80381. * @returns the updated Vector4.
  80382. */
  80383. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80384. /**
  80385. * Updates the current Vector4 coordinates with the given floats.
  80386. * @param x float to copy from
  80387. * @param y float to copy from
  80388. * @param z float to copy from
  80389. * @param w float to copy from
  80390. * @returns the updated Vector4.
  80391. */
  80392. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80393. /**
  80394. * Updates the current Vector4 coordinates with the given floats.
  80395. * @param x float to set from
  80396. * @param y float to set from
  80397. * @param z float to set from
  80398. * @param w float to set from
  80399. * @returns the updated Vector4.
  80400. */
  80401. set(x: number, y: number, z: number, w: number): Vector4;
  80402. /**
  80403. * Copies the given float to the current Vector3 coordinates
  80404. * @param v defines the x, y, z and w coordinates of the operand
  80405. * @returns the current updated Vector3
  80406. */
  80407. setAll(v: number): Vector4;
  80408. /**
  80409. * Returns a new Vector4 set from the starting index of the given array.
  80410. * @param array the array to pull values from
  80411. * @param offset the offset into the array to start at
  80412. * @returns the new vector
  80413. */
  80414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  80415. /**
  80416. * Updates the given vector "result" from the starting index of the given array.
  80417. * @param array the array to pull values from
  80418. * @param offset the offset into the array to start at
  80419. * @param result the vector to store the result in
  80420. */
  80421. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  80422. /**
  80423. * Updates the given vector "result" from the starting index of the given Float32Array.
  80424. * @param array the array to pull values from
  80425. * @param offset the offset into the array to start at
  80426. * @param result the vector to store the result in
  80427. */
  80428. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  80429. /**
  80430. * Updates the given vector "result" coordinates from the given floats.
  80431. * @param x float to set from
  80432. * @param y float to set from
  80433. * @param z float to set from
  80434. * @param w float to set from
  80435. * @param result the vector to the floats in
  80436. */
  80437. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  80438. /**
  80439. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  80440. * @returns the new vector
  80441. */
  80442. static Zero(): Vector4;
  80443. /**
  80444. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  80445. * @returns the new vector
  80446. */
  80447. static One(): Vector4;
  80448. /**
  80449. * Returns a new normalized Vector4 from the given one.
  80450. * @param vector the vector to normalize
  80451. * @returns the vector
  80452. */
  80453. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  80454. /**
  80455. * Updates the given vector "result" from the normalization of the given one.
  80456. * @param vector the vector to normalize
  80457. * @param result the vector to store the result in
  80458. */
  80459. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  80460. /**
  80461. * Returns a vector with the minimum values from the left and right vectors
  80462. * @param left left vector to minimize
  80463. * @param right right vector to minimize
  80464. * @returns a new vector with the minimum of the left and right vector values
  80465. */
  80466. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80467. /**
  80468. * Returns a vector with the maximum values from the left and right vectors
  80469. * @param left left vector to maximize
  80470. * @param right right vector to maximize
  80471. * @returns a new vector with the maximum of the left and right vector values
  80472. */
  80473. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80474. /**
  80475. * Returns the distance (float) between the vectors "value1" and "value2".
  80476. * @param value1 value to calulate the distance between
  80477. * @param value2 value to calulate the distance between
  80478. * @return the distance between the two vectors
  80479. */
  80480. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80481. /**
  80482. * Returns the squared distance (float) between the vectors "value1" and "value2".
  80483. * @param value1 value to calulate the distance between
  80484. * @param value2 value to calulate the distance between
  80485. * @return the distance between the two vectors squared
  80486. */
  80487. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80488. /**
  80489. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  80490. * @param value1 value to calulate the center between
  80491. * @param value2 value to calulate the center between
  80492. * @return the center between the two vectors
  80493. */
  80494. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  80495. /**
  80496. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  80497. * This methods computes transformed normalized direction vectors only.
  80498. * @param vector the vector to transform
  80499. * @param transformation the transformation matrix to apply
  80500. * @returns the new vector
  80501. */
  80502. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  80503. /**
  80504. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  80505. * This methods computes transformed normalized direction vectors only.
  80506. * @param vector the vector to transform
  80507. * @param transformation the transformation matrix to apply
  80508. * @param result the vector to store the result in
  80509. */
  80510. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80511. /**
  80512. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  80513. * This methods computes transformed normalized direction vectors only.
  80514. * @param x value to transform
  80515. * @param y value to transform
  80516. * @param z value to transform
  80517. * @param w value to transform
  80518. * @param transformation the transformation matrix to apply
  80519. * @param result the vector to store the results in
  80520. */
  80521. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80522. /**
  80523. * Creates a new Vector4 from a Vector3
  80524. * @param source defines the source data
  80525. * @param w defines the 4th component (default is 0)
  80526. * @returns a new Vector4
  80527. */
  80528. static FromVector3(source: Vector3, w?: number): Vector4;
  80529. }
  80530. /**
  80531. * Class used to store quaternion data
  80532. * @see https://en.wikipedia.org/wiki/Quaternion
  80533. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  80534. */
  80535. export class Quaternion {
  80536. /** defines the first component (0 by default) */
  80537. x: number;
  80538. /** defines the second component (0 by default) */
  80539. y: number;
  80540. /** defines the third component (0 by default) */
  80541. z: number;
  80542. /** defines the fourth component (1.0 by default) */
  80543. w: number;
  80544. /**
  80545. * Creates a new Quaternion from the given floats
  80546. * @param x defines the first component (0 by default)
  80547. * @param y defines the second component (0 by default)
  80548. * @param z defines the third component (0 by default)
  80549. * @param w defines the fourth component (1.0 by default)
  80550. */
  80551. constructor(
  80552. /** defines the first component (0 by default) */
  80553. x?: number,
  80554. /** defines the second component (0 by default) */
  80555. y?: number,
  80556. /** defines the third component (0 by default) */
  80557. z?: number,
  80558. /** defines the fourth component (1.0 by default) */
  80559. w?: number);
  80560. /**
  80561. * Gets a string representation for the current quaternion
  80562. * @returns a string with the Quaternion coordinates
  80563. */
  80564. toString(): string;
  80565. /**
  80566. * Gets the class name of the quaternion
  80567. * @returns the string "Quaternion"
  80568. */
  80569. getClassName(): string;
  80570. /**
  80571. * Gets a hash code for this quaternion
  80572. * @returns the quaternion hash code
  80573. */
  80574. getHashCode(): number;
  80575. /**
  80576. * Copy the quaternion to an array
  80577. * @returns a new array populated with 4 elements from the quaternion coordinates
  80578. */
  80579. asArray(): number[];
  80580. /**
  80581. * Check if two quaternions are equals
  80582. * @param otherQuaternion defines the second operand
  80583. * @return true if the current quaternion and the given one coordinates are strictly equals
  80584. */
  80585. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  80586. /**
  80587. * Gets a boolean if two quaternions are equals (using an epsilon value)
  80588. * @param otherQuaternion defines the other quaternion
  80589. * @param epsilon defines the minimal distance to consider equality
  80590. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  80591. */
  80592. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  80593. /**
  80594. * Clone the current quaternion
  80595. * @returns a new quaternion copied from the current one
  80596. */
  80597. clone(): Quaternion;
  80598. /**
  80599. * Copy a quaternion to the current one
  80600. * @param other defines the other quaternion
  80601. * @returns the updated current quaternion
  80602. */
  80603. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  80604. /**
  80605. * Updates the current quaternion with the given float coordinates
  80606. * @param x defines the x coordinate
  80607. * @param y defines the y coordinate
  80608. * @param z defines the z coordinate
  80609. * @param w defines the w coordinate
  80610. * @returns the updated current quaternion
  80611. */
  80612. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  80613. /**
  80614. * Updates the current quaternion from the given float coordinates
  80615. * @param x defines the x coordinate
  80616. * @param y defines the y coordinate
  80617. * @param z defines the z coordinate
  80618. * @param w defines the w coordinate
  80619. * @returns the updated current quaternion
  80620. */
  80621. set(x: number, y: number, z: number, w: number): Quaternion;
  80622. /**
  80623. * Adds two quaternions
  80624. * @param other defines the second operand
  80625. * @returns a new quaternion as the addition result of the given one and the current quaternion
  80626. */
  80627. add(other: DeepImmutable<Quaternion>): Quaternion;
  80628. /**
  80629. * Add a quaternion to the current one
  80630. * @param other defines the quaternion to add
  80631. * @returns the current quaternion
  80632. */
  80633. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  80634. /**
  80635. * Subtract two quaternions
  80636. * @param other defines the second operand
  80637. * @returns a new quaternion as the subtraction result of the given one from the current one
  80638. */
  80639. subtract(other: Quaternion): Quaternion;
  80640. /**
  80641. * Multiplies the current quaternion by a scale factor
  80642. * @param value defines the scale factor
  80643. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  80644. */
  80645. scale(value: number): Quaternion;
  80646. /**
  80647. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  80648. * @param scale defines the scale factor
  80649. * @param result defines the Quaternion object where to store the result
  80650. * @returns the unmodified current quaternion
  80651. */
  80652. scaleToRef(scale: number, result: Quaternion): Quaternion;
  80653. /**
  80654. * Multiplies in place the current quaternion by a scale factor
  80655. * @param value defines the scale factor
  80656. * @returns the current modified quaternion
  80657. */
  80658. scaleInPlace(value: number): Quaternion;
  80659. /**
  80660. * Scale the current quaternion values by a factor and add the result to a given quaternion
  80661. * @param scale defines the scale factor
  80662. * @param result defines the Quaternion object where to store the result
  80663. * @returns the unmodified current quaternion
  80664. */
  80665. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  80666. /**
  80667. * Multiplies two quaternions
  80668. * @param q1 defines the second operand
  80669. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  80670. */
  80671. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  80672. /**
  80673. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  80674. * @param q1 defines the second operand
  80675. * @param result defines the target quaternion
  80676. * @returns the current quaternion
  80677. */
  80678. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  80679. /**
  80680. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  80681. * @param q1 defines the second operand
  80682. * @returns the currentupdated quaternion
  80683. */
  80684. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  80685. /**
  80686. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  80687. * @param ref defines the target quaternion
  80688. * @returns the current quaternion
  80689. */
  80690. conjugateToRef(ref: Quaternion): Quaternion;
  80691. /**
  80692. * Conjugates in place (1-q) the current quaternion
  80693. * @returns the current updated quaternion
  80694. */
  80695. conjugateInPlace(): Quaternion;
  80696. /**
  80697. * Conjugates in place (1-q) the current quaternion
  80698. * @returns a new quaternion
  80699. */
  80700. conjugate(): Quaternion;
  80701. /**
  80702. * Gets length of current quaternion
  80703. * @returns the quaternion length (float)
  80704. */
  80705. length(): number;
  80706. /**
  80707. * Normalize in place the current quaternion
  80708. * @returns the current updated quaternion
  80709. */
  80710. normalize(): Quaternion;
  80711. /**
  80712. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  80713. * @param order is a reserved parameter and is ignore for now
  80714. * @returns a new Vector3 containing the Euler angles
  80715. */
  80716. toEulerAngles(order?: string): Vector3;
  80717. /**
  80718. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  80719. * @param result defines the vector which will be filled with the Euler angles
  80720. * @param order is a reserved parameter and is ignore for now
  80721. * @returns the current unchanged quaternion
  80722. */
  80723. toEulerAnglesToRef(result: Vector3): Quaternion;
  80724. /**
  80725. * Updates the given rotation matrix with the current quaternion values
  80726. * @param result defines the target matrix
  80727. * @returns the current unchanged quaternion
  80728. */
  80729. toRotationMatrix(result: Matrix): Quaternion;
  80730. /**
  80731. * Updates the current quaternion from the given rotation matrix values
  80732. * @param matrix defines the source matrix
  80733. * @returns the current updated quaternion
  80734. */
  80735. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80736. /**
  80737. * Creates a new quaternion from a rotation matrix
  80738. * @param matrix defines the source matrix
  80739. * @returns a new quaternion created from the given rotation matrix values
  80740. */
  80741. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80742. /**
  80743. * Updates the given quaternion with the given rotation matrix values
  80744. * @param matrix defines the source matrix
  80745. * @param result defines the target quaternion
  80746. */
  80747. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  80748. /**
  80749. * Returns the dot product (float) between the quaternions "left" and "right"
  80750. * @param left defines the left operand
  80751. * @param right defines the right operand
  80752. * @returns the dot product
  80753. */
  80754. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  80755. /**
  80756. * Checks if the two quaternions are close to each other
  80757. * @param quat0 defines the first quaternion to check
  80758. * @param quat1 defines the second quaternion to check
  80759. * @returns true if the two quaternions are close to each other
  80760. */
  80761. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  80762. /**
  80763. * Creates an empty quaternion
  80764. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  80765. */
  80766. static Zero(): Quaternion;
  80767. /**
  80768. * Inverse a given quaternion
  80769. * @param q defines the source quaternion
  80770. * @returns a new quaternion as the inverted current quaternion
  80771. */
  80772. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  80773. /**
  80774. * Inverse a given quaternion
  80775. * @param q defines the source quaternion
  80776. * @param result the quaternion the result will be stored in
  80777. * @returns the result quaternion
  80778. */
  80779. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  80780. /**
  80781. * Creates an identity quaternion
  80782. * @returns the identity quaternion
  80783. */
  80784. static Identity(): Quaternion;
  80785. /**
  80786. * Gets a boolean indicating if the given quaternion is identity
  80787. * @param quaternion defines the quaternion to check
  80788. * @returns true if the quaternion is identity
  80789. */
  80790. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  80791. /**
  80792. * Creates a quaternion from a rotation around an axis
  80793. * @param axis defines the axis to use
  80794. * @param angle defines the angle to use
  80795. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  80796. */
  80797. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  80798. /**
  80799. * Creates a rotation around an axis and stores it into the given quaternion
  80800. * @param axis defines the axis to use
  80801. * @param angle defines the angle to use
  80802. * @param result defines the target quaternion
  80803. * @returns the target quaternion
  80804. */
  80805. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  80806. /**
  80807. * Creates a new quaternion from data stored into an array
  80808. * @param array defines the data source
  80809. * @param offset defines the offset in the source array where the data starts
  80810. * @returns a new quaternion
  80811. */
  80812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  80813. /**
  80814. * Updates the given quaternion "result" from the starting index of the given array.
  80815. * @param array the array to pull values from
  80816. * @param offset the offset into the array to start at
  80817. * @param result the quaternion to store the result in
  80818. */
  80819. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  80820. /**
  80821. * Create a quaternion from Euler rotation angles
  80822. * @param x Pitch
  80823. * @param y Yaw
  80824. * @param z Roll
  80825. * @returns the new Quaternion
  80826. */
  80827. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  80828. /**
  80829. * Updates a quaternion from Euler rotation angles
  80830. * @param x Pitch
  80831. * @param y Yaw
  80832. * @param z Roll
  80833. * @param result the quaternion to store the result
  80834. * @returns the updated quaternion
  80835. */
  80836. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  80837. /**
  80838. * Create a quaternion from Euler rotation vector
  80839. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  80840. * @returns the new Quaternion
  80841. */
  80842. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  80843. /**
  80844. * Updates a quaternion from Euler rotation vector
  80845. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  80846. * @param result the quaternion to store the result
  80847. * @returns the updated quaternion
  80848. */
  80849. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  80850. /**
  80851. * Creates a new quaternion from the given Euler float angles (y, x, z)
  80852. * @param yaw defines the rotation around Y axis
  80853. * @param pitch defines the rotation around X axis
  80854. * @param roll defines the rotation around Z axis
  80855. * @returns the new quaternion
  80856. */
  80857. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  80858. /**
  80859. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  80860. * @param yaw defines the rotation around Y axis
  80861. * @param pitch defines the rotation around X axis
  80862. * @param roll defines the rotation around Z axis
  80863. * @param result defines the target quaternion
  80864. */
  80865. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  80866. /**
  80867. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  80868. * @param alpha defines the rotation around first axis
  80869. * @param beta defines the rotation around second axis
  80870. * @param gamma defines the rotation around third axis
  80871. * @returns the new quaternion
  80872. */
  80873. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  80874. /**
  80875. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  80876. * @param alpha defines the rotation around first axis
  80877. * @param beta defines the rotation around second axis
  80878. * @param gamma defines the rotation around third axis
  80879. * @param result defines the target quaternion
  80880. */
  80881. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  80882. /**
  80883. * 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)
  80884. * @param axis1 defines the first axis
  80885. * @param axis2 defines the second axis
  80886. * @param axis3 defines the third axis
  80887. * @returns the new quaternion
  80888. */
  80889. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  80890. /**
  80891. * 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
  80892. * @param axis1 defines the first axis
  80893. * @param axis2 defines the second axis
  80894. * @param axis3 defines the third axis
  80895. * @param ref defines the target quaternion
  80896. */
  80897. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  80898. /**
  80899. * Interpolates between two quaternions
  80900. * @param left defines first quaternion
  80901. * @param right defines second quaternion
  80902. * @param amount defines the gradient to use
  80903. * @returns the new interpolated quaternion
  80904. */
  80905. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  80906. /**
  80907. * Interpolates between two quaternions and stores it into a target quaternion
  80908. * @param left defines first quaternion
  80909. * @param right defines second quaternion
  80910. * @param amount defines the gradient to use
  80911. * @param result defines the target quaternion
  80912. */
  80913. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  80914. /**
  80915. * Interpolate between two quaternions using Hermite interpolation
  80916. * @param value1 defines first quaternion
  80917. * @param tangent1 defines the incoming tangent
  80918. * @param value2 defines second quaternion
  80919. * @param tangent2 defines the outgoing tangent
  80920. * @param amount defines the target quaternion
  80921. * @returns the new interpolated quaternion
  80922. */
  80923. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  80924. }
  80925. /**
  80926. * Class used to store matrix data (4x4)
  80927. */
  80928. export class Matrix {
  80929. private static _updateFlagSeed;
  80930. private static _identityReadOnly;
  80931. private _isIdentity;
  80932. private _isIdentityDirty;
  80933. private _isIdentity3x2;
  80934. private _isIdentity3x2Dirty;
  80935. /**
  80936. * Gets the update flag of the matrix which is an unique number for the matrix.
  80937. * It will be incremented every time the matrix data change.
  80938. * You can use it to speed the comparison between two versions of the same matrix.
  80939. */
  80940. updateFlag: number;
  80941. private readonly _m;
  80942. /**
  80943. * Gets the internal data of the matrix
  80944. */
  80945. get m(): DeepImmutable<Float32Array>;
  80946. /** @hidden */
  80947. _markAsUpdated(): void;
  80948. /** @hidden */
  80949. private _updateIdentityStatus;
  80950. /**
  80951. * Creates an empty matrix (filled with zeros)
  80952. */
  80953. constructor();
  80954. /**
  80955. * Check if the current matrix is identity
  80956. * @returns true is the matrix is the identity matrix
  80957. */
  80958. isIdentity(): boolean;
  80959. /**
  80960. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  80961. * @returns true is the matrix is the identity matrix
  80962. */
  80963. isIdentityAs3x2(): boolean;
  80964. /**
  80965. * Gets the determinant of the matrix
  80966. * @returns the matrix determinant
  80967. */
  80968. determinant(): number;
  80969. /**
  80970. * Returns the matrix as a Float32Array
  80971. * @returns the matrix underlying array
  80972. */
  80973. toArray(): DeepImmutable<Float32Array>;
  80974. /**
  80975. * Returns the matrix as a Float32Array
  80976. * @returns the matrix underlying array.
  80977. */
  80978. asArray(): DeepImmutable<Float32Array>;
  80979. /**
  80980. * Inverts the current matrix in place
  80981. * @returns the current inverted matrix
  80982. */
  80983. invert(): Matrix;
  80984. /**
  80985. * Sets all the matrix elements to zero
  80986. * @returns the current matrix
  80987. */
  80988. reset(): Matrix;
  80989. /**
  80990. * Adds the current matrix with a second one
  80991. * @param other defines the matrix to add
  80992. * @returns a new matrix as the addition of the current matrix and the given one
  80993. */
  80994. add(other: DeepImmutable<Matrix>): Matrix;
  80995. /**
  80996. * Sets the given matrix "result" to the addition of the current matrix and the given one
  80997. * @param other defines the matrix to add
  80998. * @param result defines the target matrix
  80999. * @returns the current matrix
  81000. */
  81001. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81002. /**
  81003. * Adds in place the given matrix to the current matrix
  81004. * @param other defines the second operand
  81005. * @returns the current updated matrix
  81006. */
  81007. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81008. /**
  81009. * Sets the given matrix to the current inverted Matrix
  81010. * @param other defines the target matrix
  81011. * @returns the unmodified current matrix
  81012. */
  81013. invertToRef(other: Matrix): Matrix;
  81014. /**
  81015. * add a value at the specified position in the current Matrix
  81016. * @param index the index of the value within the matrix. between 0 and 15.
  81017. * @param value the value to be added
  81018. * @returns the current updated matrix
  81019. */
  81020. addAtIndex(index: number, value: number): Matrix;
  81021. /**
  81022. * mutiply the specified position in the current Matrix by a value
  81023. * @param index the index of the value within the matrix. between 0 and 15.
  81024. * @param value the value to be added
  81025. * @returns the current updated matrix
  81026. */
  81027. multiplyAtIndex(index: number, value: number): Matrix;
  81028. /**
  81029. * Inserts the translation vector (using 3 floats) in the current matrix
  81030. * @param x defines the 1st component of the translation
  81031. * @param y defines the 2nd component of the translation
  81032. * @param z defines the 3rd component of the translation
  81033. * @returns the current updated matrix
  81034. */
  81035. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81036. /**
  81037. * Adds the translation vector (using 3 floats) in the current matrix
  81038. * @param x defines the 1st component of the translation
  81039. * @param y defines the 2nd component of the translation
  81040. * @param z defines the 3rd component of the translation
  81041. * @returns the current updated matrix
  81042. */
  81043. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81044. /**
  81045. * Inserts the translation vector in the current matrix
  81046. * @param vector3 defines the translation to insert
  81047. * @returns the current updated matrix
  81048. */
  81049. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81050. /**
  81051. * Gets the translation value of the current matrix
  81052. * @returns a new Vector3 as the extracted translation from the matrix
  81053. */
  81054. getTranslation(): Vector3;
  81055. /**
  81056. * Fill a Vector3 with the extracted translation from the matrix
  81057. * @param result defines the Vector3 where to store the translation
  81058. * @returns the current matrix
  81059. */
  81060. getTranslationToRef(result: Vector3): Matrix;
  81061. /**
  81062. * Remove rotation and scaling part from the matrix
  81063. * @returns the updated matrix
  81064. */
  81065. removeRotationAndScaling(): Matrix;
  81066. /**
  81067. * Multiply two matrices
  81068. * @param other defines the second operand
  81069. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81070. */
  81071. multiply(other: DeepImmutable<Matrix>): Matrix;
  81072. /**
  81073. * Copy the current matrix from the given one
  81074. * @param other defines the source matrix
  81075. * @returns the current updated matrix
  81076. */
  81077. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81078. /**
  81079. * Populates the given array from the starting index with the current matrix values
  81080. * @param array defines the target array
  81081. * @param offset defines the offset in the target array where to start storing values
  81082. * @returns the current matrix
  81083. */
  81084. copyToArray(array: Float32Array, offset?: number): Matrix;
  81085. /**
  81086. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81087. * @param other defines the second operand
  81088. * @param result defines the matrix where to store the multiplication
  81089. * @returns the current matrix
  81090. */
  81091. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81092. /**
  81093. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81094. * @param other defines the second operand
  81095. * @param result defines the array where to store the multiplication
  81096. * @param offset defines the offset in the target array where to start storing values
  81097. * @returns the current matrix
  81098. */
  81099. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81100. /**
  81101. * Check equality between this matrix and a second one
  81102. * @param value defines the second matrix to compare
  81103. * @returns true is the current matrix and the given one values are strictly equal
  81104. */
  81105. equals(value: DeepImmutable<Matrix>): boolean;
  81106. /**
  81107. * Clone the current matrix
  81108. * @returns a new matrix from the current matrix
  81109. */
  81110. clone(): Matrix;
  81111. /**
  81112. * Returns the name of the current matrix class
  81113. * @returns the string "Matrix"
  81114. */
  81115. getClassName(): string;
  81116. /**
  81117. * Gets the hash code of the current matrix
  81118. * @returns the hash code
  81119. */
  81120. getHashCode(): number;
  81121. /**
  81122. * Decomposes the current Matrix into a translation, rotation and scaling components
  81123. * @param scale defines the scale vector3 given as a reference to update
  81124. * @param rotation defines the rotation quaternion given as a reference to update
  81125. * @param translation defines the translation vector3 given as a reference to update
  81126. * @returns true if operation was successful
  81127. */
  81128. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81129. /**
  81130. * Gets specific row of the matrix
  81131. * @param index defines the number of the row to get
  81132. * @returns the index-th row of the current matrix as a new Vector4
  81133. */
  81134. getRow(index: number): Nullable<Vector4>;
  81135. /**
  81136. * Sets the index-th row of the current matrix to the vector4 values
  81137. * @param index defines the number of the row to set
  81138. * @param row defines the target vector4
  81139. * @returns the updated current matrix
  81140. */
  81141. setRow(index: number, row: Vector4): Matrix;
  81142. /**
  81143. * Compute the transpose of the matrix
  81144. * @returns the new transposed matrix
  81145. */
  81146. transpose(): Matrix;
  81147. /**
  81148. * Compute the transpose of the matrix and store it in a given matrix
  81149. * @param result defines the target matrix
  81150. * @returns the current matrix
  81151. */
  81152. transposeToRef(result: Matrix): Matrix;
  81153. /**
  81154. * Sets the index-th row of the current matrix with the given 4 x float values
  81155. * @param index defines the row index
  81156. * @param x defines the x component to set
  81157. * @param y defines the y component to set
  81158. * @param z defines the z component to set
  81159. * @param w defines the w component to set
  81160. * @returns the updated current matrix
  81161. */
  81162. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81163. /**
  81164. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81165. * @param scale defines the scale factor
  81166. * @returns a new matrix
  81167. */
  81168. scale(scale: number): Matrix;
  81169. /**
  81170. * Scale the current matrix values by a factor to a given result matrix
  81171. * @param scale defines the scale factor
  81172. * @param result defines the matrix to store the result
  81173. * @returns the current matrix
  81174. */
  81175. scaleToRef(scale: number, result: Matrix): Matrix;
  81176. /**
  81177. * Scale the current matrix values by a factor and add the result to a given matrix
  81178. * @param scale defines the scale factor
  81179. * @param result defines the Matrix to store the result
  81180. * @returns the current matrix
  81181. */
  81182. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81183. /**
  81184. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81185. * @param ref matrix to store the result
  81186. */
  81187. toNormalMatrix(ref: Matrix): void;
  81188. /**
  81189. * Gets only rotation part of the current matrix
  81190. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81191. */
  81192. getRotationMatrix(): Matrix;
  81193. /**
  81194. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81195. * @param result defines the target matrix to store data to
  81196. * @returns the current matrix
  81197. */
  81198. getRotationMatrixToRef(result: Matrix): Matrix;
  81199. /**
  81200. * Toggles model matrix from being right handed to left handed in place and vice versa
  81201. */
  81202. toggleModelMatrixHandInPlace(): void;
  81203. /**
  81204. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81205. */
  81206. toggleProjectionMatrixHandInPlace(): void;
  81207. /**
  81208. * Creates a matrix from an array
  81209. * @param array defines the source array
  81210. * @param offset defines an offset in the source array
  81211. * @returns a new Matrix set from the starting index of the given array
  81212. */
  81213. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81214. /**
  81215. * Copy the content of an array into a given matrix
  81216. * @param array defines the source array
  81217. * @param offset defines an offset in the source array
  81218. * @param result defines the target matrix
  81219. */
  81220. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81221. /**
  81222. * Stores an array into a matrix after having multiplied each component by a given factor
  81223. * @param array defines the source array
  81224. * @param offset defines the offset in the source array
  81225. * @param scale defines the scaling factor
  81226. * @param result defines the target matrix
  81227. */
  81228. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81229. /**
  81230. * Gets an identity matrix that must not be updated
  81231. */
  81232. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81233. /**
  81234. * Stores a list of values (16) inside a given matrix
  81235. * @param initialM11 defines 1st value of 1st row
  81236. * @param initialM12 defines 2nd value of 1st row
  81237. * @param initialM13 defines 3rd value of 1st row
  81238. * @param initialM14 defines 4th value of 1st row
  81239. * @param initialM21 defines 1st value of 2nd row
  81240. * @param initialM22 defines 2nd value of 2nd row
  81241. * @param initialM23 defines 3rd value of 2nd row
  81242. * @param initialM24 defines 4th value of 2nd row
  81243. * @param initialM31 defines 1st value of 3rd row
  81244. * @param initialM32 defines 2nd value of 3rd row
  81245. * @param initialM33 defines 3rd value of 3rd row
  81246. * @param initialM34 defines 4th value of 3rd row
  81247. * @param initialM41 defines 1st value of 4th row
  81248. * @param initialM42 defines 2nd value of 4th row
  81249. * @param initialM43 defines 3rd value of 4th row
  81250. * @param initialM44 defines 4th value of 4th row
  81251. * @param result defines the target matrix
  81252. */
  81253. 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;
  81254. /**
  81255. * Creates new matrix from a list of values (16)
  81256. * @param initialM11 defines 1st value of 1st row
  81257. * @param initialM12 defines 2nd value of 1st row
  81258. * @param initialM13 defines 3rd value of 1st row
  81259. * @param initialM14 defines 4th value of 1st row
  81260. * @param initialM21 defines 1st value of 2nd row
  81261. * @param initialM22 defines 2nd value of 2nd row
  81262. * @param initialM23 defines 3rd value of 2nd row
  81263. * @param initialM24 defines 4th value of 2nd row
  81264. * @param initialM31 defines 1st value of 3rd row
  81265. * @param initialM32 defines 2nd value of 3rd row
  81266. * @param initialM33 defines 3rd value of 3rd row
  81267. * @param initialM34 defines 4th value of 3rd row
  81268. * @param initialM41 defines 1st value of 4th row
  81269. * @param initialM42 defines 2nd value of 4th row
  81270. * @param initialM43 defines 3rd value of 4th row
  81271. * @param initialM44 defines 4th value of 4th row
  81272. * @returns the new matrix
  81273. */
  81274. 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;
  81275. /**
  81276. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81277. * @param scale defines the scale vector3
  81278. * @param rotation defines the rotation quaternion
  81279. * @param translation defines the translation vector3
  81280. * @returns a new matrix
  81281. */
  81282. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81283. /**
  81284. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81285. * @param scale defines the scale vector3
  81286. * @param rotation defines the rotation quaternion
  81287. * @param translation defines the translation vector3
  81288. * @param result defines the target matrix
  81289. */
  81290. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81291. /**
  81292. * Creates a new identity matrix
  81293. * @returns a new identity matrix
  81294. */
  81295. static Identity(): Matrix;
  81296. /**
  81297. * Creates a new identity matrix and stores the result in a given matrix
  81298. * @param result defines the target matrix
  81299. */
  81300. static IdentityToRef(result: Matrix): void;
  81301. /**
  81302. * Creates a new zero matrix
  81303. * @returns a new zero matrix
  81304. */
  81305. static Zero(): Matrix;
  81306. /**
  81307. * Creates a new rotation matrix for "angle" radians around the X axis
  81308. * @param angle defines the angle (in radians) to use
  81309. * @return the new matrix
  81310. */
  81311. static RotationX(angle: number): Matrix;
  81312. /**
  81313. * Creates a new matrix as the invert of a given matrix
  81314. * @param source defines the source matrix
  81315. * @returns the new matrix
  81316. */
  81317. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81318. /**
  81319. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81320. * @param angle defines the angle (in radians) to use
  81321. * @param result defines the target matrix
  81322. */
  81323. static RotationXToRef(angle: number, result: Matrix): void;
  81324. /**
  81325. * Creates a new rotation matrix for "angle" radians around the Y axis
  81326. * @param angle defines the angle (in radians) to use
  81327. * @return the new matrix
  81328. */
  81329. static RotationY(angle: number): Matrix;
  81330. /**
  81331. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81332. * @param angle defines the angle (in radians) to use
  81333. * @param result defines the target matrix
  81334. */
  81335. static RotationYToRef(angle: number, result: Matrix): void;
  81336. /**
  81337. * Creates a new rotation matrix for "angle" radians around the Z axis
  81338. * @param angle defines the angle (in radians) to use
  81339. * @return the new matrix
  81340. */
  81341. static RotationZ(angle: number): Matrix;
  81342. /**
  81343. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81344. * @param angle defines the angle (in radians) to use
  81345. * @param result defines the target matrix
  81346. */
  81347. static RotationZToRef(angle: number, result: Matrix): void;
  81348. /**
  81349. * Creates a new rotation matrix for "angle" radians around the given axis
  81350. * @param axis defines the axis to use
  81351. * @param angle defines the angle (in radians) to use
  81352. * @return the new matrix
  81353. */
  81354. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81355. /**
  81356. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81357. * @param axis defines the axis to use
  81358. * @param angle defines the angle (in radians) to use
  81359. * @param result defines the target matrix
  81360. */
  81361. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81362. /**
  81363. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81364. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81365. * @param from defines the vector to align
  81366. * @param to defines the vector to align to
  81367. * @param result defines the target matrix
  81368. */
  81369. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81370. /**
  81371. * Creates a rotation matrix
  81372. * @param yaw defines the yaw angle in radians (Y axis)
  81373. * @param pitch defines the pitch angle in radians (X axis)
  81374. * @param roll defines the roll angle in radians (X axis)
  81375. * @returns the new rotation matrix
  81376. */
  81377. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81378. /**
  81379. * Creates a rotation matrix and stores it in a given matrix
  81380. * @param yaw defines the yaw angle in radians (Y axis)
  81381. * @param pitch defines the pitch angle in radians (X axis)
  81382. * @param roll defines the roll angle in radians (X axis)
  81383. * @param result defines the target matrix
  81384. */
  81385. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81386. /**
  81387. * Creates a scaling matrix
  81388. * @param x defines the scale factor on X axis
  81389. * @param y defines the scale factor on Y axis
  81390. * @param z defines the scale factor on Z axis
  81391. * @returns the new matrix
  81392. */
  81393. static Scaling(x: number, y: number, z: number): Matrix;
  81394. /**
  81395. * Creates a scaling matrix and stores it in a given matrix
  81396. * @param x defines the scale factor on X axis
  81397. * @param y defines the scale factor on Y axis
  81398. * @param z defines the scale factor on Z axis
  81399. * @param result defines the target matrix
  81400. */
  81401. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  81402. /**
  81403. * Creates a translation matrix
  81404. * @param x defines the translation on X axis
  81405. * @param y defines the translation on Y axis
  81406. * @param z defines the translationon Z axis
  81407. * @returns the new matrix
  81408. */
  81409. static Translation(x: number, y: number, z: number): Matrix;
  81410. /**
  81411. * Creates a translation matrix and stores it in a given matrix
  81412. * @param x defines the translation on X axis
  81413. * @param y defines the translation on Y axis
  81414. * @param z defines the translationon Z axis
  81415. * @param result defines the target matrix
  81416. */
  81417. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  81418. /**
  81419. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81420. * @param startValue defines the start value
  81421. * @param endValue defines the end value
  81422. * @param gradient defines the gradient factor
  81423. * @returns the new matrix
  81424. */
  81425. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81426. /**
  81427. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81428. * @param startValue defines the start value
  81429. * @param endValue defines the end value
  81430. * @param gradient defines the gradient factor
  81431. * @param result defines the Matrix object where to store data
  81432. */
  81433. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81434. /**
  81435. * Builds a new matrix whose values are computed by:
  81436. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81437. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81438. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81439. * @param startValue defines the first matrix
  81440. * @param endValue defines the second matrix
  81441. * @param gradient defines the gradient between the two matrices
  81442. * @returns the new matrix
  81443. */
  81444. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81445. /**
  81446. * Update a matrix to values which are computed by:
  81447. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81448. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81449. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81450. * @param startValue defines the first matrix
  81451. * @param endValue defines the second matrix
  81452. * @param gradient defines the gradient between the two matrices
  81453. * @param result defines the target matrix
  81454. */
  81455. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81456. /**
  81457. * 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"
  81458. * This function works in left handed mode
  81459. * @param eye defines the final position of the entity
  81460. * @param target defines where the entity should look at
  81461. * @param up defines the up vector for the entity
  81462. * @returns the new matrix
  81463. */
  81464. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81465. /**
  81466. * 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".
  81467. * This function works in left handed mode
  81468. * @param eye defines the final position of the entity
  81469. * @param target defines where the entity should look at
  81470. * @param up defines the up vector for the entity
  81471. * @param result defines the target matrix
  81472. */
  81473. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81474. /**
  81475. * 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"
  81476. * This function works in right handed mode
  81477. * @param eye defines the final position of the entity
  81478. * @param target defines where the entity should look at
  81479. * @param up defines the up vector for the entity
  81480. * @returns the new matrix
  81481. */
  81482. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81483. /**
  81484. * 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".
  81485. * This function works in right handed mode
  81486. * @param eye defines the final position of the entity
  81487. * @param target defines where the entity should look at
  81488. * @param up defines the up vector for the entity
  81489. * @param result defines the target matrix
  81490. */
  81491. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81492. /**
  81493. * Create a left-handed orthographic projection matrix
  81494. * @param width defines the viewport width
  81495. * @param height defines the viewport height
  81496. * @param znear defines the near clip plane
  81497. * @param zfar defines the far clip plane
  81498. * @returns a new matrix as a left-handed orthographic projection matrix
  81499. */
  81500. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81501. /**
  81502. * Store a left-handed orthographic projection to a given matrix
  81503. * @param width defines the viewport width
  81504. * @param height defines the viewport height
  81505. * @param znear defines the near clip plane
  81506. * @param zfar defines the far clip plane
  81507. * @param result defines the target matrix
  81508. */
  81509. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  81510. /**
  81511. * Create a left-handed orthographic projection matrix
  81512. * @param left defines the viewport left coordinate
  81513. * @param right defines the viewport right coordinate
  81514. * @param bottom defines the viewport bottom coordinate
  81515. * @param top defines the viewport top coordinate
  81516. * @param znear defines the near clip plane
  81517. * @param zfar defines the far clip plane
  81518. * @returns a new matrix as a left-handed orthographic projection matrix
  81519. */
  81520. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81521. /**
  81522. * Stores a left-handed orthographic projection into a given matrix
  81523. * @param left defines the viewport left coordinate
  81524. * @param right defines the viewport right coordinate
  81525. * @param bottom defines the viewport bottom coordinate
  81526. * @param top defines the viewport top coordinate
  81527. * @param znear defines the near clip plane
  81528. * @param zfar defines the far clip plane
  81529. * @param result defines the target matrix
  81530. */
  81531. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81532. /**
  81533. * Creates a right-handed orthographic projection matrix
  81534. * @param left defines the viewport left coordinate
  81535. * @param right defines the viewport right coordinate
  81536. * @param bottom defines the viewport bottom coordinate
  81537. * @param top defines the viewport top coordinate
  81538. * @param znear defines the near clip plane
  81539. * @param zfar defines the far clip plane
  81540. * @returns a new matrix as a right-handed orthographic projection matrix
  81541. */
  81542. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81543. /**
  81544. * Stores a right-handed orthographic projection into a given matrix
  81545. * @param left defines the viewport left coordinate
  81546. * @param right defines the viewport right coordinate
  81547. * @param bottom defines the viewport bottom coordinate
  81548. * @param top defines the viewport top coordinate
  81549. * @param znear defines the near clip plane
  81550. * @param zfar defines the far clip plane
  81551. * @param result defines the target matrix
  81552. */
  81553. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81554. /**
  81555. * Creates a left-handed perspective projection matrix
  81556. * @param width defines the viewport width
  81557. * @param height defines the viewport height
  81558. * @param znear defines the near clip plane
  81559. * @param zfar defines the far clip plane
  81560. * @returns a new matrix as a left-handed perspective projection matrix
  81561. */
  81562. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81563. /**
  81564. * Creates a left-handed perspective projection matrix
  81565. * @param fov defines the horizontal field of view
  81566. * @param aspect defines the aspect ratio
  81567. * @param znear defines the near clip plane
  81568. * @param zfar defines the far clip plane
  81569. * @returns a new matrix as a left-handed perspective projection matrix
  81570. */
  81571. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81572. /**
  81573. * Stores a left-handed perspective projection into a given matrix
  81574. * @param fov defines the horizontal field of view
  81575. * @param aspect defines the aspect ratio
  81576. * @param znear defines the near clip plane
  81577. * @param zfar defines the far clip plane
  81578. * @param result defines the target matrix
  81579. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81580. */
  81581. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81582. /**
  81583. * Stores a left-handed perspective projection into a given matrix with depth reversed
  81584. * @param fov defines the horizontal field of view
  81585. * @param aspect defines the aspect ratio
  81586. * @param znear defines the near clip plane
  81587. * @param zfar not used as infinity is used as far clip
  81588. * @param result defines the target matrix
  81589. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81590. */
  81591. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81592. /**
  81593. * Creates a right-handed perspective projection matrix
  81594. * @param fov defines the horizontal field of view
  81595. * @param aspect defines the aspect ratio
  81596. * @param znear defines the near clip plane
  81597. * @param zfar defines the far clip plane
  81598. * @returns a new matrix as a right-handed perspective projection matrix
  81599. */
  81600. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81601. /**
  81602. * Stores a right-handed perspective projection into a given matrix
  81603. * @param fov defines the horizontal field of view
  81604. * @param aspect defines the aspect ratio
  81605. * @param znear defines the near clip plane
  81606. * @param zfar defines the far clip plane
  81607. * @param result defines the target matrix
  81608. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81609. */
  81610. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81611. /**
  81612. * Stores a right-handed perspective projection into a given matrix
  81613. * @param fov defines the horizontal field of view
  81614. * @param aspect defines the aspect ratio
  81615. * @param znear defines the near clip plane
  81616. * @param zfar not used as infinity is used as far clip
  81617. * @param result defines the target matrix
  81618. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81619. */
  81620. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81621. /**
  81622. * Stores a perspective projection for WebVR info a given matrix
  81623. * @param fov defines the field of view
  81624. * @param znear defines the near clip plane
  81625. * @param zfar defines the far clip plane
  81626. * @param result defines the target matrix
  81627. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  81628. */
  81629. static PerspectiveFovWebVRToRef(fov: {
  81630. upDegrees: number;
  81631. downDegrees: number;
  81632. leftDegrees: number;
  81633. rightDegrees: number;
  81634. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  81635. /**
  81636. * Computes a complete transformation matrix
  81637. * @param viewport defines the viewport to use
  81638. * @param world defines the world matrix
  81639. * @param view defines the view matrix
  81640. * @param projection defines the projection matrix
  81641. * @param zmin defines the near clip plane
  81642. * @param zmax defines the far clip plane
  81643. * @returns the transformation matrix
  81644. */
  81645. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  81646. /**
  81647. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  81648. * @param matrix defines the matrix to use
  81649. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  81650. */
  81651. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  81652. /**
  81653. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  81654. * @param matrix defines the matrix to use
  81655. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  81656. */
  81657. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  81658. /**
  81659. * Compute the transpose of a given matrix
  81660. * @param matrix defines the matrix to transpose
  81661. * @returns the new matrix
  81662. */
  81663. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  81664. /**
  81665. * Compute the transpose of a matrix and store it in a target matrix
  81666. * @param matrix defines the matrix to transpose
  81667. * @param result defines the target matrix
  81668. */
  81669. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  81670. /**
  81671. * Computes a reflection matrix from a plane
  81672. * @param plane defines the reflection plane
  81673. * @returns a new matrix
  81674. */
  81675. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  81676. /**
  81677. * Computes a reflection matrix from a plane
  81678. * @param plane defines the reflection plane
  81679. * @param result defines the target matrix
  81680. */
  81681. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  81682. /**
  81683. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  81684. * @param xaxis defines the value of the 1st axis
  81685. * @param yaxis defines the value of the 2nd axis
  81686. * @param zaxis defines the value of the 3rd axis
  81687. * @param result defines the target matrix
  81688. */
  81689. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  81690. /**
  81691. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  81692. * @param quat defines the quaternion to use
  81693. * @param result defines the target matrix
  81694. */
  81695. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  81696. }
  81697. /**
  81698. * @hidden
  81699. */
  81700. export class TmpVectors {
  81701. static Vector2: Vector2[];
  81702. static Vector3: Vector3[];
  81703. static Vector4: Vector4[];
  81704. static Quaternion: Quaternion[];
  81705. static Matrix: Matrix[];
  81706. }
  81707. }
  81708. declare module BABYLON {
  81709. /**
  81710. * Defines potential orientation for back face culling
  81711. */
  81712. export enum Orientation {
  81713. /**
  81714. * Clockwise
  81715. */
  81716. CW = 0,
  81717. /** Counter clockwise */
  81718. CCW = 1
  81719. }
  81720. /** Class used to represent a Bezier curve */
  81721. export class BezierCurve {
  81722. /**
  81723. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  81724. * @param t defines the time
  81725. * @param x1 defines the left coordinate on X axis
  81726. * @param y1 defines the left coordinate on Y axis
  81727. * @param x2 defines the right coordinate on X axis
  81728. * @param y2 defines the right coordinate on Y axis
  81729. * @returns the interpolated value
  81730. */
  81731. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  81732. }
  81733. /**
  81734. * Defines angle representation
  81735. */
  81736. export class Angle {
  81737. private _radians;
  81738. /**
  81739. * Creates an Angle object of "radians" radians (float).
  81740. * @param radians the angle in radians
  81741. */
  81742. constructor(radians: number);
  81743. /**
  81744. * Get value in degrees
  81745. * @returns the Angle value in degrees (float)
  81746. */
  81747. degrees(): number;
  81748. /**
  81749. * Get value in radians
  81750. * @returns the Angle value in radians (float)
  81751. */
  81752. radians(): number;
  81753. /**
  81754. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  81755. * @param a defines first vector
  81756. * @param b defines second vector
  81757. * @returns a new Angle
  81758. */
  81759. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  81760. /**
  81761. * Gets a new Angle object from the given float in radians
  81762. * @param radians defines the angle value in radians
  81763. * @returns a new Angle
  81764. */
  81765. static FromRadians(radians: number): Angle;
  81766. /**
  81767. * Gets a new Angle object from the given float in degrees
  81768. * @param degrees defines the angle value in degrees
  81769. * @returns a new Angle
  81770. */
  81771. static FromDegrees(degrees: number): Angle;
  81772. }
  81773. /**
  81774. * This represents an arc in a 2d space.
  81775. */
  81776. export class Arc2 {
  81777. /** Defines the start point of the arc */
  81778. startPoint: Vector2;
  81779. /** Defines the mid point of the arc */
  81780. midPoint: Vector2;
  81781. /** Defines the end point of the arc */
  81782. endPoint: Vector2;
  81783. /**
  81784. * Defines the center point of the arc.
  81785. */
  81786. centerPoint: Vector2;
  81787. /**
  81788. * Defines the radius of the arc.
  81789. */
  81790. radius: number;
  81791. /**
  81792. * Defines the angle of the arc (from mid point to end point).
  81793. */
  81794. angle: Angle;
  81795. /**
  81796. * Defines the start angle of the arc (from start point to middle point).
  81797. */
  81798. startAngle: Angle;
  81799. /**
  81800. * Defines the orientation of the arc (clock wise/counter clock wise).
  81801. */
  81802. orientation: Orientation;
  81803. /**
  81804. * Creates an Arc object from the three given points : start, middle and end.
  81805. * @param startPoint Defines the start point of the arc
  81806. * @param midPoint Defines the midlle point of the arc
  81807. * @param endPoint Defines the end point of the arc
  81808. */
  81809. constructor(
  81810. /** Defines the start point of the arc */
  81811. startPoint: Vector2,
  81812. /** Defines the mid point of the arc */
  81813. midPoint: Vector2,
  81814. /** Defines the end point of the arc */
  81815. endPoint: Vector2);
  81816. }
  81817. /**
  81818. * Represents a 2D path made up of multiple 2D points
  81819. */
  81820. export class Path2 {
  81821. private _points;
  81822. private _length;
  81823. /**
  81824. * If the path start and end point are the same
  81825. */
  81826. closed: boolean;
  81827. /**
  81828. * Creates a Path2 object from the starting 2D coordinates x and y.
  81829. * @param x the starting points x value
  81830. * @param y the starting points y value
  81831. */
  81832. constructor(x: number, y: number);
  81833. /**
  81834. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  81835. * @param x the added points x value
  81836. * @param y the added points y value
  81837. * @returns the updated Path2.
  81838. */
  81839. addLineTo(x: number, y: number): Path2;
  81840. /**
  81841. * 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.
  81842. * @param midX middle point x value
  81843. * @param midY middle point y value
  81844. * @param endX end point x value
  81845. * @param endY end point y value
  81846. * @param numberOfSegments (default: 36)
  81847. * @returns the updated Path2.
  81848. */
  81849. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  81850. /**
  81851. * Closes the Path2.
  81852. * @returns the Path2.
  81853. */
  81854. close(): Path2;
  81855. /**
  81856. * Gets the sum of the distance between each sequential point in the path
  81857. * @returns the Path2 total length (float).
  81858. */
  81859. length(): number;
  81860. /**
  81861. * Gets the points which construct the path
  81862. * @returns the Path2 internal array of points.
  81863. */
  81864. getPoints(): Vector2[];
  81865. /**
  81866. * Retreives the point at the distance aways from the starting point
  81867. * @param normalizedLengthPosition the length along the path to retreive the point from
  81868. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  81869. */
  81870. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  81871. /**
  81872. * Creates a new path starting from an x and y position
  81873. * @param x starting x value
  81874. * @param y starting y value
  81875. * @returns a new Path2 starting at the coordinates (x, y).
  81876. */
  81877. static StartingAt(x: number, y: number): Path2;
  81878. }
  81879. /**
  81880. * Represents a 3D path made up of multiple 3D points
  81881. */
  81882. export class Path3D {
  81883. /**
  81884. * an array of Vector3, the curve axis of the Path3D
  81885. */
  81886. path: Vector3[];
  81887. private _curve;
  81888. private _distances;
  81889. private _tangents;
  81890. private _normals;
  81891. private _binormals;
  81892. private _raw;
  81893. private _alignTangentsWithPath;
  81894. private readonly _pointAtData;
  81895. /**
  81896. * new Path3D(path, normal, raw)
  81897. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  81898. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  81899. * @param path an array of Vector3, the curve axis of the Path3D
  81900. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  81901. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  81902. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  81903. */
  81904. constructor(
  81905. /**
  81906. * an array of Vector3, the curve axis of the Path3D
  81907. */
  81908. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  81909. /**
  81910. * Returns the Path3D array of successive Vector3 designing its curve.
  81911. * @returns the Path3D array of successive Vector3 designing its curve.
  81912. */
  81913. getCurve(): Vector3[];
  81914. /**
  81915. * Returns the Path3D array of successive Vector3 designing its curve.
  81916. * @returns the Path3D array of successive Vector3 designing its curve.
  81917. */
  81918. getPoints(): Vector3[];
  81919. /**
  81920. * @returns the computed length (float) of the path.
  81921. */
  81922. length(): number;
  81923. /**
  81924. * Returns an array populated with tangent vectors on each Path3D curve point.
  81925. * @returns an array populated with tangent vectors on each Path3D curve point.
  81926. */
  81927. getTangents(): Vector3[];
  81928. /**
  81929. * Returns an array populated with normal vectors on each Path3D curve point.
  81930. * @returns an array populated with normal vectors on each Path3D curve point.
  81931. */
  81932. getNormals(): Vector3[];
  81933. /**
  81934. * Returns an array populated with binormal vectors on each Path3D curve point.
  81935. * @returns an array populated with binormal vectors on each Path3D curve point.
  81936. */
  81937. getBinormals(): Vector3[];
  81938. /**
  81939. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  81940. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  81941. */
  81942. getDistances(): number[];
  81943. /**
  81944. * Returns an interpolated point along this path
  81945. * @param position the position of the point along this path, from 0.0 to 1.0
  81946. * @returns a new Vector3 as the point
  81947. */
  81948. getPointAt(position: number): Vector3;
  81949. /**
  81950. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  81951. * @param position the position of the point along this path, from 0.0 to 1.0
  81952. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  81953. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  81954. */
  81955. getTangentAt(position: number, interpolated?: boolean): Vector3;
  81956. /**
  81957. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  81958. * @param position the position of the point along this path, from 0.0 to 1.0
  81959. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  81960. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  81961. */
  81962. getNormalAt(position: number, interpolated?: boolean): Vector3;
  81963. /**
  81964. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  81965. * @param position the position of the point along this path, from 0.0 to 1.0
  81966. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  81967. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  81968. */
  81969. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  81970. /**
  81971. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  81972. * @param position the position of the point along this path, from 0.0 to 1.0
  81973. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  81974. */
  81975. getDistanceAt(position: number): number;
  81976. /**
  81977. * Returns the array index of the previous point of an interpolated point along this path
  81978. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81979. * @returns the array index
  81980. */
  81981. getPreviousPointIndexAt(position: number): number;
  81982. /**
  81983. * 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)
  81984. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  81985. * @returns the sub position
  81986. */
  81987. getSubPositionAt(position: number): number;
  81988. /**
  81989. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  81990. * @param target the vector of which to get the closest position to
  81991. * @returns the position of the closest virtual point on this path to the target vector
  81992. */
  81993. getClosestPositionTo(target: Vector3): number;
  81994. /**
  81995. * Returns a sub path (slice) of this path
  81996. * @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
  81997. * @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
  81998. * @returns a sub path (slice) of this path
  81999. */
  82000. slice(start?: number, end?: number): Path3D;
  82001. /**
  82002. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82003. * @param path path which all values are copied into the curves points
  82004. * @param firstNormal which should be projected onto the curve
  82005. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82006. * @returns the same object updated.
  82007. */
  82008. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82009. private _compute;
  82010. private _getFirstNonNullVector;
  82011. private _getLastNonNullVector;
  82012. private _normalVector;
  82013. /**
  82014. * Updates the point at data for an interpolated point along this curve
  82015. * @param position the position of the point along this curve, from 0.0 to 1.0
  82016. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82017. * @returns the (updated) point at data
  82018. */
  82019. private _updatePointAtData;
  82020. /**
  82021. * Updates the point at data from the specified parameters
  82022. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82023. * @param point the interpolated point
  82024. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82025. */
  82026. private _setPointAtData;
  82027. /**
  82028. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82029. */
  82030. private _updateInterpolationMatrix;
  82031. }
  82032. /**
  82033. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82034. * A Curve3 is designed from a series of successive Vector3.
  82035. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82036. */
  82037. export class Curve3 {
  82038. private _points;
  82039. private _length;
  82040. /**
  82041. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82042. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82043. * @param v1 (Vector3) the control point
  82044. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82045. * @param nbPoints (integer) the wanted number of points in the curve
  82046. * @returns the created Curve3
  82047. */
  82048. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82049. /**
  82050. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82051. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82052. * @param v1 (Vector3) the first control point
  82053. * @param v2 (Vector3) the second control point
  82054. * @param v3 (Vector3) the end point of the Cubic Bezier
  82055. * @param nbPoints (integer) the wanted number of points in the curve
  82056. * @returns the created Curve3
  82057. */
  82058. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82059. /**
  82060. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82061. * @param p1 (Vector3) the origin point of the Hermite Spline
  82062. * @param t1 (Vector3) the tangent vector at the origin point
  82063. * @param p2 (Vector3) the end point of the Hermite Spline
  82064. * @param t2 (Vector3) the tangent vector at the end point
  82065. * @param nbPoints (integer) the wanted number of points in the curve
  82066. * @returns the created Curve3
  82067. */
  82068. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82069. /**
  82070. * Returns a Curve3 object along a CatmullRom Spline curve :
  82071. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82072. * @param nbPoints (integer) the wanted number of points between each curve control points
  82073. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82074. * @returns the created Curve3
  82075. */
  82076. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82077. /**
  82078. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82079. * A Curve3 is designed from a series of successive Vector3.
  82080. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82081. * @param points points which make up the curve
  82082. */
  82083. constructor(points: Vector3[]);
  82084. /**
  82085. * @returns the Curve3 stored array of successive Vector3
  82086. */
  82087. getPoints(): Vector3[];
  82088. /**
  82089. * @returns the computed length (float) of the curve.
  82090. */
  82091. length(): number;
  82092. /**
  82093. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82094. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82095. * curveA and curveB keep unchanged.
  82096. * @param curve the curve to continue from this curve
  82097. * @returns the newly constructed curve
  82098. */
  82099. continue(curve: DeepImmutable<Curve3>): Curve3;
  82100. private _computeLength;
  82101. }
  82102. }
  82103. declare module BABYLON {
  82104. /**
  82105. * This represents the main contract an easing function should follow.
  82106. * Easing functions are used throughout the animation system.
  82107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82108. */
  82109. export interface IEasingFunction {
  82110. /**
  82111. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82112. * of the easing function.
  82113. * The link below provides some of the most common examples of easing functions.
  82114. * @see https://easings.net/
  82115. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82116. * @returns the corresponding value on the curve defined by the easing function
  82117. */
  82118. ease(gradient: number): number;
  82119. }
  82120. /**
  82121. * Base class used for every default easing function.
  82122. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82123. */
  82124. export class EasingFunction implements IEasingFunction {
  82125. /**
  82126. * Interpolation follows the mathematical formula associated with the easing function.
  82127. */
  82128. static readonly EASINGMODE_EASEIN: number;
  82129. /**
  82130. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82131. */
  82132. static readonly EASINGMODE_EASEOUT: number;
  82133. /**
  82134. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82135. */
  82136. static readonly EASINGMODE_EASEINOUT: number;
  82137. private _easingMode;
  82138. /**
  82139. * Sets the easing mode of the current function.
  82140. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82141. */
  82142. setEasingMode(easingMode: number): void;
  82143. /**
  82144. * Gets the current easing mode.
  82145. * @returns the easing mode
  82146. */
  82147. getEasingMode(): number;
  82148. /**
  82149. * @hidden
  82150. */
  82151. easeInCore(gradient: number): number;
  82152. /**
  82153. * Given an input gradient between 0 and 1, this returns the corresponding value
  82154. * of the easing function.
  82155. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82156. * @returns the corresponding value on the curve defined by the easing function
  82157. */
  82158. ease(gradient: number): number;
  82159. }
  82160. /**
  82161. * Easing function with a circle shape (see link below).
  82162. * @see https://easings.net/#easeInCirc
  82163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82164. */
  82165. export class CircleEase extends EasingFunction implements IEasingFunction {
  82166. /** @hidden */
  82167. easeInCore(gradient: number): number;
  82168. }
  82169. /**
  82170. * Easing function with a ease back shape (see link below).
  82171. * @see https://easings.net/#easeInBack
  82172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82173. */
  82174. export class BackEase extends EasingFunction implements IEasingFunction {
  82175. /** Defines the amplitude of the function */
  82176. amplitude: number;
  82177. /**
  82178. * Instantiates a back ease easing
  82179. * @see https://easings.net/#easeInBack
  82180. * @param amplitude Defines the amplitude of the function
  82181. */
  82182. constructor(
  82183. /** Defines the amplitude of the function */
  82184. amplitude?: number);
  82185. /** @hidden */
  82186. easeInCore(gradient: number): number;
  82187. }
  82188. /**
  82189. * Easing function with a bouncing shape (see link below).
  82190. * @see https://easings.net/#easeInBounce
  82191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82192. */
  82193. export class BounceEase extends EasingFunction implements IEasingFunction {
  82194. /** Defines the number of bounces */
  82195. bounces: number;
  82196. /** Defines the amplitude of the bounce */
  82197. bounciness: number;
  82198. /**
  82199. * Instantiates a bounce easing
  82200. * @see https://easings.net/#easeInBounce
  82201. * @param bounces Defines the number of bounces
  82202. * @param bounciness Defines the amplitude of the bounce
  82203. */
  82204. constructor(
  82205. /** Defines the number of bounces */
  82206. bounces?: number,
  82207. /** Defines the amplitude of the bounce */
  82208. bounciness?: number);
  82209. /** @hidden */
  82210. easeInCore(gradient: number): number;
  82211. }
  82212. /**
  82213. * Easing function with a power of 3 shape (see link below).
  82214. * @see https://easings.net/#easeInCubic
  82215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82216. */
  82217. export class CubicEase extends EasingFunction implements IEasingFunction {
  82218. /** @hidden */
  82219. easeInCore(gradient: number): number;
  82220. }
  82221. /**
  82222. * Easing function with an elastic shape (see link below).
  82223. * @see https://easings.net/#easeInElastic
  82224. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82225. */
  82226. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82227. /** Defines the number of oscillations*/
  82228. oscillations: number;
  82229. /** Defines the amplitude of the oscillations*/
  82230. springiness: number;
  82231. /**
  82232. * Instantiates an elastic easing function
  82233. * @see https://easings.net/#easeInElastic
  82234. * @param oscillations Defines the number of oscillations
  82235. * @param springiness Defines the amplitude of the oscillations
  82236. */
  82237. constructor(
  82238. /** Defines the number of oscillations*/
  82239. oscillations?: number,
  82240. /** Defines the amplitude of the oscillations*/
  82241. springiness?: number);
  82242. /** @hidden */
  82243. easeInCore(gradient: number): number;
  82244. }
  82245. /**
  82246. * Easing function with an exponential shape (see link below).
  82247. * @see https://easings.net/#easeInExpo
  82248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82249. */
  82250. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82251. /** Defines the exponent of the function */
  82252. exponent: number;
  82253. /**
  82254. * Instantiates an exponential easing function
  82255. * @see https://easings.net/#easeInExpo
  82256. * @param exponent Defines the exponent of the function
  82257. */
  82258. constructor(
  82259. /** Defines the exponent of the function */
  82260. exponent?: number);
  82261. /** @hidden */
  82262. easeInCore(gradient: number): number;
  82263. }
  82264. /**
  82265. * Easing function with a power shape (see link below).
  82266. * @see https://easings.net/#easeInQuad
  82267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82268. */
  82269. export class PowerEase extends EasingFunction implements IEasingFunction {
  82270. /** Defines the power of the function */
  82271. power: number;
  82272. /**
  82273. * Instantiates an power base easing function
  82274. * @see https://easings.net/#easeInQuad
  82275. * @param power Defines the power of the function
  82276. */
  82277. constructor(
  82278. /** Defines the power of the function */
  82279. power?: number);
  82280. /** @hidden */
  82281. easeInCore(gradient: number): number;
  82282. }
  82283. /**
  82284. * Easing function with a power of 2 shape (see link below).
  82285. * @see https://easings.net/#easeInQuad
  82286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82287. */
  82288. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82289. /** @hidden */
  82290. easeInCore(gradient: number): number;
  82291. }
  82292. /**
  82293. * Easing function with a power of 4 shape (see link below).
  82294. * @see https://easings.net/#easeInQuart
  82295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82296. */
  82297. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82298. /** @hidden */
  82299. easeInCore(gradient: number): number;
  82300. }
  82301. /**
  82302. * Easing function with a power of 5 shape (see link below).
  82303. * @see https://easings.net/#easeInQuint
  82304. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82305. */
  82306. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82307. /** @hidden */
  82308. easeInCore(gradient: number): number;
  82309. }
  82310. /**
  82311. * Easing function with a sin shape (see link below).
  82312. * @see https://easings.net/#easeInSine
  82313. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82314. */
  82315. export class SineEase extends EasingFunction implements IEasingFunction {
  82316. /** @hidden */
  82317. easeInCore(gradient: number): number;
  82318. }
  82319. /**
  82320. * Easing function with a bezier shape (see link below).
  82321. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82322. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82323. */
  82324. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82325. /** Defines the x component of the start tangent in the bezier curve */
  82326. x1: number;
  82327. /** Defines the y component of the start tangent in the bezier curve */
  82328. y1: number;
  82329. /** Defines the x component of the end tangent in the bezier curve */
  82330. x2: number;
  82331. /** Defines the y component of the end tangent in the bezier curve */
  82332. y2: number;
  82333. /**
  82334. * Instantiates a bezier function
  82335. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82336. * @param x1 Defines the x component of the start tangent in the bezier curve
  82337. * @param y1 Defines the y component of the start tangent in the bezier curve
  82338. * @param x2 Defines the x component of the end tangent in the bezier curve
  82339. * @param y2 Defines the y component of the end tangent in the bezier curve
  82340. */
  82341. constructor(
  82342. /** Defines the x component of the start tangent in the bezier curve */
  82343. x1?: number,
  82344. /** Defines the y component of the start tangent in the bezier curve */
  82345. y1?: number,
  82346. /** Defines the x component of the end tangent in the bezier curve */
  82347. x2?: number,
  82348. /** Defines the y component of the end tangent in the bezier curve */
  82349. y2?: number);
  82350. /** @hidden */
  82351. easeInCore(gradient: number): number;
  82352. }
  82353. }
  82354. declare module BABYLON {
  82355. /**
  82356. * Class used to hold a RBG color
  82357. */
  82358. export class Color3 {
  82359. /**
  82360. * Defines the red component (between 0 and 1, default is 0)
  82361. */
  82362. r: number;
  82363. /**
  82364. * Defines the green component (between 0 and 1, default is 0)
  82365. */
  82366. g: number;
  82367. /**
  82368. * Defines the blue component (between 0 and 1, default is 0)
  82369. */
  82370. b: number;
  82371. /**
  82372. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82373. * @param r defines the red component (between 0 and 1, default is 0)
  82374. * @param g defines the green component (between 0 and 1, default is 0)
  82375. * @param b defines the blue component (between 0 and 1, default is 0)
  82376. */
  82377. constructor(
  82378. /**
  82379. * Defines the red component (between 0 and 1, default is 0)
  82380. */
  82381. r?: number,
  82382. /**
  82383. * Defines the green component (between 0 and 1, default is 0)
  82384. */
  82385. g?: number,
  82386. /**
  82387. * Defines the blue component (between 0 and 1, default is 0)
  82388. */
  82389. b?: number);
  82390. /**
  82391. * Creates a string with the Color3 current values
  82392. * @returns the string representation of the Color3 object
  82393. */
  82394. toString(): string;
  82395. /**
  82396. * Returns the string "Color3"
  82397. * @returns "Color3"
  82398. */
  82399. getClassName(): string;
  82400. /**
  82401. * Compute the Color3 hash code
  82402. * @returns an unique number that can be used to hash Color3 objects
  82403. */
  82404. getHashCode(): number;
  82405. /**
  82406. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  82407. * @param array defines the array where to store the r,g,b components
  82408. * @param index defines an optional index in the target array to define where to start storing values
  82409. * @returns the current Color3 object
  82410. */
  82411. toArray(array: FloatArray, index?: number): Color3;
  82412. /**
  82413. * Returns a new Color4 object from the current Color3 and the given alpha
  82414. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  82415. * @returns a new Color4 object
  82416. */
  82417. toColor4(alpha?: number): Color4;
  82418. /**
  82419. * Returns a new array populated with 3 numeric elements : red, green and blue values
  82420. * @returns the new array
  82421. */
  82422. asArray(): number[];
  82423. /**
  82424. * Returns the luminance value
  82425. * @returns a float value
  82426. */
  82427. toLuminance(): number;
  82428. /**
  82429. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  82430. * @param otherColor defines the second operand
  82431. * @returns the new Color3 object
  82432. */
  82433. multiply(otherColor: DeepImmutable<Color3>): Color3;
  82434. /**
  82435. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  82436. * @param otherColor defines the second operand
  82437. * @param result defines the Color3 object where to store the result
  82438. * @returns the current Color3
  82439. */
  82440. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82441. /**
  82442. * Determines equality between Color3 objects
  82443. * @param otherColor defines the second operand
  82444. * @returns true if the rgb values are equal to the given ones
  82445. */
  82446. equals(otherColor: DeepImmutable<Color3>): boolean;
  82447. /**
  82448. * Determines equality between the current Color3 object and a set of r,b,g values
  82449. * @param r defines the red component to check
  82450. * @param g defines the green component to check
  82451. * @param b defines the blue component to check
  82452. * @returns true if the rgb values are equal to the given ones
  82453. */
  82454. equalsFloats(r: number, g: number, b: number): boolean;
  82455. /**
  82456. * Multiplies in place each rgb value by scale
  82457. * @param scale defines the scaling factor
  82458. * @returns the updated Color3
  82459. */
  82460. scale(scale: number): Color3;
  82461. /**
  82462. * Multiplies the rgb values by scale and stores the result into "result"
  82463. * @param scale defines the scaling factor
  82464. * @param result defines the Color3 object where to store the result
  82465. * @returns the unmodified current Color3
  82466. */
  82467. scaleToRef(scale: number, result: Color3): Color3;
  82468. /**
  82469. * Scale the current Color3 values by a factor and add the result to a given Color3
  82470. * @param scale defines the scale factor
  82471. * @param result defines color to store the result into
  82472. * @returns the unmodified current Color3
  82473. */
  82474. scaleAndAddToRef(scale: number, result: Color3): Color3;
  82475. /**
  82476. * Clamps the rgb values by the min and max values and stores the result into "result"
  82477. * @param min defines minimum clamping value (default is 0)
  82478. * @param max defines maximum clamping value (default is 1)
  82479. * @param result defines color to store the result into
  82480. * @returns the original Color3
  82481. */
  82482. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  82483. /**
  82484. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  82485. * @param otherColor defines the second operand
  82486. * @returns the new Color3
  82487. */
  82488. add(otherColor: DeepImmutable<Color3>): Color3;
  82489. /**
  82490. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  82491. * @param otherColor defines the second operand
  82492. * @param result defines Color3 object to store the result into
  82493. * @returns the unmodified current Color3
  82494. */
  82495. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82496. /**
  82497. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  82498. * @param otherColor defines the second operand
  82499. * @returns the new Color3
  82500. */
  82501. subtract(otherColor: DeepImmutable<Color3>): Color3;
  82502. /**
  82503. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  82504. * @param otherColor defines the second operand
  82505. * @param result defines Color3 object to store the result into
  82506. * @returns the unmodified current Color3
  82507. */
  82508. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82509. /**
  82510. * Copy the current object
  82511. * @returns a new Color3 copied the current one
  82512. */
  82513. clone(): Color3;
  82514. /**
  82515. * Copies the rgb values from the source in the current Color3
  82516. * @param source defines the source Color3 object
  82517. * @returns the updated Color3 object
  82518. */
  82519. copyFrom(source: DeepImmutable<Color3>): Color3;
  82520. /**
  82521. * Updates the Color3 rgb values from the given floats
  82522. * @param r defines the red component to read from
  82523. * @param g defines the green component to read from
  82524. * @param b defines the blue component to read from
  82525. * @returns the current Color3 object
  82526. */
  82527. copyFromFloats(r: number, g: number, b: number): Color3;
  82528. /**
  82529. * Updates the Color3 rgb values from the given floats
  82530. * @param r defines the red component to read from
  82531. * @param g defines the green component to read from
  82532. * @param b defines the blue component to read from
  82533. * @returns the current Color3 object
  82534. */
  82535. set(r: number, g: number, b: number): Color3;
  82536. /**
  82537. * Compute the Color3 hexadecimal code as a string
  82538. * @returns a string containing the hexadecimal representation of the Color3 object
  82539. */
  82540. toHexString(): string;
  82541. /**
  82542. * Computes a new Color3 converted from the current one to linear space
  82543. * @returns a new Color3 object
  82544. */
  82545. toLinearSpace(): Color3;
  82546. /**
  82547. * Converts current color in rgb space to HSV values
  82548. * @returns a new color3 representing the HSV values
  82549. */
  82550. toHSV(): Color3;
  82551. /**
  82552. * Converts current color in rgb space to HSV values
  82553. * @param result defines the Color3 where to store the HSV values
  82554. */
  82555. toHSVToRef(result: Color3): void;
  82556. /**
  82557. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  82558. * @param convertedColor defines the Color3 object where to store the linear space version
  82559. * @returns the unmodified Color3
  82560. */
  82561. toLinearSpaceToRef(convertedColor: Color3): Color3;
  82562. /**
  82563. * Computes a new Color3 converted from the current one to gamma space
  82564. * @returns a new Color3 object
  82565. */
  82566. toGammaSpace(): Color3;
  82567. /**
  82568. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  82569. * @param convertedColor defines the Color3 object where to store the gamma space version
  82570. * @returns the unmodified Color3
  82571. */
  82572. toGammaSpaceToRef(convertedColor: Color3): Color3;
  82573. private static _BlackReadOnly;
  82574. /**
  82575. * Convert Hue, saturation and value to a Color3 (RGB)
  82576. * @param hue defines the hue
  82577. * @param saturation defines the saturation
  82578. * @param value defines the value
  82579. * @param result defines the Color3 where to store the RGB values
  82580. */
  82581. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  82582. /**
  82583. * Creates a new Color3 from the string containing valid hexadecimal values
  82584. * @param hex defines a string containing valid hexadecimal values
  82585. * @returns a new Color3 object
  82586. */
  82587. static FromHexString(hex: string): Color3;
  82588. /**
  82589. * Creates a new Color3 from the starting index of the given array
  82590. * @param array defines the source array
  82591. * @param offset defines an offset in the source array
  82592. * @returns a new Color3 object
  82593. */
  82594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  82595. /**
  82596. * Creates a new Color3 from integer values (< 256)
  82597. * @param r defines the red component to read from (value between 0 and 255)
  82598. * @param g defines the green component to read from (value between 0 and 255)
  82599. * @param b defines the blue component to read from (value between 0 and 255)
  82600. * @returns a new Color3 object
  82601. */
  82602. static FromInts(r: number, g: number, b: number): Color3;
  82603. /**
  82604. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82605. * @param start defines the start Color3 value
  82606. * @param end defines the end Color3 value
  82607. * @param amount defines the gradient value between start and end
  82608. * @returns a new Color3 object
  82609. */
  82610. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  82611. /**
  82612. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82613. * @param left defines the start value
  82614. * @param right defines the end value
  82615. * @param amount defines the gradient factor
  82616. * @param result defines the Color3 object where to store the result
  82617. */
  82618. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  82619. /**
  82620. * Returns a Color3 value containing a red color
  82621. * @returns a new Color3 object
  82622. */
  82623. static Red(): Color3;
  82624. /**
  82625. * Returns a Color3 value containing a green color
  82626. * @returns a new Color3 object
  82627. */
  82628. static Green(): Color3;
  82629. /**
  82630. * Returns a Color3 value containing a blue color
  82631. * @returns a new Color3 object
  82632. */
  82633. static Blue(): Color3;
  82634. /**
  82635. * Returns a Color3 value containing a black color
  82636. * @returns a new Color3 object
  82637. */
  82638. static Black(): Color3;
  82639. /**
  82640. * Gets a Color3 value containing a black color that must not be updated
  82641. */
  82642. static get BlackReadOnly(): DeepImmutable<Color3>;
  82643. /**
  82644. * Returns a Color3 value containing a white color
  82645. * @returns a new Color3 object
  82646. */
  82647. static White(): Color3;
  82648. /**
  82649. * Returns a Color3 value containing a purple color
  82650. * @returns a new Color3 object
  82651. */
  82652. static Purple(): Color3;
  82653. /**
  82654. * Returns a Color3 value containing a magenta color
  82655. * @returns a new Color3 object
  82656. */
  82657. static Magenta(): Color3;
  82658. /**
  82659. * Returns a Color3 value containing a yellow color
  82660. * @returns a new Color3 object
  82661. */
  82662. static Yellow(): Color3;
  82663. /**
  82664. * Returns a Color3 value containing a gray color
  82665. * @returns a new Color3 object
  82666. */
  82667. static Gray(): Color3;
  82668. /**
  82669. * Returns a Color3 value containing a teal color
  82670. * @returns a new Color3 object
  82671. */
  82672. static Teal(): Color3;
  82673. /**
  82674. * Returns a Color3 value containing a random color
  82675. * @returns a new Color3 object
  82676. */
  82677. static Random(): Color3;
  82678. }
  82679. /**
  82680. * Class used to hold a RBGA color
  82681. */
  82682. export class Color4 {
  82683. /**
  82684. * Defines the red component (between 0 and 1, default is 0)
  82685. */
  82686. r: number;
  82687. /**
  82688. * Defines the green component (between 0 and 1, default is 0)
  82689. */
  82690. g: number;
  82691. /**
  82692. * Defines the blue component (between 0 and 1, default is 0)
  82693. */
  82694. b: number;
  82695. /**
  82696. * Defines the alpha component (between 0 and 1, default is 1)
  82697. */
  82698. a: number;
  82699. /**
  82700. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  82701. * @param r defines the red component (between 0 and 1, default is 0)
  82702. * @param g defines the green component (between 0 and 1, default is 0)
  82703. * @param b defines the blue component (between 0 and 1, default is 0)
  82704. * @param a defines the alpha component (between 0 and 1, default is 1)
  82705. */
  82706. constructor(
  82707. /**
  82708. * Defines the red component (between 0 and 1, default is 0)
  82709. */
  82710. r?: number,
  82711. /**
  82712. * Defines the green component (between 0 and 1, default is 0)
  82713. */
  82714. g?: number,
  82715. /**
  82716. * Defines the blue component (between 0 and 1, default is 0)
  82717. */
  82718. b?: number,
  82719. /**
  82720. * Defines the alpha component (between 0 and 1, default is 1)
  82721. */
  82722. a?: number);
  82723. /**
  82724. * Adds in place the given Color4 values to the current Color4 object
  82725. * @param right defines the second operand
  82726. * @returns the current updated Color4 object
  82727. */
  82728. addInPlace(right: DeepImmutable<Color4>): Color4;
  82729. /**
  82730. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  82731. * @returns the new array
  82732. */
  82733. asArray(): number[];
  82734. /**
  82735. * Stores from the starting index in the given array the Color4 successive values
  82736. * @param array defines the array where to store the r,g,b components
  82737. * @param index defines an optional index in the target array to define where to start storing values
  82738. * @returns the current Color4 object
  82739. */
  82740. toArray(array: number[], index?: number): Color4;
  82741. /**
  82742. * Determines equality between Color4 objects
  82743. * @param otherColor defines the second operand
  82744. * @returns true if the rgba values are equal to the given ones
  82745. */
  82746. equals(otherColor: DeepImmutable<Color4>): boolean;
  82747. /**
  82748. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  82749. * @param right defines the second operand
  82750. * @returns a new Color4 object
  82751. */
  82752. add(right: DeepImmutable<Color4>): Color4;
  82753. /**
  82754. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  82755. * @param right defines the second operand
  82756. * @returns a new Color4 object
  82757. */
  82758. subtract(right: DeepImmutable<Color4>): Color4;
  82759. /**
  82760. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  82761. * @param right defines the second operand
  82762. * @param result defines the Color4 object where to store the result
  82763. * @returns the current Color4 object
  82764. */
  82765. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  82766. /**
  82767. * Creates a new Color4 with the current Color4 values multiplied by scale
  82768. * @param scale defines the scaling factor to apply
  82769. * @returns a new Color4 object
  82770. */
  82771. scale(scale: number): Color4;
  82772. /**
  82773. * Multiplies the current Color4 values by scale and stores the result in "result"
  82774. * @param scale defines the scaling factor to apply
  82775. * @param result defines the Color4 object where to store the result
  82776. * @returns the current unmodified Color4
  82777. */
  82778. scaleToRef(scale: number, result: Color4): Color4;
  82779. /**
  82780. * Scale the current Color4 values by a factor and add the result to a given Color4
  82781. * @param scale defines the scale factor
  82782. * @param result defines the Color4 object where to store the result
  82783. * @returns the unmodified current Color4
  82784. */
  82785. scaleAndAddToRef(scale: number, result: Color4): Color4;
  82786. /**
  82787. * Clamps the rgb values by the min and max values and stores the result into "result"
  82788. * @param min defines minimum clamping value (default is 0)
  82789. * @param max defines maximum clamping value (default is 1)
  82790. * @param result defines color to store the result into.
  82791. * @returns the cuurent Color4
  82792. */
  82793. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  82794. /**
  82795. * Multipy an Color4 value by another and return a new Color4 object
  82796. * @param color defines the Color4 value to multiply by
  82797. * @returns a new Color4 object
  82798. */
  82799. multiply(color: Color4): Color4;
  82800. /**
  82801. * Multipy a Color4 value by another and push the result in a reference value
  82802. * @param color defines the Color4 value to multiply by
  82803. * @param result defines the Color4 to fill the result in
  82804. * @returns the result Color4
  82805. */
  82806. multiplyToRef(color: Color4, result: Color4): Color4;
  82807. /**
  82808. * Creates a string with the Color4 current values
  82809. * @returns the string representation of the Color4 object
  82810. */
  82811. toString(): string;
  82812. /**
  82813. * Returns the string "Color4"
  82814. * @returns "Color4"
  82815. */
  82816. getClassName(): string;
  82817. /**
  82818. * Compute the Color4 hash code
  82819. * @returns an unique number that can be used to hash Color4 objects
  82820. */
  82821. getHashCode(): number;
  82822. /**
  82823. * Creates a new Color4 copied from the current one
  82824. * @returns a new Color4 object
  82825. */
  82826. clone(): Color4;
  82827. /**
  82828. * Copies the given Color4 values into the current one
  82829. * @param source defines the source Color4 object
  82830. * @returns the current updated Color4 object
  82831. */
  82832. copyFrom(source: Color4): Color4;
  82833. /**
  82834. * Copies the given float values into the current one
  82835. * @param r defines the red component to read from
  82836. * @param g defines the green component to read from
  82837. * @param b defines the blue component to read from
  82838. * @param a defines the alpha component to read from
  82839. * @returns the current updated Color4 object
  82840. */
  82841. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  82842. /**
  82843. * Copies the given float values into the current one
  82844. * @param r defines the red component to read from
  82845. * @param g defines the green component to read from
  82846. * @param b defines the blue component to read from
  82847. * @param a defines the alpha component to read from
  82848. * @returns the current updated Color4 object
  82849. */
  82850. set(r: number, g: number, b: number, a: number): Color4;
  82851. /**
  82852. * Compute the Color4 hexadecimal code as a string
  82853. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  82854. * @returns a string containing the hexadecimal representation of the Color4 object
  82855. */
  82856. toHexString(returnAsColor3?: boolean): string;
  82857. /**
  82858. * Computes a new Color4 converted from the current one to linear space
  82859. * @returns a new Color4 object
  82860. */
  82861. toLinearSpace(): Color4;
  82862. /**
  82863. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  82864. * @param convertedColor defines the Color4 object where to store the linear space version
  82865. * @returns the unmodified Color4
  82866. */
  82867. toLinearSpaceToRef(convertedColor: Color4): Color4;
  82868. /**
  82869. * Computes a new Color4 converted from the current one to gamma space
  82870. * @returns a new Color4 object
  82871. */
  82872. toGammaSpace(): Color4;
  82873. /**
  82874. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  82875. * @param convertedColor defines the Color4 object where to store the gamma space version
  82876. * @returns the unmodified Color4
  82877. */
  82878. toGammaSpaceToRef(convertedColor: Color4): Color4;
  82879. /**
  82880. * Creates a new Color4 from the string containing valid hexadecimal values
  82881. * @param hex defines a string containing valid hexadecimal values
  82882. * @returns a new Color4 object
  82883. */
  82884. static FromHexString(hex: string): Color4;
  82885. /**
  82886. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  82887. * @param left defines the start value
  82888. * @param right defines the end value
  82889. * @param amount defines the gradient factor
  82890. * @returns a new Color4 object
  82891. */
  82892. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  82893. /**
  82894. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  82895. * @param left defines the start value
  82896. * @param right defines the end value
  82897. * @param amount defines the gradient factor
  82898. * @param result defines the Color4 object where to store data
  82899. */
  82900. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  82901. /**
  82902. * Creates a new Color4 from a Color3 and an alpha value
  82903. * @param color3 defines the source Color3 to read from
  82904. * @param alpha defines the alpha component (1.0 by default)
  82905. * @returns a new Color4 object
  82906. */
  82907. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  82908. /**
  82909. * Creates a new Color4 from the starting index element of the given array
  82910. * @param array defines the source array to read from
  82911. * @param offset defines the offset in the source array
  82912. * @returns a new Color4 object
  82913. */
  82914. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  82915. /**
  82916. * Creates a new Color3 from integer values (< 256)
  82917. * @param r defines the red component to read from (value between 0 and 255)
  82918. * @param g defines the green component to read from (value between 0 and 255)
  82919. * @param b defines the blue component to read from (value between 0 and 255)
  82920. * @param a defines the alpha component to read from (value between 0 and 255)
  82921. * @returns a new Color3 object
  82922. */
  82923. static FromInts(r: number, g: number, b: number, a: number): Color4;
  82924. /**
  82925. * Check the content of a given array and convert it to an array containing RGBA data
  82926. * If the original array was already containing count * 4 values then it is returned directly
  82927. * @param colors defines the array to check
  82928. * @param count defines the number of RGBA data to expect
  82929. * @returns an array containing count * 4 values (RGBA)
  82930. */
  82931. static CheckColors4(colors: number[], count: number): number[];
  82932. }
  82933. /**
  82934. * @hidden
  82935. */
  82936. export class TmpColors {
  82937. static Color3: Color3[];
  82938. static Color4: Color4[];
  82939. }
  82940. }
  82941. declare module BABYLON {
  82942. /**
  82943. * Defines an interface which represents an animation key frame
  82944. */
  82945. export interface IAnimationKey {
  82946. /**
  82947. * Frame of the key frame
  82948. */
  82949. frame: number;
  82950. /**
  82951. * Value at the specifies key frame
  82952. */
  82953. value: any;
  82954. /**
  82955. * The input tangent for the cubic hermite spline
  82956. */
  82957. inTangent?: any;
  82958. /**
  82959. * The output tangent for the cubic hermite spline
  82960. */
  82961. outTangent?: any;
  82962. /**
  82963. * The animation interpolation type
  82964. */
  82965. interpolation?: AnimationKeyInterpolation;
  82966. }
  82967. /**
  82968. * Enum for the animation key frame interpolation type
  82969. */
  82970. export enum AnimationKeyInterpolation {
  82971. /**
  82972. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  82973. */
  82974. STEP = 1
  82975. }
  82976. }
  82977. declare module BABYLON {
  82978. /**
  82979. * Represents the range of an animation
  82980. */
  82981. export class AnimationRange {
  82982. /**The name of the animation range**/
  82983. name: string;
  82984. /**The starting frame of the animation */
  82985. from: number;
  82986. /**The ending frame of the animation*/
  82987. to: number;
  82988. /**
  82989. * Initializes the range of an animation
  82990. * @param name The name of the animation range
  82991. * @param from The starting frame of the animation
  82992. * @param to The ending frame of the animation
  82993. */
  82994. constructor(
  82995. /**The name of the animation range**/
  82996. name: string,
  82997. /**The starting frame of the animation */
  82998. from: number,
  82999. /**The ending frame of the animation*/
  83000. to: number);
  83001. /**
  83002. * Makes a copy of the animation range
  83003. * @returns A copy of the animation range
  83004. */
  83005. clone(): AnimationRange;
  83006. }
  83007. }
  83008. declare module BABYLON {
  83009. /**
  83010. * Composed of a frame, and an action function
  83011. */
  83012. export class AnimationEvent {
  83013. /** The frame for which the event is triggered **/
  83014. frame: number;
  83015. /** The event to perform when triggered **/
  83016. action: (currentFrame: number) => void;
  83017. /** Specifies if the event should be triggered only once**/
  83018. onlyOnce?: boolean | undefined;
  83019. /**
  83020. * Specifies if the animation event is done
  83021. */
  83022. isDone: boolean;
  83023. /**
  83024. * Initializes the animation event
  83025. * @param frame The frame for which the event is triggered
  83026. * @param action The event to perform when triggered
  83027. * @param onlyOnce Specifies if the event should be triggered only once
  83028. */
  83029. constructor(
  83030. /** The frame for which the event is triggered **/
  83031. frame: number,
  83032. /** The event to perform when triggered **/
  83033. action: (currentFrame: number) => void,
  83034. /** Specifies if the event should be triggered only once**/
  83035. onlyOnce?: boolean | undefined);
  83036. /** @hidden */
  83037. _clone(): AnimationEvent;
  83038. }
  83039. }
  83040. declare module BABYLON {
  83041. /**
  83042. * Interface used to define a behavior
  83043. */
  83044. export interface Behavior<T> {
  83045. /** gets or sets behavior's name */
  83046. name: string;
  83047. /**
  83048. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83049. */
  83050. init(): void;
  83051. /**
  83052. * Called when the behavior is attached to a target
  83053. * @param target defines the target where the behavior is attached to
  83054. */
  83055. attach(target: T): void;
  83056. /**
  83057. * Called when the behavior is detached from its target
  83058. */
  83059. detach(): void;
  83060. }
  83061. /**
  83062. * Interface implemented by classes supporting behaviors
  83063. */
  83064. export interface IBehaviorAware<T> {
  83065. /**
  83066. * Attach a behavior
  83067. * @param behavior defines the behavior to attach
  83068. * @returns the current host
  83069. */
  83070. addBehavior(behavior: Behavior<T>): T;
  83071. /**
  83072. * Remove a behavior from the current object
  83073. * @param behavior defines the behavior to detach
  83074. * @returns the current host
  83075. */
  83076. removeBehavior(behavior: Behavior<T>): T;
  83077. /**
  83078. * Gets a behavior using its name to search
  83079. * @param name defines the name to search
  83080. * @returns the behavior or null if not found
  83081. */
  83082. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83083. }
  83084. }
  83085. declare module BABYLON {
  83086. /**
  83087. * Defines an array and its length.
  83088. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83089. */
  83090. export interface ISmartArrayLike<T> {
  83091. /**
  83092. * The data of the array.
  83093. */
  83094. data: Array<T>;
  83095. /**
  83096. * The active length of the array.
  83097. */
  83098. length: number;
  83099. }
  83100. /**
  83101. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83102. */
  83103. export class SmartArray<T> implements ISmartArrayLike<T> {
  83104. /**
  83105. * The full set of data from the array.
  83106. */
  83107. data: Array<T>;
  83108. /**
  83109. * The active length of the array.
  83110. */
  83111. length: number;
  83112. protected _id: number;
  83113. /**
  83114. * Instantiates a Smart Array.
  83115. * @param capacity defines the default capacity of the array.
  83116. */
  83117. constructor(capacity: number);
  83118. /**
  83119. * Pushes a value at the end of the active data.
  83120. * @param value defines the object to push in the array.
  83121. */
  83122. push(value: T): void;
  83123. /**
  83124. * Iterates over the active data and apply the lambda to them.
  83125. * @param func defines the action to apply on each value.
  83126. */
  83127. forEach(func: (content: T) => void): void;
  83128. /**
  83129. * Sorts the full sets of data.
  83130. * @param compareFn defines the comparison function to apply.
  83131. */
  83132. sort(compareFn: (a: T, b: T) => number): void;
  83133. /**
  83134. * Resets the active data to an empty array.
  83135. */
  83136. reset(): void;
  83137. /**
  83138. * Releases all the data from the array as well as the array.
  83139. */
  83140. dispose(): void;
  83141. /**
  83142. * Concats the active data with a given array.
  83143. * @param array defines the data to concatenate with.
  83144. */
  83145. concat(array: any): void;
  83146. /**
  83147. * Returns the position of a value in the active data.
  83148. * @param value defines the value to find the index for
  83149. * @returns the index if found in the active data otherwise -1
  83150. */
  83151. indexOf(value: T): number;
  83152. /**
  83153. * Returns whether an element is part of the active data.
  83154. * @param value defines the value to look for
  83155. * @returns true if found in the active data otherwise false
  83156. */
  83157. contains(value: T): boolean;
  83158. private static _GlobalId;
  83159. }
  83160. /**
  83161. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83162. * The data in this array can only be present once
  83163. */
  83164. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83165. private _duplicateId;
  83166. /**
  83167. * Pushes a value at the end of the active data.
  83168. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83169. * @param value defines the object to push in the array.
  83170. */
  83171. push(value: T): void;
  83172. /**
  83173. * Pushes a value at the end of the active data.
  83174. * If the data is already present, it won t be added again
  83175. * @param value defines the object to push in the array.
  83176. * @returns true if added false if it was already present
  83177. */
  83178. pushNoDuplicate(value: T): boolean;
  83179. /**
  83180. * Resets the active data to an empty array.
  83181. */
  83182. reset(): void;
  83183. /**
  83184. * Concats the active data with a given array.
  83185. * This ensures no dupplicate will be present in the result.
  83186. * @param array defines the data to concatenate with.
  83187. */
  83188. concatWithNoDuplicate(array: any): void;
  83189. }
  83190. }
  83191. declare module BABYLON {
  83192. /**
  83193. * @ignore
  83194. * This is a list of all the different input types that are available in the application.
  83195. * Fo instance: ArcRotateCameraGamepadInput...
  83196. */
  83197. export var CameraInputTypes: {};
  83198. /**
  83199. * This is the contract to implement in order to create a new input class.
  83200. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83201. */
  83202. export interface ICameraInput<TCamera extends Camera> {
  83203. /**
  83204. * Defines the camera the input is attached to.
  83205. */
  83206. camera: Nullable<TCamera>;
  83207. /**
  83208. * Gets the class name of the current intput.
  83209. * @returns the class name
  83210. */
  83211. getClassName(): string;
  83212. /**
  83213. * Get the friendly name associated with the input class.
  83214. * @returns the input friendly name
  83215. */
  83216. getSimpleName(): string;
  83217. /**
  83218. * Attach the input controls to a specific dom element to get the input from.
  83219. * @param element Defines the element the controls should be listened from
  83220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83221. */
  83222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83223. /**
  83224. * Detach the current controls from the specified dom element.
  83225. * @param element Defines the element to stop listening the inputs from
  83226. */
  83227. detachControl(element: Nullable<HTMLElement>): void;
  83228. /**
  83229. * Update the current camera state depending on the inputs that have been used this frame.
  83230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83231. */
  83232. checkInputs?: () => void;
  83233. }
  83234. /**
  83235. * Represents a map of input types to input instance or input index to input instance.
  83236. */
  83237. export interface CameraInputsMap<TCamera extends Camera> {
  83238. /**
  83239. * Accessor to the input by input type.
  83240. */
  83241. [name: string]: ICameraInput<TCamera>;
  83242. /**
  83243. * Accessor to the input by input index.
  83244. */
  83245. [idx: number]: ICameraInput<TCamera>;
  83246. }
  83247. /**
  83248. * This represents the input manager used within a camera.
  83249. * It helps dealing with all the different kind of input attached to a camera.
  83250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83251. */
  83252. export class CameraInputsManager<TCamera extends Camera> {
  83253. /**
  83254. * Defines the list of inputs attahed to the camera.
  83255. */
  83256. attached: CameraInputsMap<TCamera>;
  83257. /**
  83258. * Defines the dom element the camera is collecting inputs from.
  83259. * This is null if the controls have not been attached.
  83260. */
  83261. attachedElement: Nullable<HTMLElement>;
  83262. /**
  83263. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83264. */
  83265. noPreventDefault: boolean;
  83266. /**
  83267. * Defined the camera the input manager belongs to.
  83268. */
  83269. camera: TCamera;
  83270. /**
  83271. * Update the current camera state depending on the inputs that have been used this frame.
  83272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83273. */
  83274. checkInputs: () => void;
  83275. /**
  83276. * Instantiate a new Camera Input Manager.
  83277. * @param camera Defines the camera the input manager blongs to
  83278. */
  83279. constructor(camera: TCamera);
  83280. /**
  83281. * Add an input method to a camera
  83282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83283. * @param input camera input method
  83284. */
  83285. add(input: ICameraInput<TCamera>): void;
  83286. /**
  83287. * Remove a specific input method from a camera
  83288. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83289. * @param inputToRemove camera input method
  83290. */
  83291. remove(inputToRemove: ICameraInput<TCamera>): void;
  83292. /**
  83293. * Remove a specific input type from a camera
  83294. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83295. * @param inputType the type of the input to remove
  83296. */
  83297. removeByType(inputType: string): void;
  83298. private _addCheckInputs;
  83299. /**
  83300. * Attach the input controls to the currently attached dom element to listen the events from.
  83301. * @param input Defines the input to attach
  83302. */
  83303. attachInput(input: ICameraInput<TCamera>): void;
  83304. /**
  83305. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83306. * @param element Defines the dom element to collect the events from
  83307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83308. */
  83309. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83310. /**
  83311. * Detach the current manager inputs controls from a specific dom element.
  83312. * @param element Defines the dom element to collect the events from
  83313. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83314. */
  83315. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83316. /**
  83317. * Rebuild the dynamic inputCheck function from the current list of
  83318. * defined inputs in the manager.
  83319. */
  83320. rebuildInputCheck(): void;
  83321. /**
  83322. * Remove all attached input methods from a camera
  83323. */
  83324. clear(): void;
  83325. /**
  83326. * Serialize the current input manager attached to a camera.
  83327. * This ensures than once parsed,
  83328. * the input associated to the camera will be identical to the current ones
  83329. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83330. */
  83331. serialize(serializedCamera: any): void;
  83332. /**
  83333. * Parses an input manager serialized JSON to restore the previous list of inputs
  83334. * and states associated to a camera.
  83335. * @param parsedCamera Defines the JSON to parse
  83336. */
  83337. parse(parsedCamera: any): void;
  83338. }
  83339. }
  83340. declare module BABYLON {
  83341. /**
  83342. * Class used to store data that will be store in GPU memory
  83343. */
  83344. export class Buffer {
  83345. private _engine;
  83346. private _buffer;
  83347. /** @hidden */
  83348. _data: Nullable<DataArray>;
  83349. private _updatable;
  83350. private _instanced;
  83351. private _divisor;
  83352. /**
  83353. * Gets the byte stride.
  83354. */
  83355. readonly byteStride: number;
  83356. /**
  83357. * Constructor
  83358. * @param engine the engine
  83359. * @param data the data to use for this buffer
  83360. * @param updatable whether the data is updatable
  83361. * @param stride the stride (optional)
  83362. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83363. * @param instanced whether the buffer is instanced (optional)
  83364. * @param useBytes set to true if the stride in in bytes (optional)
  83365. * @param divisor sets an optional divisor for instances (1 by default)
  83366. */
  83367. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83368. /**
  83369. * Create a new VertexBuffer based on the current buffer
  83370. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83371. * @param offset defines offset in the buffer (0 by default)
  83372. * @param size defines the size in floats of attributes (position is 3 for instance)
  83373. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83374. * @param instanced defines if the vertex buffer contains indexed data
  83375. * @param useBytes defines if the offset and stride are in bytes *
  83376. * @param divisor sets an optional divisor for instances (1 by default)
  83377. * @returns the new vertex buffer
  83378. */
  83379. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83380. /**
  83381. * Gets a boolean indicating if the Buffer is updatable?
  83382. * @returns true if the buffer is updatable
  83383. */
  83384. isUpdatable(): boolean;
  83385. /**
  83386. * Gets current buffer's data
  83387. * @returns a DataArray or null
  83388. */
  83389. getData(): Nullable<DataArray>;
  83390. /**
  83391. * Gets underlying native buffer
  83392. * @returns underlying native buffer
  83393. */
  83394. getBuffer(): Nullable<DataBuffer>;
  83395. /**
  83396. * Gets the stride in float32 units (i.e. byte stride / 4).
  83397. * May not be an integer if the byte stride is not divisible by 4.
  83398. * @returns the stride in float32 units
  83399. * @deprecated Please use byteStride instead.
  83400. */
  83401. getStrideSize(): number;
  83402. /**
  83403. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83404. * @param data defines the data to store
  83405. */
  83406. create(data?: Nullable<DataArray>): void;
  83407. /** @hidden */
  83408. _rebuild(): void;
  83409. /**
  83410. * Update current buffer data
  83411. * @param data defines the data to store
  83412. */
  83413. update(data: DataArray): void;
  83414. /**
  83415. * Updates the data directly.
  83416. * @param data the new data
  83417. * @param offset the new offset
  83418. * @param vertexCount the vertex count (optional)
  83419. * @param useBytes set to true if the offset is in bytes
  83420. */
  83421. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  83422. /**
  83423. * Release all resources
  83424. */
  83425. dispose(): void;
  83426. }
  83427. /**
  83428. * Specialized buffer used to store vertex data
  83429. */
  83430. export class VertexBuffer {
  83431. /** @hidden */
  83432. _buffer: Buffer;
  83433. private _kind;
  83434. private _size;
  83435. private _ownsBuffer;
  83436. private _instanced;
  83437. private _instanceDivisor;
  83438. /**
  83439. * The byte type.
  83440. */
  83441. static readonly BYTE: number;
  83442. /**
  83443. * The unsigned byte type.
  83444. */
  83445. static readonly UNSIGNED_BYTE: number;
  83446. /**
  83447. * The short type.
  83448. */
  83449. static readonly SHORT: number;
  83450. /**
  83451. * The unsigned short type.
  83452. */
  83453. static readonly UNSIGNED_SHORT: number;
  83454. /**
  83455. * The integer type.
  83456. */
  83457. static readonly INT: number;
  83458. /**
  83459. * The unsigned integer type.
  83460. */
  83461. static readonly UNSIGNED_INT: number;
  83462. /**
  83463. * The float type.
  83464. */
  83465. static readonly FLOAT: number;
  83466. /**
  83467. * Gets or sets the instance divisor when in instanced mode
  83468. */
  83469. get instanceDivisor(): number;
  83470. set instanceDivisor(value: number);
  83471. /**
  83472. * Gets the byte stride.
  83473. */
  83474. readonly byteStride: number;
  83475. /**
  83476. * Gets the byte offset.
  83477. */
  83478. readonly byteOffset: number;
  83479. /**
  83480. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  83481. */
  83482. readonly normalized: boolean;
  83483. /**
  83484. * Gets the data type of each component in the array.
  83485. */
  83486. readonly type: number;
  83487. /**
  83488. * Constructor
  83489. * @param engine the engine
  83490. * @param data the data to use for this vertex buffer
  83491. * @param kind the vertex buffer kind
  83492. * @param updatable whether the data is updatable
  83493. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83494. * @param stride the stride (optional)
  83495. * @param instanced whether the buffer is instanced (optional)
  83496. * @param offset the offset of the data (optional)
  83497. * @param size the number of components (optional)
  83498. * @param type the type of the component (optional)
  83499. * @param normalized whether the data contains normalized data (optional)
  83500. * @param useBytes set to true if stride and offset are in bytes (optional)
  83501. * @param divisor defines the instance divisor to use (1 by default)
  83502. */
  83503. 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);
  83504. /** @hidden */
  83505. _rebuild(): void;
  83506. /**
  83507. * Returns the kind of the VertexBuffer (string)
  83508. * @returns a string
  83509. */
  83510. getKind(): string;
  83511. /**
  83512. * Gets a boolean indicating if the VertexBuffer is updatable?
  83513. * @returns true if the buffer is updatable
  83514. */
  83515. isUpdatable(): boolean;
  83516. /**
  83517. * Gets current buffer's data
  83518. * @returns a DataArray or null
  83519. */
  83520. getData(): Nullable<DataArray>;
  83521. /**
  83522. * Gets underlying native buffer
  83523. * @returns underlying native buffer
  83524. */
  83525. getBuffer(): Nullable<DataBuffer>;
  83526. /**
  83527. * Gets the stride in float32 units (i.e. byte stride / 4).
  83528. * May not be an integer if the byte stride is not divisible by 4.
  83529. * @returns the stride in float32 units
  83530. * @deprecated Please use byteStride instead.
  83531. */
  83532. getStrideSize(): number;
  83533. /**
  83534. * Returns the offset as a multiple of the type byte length.
  83535. * @returns the offset in bytes
  83536. * @deprecated Please use byteOffset instead.
  83537. */
  83538. getOffset(): number;
  83539. /**
  83540. * Returns the number of components per vertex attribute (integer)
  83541. * @returns the size in float
  83542. */
  83543. getSize(): number;
  83544. /**
  83545. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83546. * @returns true if this buffer is instanced
  83547. */
  83548. getIsInstanced(): boolean;
  83549. /**
  83550. * Returns the instancing divisor, zero for non-instanced (integer).
  83551. * @returns a number
  83552. */
  83553. getInstanceDivisor(): number;
  83554. /**
  83555. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83556. * @param data defines the data to store
  83557. */
  83558. create(data?: DataArray): void;
  83559. /**
  83560. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83561. * This function will create a new buffer if the current one is not updatable
  83562. * @param data defines the data to store
  83563. */
  83564. update(data: DataArray): void;
  83565. /**
  83566. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83567. * Returns the directly updated WebGLBuffer.
  83568. * @param data the new data
  83569. * @param offset the new offset
  83570. * @param useBytes set to true if the offset is in bytes
  83571. */
  83572. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  83573. /**
  83574. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83575. */
  83576. dispose(): void;
  83577. /**
  83578. * Enumerates each value of this vertex buffer as numbers.
  83579. * @param count the number of values to enumerate
  83580. * @param callback the callback function called for each value
  83581. */
  83582. forEach(count: number, callback: (value: number, index: number) => void): void;
  83583. /**
  83584. * Positions
  83585. */
  83586. static readonly PositionKind: string;
  83587. /**
  83588. * Normals
  83589. */
  83590. static readonly NormalKind: string;
  83591. /**
  83592. * Tangents
  83593. */
  83594. static readonly TangentKind: string;
  83595. /**
  83596. * Texture coordinates
  83597. */
  83598. static readonly UVKind: string;
  83599. /**
  83600. * Texture coordinates 2
  83601. */
  83602. static readonly UV2Kind: string;
  83603. /**
  83604. * Texture coordinates 3
  83605. */
  83606. static readonly UV3Kind: string;
  83607. /**
  83608. * Texture coordinates 4
  83609. */
  83610. static readonly UV4Kind: string;
  83611. /**
  83612. * Texture coordinates 5
  83613. */
  83614. static readonly UV5Kind: string;
  83615. /**
  83616. * Texture coordinates 6
  83617. */
  83618. static readonly UV6Kind: string;
  83619. /**
  83620. * Colors
  83621. */
  83622. static readonly ColorKind: string;
  83623. /**
  83624. * Matrix indices (for bones)
  83625. */
  83626. static readonly MatricesIndicesKind: string;
  83627. /**
  83628. * Matrix weights (for bones)
  83629. */
  83630. static readonly MatricesWeightsKind: string;
  83631. /**
  83632. * Additional matrix indices (for bones)
  83633. */
  83634. static readonly MatricesIndicesExtraKind: string;
  83635. /**
  83636. * Additional matrix weights (for bones)
  83637. */
  83638. static readonly MatricesWeightsExtraKind: string;
  83639. /**
  83640. * Deduces the stride given a kind.
  83641. * @param kind The kind string to deduce
  83642. * @returns The deduced stride
  83643. */
  83644. static DeduceStride(kind: string): number;
  83645. /**
  83646. * Gets the byte length of the given type.
  83647. * @param type the type
  83648. * @returns the number of bytes
  83649. */
  83650. static GetTypeByteLength(type: number): number;
  83651. /**
  83652. * Enumerates each value of the given parameters as numbers.
  83653. * @param data the data to enumerate
  83654. * @param byteOffset the byte offset of the data
  83655. * @param byteStride the byte stride of the data
  83656. * @param componentCount the number of components per element
  83657. * @param componentType the type of the component
  83658. * @param count the number of values to enumerate
  83659. * @param normalized whether the data is normalized
  83660. * @param callback the callback function called for each value
  83661. */
  83662. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  83663. private static _GetFloatValue;
  83664. }
  83665. }
  83666. declare module BABYLON {
  83667. /**
  83668. * @hidden
  83669. */
  83670. export class IntersectionInfo {
  83671. bu: Nullable<number>;
  83672. bv: Nullable<number>;
  83673. distance: number;
  83674. faceId: number;
  83675. subMeshId: number;
  83676. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  83677. }
  83678. }
  83679. declare module BABYLON {
  83680. /**
  83681. * Class used to store bounding sphere information
  83682. */
  83683. export class BoundingSphere {
  83684. /**
  83685. * Gets the center of the bounding sphere in local space
  83686. */
  83687. readonly center: Vector3;
  83688. /**
  83689. * Radius of the bounding sphere in local space
  83690. */
  83691. radius: number;
  83692. /**
  83693. * Gets the center of the bounding sphere in world space
  83694. */
  83695. readonly centerWorld: Vector3;
  83696. /**
  83697. * Radius of the bounding sphere in world space
  83698. */
  83699. radiusWorld: number;
  83700. /**
  83701. * Gets the minimum vector in local space
  83702. */
  83703. readonly minimum: Vector3;
  83704. /**
  83705. * Gets the maximum vector in local space
  83706. */
  83707. readonly maximum: Vector3;
  83708. private _worldMatrix;
  83709. private static readonly TmpVector3;
  83710. /**
  83711. * Creates a new bounding sphere
  83712. * @param min defines the minimum vector (in local space)
  83713. * @param max defines the maximum vector (in local space)
  83714. * @param worldMatrix defines the new world matrix
  83715. */
  83716. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83717. /**
  83718. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  83719. * @param min defines the new minimum vector (in local space)
  83720. * @param max defines the new maximum vector (in local space)
  83721. * @param worldMatrix defines the new world matrix
  83722. */
  83723. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83724. /**
  83725. * Scale the current bounding sphere by applying a scale factor
  83726. * @param factor defines the scale factor to apply
  83727. * @returns the current bounding box
  83728. */
  83729. scale(factor: number): BoundingSphere;
  83730. /**
  83731. * Gets the world matrix of the bounding box
  83732. * @returns a matrix
  83733. */
  83734. getWorldMatrix(): DeepImmutable<Matrix>;
  83735. /** @hidden */
  83736. _update(worldMatrix: DeepImmutable<Matrix>): void;
  83737. /**
  83738. * Tests if the bounding sphere is intersecting the frustum planes
  83739. * @param frustumPlanes defines the frustum planes to test
  83740. * @returns true if there is an intersection
  83741. */
  83742. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83743. /**
  83744. * Tests if the bounding sphere center is in between the frustum planes.
  83745. * Used for optimistic fast inclusion.
  83746. * @param frustumPlanes defines the frustum planes to test
  83747. * @returns true if the sphere center is in between the frustum planes
  83748. */
  83749. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83750. /**
  83751. * Tests if a point is inside the bounding sphere
  83752. * @param point defines the point to test
  83753. * @returns true if the point is inside the bounding sphere
  83754. */
  83755. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83756. /**
  83757. * Checks if two sphere intersct
  83758. * @param sphere0 sphere 0
  83759. * @param sphere1 sphere 1
  83760. * @returns true if the speres intersect
  83761. */
  83762. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  83763. }
  83764. }
  83765. declare module BABYLON {
  83766. /**
  83767. * Class used to store bounding box information
  83768. */
  83769. export class BoundingBox implements ICullable {
  83770. /**
  83771. * Gets the 8 vectors representing the bounding box in local space
  83772. */
  83773. readonly vectors: Vector3[];
  83774. /**
  83775. * Gets the center of the bounding box in local space
  83776. */
  83777. readonly center: Vector3;
  83778. /**
  83779. * Gets the center of the bounding box in world space
  83780. */
  83781. readonly centerWorld: Vector3;
  83782. /**
  83783. * Gets the extend size in local space
  83784. */
  83785. readonly extendSize: Vector3;
  83786. /**
  83787. * Gets the extend size in world space
  83788. */
  83789. readonly extendSizeWorld: Vector3;
  83790. /**
  83791. * Gets the OBB (object bounding box) directions
  83792. */
  83793. readonly directions: Vector3[];
  83794. /**
  83795. * Gets the 8 vectors representing the bounding box in world space
  83796. */
  83797. readonly vectorsWorld: Vector3[];
  83798. /**
  83799. * Gets the minimum vector in world space
  83800. */
  83801. readonly minimumWorld: Vector3;
  83802. /**
  83803. * Gets the maximum vector in world space
  83804. */
  83805. readonly maximumWorld: Vector3;
  83806. /**
  83807. * Gets the minimum vector in local space
  83808. */
  83809. readonly minimum: Vector3;
  83810. /**
  83811. * Gets the maximum vector in local space
  83812. */
  83813. readonly maximum: Vector3;
  83814. private _worldMatrix;
  83815. private static readonly TmpVector3;
  83816. /**
  83817. * @hidden
  83818. */
  83819. _tag: number;
  83820. /**
  83821. * Creates a new bounding box
  83822. * @param min defines the minimum vector (in local space)
  83823. * @param max defines the maximum vector (in local space)
  83824. * @param worldMatrix defines the new world matrix
  83825. */
  83826. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83827. /**
  83828. * Recreates the entire bounding box from scratch as if we call the constructor in place
  83829. * @param min defines the new minimum vector (in local space)
  83830. * @param max defines the new maximum vector (in local space)
  83831. * @param worldMatrix defines the new world matrix
  83832. */
  83833. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83834. /**
  83835. * Scale the current bounding box by applying a scale factor
  83836. * @param factor defines the scale factor to apply
  83837. * @returns the current bounding box
  83838. */
  83839. scale(factor: number): BoundingBox;
  83840. /**
  83841. * Gets the world matrix of the bounding box
  83842. * @returns a matrix
  83843. */
  83844. getWorldMatrix(): DeepImmutable<Matrix>;
  83845. /** @hidden */
  83846. _update(world: DeepImmutable<Matrix>): void;
  83847. /**
  83848. * Tests if the bounding box is intersecting the frustum planes
  83849. * @param frustumPlanes defines the frustum planes to test
  83850. * @returns true if there is an intersection
  83851. */
  83852. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83853. /**
  83854. * Tests if the bounding box is entirely inside the frustum planes
  83855. * @param frustumPlanes defines the frustum planes to test
  83856. * @returns true if there is an inclusion
  83857. */
  83858. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83859. /**
  83860. * Tests if a point is inside the bounding box
  83861. * @param point defines the point to test
  83862. * @returns true if the point is inside the bounding box
  83863. */
  83864. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83865. /**
  83866. * Tests if the bounding box intersects with a bounding sphere
  83867. * @param sphere defines the sphere to test
  83868. * @returns true if there is an intersection
  83869. */
  83870. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  83871. /**
  83872. * Tests if the bounding box intersects with a box defined by a min and max vectors
  83873. * @param min defines the min vector to use
  83874. * @param max defines the max vector to use
  83875. * @returns true if there is an intersection
  83876. */
  83877. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  83878. /**
  83879. * Tests if two bounding boxes are intersections
  83880. * @param box0 defines the first box to test
  83881. * @param box1 defines the second box to test
  83882. * @returns true if there is an intersection
  83883. */
  83884. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  83885. /**
  83886. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  83887. * @param minPoint defines the minimum vector of the bounding box
  83888. * @param maxPoint defines the maximum vector of the bounding box
  83889. * @param sphereCenter defines the sphere center
  83890. * @param sphereRadius defines the sphere radius
  83891. * @returns true if there is an intersection
  83892. */
  83893. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  83894. /**
  83895. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  83896. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  83897. * @param frustumPlanes defines the frustum planes to test
  83898. * @return true if there is an inclusion
  83899. */
  83900. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83901. /**
  83902. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  83903. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  83904. * @param frustumPlanes defines the frustum planes to test
  83905. * @return true if there is an intersection
  83906. */
  83907. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83908. }
  83909. }
  83910. declare module BABYLON {
  83911. /** @hidden */
  83912. export class Collider {
  83913. /** Define if a collision was found */
  83914. collisionFound: boolean;
  83915. /**
  83916. * Define last intersection point in local space
  83917. */
  83918. intersectionPoint: Vector3;
  83919. /**
  83920. * Define last collided mesh
  83921. */
  83922. collidedMesh: Nullable<AbstractMesh>;
  83923. private _collisionPoint;
  83924. private _planeIntersectionPoint;
  83925. private _tempVector;
  83926. private _tempVector2;
  83927. private _tempVector3;
  83928. private _tempVector4;
  83929. private _edge;
  83930. private _baseToVertex;
  83931. private _destinationPoint;
  83932. private _slidePlaneNormal;
  83933. private _displacementVector;
  83934. /** @hidden */
  83935. _radius: Vector3;
  83936. /** @hidden */
  83937. _retry: number;
  83938. private _velocity;
  83939. private _basePoint;
  83940. private _epsilon;
  83941. /** @hidden */
  83942. _velocityWorldLength: number;
  83943. /** @hidden */
  83944. _basePointWorld: Vector3;
  83945. private _velocityWorld;
  83946. private _normalizedVelocity;
  83947. /** @hidden */
  83948. _initialVelocity: Vector3;
  83949. /** @hidden */
  83950. _initialPosition: Vector3;
  83951. private _nearestDistance;
  83952. private _collisionMask;
  83953. get collisionMask(): number;
  83954. set collisionMask(mask: number);
  83955. /**
  83956. * Gets the plane normal used to compute the sliding response (in local space)
  83957. */
  83958. get slidePlaneNormal(): Vector3;
  83959. /** @hidden */
  83960. _initialize(source: Vector3, dir: Vector3, e: number): void;
  83961. /** @hidden */
  83962. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  83963. /** @hidden */
  83964. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  83965. /** @hidden */
  83966. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83967. /** @hidden */
  83968. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  83969. /** @hidden */
  83970. _getResponse(pos: Vector3, vel: Vector3): void;
  83971. }
  83972. }
  83973. declare module BABYLON {
  83974. /**
  83975. * Interface for cullable objects
  83976. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  83977. */
  83978. export interface ICullable {
  83979. /**
  83980. * Checks if the object or part of the object is in the frustum
  83981. * @param frustumPlanes Camera near/planes
  83982. * @returns true if the object is in frustum otherwise false
  83983. */
  83984. isInFrustum(frustumPlanes: Plane[]): boolean;
  83985. /**
  83986. * Checks if a cullable object (mesh...) is in the camera frustum
  83987. * Unlike isInFrustum this cheks the full bounding box
  83988. * @param frustumPlanes Camera near/planes
  83989. * @returns true if the object is in frustum otherwise false
  83990. */
  83991. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83992. }
  83993. /**
  83994. * Info for a bounding data of a mesh
  83995. */
  83996. export class BoundingInfo implements ICullable {
  83997. /**
  83998. * Bounding box for the mesh
  83999. */
  84000. readonly boundingBox: BoundingBox;
  84001. /**
  84002. * Bounding sphere for the mesh
  84003. */
  84004. readonly boundingSphere: BoundingSphere;
  84005. private _isLocked;
  84006. private static readonly TmpVector3;
  84007. /**
  84008. * Constructs bounding info
  84009. * @param minimum min vector of the bounding box/sphere
  84010. * @param maximum max vector of the bounding box/sphere
  84011. * @param worldMatrix defines the new world matrix
  84012. */
  84013. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84014. /**
  84015. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84016. * @param min defines the new minimum vector (in local space)
  84017. * @param max defines the new maximum vector (in local space)
  84018. * @param worldMatrix defines the new world matrix
  84019. */
  84020. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84021. /**
  84022. * min vector of the bounding box/sphere
  84023. */
  84024. get minimum(): Vector3;
  84025. /**
  84026. * max vector of the bounding box/sphere
  84027. */
  84028. get maximum(): Vector3;
  84029. /**
  84030. * If the info is locked and won't be updated to avoid perf overhead
  84031. */
  84032. get isLocked(): boolean;
  84033. set isLocked(value: boolean);
  84034. /**
  84035. * Updates the bounding sphere and box
  84036. * @param world world matrix to be used to update
  84037. */
  84038. update(world: DeepImmutable<Matrix>): void;
  84039. /**
  84040. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84041. * @param center New center of the bounding info
  84042. * @param extend New extend of the bounding info
  84043. * @returns the current bounding info
  84044. */
  84045. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84046. /**
  84047. * Scale the current bounding info by applying a scale factor
  84048. * @param factor defines the scale factor to apply
  84049. * @returns the current bounding info
  84050. */
  84051. scale(factor: number): BoundingInfo;
  84052. /**
  84053. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84054. * @param frustumPlanes defines the frustum to test
  84055. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84056. * @returns true if the bounding info is in the frustum planes
  84057. */
  84058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84059. /**
  84060. * Gets the world distance between the min and max points of the bounding box
  84061. */
  84062. get diagonalLength(): number;
  84063. /**
  84064. * Checks if a cullable object (mesh...) is in the camera frustum
  84065. * Unlike isInFrustum this cheks the full bounding box
  84066. * @param frustumPlanes Camera near/planes
  84067. * @returns true if the object is in frustum otherwise false
  84068. */
  84069. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84070. /** @hidden */
  84071. _checkCollision(collider: Collider): boolean;
  84072. /**
  84073. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84074. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84075. * @param point the point to check intersection with
  84076. * @returns if the point intersects
  84077. */
  84078. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84079. /**
  84080. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84081. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84082. * @param boundingInfo the bounding info to check intersection with
  84083. * @param precise if the intersection should be done using OBB
  84084. * @returns if the bounding info intersects
  84085. */
  84086. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84087. }
  84088. }
  84089. declare module BABYLON {
  84090. /**
  84091. * Extracts minimum and maximum values from a list of indexed positions
  84092. * @param positions defines the positions to use
  84093. * @param indices defines the indices to the positions
  84094. * @param indexStart defines the start index
  84095. * @param indexCount defines the end index
  84096. * @param bias defines bias value to add to the result
  84097. * @return minimum and maximum values
  84098. */
  84099. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84100. minimum: Vector3;
  84101. maximum: Vector3;
  84102. };
  84103. /**
  84104. * Extracts minimum and maximum values from a list of positions
  84105. * @param positions defines the positions to use
  84106. * @param start defines the start index in the positions array
  84107. * @param count defines the number of positions to handle
  84108. * @param bias defines bias value to add to the result
  84109. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84110. * @return minimum and maximum values
  84111. */
  84112. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84113. minimum: Vector3;
  84114. maximum: Vector3;
  84115. };
  84116. }
  84117. declare module BABYLON {
  84118. /** @hidden */
  84119. export class WebGLDataBuffer extends DataBuffer {
  84120. private _buffer;
  84121. constructor(resource: WebGLBuffer);
  84122. get underlyingResource(): any;
  84123. }
  84124. }
  84125. declare module BABYLON {
  84126. /** @hidden */
  84127. export class WebGLPipelineContext implements IPipelineContext {
  84128. engine: ThinEngine;
  84129. program: Nullable<WebGLProgram>;
  84130. context?: WebGLRenderingContext;
  84131. vertexShader?: WebGLShader;
  84132. fragmentShader?: WebGLShader;
  84133. isParallelCompiled: boolean;
  84134. onCompiled?: () => void;
  84135. transformFeedback?: WebGLTransformFeedback | null;
  84136. vertexCompilationError: Nullable<string>;
  84137. fragmentCompilationError: Nullable<string>;
  84138. programLinkError: Nullable<string>;
  84139. programValidationError: Nullable<string>;
  84140. get isAsync(): boolean;
  84141. get isReady(): boolean;
  84142. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84143. _getVertexShaderCode(): string | null;
  84144. _getFragmentShaderCode(): string | null;
  84145. }
  84146. }
  84147. declare module BABYLON {
  84148. interface ThinEngine {
  84149. /**
  84150. * Create an uniform buffer
  84151. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84152. * @param elements defines the content of the uniform buffer
  84153. * @returns the webGL uniform buffer
  84154. */
  84155. createUniformBuffer(elements: FloatArray): DataBuffer;
  84156. /**
  84157. * Create a dynamic uniform buffer
  84158. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84159. * @param elements defines the content of the uniform buffer
  84160. * @returns the webGL uniform buffer
  84161. */
  84162. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84163. /**
  84164. * Update an existing uniform buffer
  84165. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84166. * @param uniformBuffer defines the target uniform buffer
  84167. * @param elements defines the content to update
  84168. * @param offset defines the offset in the uniform buffer where update should start
  84169. * @param count defines the size of the data to update
  84170. */
  84171. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84172. /**
  84173. * Bind an uniform buffer to the current webGL context
  84174. * @param buffer defines the buffer to bind
  84175. */
  84176. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84177. /**
  84178. * Bind a buffer to the current webGL context at a given location
  84179. * @param buffer defines the buffer to bind
  84180. * @param location defines the index where to bind the buffer
  84181. */
  84182. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84183. /**
  84184. * Bind a specific block at a given index in a specific shader program
  84185. * @param pipelineContext defines the pipeline context to use
  84186. * @param blockName defines the block name
  84187. * @param index defines the index where to bind the block
  84188. */
  84189. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84190. }
  84191. }
  84192. declare module BABYLON {
  84193. /**
  84194. * Uniform buffer objects.
  84195. *
  84196. * Handles blocks of uniform on the GPU.
  84197. *
  84198. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84199. *
  84200. * For more information, please refer to :
  84201. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84202. */
  84203. export class UniformBuffer {
  84204. private _engine;
  84205. private _buffer;
  84206. private _data;
  84207. private _bufferData;
  84208. private _dynamic?;
  84209. private _uniformLocations;
  84210. private _uniformSizes;
  84211. private _uniformLocationPointer;
  84212. private _needSync;
  84213. private _noUBO;
  84214. private _currentEffect;
  84215. /** @hidden */
  84216. _alreadyBound: boolean;
  84217. private static _MAX_UNIFORM_SIZE;
  84218. private static _tempBuffer;
  84219. /**
  84220. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84221. * This is dynamic to allow compat with webgl 1 and 2.
  84222. * You will need to pass the name of the uniform as well as the value.
  84223. */
  84224. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84225. /**
  84226. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84227. * This is dynamic to allow compat with webgl 1 and 2.
  84228. * You will need to pass the name of the uniform as well as the value.
  84229. */
  84230. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84231. /**
  84232. * Lambda to Update a single float in a uniform buffer.
  84233. * This is dynamic to allow compat with webgl 1 and 2.
  84234. * You will need to pass the name of the uniform as well as the value.
  84235. */
  84236. updateFloat: (name: string, x: number) => void;
  84237. /**
  84238. * Lambda to Update a vec2 of float in a uniform buffer.
  84239. * This is dynamic to allow compat with webgl 1 and 2.
  84240. * You will need to pass the name of the uniform as well as the value.
  84241. */
  84242. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84243. /**
  84244. * Lambda to Update a vec3 of float in a uniform buffer.
  84245. * This is dynamic to allow compat with webgl 1 and 2.
  84246. * You will need to pass the name of the uniform as well as the value.
  84247. */
  84248. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84249. /**
  84250. * Lambda to Update a vec4 of float in a uniform buffer.
  84251. * This is dynamic to allow compat with webgl 1 and 2.
  84252. * You will need to pass the name of the uniform as well as the value.
  84253. */
  84254. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84255. /**
  84256. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84257. * This is dynamic to allow compat with webgl 1 and 2.
  84258. * You will need to pass the name of the uniform as well as the value.
  84259. */
  84260. updateMatrix: (name: string, mat: Matrix) => void;
  84261. /**
  84262. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84263. * This is dynamic to allow compat with webgl 1 and 2.
  84264. * You will need to pass the name of the uniform as well as the value.
  84265. */
  84266. updateVector3: (name: string, vector: Vector3) => void;
  84267. /**
  84268. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84269. * This is dynamic to allow compat with webgl 1 and 2.
  84270. * You will need to pass the name of the uniform as well as the value.
  84271. */
  84272. updateVector4: (name: string, vector: Vector4) => void;
  84273. /**
  84274. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84275. * This is dynamic to allow compat with webgl 1 and 2.
  84276. * You will need to pass the name of the uniform as well as the value.
  84277. */
  84278. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84279. /**
  84280. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84281. * This is dynamic to allow compat with webgl 1 and 2.
  84282. * You will need to pass the name of the uniform as well as the value.
  84283. */
  84284. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84285. /**
  84286. * Instantiates a new Uniform buffer objects.
  84287. *
  84288. * Handles blocks of uniform on the GPU.
  84289. *
  84290. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84291. *
  84292. * For more information, please refer to :
  84293. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84294. * @param engine Define the engine the buffer is associated with
  84295. * @param data Define the data contained in the buffer
  84296. * @param dynamic Define if the buffer is updatable
  84297. */
  84298. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84299. /**
  84300. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84301. * or just falling back on setUniformXXX calls.
  84302. */
  84303. get useUbo(): boolean;
  84304. /**
  84305. * Indicates if the WebGL underlying uniform buffer is in sync
  84306. * with the javascript cache data.
  84307. */
  84308. get isSync(): boolean;
  84309. /**
  84310. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84311. * Also, a dynamic UniformBuffer will disable cache verification and always
  84312. * update the underlying WebGL uniform buffer to the GPU.
  84313. * @returns if Dynamic, otherwise false
  84314. */
  84315. isDynamic(): boolean;
  84316. /**
  84317. * The data cache on JS side.
  84318. * @returns the underlying data as a float array
  84319. */
  84320. getData(): Float32Array;
  84321. /**
  84322. * The underlying WebGL Uniform buffer.
  84323. * @returns the webgl buffer
  84324. */
  84325. getBuffer(): Nullable<DataBuffer>;
  84326. /**
  84327. * std140 layout specifies how to align data within an UBO structure.
  84328. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84329. * for specs.
  84330. */
  84331. private _fillAlignment;
  84332. /**
  84333. * Adds an uniform in the buffer.
  84334. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84335. * for the layout to be correct !
  84336. * @param name Name of the uniform, as used in the uniform block in the shader.
  84337. * @param size Data size, or data directly.
  84338. */
  84339. addUniform(name: string, size: number | number[]): void;
  84340. /**
  84341. * Adds a Matrix 4x4 to the uniform buffer.
  84342. * @param name Name of the uniform, as used in the uniform block in the shader.
  84343. * @param mat A 4x4 matrix.
  84344. */
  84345. addMatrix(name: string, mat: Matrix): void;
  84346. /**
  84347. * Adds a vec2 to the uniform buffer.
  84348. * @param name Name of the uniform, as used in the uniform block in the shader.
  84349. * @param x Define the x component value of the vec2
  84350. * @param y Define the y component value of the vec2
  84351. */
  84352. addFloat2(name: string, x: number, y: number): void;
  84353. /**
  84354. * Adds a vec3 to the uniform buffer.
  84355. * @param name Name of the uniform, as used in the uniform block in the shader.
  84356. * @param x Define the x component value of the vec3
  84357. * @param y Define the y component value of the vec3
  84358. * @param z Define the z component value of the vec3
  84359. */
  84360. addFloat3(name: string, x: number, y: number, z: number): void;
  84361. /**
  84362. * Adds a vec3 to the uniform buffer.
  84363. * @param name Name of the uniform, as used in the uniform block in the shader.
  84364. * @param color Define the vec3 from a Color
  84365. */
  84366. addColor3(name: string, color: Color3): void;
  84367. /**
  84368. * Adds a vec4 to the uniform buffer.
  84369. * @param name Name of the uniform, as used in the uniform block in the shader.
  84370. * @param color Define the rgb components from a Color
  84371. * @param alpha Define the a component of the vec4
  84372. */
  84373. addColor4(name: string, color: Color3, alpha: number): void;
  84374. /**
  84375. * Adds a vec3 to the uniform buffer.
  84376. * @param name Name of the uniform, as used in the uniform block in the shader.
  84377. * @param vector Define the vec3 components from a Vector
  84378. */
  84379. addVector3(name: string, vector: Vector3): void;
  84380. /**
  84381. * Adds a Matrix 3x3 to the uniform buffer.
  84382. * @param name Name of the uniform, as used in the uniform block in the shader.
  84383. */
  84384. addMatrix3x3(name: string): void;
  84385. /**
  84386. * Adds a Matrix 2x2 to the uniform buffer.
  84387. * @param name Name of the uniform, as used in the uniform block in the shader.
  84388. */
  84389. addMatrix2x2(name: string): void;
  84390. /**
  84391. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84392. */
  84393. create(): void;
  84394. /** @hidden */
  84395. _rebuild(): void;
  84396. /**
  84397. * Updates the WebGL Uniform Buffer on the GPU.
  84398. * If the `dynamic` flag is set to true, no cache comparison is done.
  84399. * Otherwise, the buffer will be updated only if the cache differs.
  84400. */
  84401. update(): void;
  84402. /**
  84403. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84404. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84405. * @param data Define the flattened data
  84406. * @param size Define the size of the data.
  84407. */
  84408. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84409. private _valueCache;
  84410. private _cacheMatrix;
  84411. private _updateMatrix3x3ForUniform;
  84412. private _updateMatrix3x3ForEffect;
  84413. private _updateMatrix2x2ForEffect;
  84414. private _updateMatrix2x2ForUniform;
  84415. private _updateFloatForEffect;
  84416. private _updateFloatForUniform;
  84417. private _updateFloat2ForEffect;
  84418. private _updateFloat2ForUniform;
  84419. private _updateFloat3ForEffect;
  84420. private _updateFloat3ForUniform;
  84421. private _updateFloat4ForEffect;
  84422. private _updateFloat4ForUniform;
  84423. private _updateMatrixForEffect;
  84424. private _updateMatrixForUniform;
  84425. private _updateVector3ForEffect;
  84426. private _updateVector3ForUniform;
  84427. private _updateVector4ForEffect;
  84428. private _updateVector4ForUniform;
  84429. private _updateColor3ForEffect;
  84430. private _updateColor3ForUniform;
  84431. private _updateColor4ForEffect;
  84432. private _updateColor4ForUniform;
  84433. /**
  84434. * Sets a sampler uniform on the effect.
  84435. * @param name Define the name of the sampler.
  84436. * @param texture Define the texture to set in the sampler
  84437. */
  84438. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84439. /**
  84440. * Directly updates the value of the uniform in the cache AND on the GPU.
  84441. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84442. * @param data Define the flattened data
  84443. */
  84444. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84445. /**
  84446. * Binds this uniform buffer to an effect.
  84447. * @param effect Define the effect to bind the buffer to
  84448. * @param name Name of the uniform block in the shader.
  84449. */
  84450. bindToEffect(effect: Effect, name: string): void;
  84451. /**
  84452. * Disposes the uniform buffer.
  84453. */
  84454. dispose(): void;
  84455. }
  84456. }
  84457. declare module BABYLON {
  84458. /**
  84459. * Enum that determines the text-wrapping mode to use.
  84460. */
  84461. export enum InspectableType {
  84462. /**
  84463. * Checkbox for booleans
  84464. */
  84465. Checkbox = 0,
  84466. /**
  84467. * Sliders for numbers
  84468. */
  84469. Slider = 1,
  84470. /**
  84471. * Vector3
  84472. */
  84473. Vector3 = 2,
  84474. /**
  84475. * Quaternions
  84476. */
  84477. Quaternion = 3,
  84478. /**
  84479. * Color3
  84480. */
  84481. Color3 = 4,
  84482. /**
  84483. * String
  84484. */
  84485. String = 5
  84486. }
  84487. /**
  84488. * Interface used to define custom inspectable properties.
  84489. * This interface is used by the inspector to display custom property grids
  84490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84491. */
  84492. export interface IInspectable {
  84493. /**
  84494. * Gets the label to display
  84495. */
  84496. label: string;
  84497. /**
  84498. * Gets the name of the property to edit
  84499. */
  84500. propertyName: string;
  84501. /**
  84502. * Gets the type of the editor to use
  84503. */
  84504. type: InspectableType;
  84505. /**
  84506. * Gets the minimum value of the property when using in "slider" mode
  84507. */
  84508. min?: number;
  84509. /**
  84510. * Gets the maximum value of the property when using in "slider" mode
  84511. */
  84512. max?: number;
  84513. /**
  84514. * Gets the setp to use when using in "slider" mode
  84515. */
  84516. step?: number;
  84517. }
  84518. }
  84519. declare module BABYLON {
  84520. /**
  84521. * Class used to provide helper for timing
  84522. */
  84523. export class TimingTools {
  84524. /**
  84525. * Polyfill for setImmediate
  84526. * @param action defines the action to execute after the current execution block
  84527. */
  84528. static SetImmediate(action: () => void): void;
  84529. }
  84530. }
  84531. declare module BABYLON {
  84532. /**
  84533. * Class used to enable instatition of objects by class name
  84534. */
  84535. export class InstantiationTools {
  84536. /**
  84537. * Use this object to register external classes like custom textures or material
  84538. * to allow the laoders to instantiate them
  84539. */
  84540. static RegisteredExternalClasses: {
  84541. [key: string]: Object;
  84542. };
  84543. /**
  84544. * Tries to instantiate a new object from a given class name
  84545. * @param className defines the class name to instantiate
  84546. * @returns the new object or null if the system was not able to do the instantiation
  84547. */
  84548. static Instantiate(className: string): any;
  84549. }
  84550. }
  84551. declare module BABYLON {
  84552. /**
  84553. * Define options used to create a depth texture
  84554. */
  84555. export class DepthTextureCreationOptions {
  84556. /** Specifies whether or not a stencil should be allocated in the texture */
  84557. generateStencil?: boolean;
  84558. /** Specifies whether or not bilinear filtering is enable on the texture */
  84559. bilinearFiltering?: boolean;
  84560. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84561. comparisonFunction?: number;
  84562. /** Specifies if the created texture is a cube texture */
  84563. isCube?: boolean;
  84564. }
  84565. }
  84566. declare module BABYLON {
  84567. interface ThinEngine {
  84568. /**
  84569. * Creates a depth stencil cube texture.
  84570. * This is only available in WebGL 2.
  84571. * @param size The size of face edge in the cube texture.
  84572. * @param options The options defining the cube texture.
  84573. * @returns The cube texture
  84574. */
  84575. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  84576. /**
  84577. * Creates a cube texture
  84578. * @param rootUrl defines the url where the files to load is located
  84579. * @param scene defines the current scene
  84580. * @param files defines the list of files to load (1 per face)
  84581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84582. * @param onLoad defines an optional callback raised when the texture is loaded
  84583. * @param onError defines an optional callback raised if there is an issue to load the texture
  84584. * @param format defines the format of the data
  84585. * @param forcedExtension defines the extension to use to pick the right loader
  84586. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84587. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84588. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84589. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84590. * @returns the cube texture as an InternalTexture
  84591. */
  84592. 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;
  84593. /**
  84594. * Creates a cube texture
  84595. * @param rootUrl defines the url where the files to load is located
  84596. * @param scene defines the current scene
  84597. * @param files defines the list of files to load (1 per face)
  84598. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84599. * @param onLoad defines an optional callback raised when the texture is loaded
  84600. * @param onError defines an optional callback raised if there is an issue to load the texture
  84601. * @param format defines the format of the data
  84602. * @param forcedExtension defines the extension to use to pick the right loader
  84603. * @returns the cube texture as an InternalTexture
  84604. */
  84605. 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;
  84606. /**
  84607. * Creates a cube texture
  84608. * @param rootUrl defines the url where the files to load is located
  84609. * @param scene defines the current scene
  84610. * @param files defines the list of files to load (1 per face)
  84611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84612. * @param onLoad defines an optional callback raised when the texture is loaded
  84613. * @param onError defines an optional callback raised if there is an issue to load the texture
  84614. * @param format defines the format of the data
  84615. * @param forcedExtension defines the extension to use to pick the right loader
  84616. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84617. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84618. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84619. * @returns the cube texture as an InternalTexture
  84620. */
  84621. 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;
  84622. /** @hidden */
  84623. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  84624. /** @hidden */
  84625. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  84626. /** @hidden */
  84627. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84628. /** @hidden */
  84629. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84630. /**
  84631. * @hidden
  84632. */
  84633. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84634. }
  84635. }
  84636. declare module BABYLON {
  84637. /**
  84638. * Class for creating a cube texture
  84639. */
  84640. export class CubeTexture extends BaseTexture {
  84641. private _delayedOnLoad;
  84642. /**
  84643. * Observable triggered once the texture has been loaded.
  84644. */
  84645. onLoadObservable: Observable<CubeTexture>;
  84646. /**
  84647. * The url of the texture
  84648. */
  84649. url: string;
  84650. /**
  84651. * Gets or sets the center of the bounding box associated with the cube texture.
  84652. * It must define where the camera used to render the texture was set
  84653. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84654. */
  84655. boundingBoxPosition: Vector3;
  84656. private _boundingBoxSize;
  84657. /**
  84658. * Gets or sets the size of the bounding box associated with the cube texture
  84659. * When defined, the cubemap will switch to local mode
  84660. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84661. * @example https://www.babylonjs-playground.com/#RNASML
  84662. */
  84663. set boundingBoxSize(value: Vector3);
  84664. /**
  84665. * Returns the bounding box size
  84666. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84667. */
  84668. get boundingBoxSize(): Vector3;
  84669. protected _rotationY: number;
  84670. /**
  84671. * Sets texture matrix rotation angle around Y axis in radians.
  84672. */
  84673. set rotationY(value: number);
  84674. /**
  84675. * Gets texture matrix rotation angle around Y axis radians.
  84676. */
  84677. get rotationY(): number;
  84678. /**
  84679. * Are mip maps generated for this texture or not.
  84680. */
  84681. get noMipmap(): boolean;
  84682. private _noMipmap;
  84683. private _files;
  84684. protected _forcedExtension: Nullable<string>;
  84685. private _extensions;
  84686. private _textureMatrix;
  84687. private _format;
  84688. private _createPolynomials;
  84689. /** @hidden */
  84690. _prefiltered: boolean;
  84691. /**
  84692. * Creates a cube texture from an array of image urls
  84693. * @param files defines an array of image urls
  84694. * @param scene defines the hosting scene
  84695. * @param noMipmap specifies if mip maps are not used
  84696. * @returns a cube texture
  84697. */
  84698. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  84699. /**
  84700. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  84701. * @param url defines the url of the prefiltered texture
  84702. * @param scene defines the scene the texture is attached to
  84703. * @param forcedExtension defines the extension of the file if different from the url
  84704. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84705. * @return the prefiltered texture
  84706. */
  84707. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  84708. /**
  84709. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  84710. * as prefiltered data.
  84711. * @param rootUrl defines the url of the texture or the root name of the six images
  84712. * @param null defines the scene or engine the texture is attached to
  84713. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  84714. * @param noMipmap defines if mipmaps should be created or not
  84715. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  84716. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  84717. * @param onError defines a callback triggered in case of error during load
  84718. * @param format defines the internal format to use for the texture once loaded
  84719. * @param prefiltered defines whether or not the texture is created from prefiltered data
  84720. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  84721. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84722. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84723. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84724. * @return the cube texture
  84725. */
  84726. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  84727. /**
  84728. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  84729. */
  84730. get isPrefiltered(): boolean;
  84731. /**
  84732. * Get the current class name of the texture useful for serialization or dynamic coding.
  84733. * @returns "CubeTexture"
  84734. */
  84735. getClassName(): string;
  84736. /**
  84737. * Update the url (and optional buffer) of this texture if url was null during construction.
  84738. * @param url the url of the texture
  84739. * @param forcedExtension defines the extension to use
  84740. * @param onLoad callback called when the texture is loaded (defaults to null)
  84741. * @param prefiltered Defines whether the updated texture is prefiltered or not
  84742. */
  84743. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  84744. /**
  84745. * Delays loading of the cube texture
  84746. * @param forcedExtension defines the extension to use
  84747. */
  84748. delayLoad(forcedExtension?: string): void;
  84749. /**
  84750. * Returns the reflection texture matrix
  84751. * @returns the reflection texture matrix
  84752. */
  84753. getReflectionTextureMatrix(): Matrix;
  84754. /**
  84755. * Sets the reflection texture matrix
  84756. * @param value Reflection texture matrix
  84757. */
  84758. setReflectionTextureMatrix(value: Matrix): void;
  84759. /**
  84760. * Parses text to create a cube texture
  84761. * @param parsedTexture define the serialized text to read from
  84762. * @param scene defines the hosting scene
  84763. * @param rootUrl defines the root url of the cube texture
  84764. * @returns a cube texture
  84765. */
  84766. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  84767. /**
  84768. * Makes a clone, or deep copy, of the cube texture
  84769. * @returns a new cube texture
  84770. */
  84771. clone(): CubeTexture;
  84772. }
  84773. }
  84774. declare module BABYLON {
  84775. /**
  84776. * Manages the defines for the Material
  84777. */
  84778. export class MaterialDefines {
  84779. /** @hidden */
  84780. protected _keys: string[];
  84781. private _isDirty;
  84782. /** @hidden */
  84783. _renderId: number;
  84784. /** @hidden */
  84785. _areLightsDirty: boolean;
  84786. /** @hidden */
  84787. _areLightsDisposed: boolean;
  84788. /** @hidden */
  84789. _areAttributesDirty: boolean;
  84790. /** @hidden */
  84791. _areTexturesDirty: boolean;
  84792. /** @hidden */
  84793. _areFresnelDirty: boolean;
  84794. /** @hidden */
  84795. _areMiscDirty: boolean;
  84796. /** @hidden */
  84797. _areImageProcessingDirty: boolean;
  84798. /** @hidden */
  84799. _normals: boolean;
  84800. /** @hidden */
  84801. _uvs: boolean;
  84802. /** @hidden */
  84803. _needNormals: boolean;
  84804. /** @hidden */
  84805. _needUVs: boolean;
  84806. [id: string]: any;
  84807. /**
  84808. * Specifies if the material needs to be re-calculated
  84809. */
  84810. get isDirty(): boolean;
  84811. /**
  84812. * Marks the material to indicate that it has been re-calculated
  84813. */
  84814. markAsProcessed(): void;
  84815. /**
  84816. * Marks the material to indicate that it needs to be re-calculated
  84817. */
  84818. markAsUnprocessed(): void;
  84819. /**
  84820. * Marks the material to indicate all of its defines need to be re-calculated
  84821. */
  84822. markAllAsDirty(): void;
  84823. /**
  84824. * Marks the material to indicate that image processing needs to be re-calculated
  84825. */
  84826. markAsImageProcessingDirty(): void;
  84827. /**
  84828. * Marks the material to indicate the lights need to be re-calculated
  84829. * @param disposed Defines whether the light is dirty due to dispose or not
  84830. */
  84831. markAsLightDirty(disposed?: boolean): void;
  84832. /**
  84833. * Marks the attribute state as changed
  84834. */
  84835. markAsAttributesDirty(): void;
  84836. /**
  84837. * Marks the texture state as changed
  84838. */
  84839. markAsTexturesDirty(): void;
  84840. /**
  84841. * Marks the fresnel state as changed
  84842. */
  84843. markAsFresnelDirty(): void;
  84844. /**
  84845. * Marks the misc state as changed
  84846. */
  84847. markAsMiscDirty(): void;
  84848. /**
  84849. * Rebuilds the material defines
  84850. */
  84851. rebuild(): void;
  84852. /**
  84853. * Specifies if two material defines are equal
  84854. * @param other - A material define instance to compare to
  84855. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  84856. */
  84857. isEqual(other: MaterialDefines): boolean;
  84858. /**
  84859. * Clones this instance's defines to another instance
  84860. * @param other - material defines to clone values to
  84861. */
  84862. cloneTo(other: MaterialDefines): void;
  84863. /**
  84864. * Resets the material define values
  84865. */
  84866. reset(): void;
  84867. /**
  84868. * Converts the material define values to a string
  84869. * @returns - String of material define information
  84870. */
  84871. toString(): string;
  84872. }
  84873. }
  84874. declare module BABYLON {
  84875. /**
  84876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  84877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  84878. * 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;
  84879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  84880. */
  84881. export class ColorCurves {
  84882. private _dirty;
  84883. private _tempColor;
  84884. private _globalCurve;
  84885. private _highlightsCurve;
  84886. private _midtonesCurve;
  84887. private _shadowsCurve;
  84888. private _positiveCurve;
  84889. private _negativeCurve;
  84890. private _globalHue;
  84891. private _globalDensity;
  84892. private _globalSaturation;
  84893. private _globalExposure;
  84894. /**
  84895. * Gets the global Hue value.
  84896. * 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).
  84897. */
  84898. get globalHue(): number;
  84899. /**
  84900. * Sets the global Hue value.
  84901. * 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).
  84902. */
  84903. set globalHue(value: number);
  84904. /**
  84905. * Gets the global Density value.
  84906. * 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.
  84907. * Values less than zero provide a filter of opposite hue.
  84908. */
  84909. get globalDensity(): number;
  84910. /**
  84911. * Sets the global Density value.
  84912. * 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.
  84913. * Values less than zero provide a filter of opposite hue.
  84914. */
  84915. set globalDensity(value: number);
  84916. /**
  84917. * Gets the global Saturation value.
  84918. * 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.
  84919. */
  84920. get globalSaturation(): number;
  84921. /**
  84922. * Sets the global Saturation value.
  84923. * 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.
  84924. */
  84925. set globalSaturation(value: number);
  84926. /**
  84927. * Gets the global Exposure value.
  84928. * 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.
  84929. */
  84930. get globalExposure(): number;
  84931. /**
  84932. * Sets the global Exposure value.
  84933. * 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.
  84934. */
  84935. set globalExposure(value: number);
  84936. private _highlightsHue;
  84937. private _highlightsDensity;
  84938. private _highlightsSaturation;
  84939. private _highlightsExposure;
  84940. /**
  84941. * Gets the highlights Hue value.
  84942. * 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).
  84943. */
  84944. get highlightsHue(): number;
  84945. /**
  84946. * Sets the highlights Hue value.
  84947. * 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).
  84948. */
  84949. set highlightsHue(value: number);
  84950. /**
  84951. * Gets the highlights Density value.
  84952. * 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.
  84953. * Values less than zero provide a filter of opposite hue.
  84954. */
  84955. get highlightsDensity(): number;
  84956. /**
  84957. * Sets the highlights Density value.
  84958. * 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.
  84959. * Values less than zero provide a filter of opposite hue.
  84960. */
  84961. set highlightsDensity(value: number);
  84962. /**
  84963. * Gets the highlights Saturation value.
  84964. * 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.
  84965. */
  84966. get highlightsSaturation(): number;
  84967. /**
  84968. * Sets the highlights Saturation value.
  84969. * 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.
  84970. */
  84971. set highlightsSaturation(value: number);
  84972. /**
  84973. * Gets the highlights Exposure value.
  84974. * 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.
  84975. */
  84976. get highlightsExposure(): number;
  84977. /**
  84978. * Sets the highlights Exposure value.
  84979. * 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.
  84980. */
  84981. set highlightsExposure(value: number);
  84982. private _midtonesHue;
  84983. private _midtonesDensity;
  84984. private _midtonesSaturation;
  84985. private _midtonesExposure;
  84986. /**
  84987. * Gets the midtones Hue value.
  84988. * 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).
  84989. */
  84990. get midtonesHue(): number;
  84991. /**
  84992. * Sets the midtones Hue value.
  84993. * 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).
  84994. */
  84995. set midtonesHue(value: number);
  84996. /**
  84997. * Gets the midtones Density value.
  84998. * 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.
  84999. * Values less than zero provide a filter of opposite hue.
  85000. */
  85001. get midtonesDensity(): number;
  85002. /**
  85003. * Sets the midtones Density value.
  85004. * 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.
  85005. * Values less than zero provide a filter of opposite hue.
  85006. */
  85007. set midtonesDensity(value: number);
  85008. /**
  85009. * Gets the midtones Saturation value.
  85010. * 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.
  85011. */
  85012. get midtonesSaturation(): number;
  85013. /**
  85014. * Sets the midtones Saturation value.
  85015. * 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.
  85016. */
  85017. set midtonesSaturation(value: number);
  85018. /**
  85019. * Gets the midtones Exposure value.
  85020. * 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.
  85021. */
  85022. get midtonesExposure(): number;
  85023. /**
  85024. * Sets the midtones Exposure value.
  85025. * 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.
  85026. */
  85027. set midtonesExposure(value: number);
  85028. private _shadowsHue;
  85029. private _shadowsDensity;
  85030. private _shadowsSaturation;
  85031. private _shadowsExposure;
  85032. /**
  85033. * Gets the shadows Hue value.
  85034. * 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).
  85035. */
  85036. get shadowsHue(): number;
  85037. /**
  85038. * Sets the shadows Hue value.
  85039. * 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).
  85040. */
  85041. set shadowsHue(value: number);
  85042. /**
  85043. * Gets the shadows Density value.
  85044. * 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.
  85045. * Values less than zero provide a filter of opposite hue.
  85046. */
  85047. get shadowsDensity(): number;
  85048. /**
  85049. * Sets the shadows Density value.
  85050. * 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.
  85051. * Values less than zero provide a filter of opposite hue.
  85052. */
  85053. set shadowsDensity(value: number);
  85054. /**
  85055. * Gets the shadows Saturation value.
  85056. * 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.
  85057. */
  85058. get shadowsSaturation(): number;
  85059. /**
  85060. * Sets the shadows Saturation value.
  85061. * 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.
  85062. */
  85063. set shadowsSaturation(value: number);
  85064. /**
  85065. * Gets the shadows Exposure value.
  85066. * 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.
  85067. */
  85068. get shadowsExposure(): number;
  85069. /**
  85070. * Sets the shadows Exposure value.
  85071. * 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.
  85072. */
  85073. set shadowsExposure(value: number);
  85074. /**
  85075. * Returns the class name
  85076. * @returns The class name
  85077. */
  85078. getClassName(): string;
  85079. /**
  85080. * Binds the color curves to the shader.
  85081. * @param colorCurves The color curve to bind
  85082. * @param effect The effect to bind to
  85083. * @param positiveUniform The positive uniform shader parameter
  85084. * @param neutralUniform The neutral uniform shader parameter
  85085. * @param negativeUniform The negative uniform shader parameter
  85086. */
  85087. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85088. /**
  85089. * Prepare the list of uniforms associated with the ColorCurves effects.
  85090. * @param uniformsList The list of uniforms used in the effect
  85091. */
  85092. static PrepareUniforms(uniformsList: string[]): void;
  85093. /**
  85094. * Returns color grading data based on a hue, density, saturation and exposure value.
  85095. * @param filterHue The hue of the color filter.
  85096. * @param filterDensity The density of the color filter.
  85097. * @param saturation The saturation.
  85098. * @param exposure The exposure.
  85099. * @param result The result data container.
  85100. */
  85101. private getColorGradingDataToRef;
  85102. /**
  85103. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85104. * @param value The input slider value in range [-100,100].
  85105. * @returns Adjusted value.
  85106. */
  85107. private static applyColorGradingSliderNonlinear;
  85108. /**
  85109. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85110. * @param hue The hue (H) input.
  85111. * @param saturation The saturation (S) input.
  85112. * @param brightness The brightness (B) input.
  85113. * @result An RGBA color represented as Vector4.
  85114. */
  85115. private static fromHSBToRef;
  85116. /**
  85117. * Returns a value clamped between min and max
  85118. * @param value The value to clamp
  85119. * @param min The minimum of value
  85120. * @param max The maximum of value
  85121. * @returns The clamped value.
  85122. */
  85123. private static clamp;
  85124. /**
  85125. * Clones the current color curve instance.
  85126. * @return The cloned curves
  85127. */
  85128. clone(): ColorCurves;
  85129. /**
  85130. * Serializes the current color curve instance to a json representation.
  85131. * @return a JSON representation
  85132. */
  85133. serialize(): any;
  85134. /**
  85135. * Parses the color curve from a json representation.
  85136. * @param source the JSON source to parse
  85137. * @return The parsed curves
  85138. */
  85139. static Parse(source: any): ColorCurves;
  85140. }
  85141. }
  85142. declare module BABYLON {
  85143. /**
  85144. * Interface to follow in your material defines to integrate easily the
  85145. * Image proccessing functions.
  85146. * @hidden
  85147. */
  85148. export interface IImageProcessingConfigurationDefines {
  85149. IMAGEPROCESSING: boolean;
  85150. VIGNETTE: boolean;
  85151. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85152. VIGNETTEBLENDMODEOPAQUE: boolean;
  85153. TONEMAPPING: boolean;
  85154. TONEMAPPING_ACES: boolean;
  85155. CONTRAST: boolean;
  85156. EXPOSURE: boolean;
  85157. COLORCURVES: boolean;
  85158. COLORGRADING: boolean;
  85159. COLORGRADING3D: boolean;
  85160. SAMPLER3DGREENDEPTH: boolean;
  85161. SAMPLER3DBGRMAP: boolean;
  85162. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85163. }
  85164. /**
  85165. * @hidden
  85166. */
  85167. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85168. IMAGEPROCESSING: boolean;
  85169. VIGNETTE: boolean;
  85170. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85171. VIGNETTEBLENDMODEOPAQUE: boolean;
  85172. TONEMAPPING: boolean;
  85173. TONEMAPPING_ACES: boolean;
  85174. CONTRAST: boolean;
  85175. COLORCURVES: boolean;
  85176. COLORGRADING: boolean;
  85177. COLORGRADING3D: boolean;
  85178. SAMPLER3DGREENDEPTH: boolean;
  85179. SAMPLER3DBGRMAP: boolean;
  85180. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85181. EXPOSURE: boolean;
  85182. constructor();
  85183. }
  85184. /**
  85185. * This groups together the common properties used for image processing either in direct forward pass
  85186. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85187. * or not.
  85188. */
  85189. export class ImageProcessingConfiguration {
  85190. /**
  85191. * Default tone mapping applied in BabylonJS.
  85192. */
  85193. static readonly TONEMAPPING_STANDARD: number;
  85194. /**
  85195. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85196. * to other engines rendering to increase portability.
  85197. */
  85198. static readonly TONEMAPPING_ACES: number;
  85199. /**
  85200. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85201. */
  85202. colorCurves: Nullable<ColorCurves>;
  85203. private _colorCurvesEnabled;
  85204. /**
  85205. * Gets wether the color curves effect is enabled.
  85206. */
  85207. get colorCurvesEnabled(): boolean;
  85208. /**
  85209. * Sets wether the color curves effect is enabled.
  85210. */
  85211. set colorCurvesEnabled(value: boolean);
  85212. private _colorGradingTexture;
  85213. /**
  85214. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85215. */
  85216. get colorGradingTexture(): Nullable<BaseTexture>;
  85217. /**
  85218. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85219. */
  85220. set colorGradingTexture(value: Nullable<BaseTexture>);
  85221. private _colorGradingEnabled;
  85222. /**
  85223. * Gets wether the color grading effect is enabled.
  85224. */
  85225. get colorGradingEnabled(): boolean;
  85226. /**
  85227. * Sets wether the color grading effect is enabled.
  85228. */
  85229. set colorGradingEnabled(value: boolean);
  85230. private _colorGradingWithGreenDepth;
  85231. /**
  85232. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85233. */
  85234. get colorGradingWithGreenDepth(): boolean;
  85235. /**
  85236. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85237. */
  85238. set colorGradingWithGreenDepth(value: boolean);
  85239. private _colorGradingBGR;
  85240. /**
  85241. * Gets wether the color grading texture contains BGR values.
  85242. */
  85243. get colorGradingBGR(): boolean;
  85244. /**
  85245. * Sets wether the color grading texture contains BGR values.
  85246. */
  85247. set colorGradingBGR(value: boolean);
  85248. /** @hidden */
  85249. _exposure: number;
  85250. /**
  85251. * Gets the Exposure used in the effect.
  85252. */
  85253. get exposure(): number;
  85254. /**
  85255. * Sets the Exposure used in the effect.
  85256. */
  85257. set exposure(value: number);
  85258. private _toneMappingEnabled;
  85259. /**
  85260. * Gets wether the tone mapping effect is enabled.
  85261. */
  85262. get toneMappingEnabled(): boolean;
  85263. /**
  85264. * Sets wether the tone mapping effect is enabled.
  85265. */
  85266. set toneMappingEnabled(value: boolean);
  85267. private _toneMappingType;
  85268. /**
  85269. * Gets the type of tone mapping effect.
  85270. */
  85271. get toneMappingType(): number;
  85272. /**
  85273. * Sets the type of tone mapping effect used in BabylonJS.
  85274. */
  85275. set toneMappingType(value: number);
  85276. protected _contrast: number;
  85277. /**
  85278. * Gets the contrast used in the effect.
  85279. */
  85280. get contrast(): number;
  85281. /**
  85282. * Sets the contrast used in the effect.
  85283. */
  85284. set contrast(value: number);
  85285. /**
  85286. * Vignette stretch size.
  85287. */
  85288. vignetteStretch: number;
  85289. /**
  85290. * Vignette centre X Offset.
  85291. */
  85292. vignetteCentreX: number;
  85293. /**
  85294. * Vignette centre Y Offset.
  85295. */
  85296. vignetteCentreY: number;
  85297. /**
  85298. * Vignette weight or intensity of the vignette effect.
  85299. */
  85300. vignetteWeight: number;
  85301. /**
  85302. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85303. * if vignetteEnabled is set to true.
  85304. */
  85305. vignetteColor: Color4;
  85306. /**
  85307. * Camera field of view used by the Vignette effect.
  85308. */
  85309. vignetteCameraFov: number;
  85310. private _vignetteBlendMode;
  85311. /**
  85312. * Gets the vignette blend mode allowing different kind of effect.
  85313. */
  85314. get vignetteBlendMode(): number;
  85315. /**
  85316. * Sets the vignette blend mode allowing different kind of effect.
  85317. */
  85318. set vignetteBlendMode(value: number);
  85319. private _vignetteEnabled;
  85320. /**
  85321. * Gets wether the vignette effect is enabled.
  85322. */
  85323. get vignetteEnabled(): boolean;
  85324. /**
  85325. * Sets wether the vignette effect is enabled.
  85326. */
  85327. set vignetteEnabled(value: boolean);
  85328. private _applyByPostProcess;
  85329. /**
  85330. * Gets wether the image processing is applied through a post process or not.
  85331. */
  85332. get applyByPostProcess(): boolean;
  85333. /**
  85334. * Sets wether the image processing is applied through a post process or not.
  85335. */
  85336. set applyByPostProcess(value: boolean);
  85337. private _isEnabled;
  85338. /**
  85339. * Gets wether the image processing is enabled or not.
  85340. */
  85341. get isEnabled(): boolean;
  85342. /**
  85343. * Sets wether the image processing is enabled or not.
  85344. */
  85345. set isEnabled(value: boolean);
  85346. /**
  85347. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85348. */
  85349. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85350. /**
  85351. * Method called each time the image processing information changes requires to recompile the effect.
  85352. */
  85353. protected _updateParameters(): void;
  85354. /**
  85355. * Gets the current class name.
  85356. * @return "ImageProcessingConfiguration"
  85357. */
  85358. getClassName(): string;
  85359. /**
  85360. * Prepare the list of uniforms associated with the Image Processing effects.
  85361. * @param uniforms The list of uniforms used in the effect
  85362. * @param defines the list of defines currently in use
  85363. */
  85364. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85365. /**
  85366. * Prepare the list of samplers associated with the Image Processing effects.
  85367. * @param samplersList The list of uniforms used in the effect
  85368. * @param defines the list of defines currently in use
  85369. */
  85370. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85371. /**
  85372. * Prepare the list of defines associated to the shader.
  85373. * @param defines the list of defines to complete
  85374. * @param forPostProcess Define if we are currently in post process mode or not
  85375. */
  85376. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85377. /**
  85378. * Returns true if all the image processing information are ready.
  85379. * @returns True if ready, otherwise, false
  85380. */
  85381. isReady(): boolean;
  85382. /**
  85383. * Binds the image processing to the shader.
  85384. * @param effect The effect to bind to
  85385. * @param overrideAspectRatio Override the aspect ratio of the effect
  85386. */
  85387. bind(effect: Effect, overrideAspectRatio?: number): void;
  85388. /**
  85389. * Clones the current image processing instance.
  85390. * @return The cloned image processing
  85391. */
  85392. clone(): ImageProcessingConfiguration;
  85393. /**
  85394. * Serializes the current image processing instance to a json representation.
  85395. * @return a JSON representation
  85396. */
  85397. serialize(): any;
  85398. /**
  85399. * Parses the image processing from a json representation.
  85400. * @param source the JSON source to parse
  85401. * @return The parsed image processing
  85402. */
  85403. static Parse(source: any): ImageProcessingConfiguration;
  85404. private static _VIGNETTEMODE_MULTIPLY;
  85405. private static _VIGNETTEMODE_OPAQUE;
  85406. /**
  85407. * Used to apply the vignette as a mix with the pixel color.
  85408. */
  85409. static get VIGNETTEMODE_MULTIPLY(): number;
  85410. /**
  85411. * Used to apply the vignette as a replacement of the pixel color.
  85412. */
  85413. static get VIGNETTEMODE_OPAQUE(): number;
  85414. }
  85415. }
  85416. declare module BABYLON {
  85417. /** @hidden */
  85418. export var postprocessVertexShader: {
  85419. name: string;
  85420. shader: string;
  85421. };
  85422. }
  85423. declare module BABYLON {
  85424. interface ThinEngine {
  85425. /**
  85426. * Creates a new render target texture
  85427. * @param size defines the size of the texture
  85428. * @param options defines the options used to create the texture
  85429. * @returns a new render target texture stored in an InternalTexture
  85430. */
  85431. createRenderTargetTexture(size: number | {
  85432. width: number;
  85433. height: number;
  85434. layers?: number;
  85435. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85436. /**
  85437. * Creates a depth stencil texture.
  85438. * This is only available in WebGL 2 or with the depth texture extension available.
  85439. * @param size The size of face edge in the texture.
  85440. * @param options The options defining the texture.
  85441. * @returns The texture
  85442. */
  85443. createDepthStencilTexture(size: number | {
  85444. width: number;
  85445. height: number;
  85446. layers?: number;
  85447. }, options: DepthTextureCreationOptions): InternalTexture;
  85448. /** @hidden */
  85449. _createDepthStencilTexture(size: number | {
  85450. width: number;
  85451. height: number;
  85452. layers?: number;
  85453. }, options: DepthTextureCreationOptions): InternalTexture;
  85454. }
  85455. }
  85456. declare module BABYLON {
  85457. /**
  85458. * Defines the kind of connection point for node based material
  85459. */
  85460. export enum NodeMaterialBlockConnectionPointTypes {
  85461. /** Float */
  85462. Float = 1,
  85463. /** Int */
  85464. Int = 2,
  85465. /** Vector2 */
  85466. Vector2 = 4,
  85467. /** Vector3 */
  85468. Vector3 = 8,
  85469. /** Vector4 */
  85470. Vector4 = 16,
  85471. /** Color3 */
  85472. Color3 = 32,
  85473. /** Color4 */
  85474. Color4 = 64,
  85475. /** Matrix */
  85476. Matrix = 128,
  85477. /** Custom object */
  85478. Object = 256,
  85479. /** Detect type based on connection */
  85480. AutoDetect = 1024,
  85481. /** Output type that will be defined by input type */
  85482. BasedOnInput = 2048
  85483. }
  85484. }
  85485. declare module BABYLON {
  85486. /**
  85487. * Enum used to define the target of a block
  85488. */
  85489. export enum NodeMaterialBlockTargets {
  85490. /** Vertex shader */
  85491. Vertex = 1,
  85492. /** Fragment shader */
  85493. Fragment = 2,
  85494. /** Neutral */
  85495. Neutral = 4,
  85496. /** Vertex and Fragment */
  85497. VertexAndFragment = 3
  85498. }
  85499. }
  85500. declare module BABYLON {
  85501. /**
  85502. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  85503. */
  85504. export enum NodeMaterialBlockConnectionPointMode {
  85505. /** Value is an uniform */
  85506. Uniform = 0,
  85507. /** Value is a mesh attribute */
  85508. Attribute = 1,
  85509. /** Value is a varying between vertex and fragment shaders */
  85510. Varying = 2,
  85511. /** Mode is undefined */
  85512. Undefined = 3
  85513. }
  85514. }
  85515. declare module BABYLON {
  85516. /**
  85517. * Enum used to define system values e.g. values automatically provided by the system
  85518. */
  85519. export enum NodeMaterialSystemValues {
  85520. /** World */
  85521. World = 1,
  85522. /** View */
  85523. View = 2,
  85524. /** Projection */
  85525. Projection = 3,
  85526. /** ViewProjection */
  85527. ViewProjection = 4,
  85528. /** WorldView */
  85529. WorldView = 5,
  85530. /** WorldViewProjection */
  85531. WorldViewProjection = 6,
  85532. /** CameraPosition */
  85533. CameraPosition = 7,
  85534. /** Fog Color */
  85535. FogColor = 8,
  85536. /** Delta time */
  85537. DeltaTime = 9
  85538. }
  85539. }
  85540. declare module BABYLON {
  85541. /** Defines supported spaces */
  85542. export enum Space {
  85543. /** Local (object) space */
  85544. LOCAL = 0,
  85545. /** World space */
  85546. WORLD = 1,
  85547. /** Bone space */
  85548. BONE = 2
  85549. }
  85550. /** Defines the 3 main axes */
  85551. export class Axis {
  85552. /** X axis */
  85553. static X: Vector3;
  85554. /** Y axis */
  85555. static Y: Vector3;
  85556. /** Z axis */
  85557. static Z: Vector3;
  85558. }
  85559. }
  85560. declare module BABYLON {
  85561. /**
  85562. * Represents a camera frustum
  85563. */
  85564. export class Frustum {
  85565. /**
  85566. * Gets the planes representing the frustum
  85567. * @param transform matrix to be applied to the returned planes
  85568. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85569. */
  85570. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85571. /**
  85572. * Gets the near frustum plane transformed by the transform matrix
  85573. * @param transform transformation matrix to be applied to the resulting frustum plane
  85574. * @param frustumPlane the resuling frustum plane
  85575. */
  85576. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85577. /**
  85578. * Gets the far frustum plane transformed by the transform matrix
  85579. * @param transform transformation matrix to be applied to the resulting frustum plane
  85580. * @param frustumPlane the resuling frustum plane
  85581. */
  85582. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85583. /**
  85584. * Gets the left frustum plane transformed by the transform matrix
  85585. * @param transform transformation matrix to be applied to the resulting frustum plane
  85586. * @param frustumPlane the resuling frustum plane
  85587. */
  85588. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85589. /**
  85590. * Gets the right frustum plane transformed by the transform matrix
  85591. * @param transform transformation matrix to be applied to the resulting frustum plane
  85592. * @param frustumPlane the resuling frustum plane
  85593. */
  85594. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85595. /**
  85596. * Gets the top frustum plane transformed by the transform matrix
  85597. * @param transform transformation matrix to be applied to the resulting frustum plane
  85598. * @param frustumPlane the resuling frustum plane
  85599. */
  85600. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85601. /**
  85602. * Gets the bottom frustum plane transformed by the transform matrix
  85603. * @param transform transformation matrix to be applied to the resulting frustum plane
  85604. * @param frustumPlane the resuling frustum plane
  85605. */
  85606. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85607. /**
  85608. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85609. * @param transform transformation matrix to be applied to the resulting frustum planes
  85610. * @param frustumPlanes the resuling frustum planes
  85611. */
  85612. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85613. }
  85614. }
  85615. declare module BABYLON {
  85616. /**
  85617. * Interface for the size containing width and height
  85618. */
  85619. export interface ISize {
  85620. /**
  85621. * Width
  85622. */
  85623. width: number;
  85624. /**
  85625. * Heighht
  85626. */
  85627. height: number;
  85628. }
  85629. /**
  85630. * Size containing widht and height
  85631. */
  85632. export class Size implements ISize {
  85633. /**
  85634. * Width
  85635. */
  85636. width: number;
  85637. /**
  85638. * Height
  85639. */
  85640. height: number;
  85641. /**
  85642. * Creates a Size object from the given width and height (floats).
  85643. * @param width width of the new size
  85644. * @param height height of the new size
  85645. */
  85646. constructor(width: number, height: number);
  85647. /**
  85648. * Returns a string with the Size width and height
  85649. * @returns a string with the Size width and height
  85650. */
  85651. toString(): string;
  85652. /**
  85653. * "Size"
  85654. * @returns the string "Size"
  85655. */
  85656. getClassName(): string;
  85657. /**
  85658. * Returns the Size hash code.
  85659. * @returns a hash code for a unique width and height
  85660. */
  85661. getHashCode(): number;
  85662. /**
  85663. * Updates the current size from the given one.
  85664. * @param src the given size
  85665. */
  85666. copyFrom(src: Size): void;
  85667. /**
  85668. * Updates in place the current Size from the given floats.
  85669. * @param width width of the new size
  85670. * @param height height of the new size
  85671. * @returns the updated Size.
  85672. */
  85673. copyFromFloats(width: number, height: number): Size;
  85674. /**
  85675. * Updates in place the current Size from the given floats.
  85676. * @param width width to set
  85677. * @param height height to set
  85678. * @returns the updated Size.
  85679. */
  85680. set(width: number, height: number): Size;
  85681. /**
  85682. * Multiplies the width and height by numbers
  85683. * @param w factor to multiple the width by
  85684. * @param h factor to multiple the height by
  85685. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85686. */
  85687. multiplyByFloats(w: number, h: number): Size;
  85688. /**
  85689. * Clones the size
  85690. * @returns a new Size copied from the given one.
  85691. */
  85692. clone(): Size;
  85693. /**
  85694. * True if the current Size and the given one width and height are strictly equal.
  85695. * @param other the other size to compare against
  85696. * @returns True if the current Size and the given one width and height are strictly equal.
  85697. */
  85698. equals(other: Size): boolean;
  85699. /**
  85700. * The surface of the Size : width * height (float).
  85701. */
  85702. get surface(): number;
  85703. /**
  85704. * Create a new size of zero
  85705. * @returns a new Size set to (0.0, 0.0)
  85706. */
  85707. static Zero(): Size;
  85708. /**
  85709. * Sums the width and height of two sizes
  85710. * @param otherSize size to add to this size
  85711. * @returns a new Size set as the addition result of the current Size and the given one.
  85712. */
  85713. add(otherSize: Size): Size;
  85714. /**
  85715. * Subtracts the width and height of two
  85716. * @param otherSize size to subtract to this size
  85717. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85718. */
  85719. subtract(otherSize: Size): Size;
  85720. /**
  85721. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85722. * @param start starting size to lerp between
  85723. * @param end end size to lerp between
  85724. * @param amount amount to lerp between the start and end values
  85725. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85726. */
  85727. static Lerp(start: Size, end: Size, amount: number): Size;
  85728. }
  85729. }
  85730. declare module BABYLON {
  85731. /**
  85732. * Contains position and normal vectors for a vertex
  85733. */
  85734. export class PositionNormalVertex {
  85735. /** the position of the vertex (defaut: 0,0,0) */
  85736. position: Vector3;
  85737. /** the normal of the vertex (defaut: 0,1,0) */
  85738. normal: Vector3;
  85739. /**
  85740. * Creates a PositionNormalVertex
  85741. * @param position the position of the vertex (defaut: 0,0,0)
  85742. * @param normal the normal of the vertex (defaut: 0,1,0)
  85743. */
  85744. constructor(
  85745. /** the position of the vertex (defaut: 0,0,0) */
  85746. position?: Vector3,
  85747. /** the normal of the vertex (defaut: 0,1,0) */
  85748. normal?: Vector3);
  85749. /**
  85750. * Clones the PositionNormalVertex
  85751. * @returns the cloned PositionNormalVertex
  85752. */
  85753. clone(): PositionNormalVertex;
  85754. }
  85755. /**
  85756. * Contains position, normal and uv vectors for a vertex
  85757. */
  85758. export class PositionNormalTextureVertex {
  85759. /** the position of the vertex (defaut: 0,0,0) */
  85760. position: Vector3;
  85761. /** the normal of the vertex (defaut: 0,1,0) */
  85762. normal: Vector3;
  85763. /** the uv of the vertex (default: 0,0) */
  85764. uv: Vector2;
  85765. /**
  85766. * Creates a PositionNormalTextureVertex
  85767. * @param position the position of the vertex (defaut: 0,0,0)
  85768. * @param normal the normal of the vertex (defaut: 0,1,0)
  85769. * @param uv the uv of the vertex (default: 0,0)
  85770. */
  85771. constructor(
  85772. /** the position of the vertex (defaut: 0,0,0) */
  85773. position?: Vector3,
  85774. /** the normal of the vertex (defaut: 0,1,0) */
  85775. normal?: Vector3,
  85776. /** the uv of the vertex (default: 0,0) */
  85777. uv?: Vector2);
  85778. /**
  85779. * Clones the PositionNormalTextureVertex
  85780. * @returns the cloned PositionNormalTextureVertex
  85781. */
  85782. clone(): PositionNormalTextureVertex;
  85783. }
  85784. }
  85785. declare module BABYLON {
  85786. /**
  85787. * Enum defining the type of animations supported by InputBlock
  85788. */
  85789. export enum AnimatedInputBlockTypes {
  85790. /** No animation */
  85791. None = 0,
  85792. /** Time based animation. Will only work for floats */
  85793. Time = 1
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. /**
  85798. * Interface describing all the common properties and methods a shadow light needs to implement.
  85799. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  85800. * as well as binding the different shadow properties to the effects.
  85801. */
  85802. export interface IShadowLight extends Light {
  85803. /**
  85804. * The light id in the scene (used in scene.findLighById for instance)
  85805. */
  85806. id: string;
  85807. /**
  85808. * The position the shdow will be casted from.
  85809. */
  85810. position: Vector3;
  85811. /**
  85812. * In 2d mode (needCube being false), the direction used to cast the shadow.
  85813. */
  85814. direction: Vector3;
  85815. /**
  85816. * The transformed position. Position of the light in world space taking parenting in account.
  85817. */
  85818. transformedPosition: Vector3;
  85819. /**
  85820. * The transformed direction. Direction of the light in world space taking parenting in account.
  85821. */
  85822. transformedDirection: Vector3;
  85823. /**
  85824. * The friendly name of the light in the scene.
  85825. */
  85826. name: string;
  85827. /**
  85828. * Defines the shadow projection clipping minimum z value.
  85829. */
  85830. shadowMinZ: number;
  85831. /**
  85832. * Defines the shadow projection clipping maximum z value.
  85833. */
  85834. shadowMaxZ: number;
  85835. /**
  85836. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  85837. * @returns true if the information has been computed, false if it does not need to (no parenting)
  85838. */
  85839. computeTransformedInformation(): boolean;
  85840. /**
  85841. * Gets the scene the light belongs to.
  85842. * @returns The scene
  85843. */
  85844. getScene(): Scene;
  85845. /**
  85846. * Callback defining a custom Projection Matrix Builder.
  85847. * This can be used to override the default projection matrix computation.
  85848. */
  85849. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  85850. /**
  85851. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  85852. * @param matrix The materix to updated with the projection information
  85853. * @param viewMatrix The transform matrix of the light
  85854. * @param renderList The list of mesh to render in the map
  85855. * @returns The current light
  85856. */
  85857. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  85858. /**
  85859. * Gets the current depth scale used in ESM.
  85860. * @returns The scale
  85861. */
  85862. getDepthScale(): number;
  85863. /**
  85864. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85865. * @returns true if a cube texture needs to be use
  85866. */
  85867. needCube(): boolean;
  85868. /**
  85869. * Detects if the projection matrix requires to be recomputed this frame.
  85870. * @returns true if it requires to be recomputed otherwise, false.
  85871. */
  85872. needProjectionMatrixCompute(): boolean;
  85873. /**
  85874. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  85875. */
  85876. forceProjectionMatrixCompute(): void;
  85877. /**
  85878. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  85879. * @param faceIndex The index of the face we are computed the direction to generate shadow
  85880. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  85881. */
  85882. getShadowDirection(faceIndex?: number): Vector3;
  85883. /**
  85884. * Gets the minZ used for shadow according to both the scene and the light.
  85885. * @param activeCamera The camera we are returning the min for
  85886. * @returns the depth min z
  85887. */
  85888. getDepthMinZ(activeCamera: Camera): number;
  85889. /**
  85890. * Gets the maxZ used for shadow according to both the scene and the light.
  85891. * @param activeCamera The camera we are returning the max for
  85892. * @returns the depth max z
  85893. */
  85894. getDepthMaxZ(activeCamera: Camera): number;
  85895. }
  85896. /**
  85897. * Base implementation IShadowLight
  85898. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  85899. */
  85900. export abstract class ShadowLight extends Light implements IShadowLight {
  85901. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  85902. protected _position: Vector3;
  85903. protected _setPosition(value: Vector3): void;
  85904. /**
  85905. * Sets the position the shadow will be casted from. Also use as the light position for both
  85906. * point and spot lights.
  85907. */
  85908. get position(): Vector3;
  85909. /**
  85910. * Sets the position the shadow will be casted from. Also use as the light position for both
  85911. * point and spot lights.
  85912. */
  85913. set position(value: Vector3);
  85914. protected _direction: Vector3;
  85915. protected _setDirection(value: Vector3): void;
  85916. /**
  85917. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  85918. * Also use as the light direction on spot and directional lights.
  85919. */
  85920. get direction(): Vector3;
  85921. /**
  85922. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  85923. * Also use as the light direction on spot and directional lights.
  85924. */
  85925. set direction(value: Vector3);
  85926. protected _shadowMinZ: number;
  85927. /**
  85928. * Gets the shadow projection clipping minimum z value.
  85929. */
  85930. get shadowMinZ(): number;
  85931. /**
  85932. * Sets the shadow projection clipping minimum z value.
  85933. */
  85934. set shadowMinZ(value: number);
  85935. protected _shadowMaxZ: number;
  85936. /**
  85937. * Sets the shadow projection clipping maximum z value.
  85938. */
  85939. get shadowMaxZ(): number;
  85940. /**
  85941. * Gets the shadow projection clipping maximum z value.
  85942. */
  85943. set shadowMaxZ(value: number);
  85944. /**
  85945. * Callback defining a custom Projection Matrix Builder.
  85946. * This can be used to override the default projection matrix computation.
  85947. */
  85948. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  85949. /**
  85950. * The transformed position. Position of the light in world space taking parenting in account.
  85951. */
  85952. transformedPosition: Vector3;
  85953. /**
  85954. * The transformed direction. Direction of the light in world space taking parenting in account.
  85955. */
  85956. transformedDirection: Vector3;
  85957. private _needProjectionMatrixCompute;
  85958. /**
  85959. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  85960. * @returns true if the information has been computed, false if it does not need to (no parenting)
  85961. */
  85962. computeTransformedInformation(): boolean;
  85963. /**
  85964. * Return the depth scale used for the shadow map.
  85965. * @returns the depth scale.
  85966. */
  85967. getDepthScale(): number;
  85968. /**
  85969. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  85970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  85971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  85972. */
  85973. getShadowDirection(faceIndex?: number): Vector3;
  85974. /**
  85975. * Returns the ShadowLight absolute position in the World.
  85976. * @returns the position vector in world space
  85977. */
  85978. getAbsolutePosition(): Vector3;
  85979. /**
  85980. * Sets the ShadowLight direction toward the passed target.
  85981. * @param target The point to target in local space
  85982. * @returns the updated ShadowLight direction
  85983. */
  85984. setDirectionToTarget(target: Vector3): Vector3;
  85985. /**
  85986. * Returns the light rotation in euler definition.
  85987. * @returns the x y z rotation in local space.
  85988. */
  85989. getRotation(): Vector3;
  85990. /**
  85991. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85992. * @returns true if a cube texture needs to be use
  85993. */
  85994. needCube(): boolean;
  85995. /**
  85996. * Detects if the projection matrix requires to be recomputed this frame.
  85997. * @returns true if it requires to be recomputed otherwise, false.
  85998. */
  85999. needProjectionMatrixCompute(): boolean;
  86000. /**
  86001. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86002. */
  86003. forceProjectionMatrixCompute(): void;
  86004. /** @hidden */
  86005. _initCache(): void;
  86006. /** @hidden */
  86007. _isSynchronized(): boolean;
  86008. /**
  86009. * Computes the world matrix of the node
  86010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86011. * @returns the world matrix
  86012. */
  86013. computeWorldMatrix(force?: boolean): Matrix;
  86014. /**
  86015. * Gets the minZ used for shadow according to both the scene and the light.
  86016. * @param activeCamera The camera we are returning the min for
  86017. * @returns the depth min z
  86018. */
  86019. getDepthMinZ(activeCamera: Camera): number;
  86020. /**
  86021. * Gets the maxZ used for shadow according to both the scene and the light.
  86022. * @param activeCamera The camera we are returning the max for
  86023. * @returns the depth max z
  86024. */
  86025. getDepthMaxZ(activeCamera: Camera): number;
  86026. /**
  86027. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86028. * @param matrix The materix to updated with the projection information
  86029. * @param viewMatrix The transform matrix of the light
  86030. * @param renderList The list of mesh to render in the map
  86031. * @returns The current light
  86032. */
  86033. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86034. }
  86035. }
  86036. declare module BABYLON {
  86037. /** @hidden */
  86038. export var packingFunctions: {
  86039. name: string;
  86040. shader: string;
  86041. };
  86042. }
  86043. declare module BABYLON {
  86044. /** @hidden */
  86045. export var bayerDitherFunctions: {
  86046. name: string;
  86047. shader: string;
  86048. };
  86049. }
  86050. declare module BABYLON {
  86051. /** @hidden */
  86052. export var shadowMapFragmentDeclaration: {
  86053. name: string;
  86054. shader: string;
  86055. };
  86056. }
  86057. declare module BABYLON {
  86058. /** @hidden */
  86059. export var clipPlaneFragmentDeclaration: {
  86060. name: string;
  86061. shader: string;
  86062. };
  86063. }
  86064. declare module BABYLON {
  86065. /** @hidden */
  86066. export var clipPlaneFragment: {
  86067. name: string;
  86068. shader: string;
  86069. };
  86070. }
  86071. declare module BABYLON {
  86072. /** @hidden */
  86073. export var shadowMapFragment: {
  86074. name: string;
  86075. shader: string;
  86076. };
  86077. }
  86078. declare module BABYLON {
  86079. /** @hidden */
  86080. export var shadowMapPixelShader: {
  86081. name: string;
  86082. shader: string;
  86083. };
  86084. }
  86085. declare module BABYLON {
  86086. /** @hidden */
  86087. export var bonesDeclaration: {
  86088. name: string;
  86089. shader: string;
  86090. };
  86091. }
  86092. declare module BABYLON {
  86093. /** @hidden */
  86094. export var morphTargetsVertexGlobalDeclaration: {
  86095. name: string;
  86096. shader: string;
  86097. };
  86098. }
  86099. declare module BABYLON {
  86100. /** @hidden */
  86101. export var morphTargetsVertexDeclaration: {
  86102. name: string;
  86103. shader: string;
  86104. };
  86105. }
  86106. declare module BABYLON {
  86107. /** @hidden */
  86108. export var instancesDeclaration: {
  86109. name: string;
  86110. shader: string;
  86111. };
  86112. }
  86113. declare module BABYLON {
  86114. /** @hidden */
  86115. export var helperFunctions: {
  86116. name: string;
  86117. shader: string;
  86118. };
  86119. }
  86120. declare module BABYLON {
  86121. /** @hidden */
  86122. export var shadowMapVertexDeclaration: {
  86123. name: string;
  86124. shader: string;
  86125. };
  86126. }
  86127. declare module BABYLON {
  86128. /** @hidden */
  86129. export var clipPlaneVertexDeclaration: {
  86130. name: string;
  86131. shader: string;
  86132. };
  86133. }
  86134. declare module BABYLON {
  86135. /** @hidden */
  86136. export var morphTargetsVertex: {
  86137. name: string;
  86138. shader: string;
  86139. };
  86140. }
  86141. declare module BABYLON {
  86142. /** @hidden */
  86143. export var instancesVertex: {
  86144. name: string;
  86145. shader: string;
  86146. };
  86147. }
  86148. declare module BABYLON {
  86149. /** @hidden */
  86150. export var bonesVertex: {
  86151. name: string;
  86152. shader: string;
  86153. };
  86154. }
  86155. declare module BABYLON {
  86156. /** @hidden */
  86157. export var shadowMapVertexNormalBias: {
  86158. name: string;
  86159. shader: string;
  86160. };
  86161. }
  86162. declare module BABYLON {
  86163. /** @hidden */
  86164. export var shadowMapVertexMetric: {
  86165. name: string;
  86166. shader: string;
  86167. };
  86168. }
  86169. declare module BABYLON {
  86170. /** @hidden */
  86171. export var clipPlaneVertex: {
  86172. name: string;
  86173. shader: string;
  86174. };
  86175. }
  86176. declare module BABYLON {
  86177. /** @hidden */
  86178. export var shadowMapVertexShader: {
  86179. name: string;
  86180. shader: string;
  86181. };
  86182. }
  86183. declare module BABYLON {
  86184. /** @hidden */
  86185. export var depthBoxBlurPixelShader: {
  86186. name: string;
  86187. shader: string;
  86188. };
  86189. }
  86190. declare module BABYLON {
  86191. /** @hidden */
  86192. export var shadowMapFragmentSoftTransparentShadow: {
  86193. name: string;
  86194. shader: string;
  86195. };
  86196. }
  86197. declare module BABYLON {
  86198. /**
  86199. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86200. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86201. */
  86202. export class EffectFallbacks implements IEffectFallbacks {
  86203. private _defines;
  86204. private _currentRank;
  86205. private _maxRank;
  86206. private _mesh;
  86207. /**
  86208. * Removes the fallback from the bound mesh.
  86209. */
  86210. unBindMesh(): void;
  86211. /**
  86212. * Adds a fallback on the specified property.
  86213. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86214. * @param define The name of the define in the shader
  86215. */
  86216. addFallback(rank: number, define: string): void;
  86217. /**
  86218. * Sets the mesh to use CPU skinning when needing to fallback.
  86219. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86220. * @param mesh The mesh to use the fallbacks.
  86221. */
  86222. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86223. /**
  86224. * Checks to see if more fallbacks are still availible.
  86225. */
  86226. get hasMoreFallbacks(): boolean;
  86227. /**
  86228. * Removes the defines that should be removed when falling back.
  86229. * @param currentDefines defines the current define statements for the shader.
  86230. * @param effect defines the current effect we try to compile
  86231. * @returns The resulting defines with defines of the current rank removed.
  86232. */
  86233. reduce(currentDefines: string, effect: Effect): string;
  86234. }
  86235. }
  86236. declare module BABYLON {
  86237. /**
  86238. * Interface used to define Action
  86239. */
  86240. export interface IAction {
  86241. /**
  86242. * Trigger for the action
  86243. */
  86244. trigger: number;
  86245. /** Options of the trigger */
  86246. triggerOptions: any;
  86247. /**
  86248. * Gets the trigger parameters
  86249. * @returns the trigger parameters
  86250. */
  86251. getTriggerParameter(): any;
  86252. /**
  86253. * Internal only - executes current action event
  86254. * @hidden
  86255. */
  86256. _executeCurrent(evt?: ActionEvent): void;
  86257. /**
  86258. * Serialize placeholder for child classes
  86259. * @param parent of child
  86260. * @returns the serialized object
  86261. */
  86262. serialize(parent: any): any;
  86263. /**
  86264. * Internal only
  86265. * @hidden
  86266. */
  86267. _prepare(): void;
  86268. /**
  86269. * Internal only - manager for action
  86270. * @hidden
  86271. */
  86272. _actionManager: AbstractActionManager;
  86273. /**
  86274. * Adds action to chain of actions, may be a DoNothingAction
  86275. * @param action defines the next action to execute
  86276. * @returns The action passed in
  86277. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86278. */
  86279. then(action: IAction): IAction;
  86280. }
  86281. /**
  86282. * The action to be carried out following a trigger
  86283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86284. */
  86285. export class Action implements IAction {
  86286. /** the trigger, with or without parameters, for the action */
  86287. triggerOptions: any;
  86288. /**
  86289. * Trigger for the action
  86290. */
  86291. trigger: number;
  86292. /**
  86293. * Internal only - manager for action
  86294. * @hidden
  86295. */
  86296. _actionManager: ActionManager;
  86297. private _nextActiveAction;
  86298. private _child;
  86299. private _condition?;
  86300. private _triggerParameter;
  86301. /**
  86302. * An event triggered prior to action being executed.
  86303. */
  86304. onBeforeExecuteObservable: Observable<Action>;
  86305. /**
  86306. * Creates a new Action
  86307. * @param triggerOptions the trigger, with or without parameters, for the action
  86308. * @param condition an optional determinant of action
  86309. */
  86310. constructor(
  86311. /** the trigger, with or without parameters, for the action */
  86312. triggerOptions: any, condition?: Condition);
  86313. /**
  86314. * Internal only
  86315. * @hidden
  86316. */
  86317. _prepare(): void;
  86318. /**
  86319. * Gets the trigger parameters
  86320. * @returns the trigger parameters
  86321. */
  86322. getTriggerParameter(): any;
  86323. /**
  86324. * Internal only - executes current action event
  86325. * @hidden
  86326. */
  86327. _executeCurrent(evt?: ActionEvent): void;
  86328. /**
  86329. * Execute placeholder for child classes
  86330. * @param evt optional action event
  86331. */
  86332. execute(evt?: ActionEvent): void;
  86333. /**
  86334. * Skips to next active action
  86335. */
  86336. skipToNextActiveAction(): void;
  86337. /**
  86338. * Adds action to chain of actions, may be a DoNothingAction
  86339. * @param action defines the next action to execute
  86340. * @returns The action passed in
  86341. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86342. */
  86343. then(action: Action): Action;
  86344. /**
  86345. * Internal only
  86346. * @hidden
  86347. */
  86348. _getProperty(propertyPath: string): string;
  86349. /**
  86350. * Internal only
  86351. * @hidden
  86352. */
  86353. _getEffectiveTarget(target: any, propertyPath: string): any;
  86354. /**
  86355. * Serialize placeholder for child classes
  86356. * @param parent of child
  86357. * @returns the serialized object
  86358. */
  86359. serialize(parent: any): any;
  86360. /**
  86361. * Internal only called by serialize
  86362. * @hidden
  86363. */
  86364. protected _serialize(serializedAction: any, parent?: any): any;
  86365. /**
  86366. * Internal only
  86367. * @hidden
  86368. */
  86369. static _SerializeValueAsString: (value: any) => string;
  86370. /**
  86371. * Internal only
  86372. * @hidden
  86373. */
  86374. static _GetTargetProperty: (target: Node | Scene) => {
  86375. name: string;
  86376. targetType: string;
  86377. value: string;
  86378. };
  86379. }
  86380. }
  86381. declare module BABYLON {
  86382. /**
  86383. * A Condition applied to an Action
  86384. */
  86385. export class Condition {
  86386. /**
  86387. * Internal only - manager for action
  86388. * @hidden
  86389. */
  86390. _actionManager: ActionManager;
  86391. /**
  86392. * Internal only
  86393. * @hidden
  86394. */
  86395. _evaluationId: number;
  86396. /**
  86397. * Internal only
  86398. * @hidden
  86399. */
  86400. _currentResult: boolean;
  86401. /**
  86402. * Creates a new Condition
  86403. * @param actionManager the manager of the action the condition is applied to
  86404. */
  86405. constructor(actionManager: ActionManager);
  86406. /**
  86407. * Check if the current condition is valid
  86408. * @returns a boolean
  86409. */
  86410. isValid(): boolean;
  86411. /**
  86412. * Internal only
  86413. * @hidden
  86414. */
  86415. _getProperty(propertyPath: string): string;
  86416. /**
  86417. * Internal only
  86418. * @hidden
  86419. */
  86420. _getEffectiveTarget(target: any, propertyPath: string): any;
  86421. /**
  86422. * Serialize placeholder for child classes
  86423. * @returns the serialized object
  86424. */
  86425. serialize(): any;
  86426. /**
  86427. * Internal only
  86428. * @hidden
  86429. */
  86430. protected _serialize(serializedCondition: any): any;
  86431. }
  86432. /**
  86433. * Defines specific conditional operators as extensions of Condition
  86434. */
  86435. export class ValueCondition extends Condition {
  86436. /** path to specify the property of the target the conditional operator uses */
  86437. propertyPath: string;
  86438. /** the value compared by the conditional operator against the current value of the property */
  86439. value: any;
  86440. /** the conditional operator, default ValueCondition.IsEqual */
  86441. operator: number;
  86442. /**
  86443. * Internal only
  86444. * @hidden
  86445. */
  86446. private static _IsEqual;
  86447. /**
  86448. * Internal only
  86449. * @hidden
  86450. */
  86451. private static _IsDifferent;
  86452. /**
  86453. * Internal only
  86454. * @hidden
  86455. */
  86456. private static _IsGreater;
  86457. /**
  86458. * Internal only
  86459. * @hidden
  86460. */
  86461. private static _IsLesser;
  86462. /**
  86463. * returns the number for IsEqual
  86464. */
  86465. static get IsEqual(): number;
  86466. /**
  86467. * Returns the number for IsDifferent
  86468. */
  86469. static get IsDifferent(): number;
  86470. /**
  86471. * Returns the number for IsGreater
  86472. */
  86473. static get IsGreater(): number;
  86474. /**
  86475. * Returns the number for IsLesser
  86476. */
  86477. static get IsLesser(): number;
  86478. /**
  86479. * Internal only The action manager for the condition
  86480. * @hidden
  86481. */
  86482. _actionManager: ActionManager;
  86483. /**
  86484. * Internal only
  86485. * @hidden
  86486. */
  86487. private _target;
  86488. /**
  86489. * Internal only
  86490. * @hidden
  86491. */
  86492. private _effectiveTarget;
  86493. /**
  86494. * Internal only
  86495. * @hidden
  86496. */
  86497. private _property;
  86498. /**
  86499. * Creates a new ValueCondition
  86500. * @param actionManager manager for the action the condition applies to
  86501. * @param target for the action
  86502. * @param propertyPath path to specify the property of the target the conditional operator uses
  86503. * @param value the value compared by the conditional operator against the current value of the property
  86504. * @param operator the conditional operator, default ValueCondition.IsEqual
  86505. */
  86506. constructor(actionManager: ActionManager, target: any,
  86507. /** path to specify the property of the target the conditional operator uses */
  86508. propertyPath: string,
  86509. /** the value compared by the conditional operator against the current value of the property */
  86510. value: any,
  86511. /** the conditional operator, default ValueCondition.IsEqual */
  86512. operator?: number);
  86513. /**
  86514. * Compares the given value with the property value for the specified conditional operator
  86515. * @returns the result of the comparison
  86516. */
  86517. isValid(): boolean;
  86518. /**
  86519. * Serialize the ValueCondition into a JSON compatible object
  86520. * @returns serialization object
  86521. */
  86522. serialize(): any;
  86523. /**
  86524. * Gets the name of the conditional operator for the ValueCondition
  86525. * @param operator the conditional operator
  86526. * @returns the name
  86527. */
  86528. static GetOperatorName(operator: number): string;
  86529. }
  86530. /**
  86531. * Defines a predicate condition as an extension of Condition
  86532. */
  86533. export class PredicateCondition extends Condition {
  86534. /** defines the predicate function used to validate the condition */
  86535. predicate: () => boolean;
  86536. /**
  86537. * Internal only - manager for action
  86538. * @hidden
  86539. */
  86540. _actionManager: ActionManager;
  86541. /**
  86542. * Creates a new PredicateCondition
  86543. * @param actionManager manager for the action the condition applies to
  86544. * @param predicate defines the predicate function used to validate the condition
  86545. */
  86546. constructor(actionManager: ActionManager,
  86547. /** defines the predicate function used to validate the condition */
  86548. predicate: () => boolean);
  86549. /**
  86550. * @returns the validity of the predicate condition
  86551. */
  86552. isValid(): boolean;
  86553. }
  86554. /**
  86555. * Defines a state condition as an extension of Condition
  86556. */
  86557. export class StateCondition extends Condition {
  86558. /** Value to compare with target state */
  86559. value: string;
  86560. /**
  86561. * Internal only - manager for action
  86562. * @hidden
  86563. */
  86564. _actionManager: ActionManager;
  86565. /**
  86566. * Internal only
  86567. * @hidden
  86568. */
  86569. private _target;
  86570. /**
  86571. * Creates a new StateCondition
  86572. * @param actionManager manager for the action the condition applies to
  86573. * @param target of the condition
  86574. * @param value to compare with target state
  86575. */
  86576. constructor(actionManager: ActionManager, target: any,
  86577. /** Value to compare with target state */
  86578. value: string);
  86579. /**
  86580. * Gets a boolean indicating if the current condition is met
  86581. * @returns the validity of the state
  86582. */
  86583. isValid(): boolean;
  86584. /**
  86585. * Serialize the StateCondition into a JSON compatible object
  86586. * @returns serialization object
  86587. */
  86588. serialize(): any;
  86589. }
  86590. }
  86591. declare module BABYLON {
  86592. /**
  86593. * This defines an action responsible to toggle a boolean once triggered.
  86594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86595. */
  86596. export class SwitchBooleanAction extends Action {
  86597. /**
  86598. * The path to the boolean property in the target object
  86599. */
  86600. propertyPath: string;
  86601. private _target;
  86602. private _effectiveTarget;
  86603. private _property;
  86604. /**
  86605. * Instantiate the action
  86606. * @param triggerOptions defines the trigger options
  86607. * @param target defines the object containing the boolean
  86608. * @param propertyPath defines the path to the boolean property in the target object
  86609. * @param condition defines the trigger related conditions
  86610. */
  86611. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  86612. /** @hidden */
  86613. _prepare(): void;
  86614. /**
  86615. * Execute the action toggle the boolean value.
  86616. */
  86617. execute(): void;
  86618. /**
  86619. * Serializes the actions and its related information.
  86620. * @param parent defines the object to serialize in
  86621. * @returns the serialized object
  86622. */
  86623. serialize(parent: any): any;
  86624. }
  86625. /**
  86626. * This defines an action responsible to set a the state field of the target
  86627. * to a desired value once triggered.
  86628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86629. */
  86630. export class SetStateAction extends Action {
  86631. /**
  86632. * The value to store in the state field.
  86633. */
  86634. value: string;
  86635. private _target;
  86636. /**
  86637. * Instantiate the action
  86638. * @param triggerOptions defines the trigger options
  86639. * @param target defines the object containing the state property
  86640. * @param value defines the value to store in the state field
  86641. * @param condition defines the trigger related conditions
  86642. */
  86643. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  86644. /**
  86645. * Execute the action and store the value on the target state property.
  86646. */
  86647. execute(): void;
  86648. /**
  86649. * Serializes the actions and its related information.
  86650. * @param parent defines the object to serialize in
  86651. * @returns the serialized object
  86652. */
  86653. serialize(parent: any): any;
  86654. }
  86655. /**
  86656. * This defines an action responsible to set a property of the target
  86657. * to a desired value once triggered.
  86658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86659. */
  86660. export class SetValueAction extends Action {
  86661. /**
  86662. * The path of the property to set in the target.
  86663. */
  86664. propertyPath: string;
  86665. /**
  86666. * The value to set in the property
  86667. */
  86668. value: any;
  86669. private _target;
  86670. private _effectiveTarget;
  86671. private _property;
  86672. /**
  86673. * Instantiate the action
  86674. * @param triggerOptions defines the trigger options
  86675. * @param target defines the object containing the property
  86676. * @param propertyPath defines the path of the property to set in the target
  86677. * @param value defines the value to set in the property
  86678. * @param condition defines the trigger related conditions
  86679. */
  86680. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86681. /** @hidden */
  86682. _prepare(): void;
  86683. /**
  86684. * Execute the action and set the targetted property to the desired value.
  86685. */
  86686. execute(): void;
  86687. /**
  86688. * Serializes the actions and its related information.
  86689. * @param parent defines the object to serialize in
  86690. * @returns the serialized object
  86691. */
  86692. serialize(parent: any): any;
  86693. }
  86694. /**
  86695. * This defines an action responsible to increment the target value
  86696. * to a desired value once triggered.
  86697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86698. */
  86699. export class IncrementValueAction extends Action {
  86700. /**
  86701. * The path of the property to increment in the target.
  86702. */
  86703. propertyPath: string;
  86704. /**
  86705. * The value we should increment the property by.
  86706. */
  86707. value: any;
  86708. private _target;
  86709. private _effectiveTarget;
  86710. private _property;
  86711. /**
  86712. * Instantiate the action
  86713. * @param triggerOptions defines the trigger options
  86714. * @param target defines the object containing the property
  86715. * @param propertyPath defines the path of the property to increment in the target
  86716. * @param value defines the value value we should increment the property by
  86717. * @param condition defines the trigger related conditions
  86718. */
  86719. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86720. /** @hidden */
  86721. _prepare(): void;
  86722. /**
  86723. * Execute the action and increment the target of the value amount.
  86724. */
  86725. execute(): void;
  86726. /**
  86727. * Serializes the actions and its related information.
  86728. * @param parent defines the object to serialize in
  86729. * @returns the serialized object
  86730. */
  86731. serialize(parent: any): any;
  86732. }
  86733. /**
  86734. * This defines an action responsible to start an animation once triggered.
  86735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86736. */
  86737. export class PlayAnimationAction extends Action {
  86738. /**
  86739. * Where the animation should start (animation frame)
  86740. */
  86741. from: number;
  86742. /**
  86743. * Where the animation should stop (animation frame)
  86744. */
  86745. to: number;
  86746. /**
  86747. * Define if the animation should loop or stop after the first play.
  86748. */
  86749. loop?: boolean;
  86750. private _target;
  86751. /**
  86752. * Instantiate the action
  86753. * @param triggerOptions defines the trigger options
  86754. * @param target defines the target animation or animation name
  86755. * @param from defines from where the animation should start (animation frame)
  86756. * @param end defines where the animation should stop (animation frame)
  86757. * @param loop defines if the animation should loop or stop after the first play
  86758. * @param condition defines the trigger related conditions
  86759. */
  86760. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  86761. /** @hidden */
  86762. _prepare(): void;
  86763. /**
  86764. * Execute the action and play the animation.
  86765. */
  86766. execute(): void;
  86767. /**
  86768. * Serializes the actions and its related information.
  86769. * @param parent defines the object to serialize in
  86770. * @returns the serialized object
  86771. */
  86772. serialize(parent: any): any;
  86773. }
  86774. /**
  86775. * This defines an action responsible to stop an animation once triggered.
  86776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86777. */
  86778. export class StopAnimationAction extends Action {
  86779. private _target;
  86780. /**
  86781. * Instantiate the action
  86782. * @param triggerOptions defines the trigger options
  86783. * @param target defines the target animation or animation name
  86784. * @param condition defines the trigger related conditions
  86785. */
  86786. constructor(triggerOptions: any, target: any, condition?: Condition);
  86787. /** @hidden */
  86788. _prepare(): void;
  86789. /**
  86790. * Execute the action and stop the animation.
  86791. */
  86792. execute(): void;
  86793. /**
  86794. * Serializes the actions and its related information.
  86795. * @param parent defines the object to serialize in
  86796. * @returns the serialized object
  86797. */
  86798. serialize(parent: any): any;
  86799. }
  86800. /**
  86801. * This defines an action responsible that does nothing once triggered.
  86802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86803. */
  86804. export class DoNothingAction extends Action {
  86805. /**
  86806. * Instantiate the action
  86807. * @param triggerOptions defines the trigger options
  86808. * @param condition defines the trigger related conditions
  86809. */
  86810. constructor(triggerOptions?: any, condition?: Condition);
  86811. /**
  86812. * Execute the action and do nothing.
  86813. */
  86814. execute(): void;
  86815. /**
  86816. * Serializes the actions and its related information.
  86817. * @param parent defines the object to serialize in
  86818. * @returns the serialized object
  86819. */
  86820. serialize(parent: any): any;
  86821. }
  86822. /**
  86823. * This defines an action responsible to trigger several actions once triggered.
  86824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86825. */
  86826. export class CombineAction extends Action {
  86827. /**
  86828. * The list of aggregated animations to run.
  86829. */
  86830. children: Action[];
  86831. /**
  86832. * Instantiate the action
  86833. * @param triggerOptions defines the trigger options
  86834. * @param children defines the list of aggregated animations to run
  86835. * @param condition defines the trigger related conditions
  86836. */
  86837. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  86838. /** @hidden */
  86839. _prepare(): void;
  86840. /**
  86841. * Execute the action and executes all the aggregated actions.
  86842. */
  86843. execute(evt: ActionEvent): void;
  86844. /**
  86845. * Serializes the actions and its related information.
  86846. * @param parent defines the object to serialize in
  86847. * @returns the serialized object
  86848. */
  86849. serialize(parent: any): any;
  86850. }
  86851. /**
  86852. * This defines an action responsible to run code (external event) once triggered.
  86853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86854. */
  86855. export class ExecuteCodeAction extends Action {
  86856. /**
  86857. * The callback function to run.
  86858. */
  86859. func: (evt: ActionEvent) => void;
  86860. /**
  86861. * Instantiate the action
  86862. * @param triggerOptions defines the trigger options
  86863. * @param func defines the callback function to run
  86864. * @param condition defines the trigger related conditions
  86865. */
  86866. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  86867. /**
  86868. * Execute the action and run the attached code.
  86869. */
  86870. execute(evt: ActionEvent): void;
  86871. }
  86872. /**
  86873. * This defines an action responsible to set the parent property of the target once triggered.
  86874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86875. */
  86876. export class SetParentAction extends Action {
  86877. private _parent;
  86878. private _target;
  86879. /**
  86880. * Instantiate the action
  86881. * @param triggerOptions defines the trigger options
  86882. * @param target defines the target containing the parent property
  86883. * @param parent defines from where the animation should start (animation frame)
  86884. * @param condition defines the trigger related conditions
  86885. */
  86886. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  86887. /** @hidden */
  86888. _prepare(): void;
  86889. /**
  86890. * Execute the action and set the parent property.
  86891. */
  86892. execute(): void;
  86893. /**
  86894. * Serializes the actions and its related information.
  86895. * @param parent defines the object to serialize in
  86896. * @returns the serialized object
  86897. */
  86898. serialize(parent: any): any;
  86899. }
  86900. }
  86901. declare module BABYLON {
  86902. /**
  86903. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  86904. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  86905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86906. */
  86907. export class ActionManager extends AbstractActionManager {
  86908. /**
  86909. * Nothing
  86910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86911. */
  86912. static readonly NothingTrigger: number;
  86913. /**
  86914. * On pick
  86915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86916. */
  86917. static readonly OnPickTrigger: number;
  86918. /**
  86919. * On left pick
  86920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86921. */
  86922. static readonly OnLeftPickTrigger: number;
  86923. /**
  86924. * On right pick
  86925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86926. */
  86927. static readonly OnRightPickTrigger: number;
  86928. /**
  86929. * On center pick
  86930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86931. */
  86932. static readonly OnCenterPickTrigger: number;
  86933. /**
  86934. * On pick down
  86935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86936. */
  86937. static readonly OnPickDownTrigger: number;
  86938. /**
  86939. * On double pick
  86940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86941. */
  86942. static readonly OnDoublePickTrigger: number;
  86943. /**
  86944. * On pick up
  86945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86946. */
  86947. static readonly OnPickUpTrigger: number;
  86948. /**
  86949. * On pick out.
  86950. * This trigger will only be raised if you also declared a OnPickDown
  86951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86952. */
  86953. static readonly OnPickOutTrigger: number;
  86954. /**
  86955. * On long press
  86956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86957. */
  86958. static readonly OnLongPressTrigger: number;
  86959. /**
  86960. * On pointer over
  86961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86962. */
  86963. static readonly OnPointerOverTrigger: number;
  86964. /**
  86965. * On pointer out
  86966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86967. */
  86968. static readonly OnPointerOutTrigger: number;
  86969. /**
  86970. * On every frame
  86971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86972. */
  86973. static readonly OnEveryFrameTrigger: number;
  86974. /**
  86975. * On intersection enter
  86976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86977. */
  86978. static readonly OnIntersectionEnterTrigger: number;
  86979. /**
  86980. * On intersection exit
  86981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86982. */
  86983. static readonly OnIntersectionExitTrigger: number;
  86984. /**
  86985. * On key down
  86986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86987. */
  86988. static readonly OnKeyDownTrigger: number;
  86989. /**
  86990. * On key up
  86991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86992. */
  86993. static readonly OnKeyUpTrigger: number;
  86994. private _scene;
  86995. /**
  86996. * Creates a new action manager
  86997. * @param scene defines the hosting scene
  86998. */
  86999. constructor(scene: Scene);
  87000. /**
  87001. * Releases all associated resources
  87002. */
  87003. dispose(): void;
  87004. /**
  87005. * Gets hosting scene
  87006. * @returns the hosting scene
  87007. */
  87008. getScene(): Scene;
  87009. /**
  87010. * Does this action manager handles actions of any of the given triggers
  87011. * @param triggers defines the triggers to be tested
  87012. * @return a boolean indicating whether one (or more) of the triggers is handled
  87013. */
  87014. hasSpecificTriggers(triggers: number[]): boolean;
  87015. /**
  87016. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87017. * speed.
  87018. * @param triggerA defines the trigger to be tested
  87019. * @param triggerB defines the trigger to be tested
  87020. * @return a boolean indicating whether one (or more) of the triggers is handled
  87021. */
  87022. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87023. /**
  87024. * Does this action manager handles actions of a given trigger
  87025. * @param trigger defines the trigger to be tested
  87026. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87027. * @return whether the trigger is handled
  87028. */
  87029. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87030. /**
  87031. * Does this action manager has pointer triggers
  87032. */
  87033. get hasPointerTriggers(): boolean;
  87034. /**
  87035. * Does this action manager has pick triggers
  87036. */
  87037. get hasPickTriggers(): boolean;
  87038. /**
  87039. * Registers an action to this action manager
  87040. * @param action defines the action to be registered
  87041. * @return the action amended (prepared) after registration
  87042. */
  87043. registerAction(action: IAction): Nullable<IAction>;
  87044. /**
  87045. * Unregisters an action to this action manager
  87046. * @param action defines the action to be unregistered
  87047. * @return a boolean indicating whether the action has been unregistered
  87048. */
  87049. unregisterAction(action: IAction): Boolean;
  87050. /**
  87051. * Process a specific trigger
  87052. * @param trigger defines the trigger to process
  87053. * @param evt defines the event details to be processed
  87054. */
  87055. processTrigger(trigger: number, evt?: IActionEvent): void;
  87056. /** @hidden */
  87057. _getEffectiveTarget(target: any, propertyPath: string): any;
  87058. /** @hidden */
  87059. _getProperty(propertyPath: string): string;
  87060. /**
  87061. * Serialize this manager to a JSON object
  87062. * @param name defines the property name to store this manager
  87063. * @returns a JSON representation of this manager
  87064. */
  87065. serialize(name: string): any;
  87066. /**
  87067. * Creates a new ActionManager from a JSON data
  87068. * @param parsedActions defines the JSON data to read from
  87069. * @param object defines the hosting mesh
  87070. * @param scene defines the hosting scene
  87071. */
  87072. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87073. /**
  87074. * Get a trigger name by index
  87075. * @param trigger defines the trigger index
  87076. * @returns a trigger name
  87077. */
  87078. static GetTriggerName(trigger: number): string;
  87079. }
  87080. }
  87081. declare module BABYLON {
  87082. /**
  87083. * Class used to represent a sprite
  87084. * @see http://doc.babylonjs.com/babylon101/sprites
  87085. */
  87086. export class Sprite implements IAnimatable {
  87087. /** defines the name */
  87088. name: string;
  87089. /** Gets or sets the current world position */
  87090. position: Vector3;
  87091. /** Gets or sets the main color */
  87092. color: Color4;
  87093. /** Gets or sets the width */
  87094. width: number;
  87095. /** Gets or sets the height */
  87096. height: number;
  87097. /** Gets or sets rotation angle */
  87098. angle: number;
  87099. /** Gets or sets the cell index in the sprite sheet */
  87100. cellIndex: number;
  87101. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87102. cellRef: string;
  87103. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87104. invertU: boolean;
  87105. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87106. invertV: boolean;
  87107. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87108. disposeWhenFinishedAnimating: boolean;
  87109. /** Gets the list of attached animations */
  87110. animations: Nullable<Array<Animation>>;
  87111. /** Gets or sets a boolean indicating if the sprite can be picked */
  87112. isPickable: boolean;
  87113. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87114. useAlphaForPicking: boolean;
  87115. /** @hidden */
  87116. _xOffset: number;
  87117. /** @hidden */
  87118. _yOffset: number;
  87119. /** @hidden */
  87120. _xSize: number;
  87121. /** @hidden */
  87122. _ySize: number;
  87123. /**
  87124. * Gets or sets the associated action manager
  87125. */
  87126. actionManager: Nullable<ActionManager>;
  87127. /**
  87128. * An event triggered when the control has been disposed
  87129. */
  87130. onDisposeObservable: Observable<Sprite>;
  87131. private _animationStarted;
  87132. private _loopAnimation;
  87133. private _fromIndex;
  87134. private _toIndex;
  87135. private _delay;
  87136. private _direction;
  87137. private _manager;
  87138. private _time;
  87139. private _onAnimationEnd;
  87140. /**
  87141. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87142. */
  87143. isVisible: boolean;
  87144. /**
  87145. * Gets or sets the sprite size
  87146. */
  87147. get size(): number;
  87148. set size(value: number);
  87149. /**
  87150. * Returns a boolean indicating if the animation is started
  87151. */
  87152. get animationStarted(): boolean;
  87153. /**
  87154. * Gets or sets the unique id of the sprite
  87155. */
  87156. uniqueId: number;
  87157. /**
  87158. * Gets the manager of this sprite
  87159. */
  87160. get manager(): ISpriteManager;
  87161. /**
  87162. * Creates a new Sprite
  87163. * @param name defines the name
  87164. * @param manager defines the manager
  87165. */
  87166. constructor(
  87167. /** defines the name */
  87168. name: string, manager: ISpriteManager);
  87169. /**
  87170. * Returns the string "Sprite"
  87171. * @returns "Sprite"
  87172. */
  87173. getClassName(): string;
  87174. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87175. get fromIndex(): number;
  87176. set fromIndex(value: number);
  87177. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87178. get toIndex(): number;
  87179. set toIndex(value: number);
  87180. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87181. get loopAnimation(): boolean;
  87182. set loopAnimation(value: boolean);
  87183. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87184. get delay(): number;
  87185. set delay(value: number);
  87186. /**
  87187. * Starts an animation
  87188. * @param from defines the initial key
  87189. * @param to defines the end key
  87190. * @param loop defines if the animation must loop
  87191. * @param delay defines the start delay (in ms)
  87192. * @param onAnimationEnd defines a callback to call when animation ends
  87193. */
  87194. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  87195. /** Stops current animation (if any) */
  87196. stopAnimation(): void;
  87197. /** @hidden */
  87198. _animate(deltaTime: number): void;
  87199. /** Release associated resources */
  87200. dispose(): void;
  87201. }
  87202. }
  87203. declare module BABYLON {
  87204. /**
  87205. * Information about the result of picking within a scene
  87206. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87207. */
  87208. export class PickingInfo {
  87209. /** @hidden */
  87210. _pickingUnavailable: boolean;
  87211. /**
  87212. * If the pick collided with an object
  87213. */
  87214. hit: boolean;
  87215. /**
  87216. * Distance away where the pick collided
  87217. */
  87218. distance: number;
  87219. /**
  87220. * The location of pick collision
  87221. */
  87222. pickedPoint: Nullable<Vector3>;
  87223. /**
  87224. * The mesh corresponding the the pick collision
  87225. */
  87226. pickedMesh: Nullable<AbstractMesh>;
  87227. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87228. bu: number;
  87229. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87230. bv: number;
  87231. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87232. faceId: number;
  87233. /** Id of the the submesh that was picked */
  87234. subMeshId: number;
  87235. /** If a sprite was picked, this will be the sprite the pick collided with */
  87236. pickedSprite: Nullable<Sprite>;
  87237. /**
  87238. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87239. */
  87240. originMesh: Nullable<AbstractMesh>;
  87241. /**
  87242. * The ray that was used to perform the picking.
  87243. */
  87244. ray: Nullable<Ray>;
  87245. /**
  87246. * Gets the normal correspodning to the face the pick collided with
  87247. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87248. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87249. * @returns The normal correspodning to the face the pick collided with
  87250. */
  87251. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87252. /**
  87253. * Gets the texture coordinates of where the pick occured
  87254. * @returns the vector containing the coordnates of the texture
  87255. */
  87256. getTextureCoordinates(): Nullable<Vector2>;
  87257. }
  87258. }
  87259. declare module BABYLON {
  87260. /**
  87261. * Class representing a ray with position and direction
  87262. */
  87263. export class Ray {
  87264. /** origin point */
  87265. origin: Vector3;
  87266. /** direction */
  87267. direction: Vector3;
  87268. /** length of the ray */
  87269. length: number;
  87270. private static readonly TmpVector3;
  87271. private _tmpRay;
  87272. /**
  87273. * Creates a new ray
  87274. * @param origin origin point
  87275. * @param direction direction
  87276. * @param length length of the ray
  87277. */
  87278. constructor(
  87279. /** origin point */
  87280. origin: Vector3,
  87281. /** direction */
  87282. direction: Vector3,
  87283. /** length of the ray */
  87284. length?: number);
  87285. /**
  87286. * Checks if the ray intersects a box
  87287. * This does not account for the ray lenght by design to improve perfs.
  87288. * @param minimum bound of the box
  87289. * @param maximum bound of the box
  87290. * @param intersectionTreshold extra extend to be added to the box in all direction
  87291. * @returns if the box was hit
  87292. */
  87293. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87294. /**
  87295. * Checks if the ray intersects a box
  87296. * This does not account for the ray lenght by design to improve perfs.
  87297. * @param box the bounding box to check
  87298. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87299. * @returns if the box was hit
  87300. */
  87301. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87302. /**
  87303. * If the ray hits a sphere
  87304. * @param sphere the bounding sphere to check
  87305. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87306. * @returns true if it hits the sphere
  87307. */
  87308. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87309. /**
  87310. * If the ray hits a triange
  87311. * @param vertex0 triangle vertex
  87312. * @param vertex1 triangle vertex
  87313. * @param vertex2 triangle vertex
  87314. * @returns intersection information if hit
  87315. */
  87316. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87317. /**
  87318. * Checks if ray intersects a plane
  87319. * @param plane the plane to check
  87320. * @returns the distance away it was hit
  87321. */
  87322. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87323. /**
  87324. * Calculate the intercept of a ray on a given axis
  87325. * @param axis to check 'x' | 'y' | 'z'
  87326. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87327. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87328. */
  87329. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87330. /**
  87331. * Checks if ray intersects a mesh
  87332. * @param mesh the mesh to check
  87333. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87334. * @returns picking info of the intersecton
  87335. */
  87336. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87337. /**
  87338. * Checks if ray intersects a mesh
  87339. * @param meshes the meshes to check
  87340. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87341. * @param results array to store result in
  87342. * @returns Array of picking infos
  87343. */
  87344. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87345. private _comparePickingInfo;
  87346. private static smallnum;
  87347. private static rayl;
  87348. /**
  87349. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87350. * @param sega the first point of the segment to test the intersection against
  87351. * @param segb the second point of the segment to test the intersection against
  87352. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87353. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87354. */
  87355. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87356. /**
  87357. * Update the ray from viewport position
  87358. * @param x position
  87359. * @param y y position
  87360. * @param viewportWidth viewport width
  87361. * @param viewportHeight viewport height
  87362. * @param world world matrix
  87363. * @param view view matrix
  87364. * @param projection projection matrix
  87365. * @returns this ray updated
  87366. */
  87367. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87368. /**
  87369. * Creates a ray with origin and direction of 0,0,0
  87370. * @returns the new ray
  87371. */
  87372. static Zero(): Ray;
  87373. /**
  87374. * Creates a new ray from screen space and viewport
  87375. * @param x position
  87376. * @param y y position
  87377. * @param viewportWidth viewport width
  87378. * @param viewportHeight viewport height
  87379. * @param world world matrix
  87380. * @param view view matrix
  87381. * @param projection projection matrix
  87382. * @returns new ray
  87383. */
  87384. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87385. /**
  87386. * 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
  87387. * transformed to the given world matrix.
  87388. * @param origin The origin point
  87389. * @param end The end point
  87390. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87391. * @returns the new ray
  87392. */
  87393. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  87394. /**
  87395. * Transforms a ray by a matrix
  87396. * @param ray ray to transform
  87397. * @param matrix matrix to apply
  87398. * @returns the resulting new ray
  87399. */
  87400. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  87401. /**
  87402. * Transforms a ray by a matrix
  87403. * @param ray ray to transform
  87404. * @param matrix matrix to apply
  87405. * @param result ray to store result in
  87406. */
  87407. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  87408. /**
  87409. * Unproject a ray from screen space to object space
  87410. * @param sourceX defines the screen space x coordinate to use
  87411. * @param sourceY defines the screen space y coordinate to use
  87412. * @param viewportWidth defines the current width of the viewport
  87413. * @param viewportHeight defines the current height of the viewport
  87414. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  87415. * @param view defines the view matrix to use
  87416. * @param projection defines the projection matrix to use
  87417. */
  87418. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  87419. }
  87420. /**
  87421. * Type used to define predicate used to select faces when a mesh intersection is detected
  87422. */
  87423. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  87424. interface Scene {
  87425. /** @hidden */
  87426. _tempPickingRay: Nullable<Ray>;
  87427. /** @hidden */
  87428. _cachedRayForTransform: Ray;
  87429. /** @hidden */
  87430. _pickWithRayInverseMatrix: Matrix;
  87431. /** @hidden */
  87432. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  87433. /** @hidden */
  87434. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  87435. }
  87436. }
  87437. declare module BABYLON {
  87438. /**
  87439. * Groups all the scene component constants in one place to ease maintenance.
  87440. * @hidden
  87441. */
  87442. export class SceneComponentConstants {
  87443. static readonly NAME_EFFECTLAYER: string;
  87444. static readonly NAME_LAYER: string;
  87445. static readonly NAME_LENSFLARESYSTEM: string;
  87446. static readonly NAME_BOUNDINGBOXRENDERER: string;
  87447. static readonly NAME_PARTICLESYSTEM: string;
  87448. static readonly NAME_GAMEPAD: string;
  87449. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  87450. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  87451. static readonly NAME_DEPTHRENDERER: string;
  87452. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  87453. static readonly NAME_SPRITE: string;
  87454. static readonly NAME_OUTLINERENDERER: string;
  87455. static readonly NAME_PROCEDURALTEXTURE: string;
  87456. static readonly NAME_SHADOWGENERATOR: string;
  87457. static readonly NAME_OCTREE: string;
  87458. static readonly NAME_PHYSICSENGINE: string;
  87459. static readonly NAME_AUDIO: string;
  87460. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  87461. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87462. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  87463. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87464. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  87465. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  87466. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  87467. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  87468. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  87469. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  87470. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  87471. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  87472. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  87473. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  87474. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  87475. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  87476. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  87477. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  87478. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  87479. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  87480. static readonly STEP_AFTERRENDER_AUDIO: number;
  87481. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  87482. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  87483. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  87484. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  87485. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  87486. static readonly STEP_POINTERMOVE_SPRITE: number;
  87487. static readonly STEP_POINTERDOWN_SPRITE: number;
  87488. static readonly STEP_POINTERUP_SPRITE: number;
  87489. }
  87490. /**
  87491. * This represents a scene component.
  87492. *
  87493. * This is used to decouple the dependency the scene is having on the different workloads like
  87494. * layers, post processes...
  87495. */
  87496. export interface ISceneComponent {
  87497. /**
  87498. * The name of the component. Each component must have a unique name.
  87499. */
  87500. name: string;
  87501. /**
  87502. * The scene the component belongs to.
  87503. */
  87504. scene: Scene;
  87505. /**
  87506. * Register the component to one instance of a scene.
  87507. */
  87508. register(): void;
  87509. /**
  87510. * Rebuilds the elements related to this component in case of
  87511. * context lost for instance.
  87512. */
  87513. rebuild(): void;
  87514. /**
  87515. * Disposes the component and the associated ressources.
  87516. */
  87517. dispose(): void;
  87518. }
  87519. /**
  87520. * This represents a SERIALIZABLE scene component.
  87521. *
  87522. * This extends Scene Component to add Serialization methods on top.
  87523. */
  87524. export interface ISceneSerializableComponent extends ISceneComponent {
  87525. /**
  87526. * Adds all the elements from the container to the scene
  87527. * @param container the container holding the elements
  87528. */
  87529. addFromContainer(container: AbstractScene): void;
  87530. /**
  87531. * Removes all the elements in the container from the scene
  87532. * @param container contains the elements to remove
  87533. * @param dispose if the removed element should be disposed (default: false)
  87534. */
  87535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  87536. /**
  87537. * Serializes the component data to the specified json object
  87538. * @param serializationObject The object to serialize to
  87539. */
  87540. serialize(serializationObject: any): void;
  87541. }
  87542. /**
  87543. * Strong typing of a Mesh related stage step action
  87544. */
  87545. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  87546. /**
  87547. * Strong typing of a Evaluate Sub Mesh related stage step action
  87548. */
  87549. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  87550. /**
  87551. * Strong typing of a Active Mesh related stage step action
  87552. */
  87553. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  87554. /**
  87555. * Strong typing of a Camera related stage step action
  87556. */
  87557. export type CameraStageAction = (camera: Camera) => void;
  87558. /**
  87559. * Strong typing of a Camera Frame buffer related stage step action
  87560. */
  87561. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  87562. /**
  87563. * Strong typing of a Render Target related stage step action
  87564. */
  87565. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  87566. /**
  87567. * Strong typing of a RenderingGroup related stage step action
  87568. */
  87569. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  87570. /**
  87571. * Strong typing of a Mesh Render related stage step action
  87572. */
  87573. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  87574. /**
  87575. * Strong typing of a simple stage step action
  87576. */
  87577. export type SimpleStageAction = () => void;
  87578. /**
  87579. * Strong typing of a render target action.
  87580. */
  87581. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  87582. /**
  87583. * Strong typing of a pointer move action.
  87584. */
  87585. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  87586. /**
  87587. * Strong typing of a pointer up/down action.
  87588. */
  87589. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  87590. /**
  87591. * Representation of a stage in the scene (Basically a list of ordered steps)
  87592. * @hidden
  87593. */
  87594. export class Stage<T extends Function> extends Array<{
  87595. index: number;
  87596. component: ISceneComponent;
  87597. action: T;
  87598. }> {
  87599. /**
  87600. * Hide ctor from the rest of the world.
  87601. * @param items The items to add.
  87602. */
  87603. private constructor();
  87604. /**
  87605. * Creates a new Stage.
  87606. * @returns A new instance of a Stage
  87607. */
  87608. static Create<T extends Function>(): Stage<T>;
  87609. /**
  87610. * Registers a step in an ordered way in the targeted stage.
  87611. * @param index Defines the position to register the step in
  87612. * @param component Defines the component attached to the step
  87613. * @param action Defines the action to launch during the step
  87614. */
  87615. registerStep(index: number, component: ISceneComponent, action: T): void;
  87616. /**
  87617. * Clears all the steps from the stage.
  87618. */
  87619. clear(): void;
  87620. }
  87621. }
  87622. declare module BABYLON {
  87623. interface Scene {
  87624. /** @hidden */
  87625. _pointerOverSprite: Nullable<Sprite>;
  87626. /** @hidden */
  87627. _pickedDownSprite: Nullable<Sprite>;
  87628. /** @hidden */
  87629. _tempSpritePickingRay: Nullable<Ray>;
  87630. /**
  87631. * All of the sprite managers added to this scene
  87632. * @see http://doc.babylonjs.com/babylon101/sprites
  87633. */
  87634. spriteManagers: Array<ISpriteManager>;
  87635. /**
  87636. * An event triggered when sprites rendering is about to start
  87637. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87638. */
  87639. onBeforeSpritesRenderingObservable: Observable<Scene>;
  87640. /**
  87641. * An event triggered when sprites rendering is done
  87642. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87643. */
  87644. onAfterSpritesRenderingObservable: Observable<Scene>;
  87645. /** @hidden */
  87646. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87647. /** Launch a ray to try to pick a sprite in the scene
  87648. * @param x position on screen
  87649. * @param y position on screen
  87650. * @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
  87651. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87652. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87653. * @returns a PickingInfo
  87654. */
  87655. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87656. /** Use the given ray to pick a sprite in the scene
  87657. * @param ray The ray (in world space) to use to pick meshes
  87658. * @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
  87659. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87660. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87661. * @returns a PickingInfo
  87662. */
  87663. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87664. /** @hidden */
  87665. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87666. /** Launch a ray to try to pick sprites in the scene
  87667. * @param x position on screen
  87668. * @param y position on screen
  87669. * @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
  87670. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87671. * @returns a PickingInfo array
  87672. */
  87673. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87674. /** Use the given ray to pick sprites in the scene
  87675. * @param ray The ray (in world space) to use to pick meshes
  87676. * @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
  87677. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87678. * @returns a PickingInfo array
  87679. */
  87680. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87681. /**
  87682. * Force the sprite under the pointer
  87683. * @param sprite defines the sprite to use
  87684. */
  87685. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  87686. /**
  87687. * Gets the sprite under the pointer
  87688. * @returns a Sprite or null if no sprite is under the pointer
  87689. */
  87690. getPointerOverSprite(): Nullable<Sprite>;
  87691. }
  87692. /**
  87693. * Defines the sprite scene component responsible to manage sprites
  87694. * in a given scene.
  87695. */
  87696. export class SpriteSceneComponent implements ISceneComponent {
  87697. /**
  87698. * The component name helpfull to identify the component in the list of scene components.
  87699. */
  87700. readonly name: string;
  87701. /**
  87702. * The scene the component belongs to.
  87703. */
  87704. scene: Scene;
  87705. /** @hidden */
  87706. private _spritePredicate;
  87707. /**
  87708. * Creates a new instance of the component for the given scene
  87709. * @param scene Defines the scene to register the component in
  87710. */
  87711. constructor(scene: Scene);
  87712. /**
  87713. * Registers the component in a given scene
  87714. */
  87715. register(): void;
  87716. /**
  87717. * Rebuilds the elements related to this component in case of
  87718. * context lost for instance.
  87719. */
  87720. rebuild(): void;
  87721. /**
  87722. * Disposes the component and the associated ressources.
  87723. */
  87724. dispose(): void;
  87725. private _pickSpriteButKeepRay;
  87726. private _pointerMove;
  87727. private _pointerDown;
  87728. private _pointerUp;
  87729. }
  87730. }
  87731. declare module BABYLON {
  87732. /** @hidden */
  87733. export var fogFragmentDeclaration: {
  87734. name: string;
  87735. shader: string;
  87736. };
  87737. }
  87738. declare module BABYLON {
  87739. /** @hidden */
  87740. export var fogFragment: {
  87741. name: string;
  87742. shader: string;
  87743. };
  87744. }
  87745. declare module BABYLON {
  87746. /** @hidden */
  87747. export var spritesPixelShader: {
  87748. name: string;
  87749. shader: string;
  87750. };
  87751. }
  87752. declare module BABYLON {
  87753. /** @hidden */
  87754. export var fogVertexDeclaration: {
  87755. name: string;
  87756. shader: string;
  87757. };
  87758. }
  87759. declare module BABYLON {
  87760. /** @hidden */
  87761. export var spritesVertexShader: {
  87762. name: string;
  87763. shader: string;
  87764. };
  87765. }
  87766. declare module BABYLON {
  87767. /**
  87768. * Defines the minimum interface to fullfil in order to be a sprite manager.
  87769. */
  87770. export interface ISpriteManager extends IDisposable {
  87771. /**
  87772. * Gets manager's name
  87773. */
  87774. name: string;
  87775. /**
  87776. * Restricts the camera to viewing objects with the same layerMask.
  87777. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  87778. */
  87779. layerMask: number;
  87780. /**
  87781. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87782. */
  87783. isPickable: boolean;
  87784. /**
  87785. * Gets the hosting scene
  87786. */
  87787. scene: Scene;
  87788. /**
  87789. * Specifies the rendering group id for this mesh (0 by default)
  87790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87791. */
  87792. renderingGroupId: number;
  87793. /**
  87794. * Defines the list of sprites managed by the manager.
  87795. */
  87796. sprites: Array<Sprite>;
  87797. /**
  87798. * Gets or sets the spritesheet texture
  87799. */
  87800. texture: Texture;
  87801. /** Defines the default width of a cell in the spritesheet */
  87802. cellWidth: number;
  87803. /** Defines the default height of a cell in the spritesheet */
  87804. cellHeight: number;
  87805. /**
  87806. * Tests the intersection of a sprite with a specific ray.
  87807. * @param ray The ray we are sending to test the collision
  87808. * @param camera The camera space we are sending rays in
  87809. * @param predicate A predicate allowing excluding sprites from the list of object to test
  87810. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87811. * @returns picking info or null.
  87812. */
  87813. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  87814. /**
  87815. * Intersects the sprites with a ray
  87816. * @param ray defines the ray to intersect with
  87817. * @param camera defines the current active camera
  87818. * @param predicate defines a predicate used to select candidate sprites
  87819. * @returns null if no hit or a PickingInfo array
  87820. */
  87821. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  87822. /**
  87823. * Renders the list of sprites on screen.
  87824. */
  87825. render(): void;
  87826. }
  87827. /**
  87828. * Class used to manage multiple sprites on the same spritesheet
  87829. * @see http://doc.babylonjs.com/babylon101/sprites
  87830. */
  87831. export class SpriteManager implements ISpriteManager {
  87832. /** defines the manager's name */
  87833. name: string;
  87834. /** Gets the list of sprites */
  87835. sprites: Sprite[];
  87836. /** Gets or sets the rendering group id (0 by default) */
  87837. renderingGroupId: number;
  87838. /** Gets or sets camera layer mask */
  87839. layerMask: number;
  87840. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  87841. fogEnabled: boolean;
  87842. /** Gets or sets a boolean indicating if the sprites are pickable */
  87843. isPickable: boolean;
  87844. /** Defines the default width of a cell in the spritesheet */
  87845. cellWidth: number;
  87846. /** Defines the default height of a cell in the spritesheet */
  87847. cellHeight: number;
  87848. /** Associative array from JSON sprite data file */
  87849. private _cellData;
  87850. /** Array of sprite names from JSON sprite data file */
  87851. private _spriteMap;
  87852. /** True when packed cell data from JSON file is ready*/
  87853. private _packedAndReady;
  87854. private _textureContent;
  87855. /**
  87856. * An event triggered when the manager is disposed.
  87857. */
  87858. onDisposeObservable: Observable<SpriteManager>;
  87859. private _onDisposeObserver;
  87860. /**
  87861. * Callback called when the manager is disposed
  87862. */
  87863. set onDispose(callback: () => void);
  87864. private _capacity;
  87865. private _fromPacked;
  87866. private _spriteTexture;
  87867. private _epsilon;
  87868. private _scene;
  87869. private _vertexData;
  87870. private _buffer;
  87871. private _vertexBuffers;
  87872. private _indexBuffer;
  87873. private _effectBase;
  87874. private _effectFog;
  87875. /**
  87876. * Gets or sets the unique id of the sprite
  87877. */
  87878. uniqueId: number;
  87879. /**
  87880. * Gets the array of sprites
  87881. */
  87882. get children(): Sprite[];
  87883. /**
  87884. * Gets the hosting scene
  87885. */
  87886. get scene(): Scene;
  87887. /**
  87888. * Gets the capacity of the manager
  87889. */
  87890. get capacity(): number;
  87891. /**
  87892. * Gets or sets the spritesheet texture
  87893. */
  87894. get texture(): Texture;
  87895. set texture(value: Texture);
  87896. private _blendMode;
  87897. /**
  87898. * Blend mode use to render the particle, it can be any of
  87899. * the static Constants.ALPHA_x properties provided in this class.
  87900. * Default value is Constants.ALPHA_COMBINE
  87901. */
  87902. get blendMode(): number;
  87903. set blendMode(blendMode: number);
  87904. /** Disables writing to the depth buffer when rendering the sprites.
  87905. * It can be handy to disable depth writing when using textures without alpha channel
  87906. * and setting some specific blend modes.
  87907. */
  87908. disableDepthWrite: boolean;
  87909. /**
  87910. * Creates a new sprite manager
  87911. * @param name defines the manager's name
  87912. * @param imgUrl defines the sprite sheet url
  87913. * @param capacity defines the maximum allowed number of sprites
  87914. * @param cellSize defines the size of a sprite cell
  87915. * @param scene defines the hosting scene
  87916. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  87917. * @param samplingMode defines the smapling mode to use with spritesheet
  87918. * @param fromPacked set to false; do not alter
  87919. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  87920. */
  87921. constructor(
  87922. /** defines the manager's name */
  87923. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  87924. /**
  87925. * Returns the string "SpriteManager"
  87926. * @returns "SpriteManager"
  87927. */
  87928. getClassName(): string;
  87929. private _makePacked;
  87930. private _appendSpriteVertex;
  87931. private _checkTextureAlpha;
  87932. /**
  87933. * Intersects the sprites with a ray
  87934. * @param ray defines the ray to intersect with
  87935. * @param camera defines the current active camera
  87936. * @param predicate defines a predicate used to select candidate sprites
  87937. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  87938. * @returns null if no hit or a PickingInfo
  87939. */
  87940. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  87941. /**
  87942. * Intersects the sprites with a ray
  87943. * @param ray defines the ray to intersect with
  87944. * @param camera defines the current active camera
  87945. * @param predicate defines a predicate used to select candidate sprites
  87946. * @returns null if no hit or a PickingInfo array
  87947. */
  87948. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  87949. /**
  87950. * Render all child sprites
  87951. */
  87952. render(): void;
  87953. /**
  87954. * Release associated resources
  87955. */
  87956. dispose(): void;
  87957. }
  87958. }
  87959. declare module BABYLON {
  87960. /** Interface used by value gradients (color, factor, ...) */
  87961. export interface IValueGradient {
  87962. /**
  87963. * Gets or sets the gradient value (between 0 and 1)
  87964. */
  87965. gradient: number;
  87966. }
  87967. /** Class used to store color4 gradient */
  87968. export class ColorGradient implements IValueGradient {
  87969. /**
  87970. * Gets or sets the gradient value (between 0 and 1)
  87971. */
  87972. gradient: number;
  87973. /**
  87974. * Gets or sets first associated color
  87975. */
  87976. color1: Color4;
  87977. /**
  87978. * Gets or sets second associated color
  87979. */
  87980. color2?: Color4 | undefined;
  87981. /**
  87982. * Creates a new color4 gradient
  87983. * @param gradient gets or sets the gradient value (between 0 and 1)
  87984. * @param color1 gets or sets first associated color
  87985. * @param color2 gets or sets first second color
  87986. */
  87987. constructor(
  87988. /**
  87989. * Gets or sets the gradient value (between 0 and 1)
  87990. */
  87991. gradient: number,
  87992. /**
  87993. * Gets or sets first associated color
  87994. */
  87995. color1: Color4,
  87996. /**
  87997. * Gets or sets second associated color
  87998. */
  87999. color2?: Color4 | undefined);
  88000. /**
  88001. * Will get a color picked randomly between color1 and color2.
  88002. * If color2 is undefined then color1 will be used
  88003. * @param result defines the target Color4 to store the result in
  88004. */
  88005. getColorToRef(result: Color4): void;
  88006. }
  88007. /** Class used to store color 3 gradient */
  88008. export class Color3Gradient implements IValueGradient {
  88009. /**
  88010. * Gets or sets the gradient value (between 0 and 1)
  88011. */
  88012. gradient: number;
  88013. /**
  88014. * Gets or sets the associated color
  88015. */
  88016. color: Color3;
  88017. /**
  88018. * Creates a new color3 gradient
  88019. * @param gradient gets or sets the gradient value (between 0 and 1)
  88020. * @param color gets or sets associated color
  88021. */
  88022. constructor(
  88023. /**
  88024. * Gets or sets the gradient value (between 0 and 1)
  88025. */
  88026. gradient: number,
  88027. /**
  88028. * Gets or sets the associated color
  88029. */
  88030. color: Color3);
  88031. }
  88032. /** Class used to store factor gradient */
  88033. export class FactorGradient implements IValueGradient {
  88034. /**
  88035. * Gets or sets the gradient value (between 0 and 1)
  88036. */
  88037. gradient: number;
  88038. /**
  88039. * Gets or sets first associated factor
  88040. */
  88041. factor1: number;
  88042. /**
  88043. * Gets or sets second associated factor
  88044. */
  88045. factor2?: number | undefined;
  88046. /**
  88047. * Creates a new factor gradient
  88048. * @param gradient gets or sets the gradient value (between 0 and 1)
  88049. * @param factor1 gets or sets first associated factor
  88050. * @param factor2 gets or sets second associated factor
  88051. */
  88052. constructor(
  88053. /**
  88054. * Gets or sets the gradient value (between 0 and 1)
  88055. */
  88056. gradient: number,
  88057. /**
  88058. * Gets or sets first associated factor
  88059. */
  88060. factor1: number,
  88061. /**
  88062. * Gets or sets second associated factor
  88063. */
  88064. factor2?: number | undefined);
  88065. /**
  88066. * Will get a number picked randomly between factor1 and factor2.
  88067. * If factor2 is undefined then factor1 will be used
  88068. * @returns the picked number
  88069. */
  88070. getFactor(): number;
  88071. }
  88072. /**
  88073. * Helper used to simplify some generic gradient tasks
  88074. */
  88075. export class GradientHelper {
  88076. /**
  88077. * Gets the current gradient from an array of IValueGradient
  88078. * @param ratio defines the current ratio to get
  88079. * @param gradients defines the array of IValueGradient
  88080. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88081. */
  88082. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88083. }
  88084. }
  88085. declare module BABYLON {
  88086. interface ThinEngine {
  88087. /**
  88088. * Creates a dynamic texture
  88089. * @param width defines the width of the texture
  88090. * @param height defines the height of the texture
  88091. * @param generateMipMaps defines if the engine should generate the mip levels
  88092. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88093. * @returns the dynamic texture inside an InternalTexture
  88094. */
  88095. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88096. /**
  88097. * Update the content of a dynamic texture
  88098. * @param texture defines the texture to update
  88099. * @param canvas defines the canvas containing the source
  88100. * @param invertY defines if data must be stored with Y axis inverted
  88101. * @param premulAlpha defines if alpha is stored as premultiplied
  88102. * @param format defines the format of the data
  88103. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88104. */
  88105. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88106. }
  88107. }
  88108. declare module BABYLON {
  88109. /**
  88110. * Helper class used to generate a canvas to manipulate images
  88111. */
  88112. export class CanvasGenerator {
  88113. /**
  88114. * Create a new canvas (or offscreen canvas depending on the context)
  88115. * @param width defines the expected width
  88116. * @param height defines the expected height
  88117. * @return a new canvas or offscreen canvas
  88118. */
  88119. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88120. }
  88121. }
  88122. declare module BABYLON {
  88123. /**
  88124. * A class extending Texture allowing drawing on a texture
  88125. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88126. */
  88127. export class DynamicTexture extends Texture {
  88128. private _generateMipMaps;
  88129. private _canvas;
  88130. private _context;
  88131. /**
  88132. * Creates a DynamicTexture
  88133. * @param name defines the name of the texture
  88134. * @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
  88135. * @param scene defines the scene where you want the texture
  88136. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88137. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88138. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88139. */
  88140. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88141. /**
  88142. * Get the current class name of the texture useful for serialization or dynamic coding.
  88143. * @returns "DynamicTexture"
  88144. */
  88145. getClassName(): string;
  88146. /**
  88147. * Gets the current state of canRescale
  88148. */
  88149. get canRescale(): boolean;
  88150. private _recreate;
  88151. /**
  88152. * Scales the texture
  88153. * @param ratio the scale factor to apply to both width and height
  88154. */
  88155. scale(ratio: number): void;
  88156. /**
  88157. * Resizes the texture
  88158. * @param width the new width
  88159. * @param height the new height
  88160. */
  88161. scaleTo(width: number, height: number): void;
  88162. /**
  88163. * Gets the context of the canvas used by the texture
  88164. * @returns the canvas context of the dynamic texture
  88165. */
  88166. getContext(): CanvasRenderingContext2D;
  88167. /**
  88168. * Clears the texture
  88169. */
  88170. clear(): void;
  88171. /**
  88172. * Updates the texture
  88173. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88174. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88175. */
  88176. update(invertY?: boolean, premulAlpha?: boolean): void;
  88177. /**
  88178. * Draws text onto the texture
  88179. * @param text defines the text to be drawn
  88180. * @param x defines the placement of the text from the left
  88181. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88182. * @param font defines the font to be used with font-style, font-size, font-name
  88183. * @param color defines the color used for the text
  88184. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88185. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88186. * @param update defines whether texture is immediately update (default is true)
  88187. */
  88188. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88189. /**
  88190. * Clones the texture
  88191. * @returns the clone of the texture.
  88192. */
  88193. clone(): DynamicTexture;
  88194. /**
  88195. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88196. * @returns a serialized dynamic texture object
  88197. */
  88198. serialize(): any;
  88199. /** @hidden */
  88200. _rebuild(): void;
  88201. }
  88202. }
  88203. declare module BABYLON {
  88204. interface ThinEngine {
  88205. /**
  88206. * Creates a raw texture
  88207. * @param data defines the data to store in the texture
  88208. * @param width defines the width of the texture
  88209. * @param height defines the height of the texture
  88210. * @param format defines the format of the data
  88211. * @param generateMipMaps defines if the engine should generate the mip levels
  88212. * @param invertY defines if data must be stored with Y axis inverted
  88213. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88214. * @param compression defines the compression used (null by default)
  88215. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88216. * @returns the raw texture inside an InternalTexture
  88217. */
  88218. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88219. /**
  88220. * Update a raw texture
  88221. * @param texture defines the texture to update
  88222. * @param data defines the data to store in the texture
  88223. * @param format defines the format of the data
  88224. * @param invertY defines if data must be stored with Y axis inverted
  88225. */
  88226. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88227. /**
  88228. * Update a raw texture
  88229. * @param texture defines the texture to update
  88230. * @param data defines the data to store in the texture
  88231. * @param format defines the format of the data
  88232. * @param invertY defines if data must be stored with Y axis inverted
  88233. * @param compression defines the compression used (null by default)
  88234. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88235. */
  88236. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88237. /**
  88238. * Creates a new raw cube texture
  88239. * @param data defines the array of data to use to create each face
  88240. * @param size defines the size of the textures
  88241. * @param format defines the format of the data
  88242. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88243. * @param generateMipMaps defines if the engine should generate the mip levels
  88244. * @param invertY defines if data must be stored with Y axis inverted
  88245. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88246. * @param compression defines the compression used (null by default)
  88247. * @returns the cube texture as an InternalTexture
  88248. */
  88249. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88250. /**
  88251. * Update a raw cube texture
  88252. * @param texture defines the texture to udpdate
  88253. * @param data defines the data to store
  88254. * @param format defines the data format
  88255. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88256. * @param invertY defines if data must be stored with Y axis inverted
  88257. */
  88258. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88259. /**
  88260. * Update a raw cube texture
  88261. * @param texture defines the texture to udpdate
  88262. * @param data defines the data to store
  88263. * @param format defines the data format
  88264. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88265. * @param invertY defines if data must be stored with Y axis inverted
  88266. * @param compression defines the compression used (null by default)
  88267. */
  88268. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88269. /**
  88270. * Update a raw cube texture
  88271. * @param texture defines the texture to udpdate
  88272. * @param data defines the data to store
  88273. * @param format defines the data format
  88274. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88275. * @param invertY defines if data must be stored with Y axis inverted
  88276. * @param compression defines the compression used (null by default)
  88277. * @param level defines which level of the texture to update
  88278. */
  88279. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88280. /**
  88281. * Creates a new raw cube texture from a specified url
  88282. * @param url defines the url where the data is located
  88283. * @param scene defines the current scene
  88284. * @param size defines the size of the textures
  88285. * @param format defines the format of the data
  88286. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88287. * @param noMipmap defines if the engine should avoid generating the mip levels
  88288. * @param callback defines a callback used to extract texture data from loaded data
  88289. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88290. * @param onLoad defines a callback called when texture is loaded
  88291. * @param onError defines a callback called if there is an error
  88292. * @returns the cube texture as an InternalTexture
  88293. */
  88294. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  88295. /**
  88296. * Creates a new raw cube texture from a specified url
  88297. * @param url defines the url where the data is located
  88298. * @param scene defines the current scene
  88299. * @param size defines the size of the textures
  88300. * @param format defines the format of the data
  88301. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88302. * @param noMipmap defines if the engine should avoid generating the mip levels
  88303. * @param callback defines a callback used to extract texture data from loaded data
  88304. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88305. * @param onLoad defines a callback called when texture is loaded
  88306. * @param onError defines a callback called if there is an error
  88307. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88308. * @param invertY defines if data must be stored with Y axis inverted
  88309. * @returns the cube texture as an InternalTexture
  88310. */
  88311. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  88312. /**
  88313. * Creates a new raw 3D texture
  88314. * @param data defines the data used to create the texture
  88315. * @param width defines the width of the texture
  88316. * @param height defines the height of the texture
  88317. * @param depth defines the depth of the texture
  88318. * @param format defines the format of the texture
  88319. * @param generateMipMaps defines if the engine must generate mip levels
  88320. * @param invertY defines if data must be stored with Y axis inverted
  88321. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88322. * @param compression defines the compressed used (can be null)
  88323. * @param textureType defines the compressed used (can be null)
  88324. * @returns a new raw 3D texture (stored in an InternalTexture)
  88325. */
  88326. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88327. /**
  88328. * Update a raw 3D texture
  88329. * @param texture defines the texture to update
  88330. * @param data defines the data to store
  88331. * @param format defines the data format
  88332. * @param invertY defines if data must be stored with Y axis inverted
  88333. */
  88334. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88335. /**
  88336. * Update a raw 3D texture
  88337. * @param texture defines the texture to update
  88338. * @param data defines the data to store
  88339. * @param format defines the data format
  88340. * @param invertY defines if data must be stored with Y axis inverted
  88341. * @param compression defines the used compression (can be null)
  88342. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88343. */
  88344. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88345. /**
  88346. * Creates a new raw 2D array texture
  88347. * @param data defines the data used to create the texture
  88348. * @param width defines the width of the texture
  88349. * @param height defines the height of the texture
  88350. * @param depth defines the number of layers of the texture
  88351. * @param format defines the format of the texture
  88352. * @param generateMipMaps defines if the engine must generate mip levels
  88353. * @param invertY defines if data must be stored with Y axis inverted
  88354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88355. * @param compression defines the compressed used (can be null)
  88356. * @param textureType defines the compressed used (can be null)
  88357. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88358. */
  88359. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88360. /**
  88361. * Update a raw 2D array texture
  88362. * @param texture defines the texture to update
  88363. * @param data defines the data to store
  88364. * @param format defines the data format
  88365. * @param invertY defines if data must be stored with Y axis inverted
  88366. */
  88367. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88368. /**
  88369. * Update a raw 2D array texture
  88370. * @param texture defines the texture to update
  88371. * @param data defines the data to store
  88372. * @param format defines the data format
  88373. * @param invertY defines if data must be stored with Y axis inverted
  88374. * @param compression defines the used compression (can be null)
  88375. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88376. */
  88377. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88378. }
  88379. }
  88380. declare module BABYLON {
  88381. /**
  88382. * Raw texture can help creating a texture directly from an array of data.
  88383. * This can be super useful if you either get the data from an uncompressed source or
  88384. * if you wish to create your texture pixel by pixel.
  88385. */
  88386. export class RawTexture extends Texture {
  88387. /**
  88388. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88389. */
  88390. format: number;
  88391. /**
  88392. * Instantiates a new RawTexture.
  88393. * Raw texture can help creating a texture directly from an array of data.
  88394. * This can be super useful if you either get the data from an uncompressed source or
  88395. * if you wish to create your texture pixel by pixel.
  88396. * @param data define the array of data to use to create the texture
  88397. * @param width define the width of the texture
  88398. * @param height define the height of the texture
  88399. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88400. * @param scene define the scene the texture belongs to
  88401. * @param generateMipMaps define whether mip maps should be generated or not
  88402. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88403. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88404. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88405. */
  88406. constructor(data: ArrayBufferView, width: number, height: number,
  88407. /**
  88408. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88409. */
  88410. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  88411. /**
  88412. * Updates the texture underlying data.
  88413. * @param data Define the new data of the texture
  88414. */
  88415. update(data: ArrayBufferView): void;
  88416. /**
  88417. * Creates a luminance texture from some data.
  88418. * @param data Define the texture data
  88419. * @param width Define the width of the texture
  88420. * @param height Define the height of the texture
  88421. * @param scene Define the scene the texture belongs to
  88422. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88423. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88424. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88425. * @returns the luminance texture
  88426. */
  88427. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88428. /**
  88429. * Creates a luminance alpha texture from some data.
  88430. * @param data Define the texture data
  88431. * @param width Define the width of the texture
  88432. * @param height Define the height of the texture
  88433. * @param scene Define the scene the texture belongs to
  88434. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88435. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88436. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88437. * @returns the luminance alpha texture
  88438. */
  88439. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88440. /**
  88441. * Creates an alpha texture from some data.
  88442. * @param data Define the texture data
  88443. * @param width Define the width of the texture
  88444. * @param height Define the height of the texture
  88445. * @param scene Define the scene the texture belongs to
  88446. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88447. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88448. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88449. * @returns the alpha texture
  88450. */
  88451. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88452. /**
  88453. * Creates a RGB texture from some data.
  88454. * @param data Define the texture data
  88455. * @param width Define the width of the texture
  88456. * @param height Define the height of the texture
  88457. * @param scene Define the scene the texture belongs to
  88458. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88459. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88460. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88461. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88462. * @returns the RGB alpha texture
  88463. */
  88464. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88465. /**
  88466. * Creates a RGBA texture from some data.
  88467. * @param data Define the texture data
  88468. * @param width Define the width of the texture
  88469. * @param height Define the height of the texture
  88470. * @param scene Define the scene the texture belongs to
  88471. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88472. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88473. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88474. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88475. * @returns the RGBA texture
  88476. */
  88477. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88478. /**
  88479. * Creates a R texture from some data.
  88480. * @param data Define the texture data
  88481. * @param width Define the width of the texture
  88482. * @param height Define the height of the texture
  88483. * @param scene Define the scene the texture belongs to
  88484. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88485. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88486. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88487. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88488. * @returns the R texture
  88489. */
  88490. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88491. }
  88492. }
  88493. declare module BABYLON {
  88494. interface AbstractScene {
  88495. /**
  88496. * The list of procedural textures added to the scene
  88497. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88498. */
  88499. proceduralTextures: Array<ProceduralTexture>;
  88500. }
  88501. /**
  88502. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88503. * in a given scene.
  88504. */
  88505. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88506. /**
  88507. * The component name helpfull to identify the component in the list of scene components.
  88508. */
  88509. readonly name: string;
  88510. /**
  88511. * The scene the component belongs to.
  88512. */
  88513. scene: Scene;
  88514. /**
  88515. * Creates a new instance of the component for the given scene
  88516. * @param scene Defines the scene to register the component in
  88517. */
  88518. constructor(scene: Scene);
  88519. /**
  88520. * Registers the component in a given scene
  88521. */
  88522. register(): void;
  88523. /**
  88524. * Rebuilds the elements related to this component in case of
  88525. * context lost for instance.
  88526. */
  88527. rebuild(): void;
  88528. /**
  88529. * Disposes the component and the associated ressources.
  88530. */
  88531. dispose(): void;
  88532. private _beforeClear;
  88533. }
  88534. }
  88535. declare module BABYLON {
  88536. interface ThinEngine {
  88537. /**
  88538. * Creates a new render target cube texture
  88539. * @param size defines the size of the texture
  88540. * @param options defines the options used to create the texture
  88541. * @returns a new render target cube texture stored in an InternalTexture
  88542. */
  88543. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88544. }
  88545. }
  88546. declare module BABYLON {
  88547. /** @hidden */
  88548. export var proceduralVertexShader: {
  88549. name: string;
  88550. shader: string;
  88551. };
  88552. }
  88553. declare module BABYLON {
  88554. /**
  88555. * 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.
  88556. * This is the base class of any Procedural texture and contains most of the shareable code.
  88557. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88558. */
  88559. export class ProceduralTexture extends Texture {
  88560. isCube: boolean;
  88561. /**
  88562. * Define if the texture is enabled or not (disabled texture will not render)
  88563. */
  88564. isEnabled: boolean;
  88565. /**
  88566. * Define if the texture must be cleared before rendering (default is true)
  88567. */
  88568. autoClear: boolean;
  88569. /**
  88570. * Callback called when the texture is generated
  88571. */
  88572. onGenerated: () => void;
  88573. /**
  88574. * Event raised when the texture is generated
  88575. */
  88576. onGeneratedObservable: Observable<ProceduralTexture>;
  88577. /** @hidden */
  88578. _generateMipMaps: boolean;
  88579. /** @hidden **/
  88580. _effect: Effect;
  88581. /** @hidden */
  88582. _textures: {
  88583. [key: string]: Texture;
  88584. };
  88585. /** @hidden */
  88586. protected _fallbackTexture: Nullable<Texture>;
  88587. private _size;
  88588. private _currentRefreshId;
  88589. private _frameId;
  88590. private _refreshRate;
  88591. private _vertexBuffers;
  88592. private _indexBuffer;
  88593. private _uniforms;
  88594. private _samplers;
  88595. private _fragment;
  88596. private _floats;
  88597. private _ints;
  88598. private _floatsArrays;
  88599. private _colors3;
  88600. private _colors4;
  88601. private _vectors2;
  88602. private _vectors3;
  88603. private _matrices;
  88604. private _fallbackTextureUsed;
  88605. private _fullEngine;
  88606. private _cachedDefines;
  88607. private _contentUpdateId;
  88608. private _contentData;
  88609. /**
  88610. * Instantiates a new procedural texture.
  88611. * 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.
  88612. * This is the base class of any Procedural texture and contains most of the shareable code.
  88613. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88614. * @param name Define the name of the texture
  88615. * @param size Define the size of the texture to create
  88616. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88617. * @param scene Define the scene the texture belongs to
  88618. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88619. * @param generateMipMaps Define if the texture should creates mip maps or not
  88620. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88621. */
  88622. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88623. /**
  88624. * The effect that is created when initializing the post process.
  88625. * @returns The created effect corresponding the the postprocess.
  88626. */
  88627. getEffect(): Effect;
  88628. /**
  88629. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88630. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88631. */
  88632. getContent(): Nullable<ArrayBufferView>;
  88633. private _createIndexBuffer;
  88634. /** @hidden */
  88635. _rebuild(): void;
  88636. /**
  88637. * Resets the texture in order to recreate its associated resources.
  88638. * This can be called in case of context loss
  88639. */
  88640. reset(): void;
  88641. protected _getDefines(): string;
  88642. /**
  88643. * Is the texture ready to be used ? (rendered at least once)
  88644. * @returns true if ready, otherwise, false.
  88645. */
  88646. isReady(): boolean;
  88647. /**
  88648. * Resets the refresh counter of the texture and start bak from scratch.
  88649. * Could be useful to regenerate the texture if it is setup to render only once.
  88650. */
  88651. resetRefreshCounter(): void;
  88652. /**
  88653. * Set the fragment shader to use in order to render the texture.
  88654. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88655. */
  88656. setFragment(fragment: any): void;
  88657. /**
  88658. * Define the refresh rate of the texture or the rendering frequency.
  88659. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88660. */
  88661. get refreshRate(): number;
  88662. set refreshRate(value: number);
  88663. /** @hidden */
  88664. _shouldRender(): boolean;
  88665. /**
  88666. * Get the size the texture is rendering at.
  88667. * @returns the size (texture is always squared)
  88668. */
  88669. getRenderSize(): number;
  88670. /**
  88671. * Resize the texture to new value.
  88672. * @param size Define the new size the texture should have
  88673. * @param generateMipMaps Define whether the new texture should create mip maps
  88674. */
  88675. resize(size: number, generateMipMaps: boolean): void;
  88676. private _checkUniform;
  88677. /**
  88678. * Set a texture in the shader program used to render.
  88679. * @param name Define the name of the uniform samplers as defined in the shader
  88680. * @param texture Define the texture to bind to this sampler
  88681. * @return the texture itself allowing "fluent" like uniform updates
  88682. */
  88683. setTexture(name: string, texture: Texture): ProceduralTexture;
  88684. /**
  88685. * Set a float in the shader.
  88686. * @param name Define the name of the uniform as defined in the shader
  88687. * @param value Define the value to give to the uniform
  88688. * @return the texture itself allowing "fluent" like uniform updates
  88689. */
  88690. setFloat(name: string, value: number): ProceduralTexture;
  88691. /**
  88692. * Set a int in the shader.
  88693. * @param name Define the name of the uniform as defined in the shader
  88694. * @param value Define the value to give to the uniform
  88695. * @return the texture itself allowing "fluent" like uniform updates
  88696. */
  88697. setInt(name: string, value: number): ProceduralTexture;
  88698. /**
  88699. * Set an array of floats in the shader.
  88700. * @param name Define the name of the uniform as defined in the shader
  88701. * @param value Define the value to give to the uniform
  88702. * @return the texture itself allowing "fluent" like uniform updates
  88703. */
  88704. setFloats(name: string, value: number[]): ProceduralTexture;
  88705. /**
  88706. * Set a vec3 in the shader from a Color3.
  88707. * @param name Define the name of the uniform as defined in the shader
  88708. * @param value Define the value to give to the uniform
  88709. * @return the texture itself allowing "fluent" like uniform updates
  88710. */
  88711. setColor3(name: string, value: Color3): ProceduralTexture;
  88712. /**
  88713. * Set a vec4 in the shader from a Color4.
  88714. * @param name Define the name of the uniform as defined in the shader
  88715. * @param value Define the value to give to the uniform
  88716. * @return the texture itself allowing "fluent" like uniform updates
  88717. */
  88718. setColor4(name: string, value: Color4): ProceduralTexture;
  88719. /**
  88720. * Set a vec2 in the shader from a Vector2.
  88721. * @param name Define the name of the uniform as defined in the shader
  88722. * @param value Define the value to give to the uniform
  88723. * @return the texture itself allowing "fluent" like uniform updates
  88724. */
  88725. setVector2(name: string, value: Vector2): ProceduralTexture;
  88726. /**
  88727. * Set a vec3 in the shader from a Vector3.
  88728. * @param name Define the name of the uniform as defined in the shader
  88729. * @param value Define the value to give to the uniform
  88730. * @return the texture itself allowing "fluent" like uniform updates
  88731. */
  88732. setVector3(name: string, value: Vector3): ProceduralTexture;
  88733. /**
  88734. * Set a mat4 in the shader from a MAtrix.
  88735. * @param name Define the name of the uniform as defined in the shader
  88736. * @param value Define the value to give to the uniform
  88737. * @return the texture itself allowing "fluent" like uniform updates
  88738. */
  88739. setMatrix(name: string, value: Matrix): ProceduralTexture;
  88740. /**
  88741. * Render the texture to its associated render target.
  88742. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  88743. */
  88744. render(useCameraPostProcess?: boolean): void;
  88745. /**
  88746. * Clone the texture.
  88747. * @returns the cloned texture
  88748. */
  88749. clone(): ProceduralTexture;
  88750. /**
  88751. * Dispose the texture and release its asoociated resources.
  88752. */
  88753. dispose(): void;
  88754. }
  88755. }
  88756. declare module BABYLON {
  88757. /**
  88758. * This represents the base class for particle system in Babylon.
  88759. * 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.
  88760. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88761. * @example https://doc.babylonjs.com/babylon101/particles
  88762. */
  88763. export class BaseParticleSystem {
  88764. /**
  88765. * Source color is added to the destination color without alpha affecting the result
  88766. */
  88767. static BLENDMODE_ONEONE: number;
  88768. /**
  88769. * Blend current color and particle color using particle’s alpha
  88770. */
  88771. static BLENDMODE_STANDARD: number;
  88772. /**
  88773. * Add current color and particle color multiplied by particle’s alpha
  88774. */
  88775. static BLENDMODE_ADD: number;
  88776. /**
  88777. * Multiply current color with particle color
  88778. */
  88779. static BLENDMODE_MULTIPLY: number;
  88780. /**
  88781. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  88782. */
  88783. static BLENDMODE_MULTIPLYADD: number;
  88784. /**
  88785. * List of animations used by the particle system.
  88786. */
  88787. animations: Animation[];
  88788. /**
  88789. * Gets or sets the unique id of the particle system
  88790. */
  88791. uniqueId: number;
  88792. /**
  88793. * The id of the Particle system.
  88794. */
  88795. id: string;
  88796. /**
  88797. * The friendly name of the Particle system.
  88798. */
  88799. name: string;
  88800. /**
  88801. * Snippet ID if the particle system was created from the snippet server
  88802. */
  88803. snippetId: string;
  88804. /**
  88805. * The rendering group used by the Particle system to chose when to render.
  88806. */
  88807. renderingGroupId: number;
  88808. /**
  88809. * The emitter represents the Mesh or position we are attaching the particle system to.
  88810. */
  88811. emitter: Nullable<AbstractMesh | Vector3>;
  88812. /**
  88813. * The maximum number of particles to emit per frame
  88814. */
  88815. emitRate: number;
  88816. /**
  88817. * If you want to launch only a few particles at once, that can be done, as well.
  88818. */
  88819. manualEmitCount: number;
  88820. /**
  88821. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88822. */
  88823. updateSpeed: number;
  88824. /**
  88825. * The amount of time the particle system is running (depends of the overall update speed).
  88826. */
  88827. targetStopDuration: number;
  88828. /**
  88829. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88830. */
  88831. disposeOnStop: boolean;
  88832. /**
  88833. * Minimum power of emitting particles.
  88834. */
  88835. minEmitPower: number;
  88836. /**
  88837. * Maximum power of emitting particles.
  88838. */
  88839. maxEmitPower: number;
  88840. /**
  88841. * Minimum life time of emitting particles.
  88842. */
  88843. minLifeTime: number;
  88844. /**
  88845. * Maximum life time of emitting particles.
  88846. */
  88847. maxLifeTime: number;
  88848. /**
  88849. * Minimum Size of emitting particles.
  88850. */
  88851. minSize: number;
  88852. /**
  88853. * Maximum Size of emitting particles.
  88854. */
  88855. maxSize: number;
  88856. /**
  88857. * Minimum scale of emitting particles on X axis.
  88858. */
  88859. minScaleX: number;
  88860. /**
  88861. * Maximum scale of emitting particles on X axis.
  88862. */
  88863. maxScaleX: number;
  88864. /**
  88865. * Minimum scale of emitting particles on Y axis.
  88866. */
  88867. minScaleY: number;
  88868. /**
  88869. * Maximum scale of emitting particles on Y axis.
  88870. */
  88871. maxScaleY: number;
  88872. /**
  88873. * Gets or sets the minimal initial rotation in radians.
  88874. */
  88875. minInitialRotation: number;
  88876. /**
  88877. * Gets or sets the maximal initial rotation in radians.
  88878. */
  88879. maxInitialRotation: number;
  88880. /**
  88881. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88882. */
  88883. minAngularSpeed: number;
  88884. /**
  88885. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88886. */
  88887. maxAngularSpeed: number;
  88888. /**
  88889. * The texture used to render each particle. (this can be a spritesheet)
  88890. */
  88891. particleTexture: Nullable<Texture>;
  88892. /**
  88893. * The layer mask we are rendering the particles through.
  88894. */
  88895. layerMask: number;
  88896. /**
  88897. * This can help using your own shader to render the particle system.
  88898. * The according effect will be created
  88899. */
  88900. customShader: any;
  88901. /**
  88902. * By default particle system starts as soon as they are created. This prevents the
  88903. * automatic start to happen and let you decide when to start emitting particles.
  88904. */
  88905. preventAutoStart: boolean;
  88906. private _noiseTexture;
  88907. /**
  88908. * Gets or sets a texture used to add random noise to particle positions
  88909. */
  88910. get noiseTexture(): Nullable<ProceduralTexture>;
  88911. set noiseTexture(value: Nullable<ProceduralTexture>);
  88912. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88913. noiseStrength: Vector3;
  88914. /**
  88915. * Callback triggered when the particle animation is ending.
  88916. */
  88917. onAnimationEnd: Nullable<() => void>;
  88918. /**
  88919. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  88920. */
  88921. blendMode: number;
  88922. /**
  88923. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  88924. * to override the particles.
  88925. */
  88926. forceDepthWrite: boolean;
  88927. /** 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 */
  88928. preWarmCycles: number;
  88929. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  88930. preWarmStepOffset: number;
  88931. /**
  88932. * 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)
  88933. */
  88934. spriteCellChangeSpeed: number;
  88935. /**
  88936. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  88937. */
  88938. startSpriteCellID: number;
  88939. /**
  88940. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  88941. */
  88942. endSpriteCellID: number;
  88943. /**
  88944. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  88945. */
  88946. spriteCellWidth: number;
  88947. /**
  88948. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  88949. */
  88950. spriteCellHeight: number;
  88951. /**
  88952. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  88953. */
  88954. spriteRandomStartCell: boolean;
  88955. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88956. translationPivot: Vector2;
  88957. /** @hidden */
  88958. protected _isAnimationSheetEnabled: boolean;
  88959. /**
  88960. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88961. */
  88962. beginAnimationOnStart: boolean;
  88963. /**
  88964. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88965. */
  88966. beginAnimationFrom: number;
  88967. /**
  88968. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88969. */
  88970. beginAnimationTo: number;
  88971. /**
  88972. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88973. */
  88974. beginAnimationLoop: boolean;
  88975. /**
  88976. * Gets or sets a world offset applied to all particles
  88977. */
  88978. worldOffset: Vector3;
  88979. /**
  88980. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  88981. */
  88982. get isAnimationSheetEnabled(): boolean;
  88983. set isAnimationSheetEnabled(value: boolean);
  88984. /**
  88985. * Get hosting scene
  88986. * @returns the scene
  88987. */
  88988. getScene(): Scene;
  88989. /**
  88990. * You can use gravity if you want to give an orientation to your particles.
  88991. */
  88992. gravity: Vector3;
  88993. protected _colorGradients: Nullable<Array<ColorGradient>>;
  88994. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  88995. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  88996. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  88997. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  88998. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  88999. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89000. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89001. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89002. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89003. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89004. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89005. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89006. /**
  89007. * Defines the delay in milliseconds before starting the system (0 by default)
  89008. */
  89009. startDelay: number;
  89010. /**
  89011. * Gets the current list of drag gradients.
  89012. * You must use addDragGradient and removeDragGradient to udpate this list
  89013. * @returns the list of drag gradients
  89014. */
  89015. getDragGradients(): Nullable<Array<FactorGradient>>;
  89016. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89017. limitVelocityDamping: number;
  89018. /**
  89019. * Gets the current list of limit velocity gradients.
  89020. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89021. * @returns the list of limit velocity gradients
  89022. */
  89023. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89024. /**
  89025. * Gets the current list of color gradients.
  89026. * You must use addColorGradient and removeColorGradient to udpate this list
  89027. * @returns the list of color gradients
  89028. */
  89029. getColorGradients(): Nullable<Array<ColorGradient>>;
  89030. /**
  89031. * Gets the current list of size gradients.
  89032. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89033. * @returns the list of size gradients
  89034. */
  89035. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89036. /**
  89037. * Gets the current list of color remap gradients.
  89038. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89039. * @returns the list of color remap gradients
  89040. */
  89041. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89042. /**
  89043. * Gets the current list of alpha remap gradients.
  89044. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89045. * @returns the list of alpha remap gradients
  89046. */
  89047. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89048. /**
  89049. * Gets the current list of life time gradients.
  89050. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89051. * @returns the list of life time gradients
  89052. */
  89053. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89054. /**
  89055. * Gets the current list of angular speed gradients.
  89056. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89057. * @returns the list of angular speed gradients
  89058. */
  89059. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89060. /**
  89061. * Gets the current list of velocity gradients.
  89062. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89063. * @returns the list of velocity gradients
  89064. */
  89065. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89066. /**
  89067. * Gets the current list of start size gradients.
  89068. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89069. * @returns the list of start size gradients
  89070. */
  89071. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89072. /**
  89073. * Gets the current list of emit rate gradients.
  89074. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89075. * @returns the list of emit rate gradients
  89076. */
  89077. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89078. /**
  89079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89080. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89081. */
  89082. get direction1(): Vector3;
  89083. set direction1(value: Vector3);
  89084. /**
  89085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89086. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89087. */
  89088. get direction2(): Vector3;
  89089. set direction2(value: Vector3);
  89090. /**
  89091. * 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.
  89092. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89093. */
  89094. get minEmitBox(): Vector3;
  89095. set minEmitBox(value: Vector3);
  89096. /**
  89097. * 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.
  89098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89099. */
  89100. get maxEmitBox(): Vector3;
  89101. set maxEmitBox(value: Vector3);
  89102. /**
  89103. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89104. */
  89105. color1: Color4;
  89106. /**
  89107. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89108. */
  89109. color2: Color4;
  89110. /**
  89111. * Color the particle will have at the end of its lifetime
  89112. */
  89113. colorDead: Color4;
  89114. /**
  89115. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89116. */
  89117. textureMask: Color4;
  89118. /**
  89119. * The particle emitter type defines the emitter used by the particle system.
  89120. * It can be for example box, sphere, or cone...
  89121. */
  89122. particleEmitterType: IParticleEmitterType;
  89123. /** @hidden */
  89124. _isSubEmitter: boolean;
  89125. /**
  89126. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89127. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89128. */
  89129. billboardMode: number;
  89130. protected _isBillboardBased: boolean;
  89131. /**
  89132. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89133. */
  89134. get isBillboardBased(): boolean;
  89135. set isBillboardBased(value: boolean);
  89136. /**
  89137. * The scene the particle system belongs to.
  89138. */
  89139. protected _scene: Scene;
  89140. /**
  89141. * Local cache of defines for image processing.
  89142. */
  89143. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89144. /**
  89145. * Default configuration related to image processing available in the standard Material.
  89146. */
  89147. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89148. /**
  89149. * Gets the image processing configuration used either in this material.
  89150. */
  89151. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89152. /**
  89153. * Sets the Default image processing configuration used either in the this material.
  89154. *
  89155. * If sets to null, the scene one is in use.
  89156. */
  89157. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89158. /**
  89159. * Attaches a new image processing configuration to the Standard Material.
  89160. * @param configuration
  89161. */
  89162. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89163. /** @hidden */
  89164. protected _reset(): void;
  89165. /** @hidden */
  89166. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89167. /**
  89168. * Instantiates a particle system.
  89169. * 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.
  89170. * @param name The name of the particle system
  89171. */
  89172. constructor(name: string);
  89173. /**
  89174. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89175. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89176. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89177. * @returns the emitter
  89178. */
  89179. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89180. /**
  89181. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89182. * @param radius The radius of the hemisphere to emit from
  89183. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89184. * @returns the emitter
  89185. */
  89186. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89187. /**
  89188. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89189. * @param radius The radius of the sphere to emit from
  89190. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89191. * @returns the emitter
  89192. */
  89193. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89194. /**
  89195. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89196. * @param radius The radius of the sphere to emit from
  89197. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89198. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89199. * @returns the emitter
  89200. */
  89201. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89202. /**
  89203. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89204. * @param radius The radius of the emission cylinder
  89205. * @param height The height of the emission cylinder
  89206. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89207. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89208. * @returns the emitter
  89209. */
  89210. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89211. /**
  89212. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89213. * @param radius The radius of the cylinder to emit from
  89214. * @param height The height of the emission cylinder
  89215. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89216. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89217. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89218. * @returns the emitter
  89219. */
  89220. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89221. /**
  89222. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89223. * @param radius The radius of the cone to emit from
  89224. * @param angle The base angle of the cone
  89225. * @returns the emitter
  89226. */
  89227. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89228. /**
  89229. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89230. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89231. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89232. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89233. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89234. * @returns the emitter
  89235. */
  89236. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89237. }
  89238. }
  89239. declare module BABYLON {
  89240. /**
  89241. * Type of sub emitter
  89242. */
  89243. export enum SubEmitterType {
  89244. /**
  89245. * Attached to the particle over it's lifetime
  89246. */
  89247. ATTACHED = 0,
  89248. /**
  89249. * Created when the particle dies
  89250. */
  89251. END = 1
  89252. }
  89253. /**
  89254. * Sub emitter class used to emit particles from an existing particle
  89255. */
  89256. export class SubEmitter {
  89257. /**
  89258. * the particle system to be used by the sub emitter
  89259. */
  89260. particleSystem: ParticleSystem;
  89261. /**
  89262. * Type of the submitter (Default: END)
  89263. */
  89264. type: SubEmitterType;
  89265. /**
  89266. * 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)
  89267. * Note: This only is supported when using an emitter of type Mesh
  89268. */
  89269. inheritDirection: boolean;
  89270. /**
  89271. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89272. */
  89273. inheritedVelocityAmount: number;
  89274. /**
  89275. * Creates a sub emitter
  89276. * @param particleSystem the particle system to be used by the sub emitter
  89277. */
  89278. constructor(
  89279. /**
  89280. * the particle system to be used by the sub emitter
  89281. */
  89282. particleSystem: ParticleSystem);
  89283. /**
  89284. * Clones the sub emitter
  89285. * @returns the cloned sub emitter
  89286. */
  89287. clone(): SubEmitter;
  89288. /**
  89289. * Serialize current object to a JSON object
  89290. * @returns the serialized object
  89291. */
  89292. serialize(): any;
  89293. /** @hidden */
  89294. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89295. /**
  89296. * Creates a new SubEmitter from a serialized JSON version
  89297. * @param serializationObject defines the JSON object to read from
  89298. * @param scene defines the hosting scene
  89299. * @param rootUrl defines the rootUrl for data loading
  89300. * @returns a new SubEmitter
  89301. */
  89302. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89303. /** Release associated resources */
  89304. dispose(): void;
  89305. }
  89306. }
  89307. declare module BABYLON {
  89308. /** @hidden */
  89309. export var imageProcessingDeclaration: {
  89310. name: string;
  89311. shader: string;
  89312. };
  89313. }
  89314. declare module BABYLON {
  89315. /** @hidden */
  89316. export var imageProcessingFunctions: {
  89317. name: string;
  89318. shader: string;
  89319. };
  89320. }
  89321. declare module BABYLON {
  89322. /** @hidden */
  89323. export var particlesPixelShader: {
  89324. name: string;
  89325. shader: string;
  89326. };
  89327. }
  89328. declare module BABYLON {
  89329. /** @hidden */
  89330. export var particlesVertexShader: {
  89331. name: string;
  89332. shader: string;
  89333. };
  89334. }
  89335. declare module BABYLON {
  89336. /**
  89337. * This represents a particle system in Babylon.
  89338. * 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.
  89339. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89340. * @example https://doc.babylonjs.com/babylon101/particles
  89341. */
  89342. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89343. /**
  89344. * Billboard mode will only apply to Y axis
  89345. */
  89346. static readonly BILLBOARDMODE_Y: number;
  89347. /**
  89348. * Billboard mode will apply to all axes
  89349. */
  89350. static readonly BILLBOARDMODE_ALL: number;
  89351. /**
  89352. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89353. */
  89354. static readonly BILLBOARDMODE_STRETCHED: number;
  89355. /**
  89356. * This function can be defined to provide custom update for active particles.
  89357. * This function will be called instead of regular update (age, position, color, etc.).
  89358. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89359. */
  89360. updateFunction: (particles: Particle[]) => void;
  89361. private _emitterWorldMatrix;
  89362. /**
  89363. * This function can be defined to specify initial direction for every new particle.
  89364. * It by default use the emitterType defined function
  89365. */
  89366. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89367. /**
  89368. * This function can be defined to specify initial position for every new particle.
  89369. * It by default use the emitterType defined function
  89370. */
  89371. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89372. /**
  89373. * @hidden
  89374. */
  89375. _inheritedVelocityOffset: Vector3;
  89376. /**
  89377. * An event triggered when the system is disposed
  89378. */
  89379. onDisposeObservable: Observable<IParticleSystem>;
  89380. private _onDisposeObserver;
  89381. /**
  89382. * Sets a callback that will be triggered when the system is disposed
  89383. */
  89384. set onDispose(callback: () => void);
  89385. private _particles;
  89386. private _epsilon;
  89387. private _capacity;
  89388. private _stockParticles;
  89389. private _newPartsExcess;
  89390. private _vertexData;
  89391. private _vertexBuffer;
  89392. private _vertexBuffers;
  89393. private _spriteBuffer;
  89394. private _indexBuffer;
  89395. private _effect;
  89396. private _customEffect;
  89397. private _cachedDefines;
  89398. private _scaledColorStep;
  89399. private _colorDiff;
  89400. private _scaledDirection;
  89401. private _scaledGravity;
  89402. private _currentRenderId;
  89403. private _alive;
  89404. private _useInstancing;
  89405. private _started;
  89406. private _stopped;
  89407. private _actualFrame;
  89408. private _scaledUpdateSpeed;
  89409. private _vertexBufferSize;
  89410. /** @hidden */
  89411. _currentEmitRateGradient: Nullable<FactorGradient>;
  89412. /** @hidden */
  89413. _currentEmitRate1: number;
  89414. /** @hidden */
  89415. _currentEmitRate2: number;
  89416. /** @hidden */
  89417. _currentStartSizeGradient: Nullable<FactorGradient>;
  89418. /** @hidden */
  89419. _currentStartSize1: number;
  89420. /** @hidden */
  89421. _currentStartSize2: number;
  89422. private readonly _rawTextureWidth;
  89423. private _rampGradientsTexture;
  89424. private _useRampGradients;
  89425. /** Gets or sets a boolean indicating that ramp gradients must be used
  89426. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89427. */
  89428. get useRampGradients(): boolean;
  89429. set useRampGradients(value: boolean);
  89430. /**
  89431. * 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.
  89432. * 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: [])
  89433. */
  89434. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89435. private _subEmitters;
  89436. /**
  89437. * @hidden
  89438. * If the particle systems emitter should be disposed when the particle system is disposed
  89439. */
  89440. _disposeEmitterOnDispose: boolean;
  89441. /**
  89442. * The current active Sub-systems, this property is used by the root particle system only.
  89443. */
  89444. activeSubSystems: Array<ParticleSystem>;
  89445. /**
  89446. * Specifies if the particles are updated in emitter local space or world space
  89447. */
  89448. isLocal: boolean;
  89449. private _rootParticleSystem;
  89450. /**
  89451. * Gets the current list of active particles
  89452. */
  89453. get particles(): Particle[];
  89454. /**
  89455. * Gets the number of particles active at the same time.
  89456. * @returns The number of active particles.
  89457. */
  89458. getActiveCount(): number;
  89459. /**
  89460. * Returns the string "ParticleSystem"
  89461. * @returns a string containing the class name
  89462. */
  89463. getClassName(): string;
  89464. /**
  89465. * Gets a boolean indicating that the system is stopping
  89466. * @returns true if the system is currently stopping
  89467. */
  89468. isStopping(): boolean;
  89469. /**
  89470. * Gets the custom effect used to render the particles
  89471. * @param blendMode Blend mode for which the effect should be retrieved
  89472. * @returns The effect
  89473. */
  89474. getCustomEffect(blendMode?: number): Nullable<Effect>;
  89475. /**
  89476. * Sets the custom effect used to render the particles
  89477. * @param effect The effect to set
  89478. * @param blendMode Blend mode for which the effect should be set
  89479. */
  89480. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  89481. /** @hidden */
  89482. private _onBeforeDrawParticlesObservable;
  89483. /**
  89484. * Observable that will be called just before the particles are drawn
  89485. */
  89486. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  89487. /**
  89488. * Gets the name of the particle vertex shader
  89489. */
  89490. get vertexShaderName(): string;
  89491. /**
  89492. * Instantiates a particle system.
  89493. * 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.
  89494. * @param name The name of the particle system
  89495. * @param capacity The max number of particles alive at the same time
  89496. * @param scene The scene the particle system belongs to
  89497. * @param customEffect a custom effect used to change the way particles are rendered by default
  89498. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89499. * @param epsilon Offset used to render the particles
  89500. */
  89501. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89502. private _addFactorGradient;
  89503. private _removeFactorGradient;
  89504. /**
  89505. * Adds a new life time gradient
  89506. * @param gradient defines the gradient to use (between 0 and 1)
  89507. * @param factor defines the life time factor to affect to the specified gradient
  89508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89509. * @returns the current particle system
  89510. */
  89511. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89512. /**
  89513. * Remove a specific life time gradient
  89514. * @param gradient defines the gradient to remove
  89515. * @returns the current particle system
  89516. */
  89517. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89518. /**
  89519. * Adds a new size gradient
  89520. * @param gradient defines the gradient to use (between 0 and 1)
  89521. * @param factor defines the size factor to affect to the specified gradient
  89522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89523. * @returns the current particle system
  89524. */
  89525. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89526. /**
  89527. * Remove a specific size gradient
  89528. * @param gradient defines the gradient to remove
  89529. * @returns the current particle system
  89530. */
  89531. removeSizeGradient(gradient: number): IParticleSystem;
  89532. /**
  89533. * Adds a new color remap gradient
  89534. * @param gradient defines the gradient to use (between 0 and 1)
  89535. * @param min defines the color remap minimal range
  89536. * @param max defines the color remap maximal range
  89537. * @returns the current particle system
  89538. */
  89539. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89540. /**
  89541. * Remove a specific color remap gradient
  89542. * @param gradient defines the gradient to remove
  89543. * @returns the current particle system
  89544. */
  89545. removeColorRemapGradient(gradient: number): IParticleSystem;
  89546. /**
  89547. * Adds a new alpha remap gradient
  89548. * @param gradient defines the gradient to use (between 0 and 1)
  89549. * @param min defines the alpha remap minimal range
  89550. * @param max defines the alpha remap maximal range
  89551. * @returns the current particle system
  89552. */
  89553. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89554. /**
  89555. * Remove a specific alpha remap gradient
  89556. * @param gradient defines the gradient to remove
  89557. * @returns the current particle system
  89558. */
  89559. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89560. /**
  89561. * Adds a new angular speed gradient
  89562. * @param gradient defines the gradient to use (between 0 and 1)
  89563. * @param factor defines the angular speed to affect to the specified gradient
  89564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89565. * @returns the current particle system
  89566. */
  89567. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89568. /**
  89569. * Remove a specific angular speed gradient
  89570. * @param gradient defines the gradient to remove
  89571. * @returns the current particle system
  89572. */
  89573. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89574. /**
  89575. * Adds a new velocity gradient
  89576. * @param gradient defines the gradient to use (between 0 and 1)
  89577. * @param factor defines the velocity to affect to the specified gradient
  89578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89579. * @returns the current particle system
  89580. */
  89581. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89582. /**
  89583. * Remove a specific velocity gradient
  89584. * @param gradient defines the gradient to remove
  89585. * @returns the current particle system
  89586. */
  89587. removeVelocityGradient(gradient: number): IParticleSystem;
  89588. /**
  89589. * Adds a new limit velocity gradient
  89590. * @param gradient defines the gradient to use (between 0 and 1)
  89591. * @param factor defines the limit velocity value to affect to the specified gradient
  89592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89593. * @returns the current particle system
  89594. */
  89595. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89596. /**
  89597. * Remove a specific limit velocity gradient
  89598. * @param gradient defines the gradient to remove
  89599. * @returns the current particle system
  89600. */
  89601. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89602. /**
  89603. * Adds a new drag gradient
  89604. * @param gradient defines the gradient to use (between 0 and 1)
  89605. * @param factor defines the drag value to affect to the specified gradient
  89606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89607. * @returns the current particle system
  89608. */
  89609. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89610. /**
  89611. * Remove a specific drag gradient
  89612. * @param gradient defines the gradient to remove
  89613. * @returns the current particle system
  89614. */
  89615. removeDragGradient(gradient: number): IParticleSystem;
  89616. /**
  89617. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89618. * @param gradient defines the gradient to use (between 0 and 1)
  89619. * @param factor defines the emit rate value to affect to the specified gradient
  89620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89621. * @returns the current particle system
  89622. */
  89623. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89624. /**
  89625. * Remove a specific emit rate gradient
  89626. * @param gradient defines the gradient to remove
  89627. * @returns the current particle system
  89628. */
  89629. removeEmitRateGradient(gradient: number): IParticleSystem;
  89630. /**
  89631. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89632. * @param gradient defines the gradient to use (between 0 and 1)
  89633. * @param factor defines the start size value to affect to the specified gradient
  89634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89635. * @returns the current particle system
  89636. */
  89637. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89638. /**
  89639. * Remove a specific start size gradient
  89640. * @param gradient defines the gradient to remove
  89641. * @returns the current particle system
  89642. */
  89643. removeStartSizeGradient(gradient: number): IParticleSystem;
  89644. private _createRampGradientTexture;
  89645. /**
  89646. * Gets the current list of ramp gradients.
  89647. * You must use addRampGradient and removeRampGradient to udpate this list
  89648. * @returns the list of ramp gradients
  89649. */
  89650. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89651. /** Force the system to rebuild all gradients that need to be resync */
  89652. forceRefreshGradients(): void;
  89653. private _syncRampGradientTexture;
  89654. /**
  89655. * Adds a new ramp gradient used to remap particle colors
  89656. * @param gradient defines the gradient to use (between 0 and 1)
  89657. * @param color defines the color to affect to the specified gradient
  89658. * @returns the current particle system
  89659. */
  89660. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89661. /**
  89662. * Remove a specific ramp gradient
  89663. * @param gradient defines the gradient to remove
  89664. * @returns the current particle system
  89665. */
  89666. removeRampGradient(gradient: number): ParticleSystem;
  89667. /**
  89668. * Adds a new color gradient
  89669. * @param gradient defines the gradient to use (between 0 and 1)
  89670. * @param color1 defines the color to affect to the specified gradient
  89671. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89672. * @returns this particle system
  89673. */
  89674. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89675. /**
  89676. * Remove a specific color gradient
  89677. * @param gradient defines the gradient to remove
  89678. * @returns this particle system
  89679. */
  89680. removeColorGradient(gradient: number): IParticleSystem;
  89681. private _fetchR;
  89682. protected _reset(): void;
  89683. private _resetEffect;
  89684. private _createVertexBuffers;
  89685. private _createIndexBuffer;
  89686. /**
  89687. * Gets the maximum number of particles active at the same time.
  89688. * @returns The max number of active particles.
  89689. */
  89690. getCapacity(): number;
  89691. /**
  89692. * Gets whether there are still active particles in the system.
  89693. * @returns True if it is alive, otherwise false.
  89694. */
  89695. isAlive(): boolean;
  89696. /**
  89697. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89698. * @returns True if it has been started, otherwise false.
  89699. */
  89700. isStarted(): boolean;
  89701. private _prepareSubEmitterInternalArray;
  89702. /**
  89703. * Starts the particle system and begins to emit
  89704. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89705. */
  89706. start(delay?: number): void;
  89707. /**
  89708. * Stops the particle system.
  89709. * @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.
  89710. */
  89711. stop(stopSubEmitters?: boolean): void;
  89712. /**
  89713. * Remove all active particles
  89714. */
  89715. reset(): void;
  89716. /**
  89717. * @hidden (for internal use only)
  89718. */
  89719. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89720. /**
  89721. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89722. * Its lifetime will start back at 0.
  89723. */
  89724. recycleParticle: (particle: Particle) => void;
  89725. private _stopSubEmitters;
  89726. private _createParticle;
  89727. private _removeFromRoot;
  89728. private _emitFromParticle;
  89729. private _update;
  89730. /** @hidden */
  89731. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  89732. /** @hidden */
  89733. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  89734. /**
  89735. * Fill the defines array according to the current settings of the particle system
  89736. * @param defines Array to be updated
  89737. * @param blendMode blend mode to take into account when updating the array
  89738. */
  89739. fillDefines(defines: Array<string>, blendMode: number): void;
  89740. /**
  89741. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  89742. * @param uniforms Uniforms array to fill
  89743. * @param attributes Attributes array to fill
  89744. * @param samplers Samplers array to fill
  89745. */
  89746. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  89747. /** @hidden */
  89748. private _getEffect;
  89749. /**
  89750. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  89751. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  89752. */
  89753. animate(preWarmOnly?: boolean): void;
  89754. private _appendParticleVertices;
  89755. /**
  89756. * Rebuilds the particle system.
  89757. */
  89758. rebuild(): void;
  89759. /**
  89760. * Is this system ready to be used/rendered
  89761. * @return true if the system is ready
  89762. */
  89763. isReady(): boolean;
  89764. private _render;
  89765. /**
  89766. * Renders the particle system in its current state.
  89767. * @returns the current number of particles
  89768. */
  89769. render(): number;
  89770. /**
  89771. * Disposes the particle system and free the associated resources
  89772. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89773. */
  89774. dispose(disposeTexture?: boolean): void;
  89775. /**
  89776. * Clones the particle system.
  89777. * @param name The name of the cloned object
  89778. * @param newEmitter The new emitter to use
  89779. * @returns the cloned particle system
  89780. */
  89781. clone(name: string, newEmitter: any): ParticleSystem;
  89782. /**
  89783. * Serializes the particle system to a JSON object
  89784. * @param serializeTexture defines if the texture must be serialized as well
  89785. * @returns the JSON object
  89786. */
  89787. serialize(serializeTexture?: boolean): any;
  89788. /** @hidden */
  89789. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  89790. /** @hidden */
  89791. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  89792. /**
  89793. * Parses a JSON object to create a particle system.
  89794. * @param parsedParticleSystem The JSON object to parse
  89795. * @param scene The scene to create the particle system in
  89796. * @param rootUrl The root url to use to load external dependencies like texture
  89797. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  89798. * @returns the Parsed particle system
  89799. */
  89800. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  89801. }
  89802. }
  89803. declare module BABYLON {
  89804. /**
  89805. * A particle represents one of the element emitted by a particle system.
  89806. * This is mainly define by its coordinates, direction, velocity and age.
  89807. */
  89808. export class Particle {
  89809. /**
  89810. * The particle system the particle belongs to.
  89811. */
  89812. particleSystem: ParticleSystem;
  89813. private static _Count;
  89814. /**
  89815. * Unique ID of the particle
  89816. */
  89817. id: number;
  89818. /**
  89819. * The world position of the particle in the scene.
  89820. */
  89821. position: Vector3;
  89822. /**
  89823. * The world direction of the particle in the scene.
  89824. */
  89825. direction: Vector3;
  89826. /**
  89827. * The color of the particle.
  89828. */
  89829. color: Color4;
  89830. /**
  89831. * The color change of the particle per step.
  89832. */
  89833. colorStep: Color4;
  89834. /**
  89835. * Defines how long will the life of the particle be.
  89836. */
  89837. lifeTime: number;
  89838. /**
  89839. * The current age of the particle.
  89840. */
  89841. age: number;
  89842. /**
  89843. * The current size of the particle.
  89844. */
  89845. size: number;
  89846. /**
  89847. * The current scale of the particle.
  89848. */
  89849. scale: Vector2;
  89850. /**
  89851. * The current angle of the particle.
  89852. */
  89853. angle: number;
  89854. /**
  89855. * Defines how fast is the angle changing.
  89856. */
  89857. angularSpeed: number;
  89858. /**
  89859. * Defines the cell index used by the particle to be rendered from a sprite.
  89860. */
  89861. cellIndex: number;
  89862. /**
  89863. * The information required to support color remapping
  89864. */
  89865. remapData: Vector4;
  89866. /** @hidden */
  89867. _randomCellOffset?: number;
  89868. /** @hidden */
  89869. _initialDirection: Nullable<Vector3>;
  89870. /** @hidden */
  89871. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  89872. /** @hidden */
  89873. _initialStartSpriteCellID: number;
  89874. /** @hidden */
  89875. _initialEndSpriteCellID: number;
  89876. /** @hidden */
  89877. _currentColorGradient: Nullable<ColorGradient>;
  89878. /** @hidden */
  89879. _currentColor1: Color4;
  89880. /** @hidden */
  89881. _currentColor2: Color4;
  89882. /** @hidden */
  89883. _currentSizeGradient: Nullable<FactorGradient>;
  89884. /** @hidden */
  89885. _currentSize1: number;
  89886. /** @hidden */
  89887. _currentSize2: number;
  89888. /** @hidden */
  89889. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  89890. /** @hidden */
  89891. _currentAngularSpeed1: number;
  89892. /** @hidden */
  89893. _currentAngularSpeed2: number;
  89894. /** @hidden */
  89895. _currentVelocityGradient: Nullable<FactorGradient>;
  89896. /** @hidden */
  89897. _currentVelocity1: number;
  89898. /** @hidden */
  89899. _currentVelocity2: number;
  89900. /** @hidden */
  89901. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  89902. /** @hidden */
  89903. _currentLimitVelocity1: number;
  89904. /** @hidden */
  89905. _currentLimitVelocity2: number;
  89906. /** @hidden */
  89907. _currentDragGradient: Nullable<FactorGradient>;
  89908. /** @hidden */
  89909. _currentDrag1: number;
  89910. /** @hidden */
  89911. _currentDrag2: number;
  89912. /** @hidden */
  89913. _randomNoiseCoordinates1: Vector3;
  89914. /** @hidden */
  89915. _randomNoiseCoordinates2: Vector3;
  89916. /** @hidden */
  89917. _localPosition?: Vector3;
  89918. /**
  89919. * Creates a new instance Particle
  89920. * @param particleSystem the particle system the particle belongs to
  89921. */
  89922. constructor(
  89923. /**
  89924. * The particle system the particle belongs to.
  89925. */
  89926. particleSystem: ParticleSystem);
  89927. private updateCellInfoFromSystem;
  89928. /**
  89929. * Defines how the sprite cell index is updated for the particle
  89930. */
  89931. updateCellIndex(): void;
  89932. /** @hidden */
  89933. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  89934. /** @hidden */
  89935. _inheritParticleInfoToSubEmitters(): void;
  89936. /** @hidden */
  89937. _reset(): void;
  89938. /**
  89939. * Copy the properties of particle to another one.
  89940. * @param other the particle to copy the information to.
  89941. */
  89942. copyTo(other: Particle): void;
  89943. }
  89944. }
  89945. declare module BABYLON {
  89946. /**
  89947. * Particle emitter represents a volume emitting particles.
  89948. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  89949. */
  89950. export interface IParticleEmitterType {
  89951. /**
  89952. * Called by the particle System when the direction is computed for the created particle.
  89953. * @param worldMatrix is the world matrix of the particle system
  89954. * @param directionToUpdate is the direction vector to update with the result
  89955. * @param particle is the particle we are computed the direction for
  89956. * @param isLocal defines if the direction should be set in local space
  89957. */
  89958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89959. /**
  89960. * Called by the particle System when the position is computed for the created particle.
  89961. * @param worldMatrix is the world matrix of the particle system
  89962. * @param positionToUpdate is the position vector to update with the result
  89963. * @param particle is the particle we are computed the position for
  89964. * @param isLocal defines if the position should be set in local space
  89965. */
  89966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  89967. /**
  89968. * Clones the current emitter and returns a copy of it
  89969. * @returns the new emitter
  89970. */
  89971. clone(): IParticleEmitterType;
  89972. /**
  89973. * Called by the GPUParticleSystem to setup the update shader
  89974. * @param effect defines the update shader
  89975. */
  89976. applyToShader(effect: Effect): void;
  89977. /**
  89978. * Returns a string to use to update the GPU particles update shader
  89979. * @returns the effect defines string
  89980. */
  89981. getEffectDefines(): string;
  89982. /**
  89983. * Returns a string representing the class name
  89984. * @returns a string containing the class name
  89985. */
  89986. getClassName(): string;
  89987. /**
  89988. * Serializes the particle system to a JSON object.
  89989. * @returns the JSON object
  89990. */
  89991. serialize(): any;
  89992. /**
  89993. * Parse properties from a JSON object
  89994. * @param serializationObject defines the JSON object
  89995. * @param scene defines the hosting scene
  89996. */
  89997. parse(serializationObject: any, scene: Scene): void;
  89998. }
  89999. }
  90000. declare module BABYLON {
  90001. /**
  90002. * Particle emitter emitting particles from the inside of a box.
  90003. * It emits the particles randomly between 2 given directions.
  90004. */
  90005. export class BoxParticleEmitter implements IParticleEmitterType {
  90006. /**
  90007. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90008. */
  90009. direction1: Vector3;
  90010. /**
  90011. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90012. */
  90013. direction2: Vector3;
  90014. /**
  90015. * 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.
  90016. */
  90017. minEmitBox: Vector3;
  90018. /**
  90019. * 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.
  90020. */
  90021. maxEmitBox: Vector3;
  90022. /**
  90023. * Creates a new instance BoxParticleEmitter
  90024. */
  90025. constructor();
  90026. /**
  90027. * Called by the particle System when the direction is computed for the created particle.
  90028. * @param worldMatrix is the world matrix of the particle system
  90029. * @param directionToUpdate is the direction vector to update with the result
  90030. * @param particle is the particle we are computed the direction for
  90031. * @param isLocal defines if the direction should be set in local space
  90032. */
  90033. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90034. /**
  90035. * Called by the particle System when the position is computed for the created particle.
  90036. * @param worldMatrix is the world matrix of the particle system
  90037. * @param positionToUpdate is the position vector to update with the result
  90038. * @param particle is the particle we are computed the position for
  90039. * @param isLocal defines if the position should be set in local space
  90040. */
  90041. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90042. /**
  90043. * Clones the current emitter and returns a copy of it
  90044. * @returns the new emitter
  90045. */
  90046. clone(): BoxParticleEmitter;
  90047. /**
  90048. * Called by the GPUParticleSystem to setup the update shader
  90049. * @param effect defines the update shader
  90050. */
  90051. applyToShader(effect: Effect): void;
  90052. /**
  90053. * Returns a string to use to update the GPU particles update shader
  90054. * @returns a string containng the defines string
  90055. */
  90056. getEffectDefines(): string;
  90057. /**
  90058. * Returns the string "BoxParticleEmitter"
  90059. * @returns a string containing the class name
  90060. */
  90061. getClassName(): string;
  90062. /**
  90063. * Serializes the particle system to a JSON object.
  90064. * @returns the JSON object
  90065. */
  90066. serialize(): any;
  90067. /**
  90068. * Parse properties from a JSON object
  90069. * @param serializationObject defines the JSON object
  90070. */
  90071. parse(serializationObject: any): void;
  90072. }
  90073. }
  90074. declare module BABYLON {
  90075. /**
  90076. * Particle emitter emitting particles from the inside of a cone.
  90077. * It emits the particles alongside the cone volume from the base to the particle.
  90078. * The emission direction might be randomized.
  90079. */
  90080. export class ConeParticleEmitter implements IParticleEmitterType {
  90081. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90082. directionRandomizer: number;
  90083. private _radius;
  90084. private _angle;
  90085. private _height;
  90086. /**
  90087. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90088. */
  90089. radiusRange: number;
  90090. /**
  90091. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90092. */
  90093. heightRange: number;
  90094. /**
  90095. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90096. */
  90097. emitFromSpawnPointOnly: boolean;
  90098. /**
  90099. * Gets or sets the radius of the emission cone
  90100. */
  90101. get radius(): number;
  90102. set radius(value: number);
  90103. /**
  90104. * Gets or sets the angle of the emission cone
  90105. */
  90106. get angle(): number;
  90107. set angle(value: number);
  90108. private _buildHeight;
  90109. /**
  90110. * Creates a new instance ConeParticleEmitter
  90111. * @param radius the radius of the emission cone (1 by default)
  90112. * @param angle the cone base angle (PI by default)
  90113. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90114. */
  90115. constructor(radius?: number, angle?: number,
  90116. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90117. directionRandomizer?: number);
  90118. /**
  90119. * Called by the particle System when the direction is computed for the created particle.
  90120. * @param worldMatrix is the world matrix of the particle system
  90121. * @param directionToUpdate is the direction vector to update with the result
  90122. * @param particle is the particle we are computed the direction for
  90123. * @param isLocal defines if the direction should be set in local space
  90124. */
  90125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90126. /**
  90127. * Called by the particle System when the position is computed for the created particle.
  90128. * @param worldMatrix is the world matrix of the particle system
  90129. * @param positionToUpdate is the position vector to update with the result
  90130. * @param particle is the particle we are computed the position for
  90131. * @param isLocal defines if the position should be set in local space
  90132. */
  90133. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90134. /**
  90135. * Clones the current emitter and returns a copy of it
  90136. * @returns the new emitter
  90137. */
  90138. clone(): ConeParticleEmitter;
  90139. /**
  90140. * Called by the GPUParticleSystem to setup the update shader
  90141. * @param effect defines the update shader
  90142. */
  90143. applyToShader(effect: Effect): void;
  90144. /**
  90145. * Returns a string to use to update the GPU particles update shader
  90146. * @returns a string containng the defines string
  90147. */
  90148. getEffectDefines(): string;
  90149. /**
  90150. * Returns the string "ConeParticleEmitter"
  90151. * @returns a string containing the class name
  90152. */
  90153. getClassName(): string;
  90154. /**
  90155. * Serializes the particle system to a JSON object.
  90156. * @returns the JSON object
  90157. */
  90158. serialize(): any;
  90159. /**
  90160. * Parse properties from a JSON object
  90161. * @param serializationObject defines the JSON object
  90162. */
  90163. parse(serializationObject: any): void;
  90164. }
  90165. }
  90166. declare module BABYLON {
  90167. /**
  90168. * Particle emitter emitting particles from the inside of a cylinder.
  90169. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90170. */
  90171. export class CylinderParticleEmitter implements IParticleEmitterType {
  90172. /**
  90173. * The radius of the emission cylinder.
  90174. */
  90175. radius: number;
  90176. /**
  90177. * The height of the emission cylinder.
  90178. */
  90179. height: number;
  90180. /**
  90181. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90182. */
  90183. radiusRange: number;
  90184. /**
  90185. * How much to randomize the particle direction [0-1].
  90186. */
  90187. directionRandomizer: number;
  90188. /**
  90189. * Creates a new instance CylinderParticleEmitter
  90190. * @param radius the radius of the emission cylinder (1 by default)
  90191. * @param height the height of the emission cylinder (1 by default)
  90192. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90193. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90194. */
  90195. constructor(
  90196. /**
  90197. * The radius of the emission cylinder.
  90198. */
  90199. radius?: number,
  90200. /**
  90201. * The height of the emission cylinder.
  90202. */
  90203. height?: number,
  90204. /**
  90205. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90206. */
  90207. radiusRange?: number,
  90208. /**
  90209. * How much to randomize the particle direction [0-1].
  90210. */
  90211. directionRandomizer?: number);
  90212. /**
  90213. * Called by the particle System when the direction is computed for the created particle.
  90214. * @param worldMatrix is the world matrix of the particle system
  90215. * @param directionToUpdate is the direction vector to update with the result
  90216. * @param particle is the particle we are computed the direction for
  90217. * @param isLocal defines if the direction should be set in local space
  90218. */
  90219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90220. /**
  90221. * Called by the particle System when the position is computed for the created particle.
  90222. * @param worldMatrix is the world matrix of the particle system
  90223. * @param positionToUpdate is the position vector to update with the result
  90224. * @param particle is the particle we are computed the position for
  90225. * @param isLocal defines if the position should be set in local space
  90226. */
  90227. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90228. /**
  90229. * Clones the current emitter and returns a copy of it
  90230. * @returns the new emitter
  90231. */
  90232. clone(): CylinderParticleEmitter;
  90233. /**
  90234. * Called by the GPUParticleSystem to setup the update shader
  90235. * @param effect defines the update shader
  90236. */
  90237. applyToShader(effect: Effect): void;
  90238. /**
  90239. * Returns a string to use to update the GPU particles update shader
  90240. * @returns a string containng the defines string
  90241. */
  90242. getEffectDefines(): string;
  90243. /**
  90244. * Returns the string "CylinderParticleEmitter"
  90245. * @returns a string containing the class name
  90246. */
  90247. getClassName(): string;
  90248. /**
  90249. * Serializes the particle system to a JSON object.
  90250. * @returns the JSON object
  90251. */
  90252. serialize(): any;
  90253. /**
  90254. * Parse properties from a JSON object
  90255. * @param serializationObject defines the JSON object
  90256. */
  90257. parse(serializationObject: any): void;
  90258. }
  90259. /**
  90260. * Particle emitter emitting particles from the inside of a cylinder.
  90261. * It emits the particles randomly between two vectors.
  90262. */
  90263. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90264. /**
  90265. * The min limit of the emission direction.
  90266. */
  90267. direction1: Vector3;
  90268. /**
  90269. * The max limit of the emission direction.
  90270. */
  90271. direction2: Vector3;
  90272. /**
  90273. * Creates a new instance CylinderDirectedParticleEmitter
  90274. * @param radius the radius of the emission cylinder (1 by default)
  90275. * @param height the height of the emission cylinder (1 by default)
  90276. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90277. * @param direction1 the min limit of the emission direction (up vector by default)
  90278. * @param direction2 the max limit of the emission direction (up vector by default)
  90279. */
  90280. constructor(radius?: number, height?: number, radiusRange?: number,
  90281. /**
  90282. * The min limit of the emission direction.
  90283. */
  90284. direction1?: Vector3,
  90285. /**
  90286. * The max limit of the emission direction.
  90287. */
  90288. direction2?: Vector3);
  90289. /**
  90290. * Called by the particle System when the direction is computed for the created particle.
  90291. * @param worldMatrix is the world matrix of the particle system
  90292. * @param directionToUpdate is the direction vector to update with the result
  90293. * @param particle is the particle we are computed the direction for
  90294. */
  90295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90296. /**
  90297. * Clones the current emitter and returns a copy of it
  90298. * @returns the new emitter
  90299. */
  90300. clone(): CylinderDirectedParticleEmitter;
  90301. /**
  90302. * Called by the GPUParticleSystem to setup the update shader
  90303. * @param effect defines the update shader
  90304. */
  90305. applyToShader(effect: Effect): void;
  90306. /**
  90307. * Returns a string to use to update the GPU particles update shader
  90308. * @returns a string containng the defines string
  90309. */
  90310. getEffectDefines(): string;
  90311. /**
  90312. * Returns the string "CylinderDirectedParticleEmitter"
  90313. * @returns a string containing the class name
  90314. */
  90315. getClassName(): string;
  90316. /**
  90317. * Serializes the particle system to a JSON object.
  90318. * @returns the JSON object
  90319. */
  90320. serialize(): any;
  90321. /**
  90322. * Parse properties from a JSON object
  90323. * @param serializationObject defines the JSON object
  90324. */
  90325. parse(serializationObject: any): void;
  90326. }
  90327. }
  90328. declare module BABYLON {
  90329. /**
  90330. * Particle emitter emitting particles from the inside of a hemisphere.
  90331. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90332. */
  90333. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90334. /**
  90335. * The radius of the emission hemisphere.
  90336. */
  90337. radius: number;
  90338. /**
  90339. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90340. */
  90341. radiusRange: number;
  90342. /**
  90343. * How much to randomize the particle direction [0-1].
  90344. */
  90345. directionRandomizer: number;
  90346. /**
  90347. * Creates a new instance HemisphericParticleEmitter
  90348. * @param radius the radius of the emission hemisphere (1 by default)
  90349. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90350. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90351. */
  90352. constructor(
  90353. /**
  90354. * The radius of the emission hemisphere.
  90355. */
  90356. radius?: number,
  90357. /**
  90358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90359. */
  90360. radiusRange?: number,
  90361. /**
  90362. * How much to randomize the particle direction [0-1].
  90363. */
  90364. directionRandomizer?: number);
  90365. /**
  90366. * Called by the particle System when the direction is computed for the created particle.
  90367. * @param worldMatrix is the world matrix of the particle system
  90368. * @param directionToUpdate is the direction vector to update with the result
  90369. * @param particle is the particle we are computed the direction for
  90370. * @param isLocal defines if the direction should be set in local space
  90371. */
  90372. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90373. /**
  90374. * Called by the particle System when the position is computed for the created particle.
  90375. * @param worldMatrix is the world matrix of the particle system
  90376. * @param positionToUpdate is the position vector to update with the result
  90377. * @param particle is the particle we are computed the position for
  90378. * @param isLocal defines if the position should be set in local space
  90379. */
  90380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90381. /**
  90382. * Clones the current emitter and returns a copy of it
  90383. * @returns the new emitter
  90384. */
  90385. clone(): HemisphericParticleEmitter;
  90386. /**
  90387. * Called by the GPUParticleSystem to setup the update shader
  90388. * @param effect defines the update shader
  90389. */
  90390. applyToShader(effect: Effect): void;
  90391. /**
  90392. * Returns a string to use to update the GPU particles update shader
  90393. * @returns a string containng the defines string
  90394. */
  90395. getEffectDefines(): string;
  90396. /**
  90397. * Returns the string "HemisphericParticleEmitter"
  90398. * @returns a string containing the class name
  90399. */
  90400. getClassName(): string;
  90401. /**
  90402. * Serializes the particle system to a JSON object.
  90403. * @returns the JSON object
  90404. */
  90405. serialize(): any;
  90406. /**
  90407. * Parse properties from a JSON object
  90408. * @param serializationObject defines the JSON object
  90409. */
  90410. parse(serializationObject: any): void;
  90411. }
  90412. }
  90413. declare module BABYLON {
  90414. /**
  90415. * Particle emitter emitting particles from a point.
  90416. * It emits the particles randomly between 2 given directions.
  90417. */
  90418. export class PointParticleEmitter implements IParticleEmitterType {
  90419. /**
  90420. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90421. */
  90422. direction1: Vector3;
  90423. /**
  90424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90425. */
  90426. direction2: Vector3;
  90427. /**
  90428. * Creates a new instance PointParticleEmitter
  90429. */
  90430. constructor();
  90431. /**
  90432. * Called by the particle System when the direction is computed for the created particle.
  90433. * @param worldMatrix is the world matrix of the particle system
  90434. * @param directionToUpdate is the direction vector to update with the result
  90435. * @param particle is the particle we are computed the direction for
  90436. * @param isLocal defines if the direction should be set in local space
  90437. */
  90438. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90439. /**
  90440. * Called by the particle System when the position is computed for the created particle.
  90441. * @param worldMatrix is the world matrix of the particle system
  90442. * @param positionToUpdate is the position vector to update with the result
  90443. * @param particle is the particle we are computed the position for
  90444. * @param isLocal defines if the position should be set in local space
  90445. */
  90446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90447. /**
  90448. * Clones the current emitter and returns a copy of it
  90449. * @returns the new emitter
  90450. */
  90451. clone(): PointParticleEmitter;
  90452. /**
  90453. * Called by the GPUParticleSystem to setup the update shader
  90454. * @param effect defines the update shader
  90455. */
  90456. applyToShader(effect: Effect): void;
  90457. /**
  90458. * Returns a string to use to update the GPU particles update shader
  90459. * @returns a string containng the defines string
  90460. */
  90461. getEffectDefines(): string;
  90462. /**
  90463. * Returns the string "PointParticleEmitter"
  90464. * @returns a string containing the class name
  90465. */
  90466. getClassName(): string;
  90467. /**
  90468. * Serializes the particle system to a JSON object.
  90469. * @returns the JSON object
  90470. */
  90471. serialize(): any;
  90472. /**
  90473. * Parse properties from a JSON object
  90474. * @param serializationObject defines the JSON object
  90475. */
  90476. parse(serializationObject: any): void;
  90477. }
  90478. }
  90479. declare module BABYLON {
  90480. /**
  90481. * Particle emitter emitting particles from the inside of a sphere.
  90482. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90483. */
  90484. export class SphereParticleEmitter implements IParticleEmitterType {
  90485. /**
  90486. * The radius of the emission sphere.
  90487. */
  90488. radius: number;
  90489. /**
  90490. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90491. */
  90492. radiusRange: number;
  90493. /**
  90494. * How much to randomize the particle direction [0-1].
  90495. */
  90496. directionRandomizer: number;
  90497. /**
  90498. * Creates a new instance SphereParticleEmitter
  90499. * @param radius the radius of the emission sphere (1 by default)
  90500. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90501. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90502. */
  90503. constructor(
  90504. /**
  90505. * The radius of the emission sphere.
  90506. */
  90507. radius?: number,
  90508. /**
  90509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90510. */
  90511. radiusRange?: number,
  90512. /**
  90513. * How much to randomize the particle direction [0-1].
  90514. */
  90515. directionRandomizer?: number);
  90516. /**
  90517. * Called by the particle System when the direction is computed for the created particle.
  90518. * @param worldMatrix is the world matrix of the particle system
  90519. * @param directionToUpdate is the direction vector to update with the result
  90520. * @param particle is the particle we are computed the direction for
  90521. * @param isLocal defines if the direction should be set in local space
  90522. */
  90523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90524. /**
  90525. * Called by the particle System when the position is computed for the created particle.
  90526. * @param worldMatrix is the world matrix of the particle system
  90527. * @param positionToUpdate is the position vector to update with the result
  90528. * @param particle is the particle we are computed the position for
  90529. * @param isLocal defines if the position should be set in local space
  90530. */
  90531. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90532. /**
  90533. * Clones the current emitter and returns a copy of it
  90534. * @returns the new emitter
  90535. */
  90536. clone(): SphereParticleEmitter;
  90537. /**
  90538. * Called by the GPUParticleSystem to setup the update shader
  90539. * @param effect defines the update shader
  90540. */
  90541. applyToShader(effect: Effect): void;
  90542. /**
  90543. * Returns a string to use to update the GPU particles update shader
  90544. * @returns a string containng the defines string
  90545. */
  90546. getEffectDefines(): string;
  90547. /**
  90548. * Returns the string "SphereParticleEmitter"
  90549. * @returns a string containing the class name
  90550. */
  90551. getClassName(): string;
  90552. /**
  90553. * Serializes the particle system to a JSON object.
  90554. * @returns the JSON object
  90555. */
  90556. serialize(): any;
  90557. /**
  90558. * Parse properties from a JSON object
  90559. * @param serializationObject defines the JSON object
  90560. */
  90561. parse(serializationObject: any): void;
  90562. }
  90563. /**
  90564. * Particle emitter emitting particles from the inside of a sphere.
  90565. * It emits the particles randomly between two vectors.
  90566. */
  90567. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90568. /**
  90569. * The min limit of the emission direction.
  90570. */
  90571. direction1: Vector3;
  90572. /**
  90573. * The max limit of the emission direction.
  90574. */
  90575. direction2: Vector3;
  90576. /**
  90577. * Creates a new instance SphereDirectedParticleEmitter
  90578. * @param radius the radius of the emission sphere (1 by default)
  90579. * @param direction1 the min limit of the emission direction (up vector by default)
  90580. * @param direction2 the max limit of the emission direction (up vector by default)
  90581. */
  90582. constructor(radius?: number,
  90583. /**
  90584. * The min limit of the emission direction.
  90585. */
  90586. direction1?: Vector3,
  90587. /**
  90588. * The max limit of the emission direction.
  90589. */
  90590. direction2?: Vector3);
  90591. /**
  90592. * Called by the particle System when the direction is computed for the created particle.
  90593. * @param worldMatrix is the world matrix of the particle system
  90594. * @param directionToUpdate is the direction vector to update with the result
  90595. * @param particle is the particle we are computed the direction for
  90596. */
  90597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90598. /**
  90599. * Clones the current emitter and returns a copy of it
  90600. * @returns the new emitter
  90601. */
  90602. clone(): SphereDirectedParticleEmitter;
  90603. /**
  90604. * Called by the GPUParticleSystem to setup the update shader
  90605. * @param effect defines the update shader
  90606. */
  90607. applyToShader(effect: Effect): void;
  90608. /**
  90609. * Returns a string to use to update the GPU particles update shader
  90610. * @returns a string containng the defines string
  90611. */
  90612. getEffectDefines(): string;
  90613. /**
  90614. * Returns the string "SphereDirectedParticleEmitter"
  90615. * @returns a string containing the class name
  90616. */
  90617. getClassName(): string;
  90618. /**
  90619. * Serializes the particle system to a JSON object.
  90620. * @returns the JSON object
  90621. */
  90622. serialize(): any;
  90623. /**
  90624. * Parse properties from a JSON object
  90625. * @param serializationObject defines the JSON object
  90626. */
  90627. parse(serializationObject: any): void;
  90628. }
  90629. }
  90630. declare module BABYLON {
  90631. /**
  90632. * Particle emitter emitting particles from a custom list of positions.
  90633. */
  90634. export class CustomParticleEmitter implements IParticleEmitterType {
  90635. /**
  90636. * Gets or sets the position generator that will create the inital position of each particle.
  90637. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90638. */
  90639. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  90640. /**
  90641. * Gets or sets the destination generator that will create the final destination of each particle.
  90642. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90643. */
  90644. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  90645. /**
  90646. * Creates a new instance CustomParticleEmitter
  90647. */
  90648. constructor();
  90649. /**
  90650. * Called by the particle System when the direction is computed for the created particle.
  90651. * @param worldMatrix is the world matrix of the particle system
  90652. * @param directionToUpdate is the direction vector to update with the result
  90653. * @param particle is the particle we are computed the direction for
  90654. * @param isLocal defines if the direction should be set in local space
  90655. */
  90656. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90657. /**
  90658. * Called by the particle System when the position is computed for the created particle.
  90659. * @param worldMatrix is the world matrix of the particle system
  90660. * @param positionToUpdate is the position vector to update with the result
  90661. * @param particle is the particle we are computed the position for
  90662. * @param isLocal defines if the position should be set in local space
  90663. */
  90664. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90665. /**
  90666. * Clones the current emitter and returns a copy of it
  90667. * @returns the new emitter
  90668. */
  90669. clone(): CustomParticleEmitter;
  90670. /**
  90671. * Called by the GPUParticleSystem to setup the update shader
  90672. * @param effect defines the update shader
  90673. */
  90674. applyToShader(effect: Effect): void;
  90675. /**
  90676. * Returns a string to use to update the GPU particles update shader
  90677. * @returns a string containng the defines string
  90678. */
  90679. getEffectDefines(): string;
  90680. /**
  90681. * Returns the string "PointParticleEmitter"
  90682. * @returns a string containing the class name
  90683. */
  90684. getClassName(): string;
  90685. /**
  90686. * Serializes the particle system to a JSON object.
  90687. * @returns the JSON object
  90688. */
  90689. serialize(): any;
  90690. /**
  90691. * Parse properties from a JSON object
  90692. * @param serializationObject defines the JSON object
  90693. */
  90694. parse(serializationObject: any): void;
  90695. }
  90696. }
  90697. declare module BABYLON {
  90698. /**
  90699. * Particle emitter emitting particles from the inside of a box.
  90700. * It emits the particles randomly between 2 given directions.
  90701. */
  90702. export class MeshParticleEmitter implements IParticleEmitterType {
  90703. private _indices;
  90704. private _positions;
  90705. private _normals;
  90706. private _storedNormal;
  90707. private _mesh;
  90708. /**
  90709. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90710. */
  90711. direction1: Vector3;
  90712. /**
  90713. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90714. */
  90715. direction2: Vector3;
  90716. /**
  90717. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  90718. */
  90719. useMeshNormalsForDirection: boolean;
  90720. /** Defines the mesh to use as source */
  90721. get mesh(): Nullable<AbstractMesh>;
  90722. set mesh(value: Nullable<AbstractMesh>);
  90723. /**
  90724. * Creates a new instance MeshParticleEmitter
  90725. * @param mesh defines the mesh to use as source
  90726. */
  90727. constructor(mesh?: Nullable<AbstractMesh>);
  90728. /**
  90729. * Called by the particle System when the direction is computed for the created particle.
  90730. * @param worldMatrix is the world matrix of the particle system
  90731. * @param directionToUpdate is the direction vector to update with the result
  90732. * @param particle is the particle we are computed the direction for
  90733. * @param isLocal defines if the direction should be set in local space
  90734. */
  90735. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90736. /**
  90737. * Called by the particle System when the position is computed for the created particle.
  90738. * @param worldMatrix is the world matrix of the particle system
  90739. * @param positionToUpdate is the position vector to update with the result
  90740. * @param particle is the particle we are computed the position for
  90741. * @param isLocal defines if the position should be set in local space
  90742. */
  90743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90744. /**
  90745. * Clones the current emitter and returns a copy of it
  90746. * @returns the new emitter
  90747. */
  90748. clone(): MeshParticleEmitter;
  90749. /**
  90750. * Called by the GPUParticleSystem to setup the update shader
  90751. * @param effect defines the update shader
  90752. */
  90753. applyToShader(effect: Effect): void;
  90754. /**
  90755. * Returns a string to use to update the GPU particles update shader
  90756. * @returns a string containng the defines string
  90757. */
  90758. getEffectDefines(): string;
  90759. /**
  90760. * Returns the string "BoxParticleEmitter"
  90761. * @returns a string containing the class name
  90762. */
  90763. getClassName(): string;
  90764. /**
  90765. * Serializes the particle system to a JSON object.
  90766. * @returns the JSON object
  90767. */
  90768. serialize(): any;
  90769. /**
  90770. * Parse properties from a JSON object
  90771. * @param serializationObject defines the JSON object
  90772. * @param scene defines the hosting scene
  90773. */
  90774. parse(serializationObject: any, scene: Scene): void;
  90775. }
  90776. }
  90777. declare module BABYLON {
  90778. /**
  90779. * Interface representing a particle system in Babylon.js.
  90780. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  90781. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  90782. */
  90783. export interface IParticleSystem {
  90784. /**
  90785. * List of animations used by the particle system.
  90786. */
  90787. animations: Animation[];
  90788. /**
  90789. * The id of the Particle system.
  90790. */
  90791. id: string;
  90792. /**
  90793. * The name of the Particle system.
  90794. */
  90795. name: string;
  90796. /**
  90797. * The emitter represents the Mesh or position we are attaching the particle system to.
  90798. */
  90799. emitter: Nullable<AbstractMesh | Vector3>;
  90800. /**
  90801. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90802. */
  90803. isBillboardBased: boolean;
  90804. /**
  90805. * The rendering group used by the Particle system to chose when to render.
  90806. */
  90807. renderingGroupId: number;
  90808. /**
  90809. * The layer mask we are rendering the particles through.
  90810. */
  90811. layerMask: number;
  90812. /**
  90813. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90814. */
  90815. updateSpeed: number;
  90816. /**
  90817. * The amount of time the particle system is running (depends of the overall update speed).
  90818. */
  90819. targetStopDuration: number;
  90820. /**
  90821. * The texture used to render each particle. (this can be a spritesheet)
  90822. */
  90823. particleTexture: Nullable<Texture>;
  90824. /**
  90825. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  90826. */
  90827. blendMode: number;
  90828. /**
  90829. * Minimum life time of emitting particles.
  90830. */
  90831. minLifeTime: number;
  90832. /**
  90833. * Maximum life time of emitting particles.
  90834. */
  90835. maxLifeTime: number;
  90836. /**
  90837. * Minimum Size of emitting particles.
  90838. */
  90839. minSize: number;
  90840. /**
  90841. * Maximum Size of emitting particles.
  90842. */
  90843. maxSize: number;
  90844. /**
  90845. * Minimum scale of emitting particles on X axis.
  90846. */
  90847. minScaleX: number;
  90848. /**
  90849. * Maximum scale of emitting particles on X axis.
  90850. */
  90851. maxScaleX: number;
  90852. /**
  90853. * Minimum scale of emitting particles on Y axis.
  90854. */
  90855. minScaleY: number;
  90856. /**
  90857. * Maximum scale of emitting particles on Y axis.
  90858. */
  90859. maxScaleY: number;
  90860. /**
  90861. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90862. */
  90863. color1: Color4;
  90864. /**
  90865. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90866. */
  90867. color2: Color4;
  90868. /**
  90869. * Color the particle will have at the end of its lifetime.
  90870. */
  90871. colorDead: Color4;
  90872. /**
  90873. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  90874. */
  90875. emitRate: number;
  90876. /**
  90877. * You can use gravity if you want to give an orientation to your particles.
  90878. */
  90879. gravity: Vector3;
  90880. /**
  90881. * Minimum power of emitting particles.
  90882. */
  90883. minEmitPower: number;
  90884. /**
  90885. * Maximum power of emitting particles.
  90886. */
  90887. maxEmitPower: number;
  90888. /**
  90889. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90890. */
  90891. minAngularSpeed: number;
  90892. /**
  90893. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90894. */
  90895. maxAngularSpeed: number;
  90896. /**
  90897. * Gets or sets the minimal initial rotation in radians.
  90898. */
  90899. minInitialRotation: number;
  90900. /**
  90901. * Gets or sets the maximal initial rotation in radians.
  90902. */
  90903. maxInitialRotation: number;
  90904. /**
  90905. * The particle emitter type defines the emitter used by the particle system.
  90906. * It can be for example box, sphere, or cone...
  90907. */
  90908. particleEmitterType: Nullable<IParticleEmitterType>;
  90909. /**
  90910. * Defines the delay in milliseconds before starting the system (0 by default)
  90911. */
  90912. startDelay: number;
  90913. /**
  90914. * 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
  90915. */
  90916. preWarmCycles: number;
  90917. /**
  90918. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  90919. */
  90920. preWarmStepOffset: number;
  90921. /**
  90922. * 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)
  90923. */
  90924. spriteCellChangeSpeed: number;
  90925. /**
  90926. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90927. */
  90928. startSpriteCellID: number;
  90929. /**
  90930. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90931. */
  90932. endSpriteCellID: number;
  90933. /**
  90934. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90935. */
  90936. spriteCellWidth: number;
  90937. /**
  90938. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90939. */
  90940. spriteCellHeight: number;
  90941. /**
  90942. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90943. */
  90944. spriteRandomStartCell: boolean;
  90945. /**
  90946. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  90947. */
  90948. isAnimationSheetEnabled: boolean;
  90949. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90950. translationPivot: Vector2;
  90951. /**
  90952. * Gets or sets a texture used to add random noise to particle positions
  90953. */
  90954. noiseTexture: Nullable<BaseTexture>;
  90955. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90956. noiseStrength: Vector3;
  90957. /**
  90958. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90959. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90960. */
  90961. billboardMode: number;
  90962. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90963. limitVelocityDamping: number;
  90964. /**
  90965. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90966. */
  90967. beginAnimationOnStart: boolean;
  90968. /**
  90969. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90970. */
  90971. beginAnimationFrom: number;
  90972. /**
  90973. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90974. */
  90975. beginAnimationTo: number;
  90976. /**
  90977. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90978. */
  90979. beginAnimationLoop: boolean;
  90980. /**
  90981. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90982. */
  90983. disposeOnStop: boolean;
  90984. /**
  90985. * Specifies if the particles are updated in emitter local space or world space
  90986. */
  90987. isLocal: boolean;
  90988. /** Snippet ID if the particle system was created from the snippet server */
  90989. snippetId: string;
  90990. /**
  90991. * Gets the maximum number of particles active at the same time.
  90992. * @returns The max number of active particles.
  90993. */
  90994. getCapacity(): number;
  90995. /**
  90996. * Gets the number of particles active at the same time.
  90997. * @returns The number of active particles.
  90998. */
  90999. getActiveCount(): number;
  91000. /**
  91001. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91002. * @returns True if it has been started, otherwise false.
  91003. */
  91004. isStarted(): boolean;
  91005. /**
  91006. * Animates the particle system for this frame.
  91007. */
  91008. animate(): void;
  91009. /**
  91010. * Renders the particle system in its current state.
  91011. * @returns the current number of particles
  91012. */
  91013. render(): number;
  91014. /**
  91015. * Dispose the particle system and frees its associated resources.
  91016. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91017. */
  91018. dispose(disposeTexture?: boolean): void;
  91019. /**
  91020. * An event triggered when the system is disposed
  91021. */
  91022. onDisposeObservable: Observable<IParticleSystem>;
  91023. /**
  91024. * Clones the particle system.
  91025. * @param name The name of the cloned object
  91026. * @param newEmitter The new emitter to use
  91027. * @returns the cloned particle system
  91028. */
  91029. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91030. /**
  91031. * Serializes the particle system to a JSON object
  91032. * @param serializeTexture defines if the texture must be serialized as well
  91033. * @returns the JSON object
  91034. */
  91035. serialize(serializeTexture: boolean): any;
  91036. /**
  91037. * Rebuild the particle system
  91038. */
  91039. rebuild(): void;
  91040. /** Force the system to rebuild all gradients that need to be resync */
  91041. forceRefreshGradients(): void;
  91042. /**
  91043. * Starts the particle system and begins to emit
  91044. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91045. */
  91046. start(delay?: number): void;
  91047. /**
  91048. * Stops the particle system.
  91049. */
  91050. stop(): void;
  91051. /**
  91052. * Remove all active particles
  91053. */
  91054. reset(): void;
  91055. /**
  91056. * Gets a boolean indicating that the system is stopping
  91057. * @returns true if the system is currently stopping
  91058. */
  91059. isStopping(): boolean;
  91060. /**
  91061. * Is this system ready to be used/rendered
  91062. * @return true if the system is ready
  91063. */
  91064. isReady(): boolean;
  91065. /**
  91066. * Returns the string "ParticleSystem"
  91067. * @returns a string containing the class name
  91068. */
  91069. getClassName(): string;
  91070. /**
  91071. * Gets the custom effect used to render the particles
  91072. * @param blendMode Blend mode for which the effect should be retrieved
  91073. * @returns The effect
  91074. */
  91075. getCustomEffect(blendMode: number): Nullable<Effect>;
  91076. /**
  91077. * Sets the custom effect used to render the particles
  91078. * @param effect The effect to set
  91079. * @param blendMode Blend mode for which the effect should be set
  91080. */
  91081. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91082. /**
  91083. * Fill the defines array according to the current settings of the particle system
  91084. * @param defines Array to be updated
  91085. * @param blendMode blend mode to take into account when updating the array
  91086. */
  91087. fillDefines(defines: Array<string>, blendMode: number): void;
  91088. /**
  91089. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91090. * @param uniforms Uniforms array to fill
  91091. * @param attributes Attributes array to fill
  91092. * @param samplers Samplers array to fill
  91093. */
  91094. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91095. /**
  91096. * Observable that will be called just before the particles are drawn
  91097. */
  91098. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91099. /**
  91100. * Gets the name of the particle vertex shader
  91101. */
  91102. vertexShaderName: string;
  91103. /**
  91104. * Adds a new color gradient
  91105. * @param gradient defines the gradient to use (between 0 and 1)
  91106. * @param color1 defines the color to affect to the specified gradient
  91107. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91108. * @returns the current particle system
  91109. */
  91110. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91111. /**
  91112. * Remove a specific color gradient
  91113. * @param gradient defines the gradient to remove
  91114. * @returns the current particle system
  91115. */
  91116. removeColorGradient(gradient: number): IParticleSystem;
  91117. /**
  91118. * Adds a new size gradient
  91119. * @param gradient defines the gradient to use (between 0 and 1)
  91120. * @param factor defines the size factor to affect to the specified gradient
  91121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91122. * @returns the current particle system
  91123. */
  91124. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91125. /**
  91126. * Remove a specific size gradient
  91127. * @param gradient defines the gradient to remove
  91128. * @returns the current particle system
  91129. */
  91130. removeSizeGradient(gradient: number): IParticleSystem;
  91131. /**
  91132. * Gets the current list of color gradients.
  91133. * You must use addColorGradient and removeColorGradient to udpate this list
  91134. * @returns the list of color gradients
  91135. */
  91136. getColorGradients(): Nullable<Array<ColorGradient>>;
  91137. /**
  91138. * Gets the current list of size gradients.
  91139. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91140. * @returns the list of size gradients
  91141. */
  91142. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91143. /**
  91144. * Gets the current list of angular speed gradients.
  91145. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91146. * @returns the list of angular speed gradients
  91147. */
  91148. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91149. /**
  91150. * Adds a new angular speed gradient
  91151. * @param gradient defines the gradient to use (between 0 and 1)
  91152. * @param factor defines the angular speed to affect to the specified gradient
  91153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91154. * @returns the current particle system
  91155. */
  91156. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91157. /**
  91158. * Remove a specific angular speed gradient
  91159. * @param gradient defines the gradient to remove
  91160. * @returns the current particle system
  91161. */
  91162. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91163. /**
  91164. * Gets the current list of velocity gradients.
  91165. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91166. * @returns the list of velocity gradients
  91167. */
  91168. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91169. /**
  91170. * Adds a new velocity gradient
  91171. * @param gradient defines the gradient to use (between 0 and 1)
  91172. * @param factor defines the velocity to affect to the specified gradient
  91173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91174. * @returns the current particle system
  91175. */
  91176. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91177. /**
  91178. * Remove a specific velocity gradient
  91179. * @param gradient defines the gradient to remove
  91180. * @returns the current particle system
  91181. */
  91182. removeVelocityGradient(gradient: number): IParticleSystem;
  91183. /**
  91184. * Gets the current list of limit velocity gradients.
  91185. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91186. * @returns the list of limit velocity gradients
  91187. */
  91188. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91189. /**
  91190. * Adds a new limit velocity gradient
  91191. * @param gradient defines the gradient to use (between 0 and 1)
  91192. * @param factor defines the limit velocity to affect to the specified gradient
  91193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91194. * @returns the current particle system
  91195. */
  91196. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91197. /**
  91198. * Remove a specific limit velocity gradient
  91199. * @param gradient defines the gradient to remove
  91200. * @returns the current particle system
  91201. */
  91202. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91203. /**
  91204. * Adds a new drag gradient
  91205. * @param gradient defines the gradient to use (between 0 and 1)
  91206. * @param factor defines the drag to affect to the specified gradient
  91207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91208. * @returns the current particle system
  91209. */
  91210. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91211. /**
  91212. * Remove a specific drag gradient
  91213. * @param gradient defines the gradient to remove
  91214. * @returns the current particle system
  91215. */
  91216. removeDragGradient(gradient: number): IParticleSystem;
  91217. /**
  91218. * Gets the current list of drag gradients.
  91219. * You must use addDragGradient and removeDragGradient to udpate this list
  91220. * @returns the list of drag gradients
  91221. */
  91222. getDragGradients(): Nullable<Array<FactorGradient>>;
  91223. /**
  91224. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91225. * @param gradient defines the gradient to use (between 0 and 1)
  91226. * @param factor defines the emit rate to affect to the specified gradient
  91227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91228. * @returns the current particle system
  91229. */
  91230. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91231. /**
  91232. * Remove a specific emit rate gradient
  91233. * @param gradient defines the gradient to remove
  91234. * @returns the current particle system
  91235. */
  91236. removeEmitRateGradient(gradient: number): IParticleSystem;
  91237. /**
  91238. * Gets the current list of emit rate gradients.
  91239. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91240. * @returns the list of emit rate gradients
  91241. */
  91242. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91243. /**
  91244. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91245. * @param gradient defines the gradient to use (between 0 and 1)
  91246. * @param factor defines the start size to affect to the specified gradient
  91247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91248. * @returns the current particle system
  91249. */
  91250. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91251. /**
  91252. * Remove a specific start size gradient
  91253. * @param gradient defines the gradient to remove
  91254. * @returns the current particle system
  91255. */
  91256. removeStartSizeGradient(gradient: number): IParticleSystem;
  91257. /**
  91258. * Gets the current list of start size gradients.
  91259. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91260. * @returns the list of start size gradients
  91261. */
  91262. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91263. /**
  91264. * Adds a new life time gradient
  91265. * @param gradient defines the gradient to use (between 0 and 1)
  91266. * @param factor defines the life time factor to affect to the specified gradient
  91267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91268. * @returns the current particle system
  91269. */
  91270. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91271. /**
  91272. * Remove a specific life time gradient
  91273. * @param gradient defines the gradient to remove
  91274. * @returns the current particle system
  91275. */
  91276. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91277. /**
  91278. * Gets the current list of life time gradients.
  91279. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91280. * @returns the list of life time gradients
  91281. */
  91282. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91283. /**
  91284. * Gets the current list of color gradients.
  91285. * You must use addColorGradient and removeColorGradient to udpate this list
  91286. * @returns the list of color gradients
  91287. */
  91288. getColorGradients(): Nullable<Array<ColorGradient>>;
  91289. /**
  91290. * Adds a new ramp gradient used to remap particle colors
  91291. * @param gradient defines the gradient to use (between 0 and 1)
  91292. * @param color defines the color to affect to the specified gradient
  91293. * @returns the current particle system
  91294. */
  91295. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91296. /**
  91297. * Gets the current list of ramp gradients.
  91298. * You must use addRampGradient and removeRampGradient to udpate this list
  91299. * @returns the list of ramp gradients
  91300. */
  91301. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91302. /** Gets or sets a boolean indicating that ramp gradients must be used
  91303. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91304. */
  91305. useRampGradients: boolean;
  91306. /**
  91307. * Adds a new color remap gradient
  91308. * @param gradient defines the gradient to use (between 0 and 1)
  91309. * @param min defines the color remap minimal range
  91310. * @param max defines the color remap maximal range
  91311. * @returns the current particle system
  91312. */
  91313. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91314. /**
  91315. * Gets the current list of color remap gradients.
  91316. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91317. * @returns the list of color remap gradients
  91318. */
  91319. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91320. /**
  91321. * Adds a new alpha remap gradient
  91322. * @param gradient defines the gradient to use (between 0 and 1)
  91323. * @param min defines the alpha remap minimal range
  91324. * @param max defines the alpha remap maximal range
  91325. * @returns the current particle system
  91326. */
  91327. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91328. /**
  91329. * Gets the current list of alpha remap gradients.
  91330. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91331. * @returns the list of alpha remap gradients
  91332. */
  91333. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91334. /**
  91335. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91338. * @returns the emitter
  91339. */
  91340. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91341. /**
  91342. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91343. * @param radius The radius of the hemisphere to emit from
  91344. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91345. * @returns the emitter
  91346. */
  91347. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91348. /**
  91349. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91350. * @param radius The radius of the sphere to emit from
  91351. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91352. * @returns the emitter
  91353. */
  91354. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91355. /**
  91356. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91357. * @param radius The radius of the sphere to emit from
  91358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91360. * @returns the emitter
  91361. */
  91362. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91363. /**
  91364. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91365. * @param radius The radius of the emission cylinder
  91366. * @param height The height of the emission cylinder
  91367. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91368. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91369. * @returns the emitter
  91370. */
  91371. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91372. /**
  91373. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91374. * @param radius The radius of the cylinder to emit from
  91375. * @param height The height of the emission cylinder
  91376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91379. * @returns the emitter
  91380. */
  91381. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91382. /**
  91383. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91384. * @param radius The radius of the cone to emit from
  91385. * @param angle The base angle of the cone
  91386. * @returns the emitter
  91387. */
  91388. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91389. /**
  91390. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91391. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91392. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91393. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91394. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91395. * @returns the emitter
  91396. */
  91397. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91398. /**
  91399. * Get hosting scene
  91400. * @returns the scene
  91401. */
  91402. getScene(): Scene;
  91403. }
  91404. }
  91405. declare module BABYLON {
  91406. /**
  91407. * 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.
  91408. * @see https://doc.babylonjs.com/how_to/transformnode
  91409. */
  91410. export class TransformNode extends Node {
  91411. /**
  91412. * Object will not rotate to face the camera
  91413. */
  91414. static BILLBOARDMODE_NONE: number;
  91415. /**
  91416. * Object will rotate to face the camera but only on the x axis
  91417. */
  91418. static BILLBOARDMODE_X: number;
  91419. /**
  91420. * Object will rotate to face the camera but only on the y axis
  91421. */
  91422. static BILLBOARDMODE_Y: number;
  91423. /**
  91424. * Object will rotate to face the camera but only on the z axis
  91425. */
  91426. static BILLBOARDMODE_Z: number;
  91427. /**
  91428. * Object will rotate to face the camera
  91429. */
  91430. static BILLBOARDMODE_ALL: number;
  91431. /**
  91432. * Object will rotate to face the camera's position instead of orientation
  91433. */
  91434. static BILLBOARDMODE_USE_POSITION: number;
  91435. private _forward;
  91436. private _forwardInverted;
  91437. private _up;
  91438. private _right;
  91439. private _rightInverted;
  91440. private _position;
  91441. private _rotation;
  91442. private _rotationQuaternion;
  91443. protected _scaling: Vector3;
  91444. protected _isDirty: boolean;
  91445. private _transformToBoneReferal;
  91446. private _isAbsoluteSynced;
  91447. private _billboardMode;
  91448. /**
  91449. * Gets or sets the billboard mode. Default is 0.
  91450. *
  91451. * | Value | Type | Description |
  91452. * | --- | --- | --- |
  91453. * | 0 | BILLBOARDMODE_NONE | |
  91454. * | 1 | BILLBOARDMODE_X | |
  91455. * | 2 | BILLBOARDMODE_Y | |
  91456. * | 4 | BILLBOARDMODE_Z | |
  91457. * | 7 | BILLBOARDMODE_ALL | |
  91458. *
  91459. */
  91460. get billboardMode(): number;
  91461. set billboardMode(value: number);
  91462. private _preserveParentRotationForBillboard;
  91463. /**
  91464. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  91465. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  91466. */
  91467. get preserveParentRotationForBillboard(): boolean;
  91468. set preserveParentRotationForBillboard(value: boolean);
  91469. /**
  91470. * 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
  91471. */
  91472. scalingDeterminant: number;
  91473. private _infiniteDistance;
  91474. /**
  91475. * Gets or sets the distance of the object to max, often used by skybox
  91476. */
  91477. get infiniteDistance(): boolean;
  91478. set infiniteDistance(value: boolean);
  91479. /**
  91480. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91481. * By default the system will update normals to compensate
  91482. */
  91483. ignoreNonUniformScaling: boolean;
  91484. /**
  91485. * 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
  91486. */
  91487. reIntegrateRotationIntoRotationQuaternion: boolean;
  91488. /** @hidden */
  91489. _poseMatrix: Nullable<Matrix>;
  91490. /** @hidden */
  91491. _localMatrix: Matrix;
  91492. private _usePivotMatrix;
  91493. private _absolutePosition;
  91494. private _absoluteScaling;
  91495. private _absoluteRotationQuaternion;
  91496. private _pivotMatrix;
  91497. private _pivotMatrixInverse;
  91498. protected _postMultiplyPivotMatrix: boolean;
  91499. protected _isWorldMatrixFrozen: boolean;
  91500. /** @hidden */
  91501. _indexInSceneTransformNodesArray: number;
  91502. /**
  91503. * An event triggered after the world matrix is updated
  91504. */
  91505. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  91506. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  91507. /**
  91508. * Gets a string identifying the name of the class
  91509. * @returns "TransformNode" string
  91510. */
  91511. getClassName(): string;
  91512. /**
  91513. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91514. */
  91515. get position(): Vector3;
  91516. set position(newPosition: Vector3);
  91517. /**
  91518. * 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)).
  91519. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91520. */
  91521. get rotation(): Vector3;
  91522. set rotation(newRotation: Vector3);
  91523. /**
  91524. * 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)).
  91525. */
  91526. get scaling(): Vector3;
  91527. set scaling(newScaling: Vector3);
  91528. /**
  91529. * 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).
  91530. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91531. */
  91532. get rotationQuaternion(): Nullable<Quaternion>;
  91533. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  91534. /**
  91535. * The forward direction of that transform in world space.
  91536. */
  91537. get forward(): Vector3;
  91538. /**
  91539. * The up direction of that transform in world space.
  91540. */
  91541. get up(): Vector3;
  91542. /**
  91543. * The right direction of that transform in world space.
  91544. */
  91545. get right(): Vector3;
  91546. /**
  91547. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91548. * @param matrix the matrix to copy the pose from
  91549. * @returns this TransformNode.
  91550. */
  91551. updatePoseMatrix(matrix: Matrix): TransformNode;
  91552. /**
  91553. * Returns the mesh Pose matrix.
  91554. * @returns the pose matrix
  91555. */
  91556. getPoseMatrix(): Matrix;
  91557. /** @hidden */
  91558. _isSynchronized(): boolean;
  91559. /** @hidden */
  91560. _initCache(): void;
  91561. /**
  91562. * Flag the transform node as dirty (Forcing it to update everything)
  91563. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91564. * @returns this transform node
  91565. */
  91566. markAsDirty(property: string): TransformNode;
  91567. /**
  91568. * Returns the current mesh absolute position.
  91569. * Returns a Vector3.
  91570. */
  91571. get absolutePosition(): Vector3;
  91572. /**
  91573. * Returns the current mesh absolute scaling.
  91574. * Returns a Vector3.
  91575. */
  91576. get absoluteScaling(): Vector3;
  91577. /**
  91578. * Returns the current mesh absolute rotation.
  91579. * Returns a Quaternion.
  91580. */
  91581. get absoluteRotationQuaternion(): Quaternion;
  91582. /**
  91583. * Sets a new matrix to apply before all other transformation
  91584. * @param matrix defines the transform matrix
  91585. * @returns the current TransformNode
  91586. */
  91587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  91588. /**
  91589. * Sets a new pivot matrix to the current node
  91590. * @param matrix defines the new pivot matrix to use
  91591. * @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
  91592. * @returns the current TransformNode
  91593. */
  91594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  91595. /**
  91596. * Returns the mesh pivot matrix.
  91597. * Default : Identity.
  91598. * @returns the matrix
  91599. */
  91600. getPivotMatrix(): Matrix;
  91601. /**
  91602. * Instantiate (when possible) or clone that node with its hierarchy
  91603. * @param newParent defines the new parent to use for the instance (or clone)
  91604. * @param options defines options to configure how copy is done
  91605. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  91606. * @returns an instance (or a clone) of the current node with its hiearchy
  91607. */
  91608. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91609. doNotInstantiate: boolean;
  91610. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91611. /**
  91612. * Prevents the World matrix to be computed any longer
  91613. * @param newWorldMatrix defines an optional matrix to use as world matrix
  91614. * @returns the TransformNode.
  91615. */
  91616. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  91617. /**
  91618. * Allows back the World matrix computation.
  91619. * @returns the TransformNode.
  91620. */
  91621. unfreezeWorldMatrix(): this;
  91622. /**
  91623. * True if the World matrix has been frozen.
  91624. */
  91625. get isWorldMatrixFrozen(): boolean;
  91626. /**
  91627. * Retuns the mesh absolute position in the World.
  91628. * @returns a Vector3.
  91629. */
  91630. getAbsolutePosition(): Vector3;
  91631. /**
  91632. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  91633. * @param absolutePosition the absolute position to set
  91634. * @returns the TransformNode.
  91635. */
  91636. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91637. /**
  91638. * Sets the mesh position in its local space.
  91639. * @param vector3 the position to set in localspace
  91640. * @returns the TransformNode.
  91641. */
  91642. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  91643. /**
  91644. * Returns the mesh position in the local space from the current World matrix values.
  91645. * @returns a new Vector3.
  91646. */
  91647. getPositionExpressedInLocalSpace(): Vector3;
  91648. /**
  91649. * Translates the mesh along the passed Vector3 in its local space.
  91650. * @param vector3 the distance to translate in localspace
  91651. * @returns the TransformNode.
  91652. */
  91653. locallyTranslate(vector3: Vector3): TransformNode;
  91654. private static _lookAtVectorCache;
  91655. /**
  91656. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  91657. * @param targetPoint the position (must be in same space as current mesh) to look at
  91658. * @param yawCor optional yaw (y-axis) correction in radians
  91659. * @param pitchCor optional pitch (x-axis) correction in radians
  91660. * @param rollCor optional roll (z-axis) correction in radians
  91661. * @param space the choosen space of the target
  91662. * @returns the TransformNode.
  91663. */
  91664. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  91665. /**
  91666. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91667. * This Vector3 is expressed in the World space.
  91668. * @param localAxis axis to rotate
  91669. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91670. */
  91671. getDirection(localAxis: Vector3): Vector3;
  91672. /**
  91673. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  91674. * localAxis is expressed in the mesh local space.
  91675. * result is computed in the Wordl space from the mesh World matrix.
  91676. * @param localAxis axis to rotate
  91677. * @param result the resulting transformnode
  91678. * @returns this TransformNode.
  91679. */
  91680. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  91681. /**
  91682. * Sets this transform node rotation to the given local axis.
  91683. * @param localAxis the axis in local space
  91684. * @param yawCor optional yaw (y-axis) correction in radians
  91685. * @param pitchCor optional pitch (x-axis) correction in radians
  91686. * @param rollCor optional roll (z-axis) correction in radians
  91687. * @returns this TransformNode
  91688. */
  91689. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  91690. /**
  91691. * Sets a new pivot point to the current node
  91692. * @param point defines the new pivot point to use
  91693. * @param space defines if the point is in world or local space (local by default)
  91694. * @returns the current TransformNode
  91695. */
  91696. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  91697. /**
  91698. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  91699. * @returns the pivot point
  91700. */
  91701. getPivotPoint(): Vector3;
  91702. /**
  91703. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  91704. * @param result the vector3 to store the result
  91705. * @returns this TransformNode.
  91706. */
  91707. getPivotPointToRef(result: Vector3): TransformNode;
  91708. /**
  91709. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  91710. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  91711. */
  91712. getAbsolutePivotPoint(): Vector3;
  91713. /**
  91714. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  91715. * @param result vector3 to store the result
  91716. * @returns this TransformNode.
  91717. */
  91718. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  91719. /**
  91720. * Defines the passed node as the parent of the current node.
  91721. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  91722. * @see https://doc.babylonjs.com/how_to/parenting
  91723. * @param node the node ot set as the parent
  91724. * @returns this TransformNode.
  91725. */
  91726. setParent(node: Nullable<Node>): TransformNode;
  91727. private _nonUniformScaling;
  91728. /**
  91729. * True if the scaling property of this object is non uniform eg. (1,2,1)
  91730. */
  91731. get nonUniformScaling(): boolean;
  91732. /** @hidden */
  91733. _updateNonUniformScalingState(value: boolean): boolean;
  91734. /**
  91735. * Attach the current TransformNode to another TransformNode associated with a bone
  91736. * @param bone Bone affecting the TransformNode
  91737. * @param affectedTransformNode TransformNode associated with the bone
  91738. * @returns this object
  91739. */
  91740. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  91741. /**
  91742. * Detach the transform node if its associated with a bone
  91743. * @returns this object
  91744. */
  91745. detachFromBone(): TransformNode;
  91746. private static _rotationAxisCache;
  91747. /**
  91748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  91749. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  91750. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  91751. * The passed axis is also normalized.
  91752. * @param axis the axis to rotate around
  91753. * @param amount the amount to rotate in radians
  91754. * @param space Space to rotate in (Default: local)
  91755. * @returns the TransformNode.
  91756. */
  91757. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91758. /**
  91759. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  91760. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  91761. * The passed axis is also normalized. .
  91762. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  91763. * @param point the point to rotate around
  91764. * @param axis the axis to rotate around
  91765. * @param amount the amount to rotate in radians
  91766. * @returns the TransformNode
  91767. */
  91768. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  91769. /**
  91770. * Translates the mesh along the axis vector for the passed distance in the given space.
  91771. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  91772. * @param axis the axis to translate in
  91773. * @param distance the distance to translate
  91774. * @param space Space to rotate in (Default: local)
  91775. * @returns the TransformNode.
  91776. */
  91777. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91778. /**
  91779. * Adds a rotation step to the mesh current rotation.
  91780. * x, y, z are Euler angles expressed in radians.
  91781. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  91782. * This means this rotation is made in the mesh local space only.
  91783. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  91784. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  91785. * ```javascript
  91786. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  91787. * ```
  91788. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  91789. * 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.
  91790. * @param x Rotation to add
  91791. * @param y Rotation to add
  91792. * @param z Rotation to add
  91793. * @returns the TransformNode.
  91794. */
  91795. addRotation(x: number, y: number, z: number): TransformNode;
  91796. /**
  91797. * @hidden
  91798. */
  91799. protected _getEffectiveParent(): Nullable<Node>;
  91800. /**
  91801. * Computes the world matrix of the node
  91802. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91803. * @returns the world matrix
  91804. */
  91805. computeWorldMatrix(force?: boolean): Matrix;
  91806. /**
  91807. * Resets this nodeTransform's local matrix to Matrix.Identity().
  91808. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  91809. */
  91810. resetLocalMatrix(independentOfChildren?: boolean): void;
  91811. protected _afterComputeWorldMatrix(): void;
  91812. /**
  91813. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  91814. * @param func callback function to add
  91815. *
  91816. * @returns the TransformNode.
  91817. */
  91818. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  91819. /**
  91820. * Removes a registered callback function.
  91821. * @param func callback function to remove
  91822. * @returns the TransformNode.
  91823. */
  91824. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  91825. /**
  91826. * Gets the position of the current mesh in camera space
  91827. * @param camera defines the camera to use
  91828. * @returns a position
  91829. */
  91830. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  91831. /**
  91832. * Returns the distance from the mesh to the active camera
  91833. * @param camera defines the camera to use
  91834. * @returns the distance
  91835. */
  91836. getDistanceToCamera(camera?: Nullable<Camera>): number;
  91837. /**
  91838. * Clone the current transform node
  91839. * @param name Name of the new clone
  91840. * @param newParent New parent for the clone
  91841. * @param doNotCloneChildren Do not clone children hierarchy
  91842. * @returns the new transform node
  91843. */
  91844. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  91845. /**
  91846. * Serializes the objects information.
  91847. * @param currentSerializationObject defines the object to serialize in
  91848. * @returns the serialized object
  91849. */
  91850. serialize(currentSerializationObject?: any): any;
  91851. /**
  91852. * Returns a new TransformNode object parsed from the source provided.
  91853. * @param parsedTransformNode is the source.
  91854. * @param scene the scne the object belongs to
  91855. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  91856. * @returns a new TransformNode object parsed from the source provided.
  91857. */
  91858. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  91859. /**
  91860. * Get all child-transformNodes of this node
  91861. * @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
  91862. * @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
  91863. * @returns an array of TransformNode
  91864. */
  91865. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  91866. /**
  91867. * Releases resources associated with this transform node.
  91868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91870. */
  91871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91872. /**
  91873. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91874. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91875. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91876. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91877. * @returns the current mesh
  91878. */
  91879. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  91880. private _syncAbsoluteScalingAndRotation;
  91881. }
  91882. }
  91883. declare module BABYLON {
  91884. /**
  91885. * Class used to override all child animations of a given target
  91886. */
  91887. export class AnimationPropertiesOverride {
  91888. /**
  91889. * Gets or sets a value indicating if animation blending must be used
  91890. */
  91891. enableBlending: boolean;
  91892. /**
  91893. * Gets or sets the blending speed to use when enableBlending is true
  91894. */
  91895. blendingSpeed: number;
  91896. /**
  91897. * Gets or sets the default loop mode to use
  91898. */
  91899. loopMode: number;
  91900. }
  91901. }
  91902. declare module BABYLON {
  91903. /**
  91904. * Class used to store bone information
  91905. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91906. */
  91907. export class Bone extends Node {
  91908. /**
  91909. * defines the bone name
  91910. */
  91911. name: string;
  91912. private static _tmpVecs;
  91913. private static _tmpQuat;
  91914. private static _tmpMats;
  91915. /**
  91916. * Gets the list of child bones
  91917. */
  91918. children: Bone[];
  91919. /** Gets the animations associated with this bone */
  91920. animations: Animation[];
  91921. /**
  91922. * Gets or sets bone length
  91923. */
  91924. length: number;
  91925. /**
  91926. * @hidden Internal only
  91927. * Set this value to map this bone to a different index in the transform matrices
  91928. * Set this value to -1 to exclude the bone from the transform matrices
  91929. */
  91930. _index: Nullable<number>;
  91931. private _skeleton;
  91932. private _localMatrix;
  91933. private _restPose;
  91934. private _baseMatrix;
  91935. private _absoluteTransform;
  91936. private _invertedAbsoluteTransform;
  91937. private _parent;
  91938. private _scalingDeterminant;
  91939. private _worldTransform;
  91940. private _localScaling;
  91941. private _localRotation;
  91942. private _localPosition;
  91943. private _needToDecompose;
  91944. private _needToCompose;
  91945. /** @hidden */
  91946. _linkedTransformNode: Nullable<TransformNode>;
  91947. /** @hidden */
  91948. _waitingTransformNodeId: Nullable<string>;
  91949. /** @hidden */
  91950. get _matrix(): Matrix;
  91951. /** @hidden */
  91952. set _matrix(value: Matrix);
  91953. /**
  91954. * Create a new bone
  91955. * @param name defines the bone name
  91956. * @param skeleton defines the parent skeleton
  91957. * @param parentBone defines the parent (can be null if the bone is the root)
  91958. * @param localMatrix defines the local matrix
  91959. * @param restPose defines the rest pose matrix
  91960. * @param baseMatrix defines the base matrix
  91961. * @param index defines index of the bone in the hiearchy
  91962. */
  91963. constructor(
  91964. /**
  91965. * defines the bone name
  91966. */
  91967. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  91968. /**
  91969. * Gets the current object class name.
  91970. * @return the class name
  91971. */
  91972. getClassName(): string;
  91973. /**
  91974. * Gets the parent skeleton
  91975. * @returns a skeleton
  91976. */
  91977. getSkeleton(): Skeleton;
  91978. /**
  91979. * Gets parent bone
  91980. * @returns a bone or null if the bone is the root of the bone hierarchy
  91981. */
  91982. getParent(): Nullable<Bone>;
  91983. /**
  91984. * Returns an array containing the root bones
  91985. * @returns an array containing the root bones
  91986. */
  91987. getChildren(): Array<Bone>;
  91988. /**
  91989. * Gets the node index in matrix array generated for rendering
  91990. * @returns the node index
  91991. */
  91992. getIndex(): number;
  91993. /**
  91994. * Sets the parent bone
  91995. * @param parent defines the parent (can be null if the bone is the root)
  91996. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  91997. */
  91998. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  91999. /**
  92000. * Gets the local matrix
  92001. * @returns a matrix
  92002. */
  92003. getLocalMatrix(): Matrix;
  92004. /**
  92005. * Gets the base matrix (initial matrix which remains unchanged)
  92006. * @returns a matrix
  92007. */
  92008. getBaseMatrix(): Matrix;
  92009. /**
  92010. * Gets the rest pose matrix
  92011. * @returns a matrix
  92012. */
  92013. getRestPose(): Matrix;
  92014. /**
  92015. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92016. */
  92017. getWorldMatrix(): Matrix;
  92018. /**
  92019. * Sets the local matrix to rest pose matrix
  92020. */
  92021. returnToRest(): void;
  92022. /**
  92023. * Gets the inverse of the absolute transform matrix.
  92024. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92025. * @returns a matrix
  92026. */
  92027. getInvertedAbsoluteTransform(): Matrix;
  92028. /**
  92029. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92030. * @returns a matrix
  92031. */
  92032. getAbsoluteTransform(): Matrix;
  92033. /**
  92034. * Links with the given transform node.
  92035. * The local matrix of this bone is copied from the transform node every frame.
  92036. * @param transformNode defines the transform node to link to
  92037. */
  92038. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92039. /**
  92040. * Gets the node used to drive the bone's transformation
  92041. * @returns a transform node or null
  92042. */
  92043. getTransformNode(): Nullable<TransformNode>;
  92044. /** Gets or sets current position (in local space) */
  92045. get position(): Vector3;
  92046. set position(newPosition: Vector3);
  92047. /** Gets or sets current rotation (in local space) */
  92048. get rotation(): Vector3;
  92049. set rotation(newRotation: Vector3);
  92050. /** Gets or sets current rotation quaternion (in local space) */
  92051. get rotationQuaternion(): Quaternion;
  92052. set rotationQuaternion(newRotation: Quaternion);
  92053. /** Gets or sets current scaling (in local space) */
  92054. get scaling(): Vector3;
  92055. set scaling(newScaling: Vector3);
  92056. /**
  92057. * Gets the animation properties override
  92058. */
  92059. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92060. private _decompose;
  92061. private _compose;
  92062. /**
  92063. * Update the base and local matrices
  92064. * @param matrix defines the new base or local matrix
  92065. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92066. * @param updateLocalMatrix defines if the local matrix should be updated
  92067. */
  92068. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92069. /** @hidden */
  92070. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92071. /**
  92072. * Flag the bone as dirty (Forcing it to update everything)
  92073. */
  92074. markAsDirty(): void;
  92075. /** @hidden */
  92076. _markAsDirtyAndCompose(): void;
  92077. private _markAsDirtyAndDecompose;
  92078. /**
  92079. * Translate the bone in local or world space
  92080. * @param vec The amount to translate the bone
  92081. * @param space The space that the translation is in
  92082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92083. */
  92084. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92085. /**
  92086. * Set the postion of the bone in local or world space
  92087. * @param position The position to set the bone
  92088. * @param space The space that the position is in
  92089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92090. */
  92091. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92092. /**
  92093. * Set the absolute position of the bone (world space)
  92094. * @param position The position to set the bone
  92095. * @param mesh The mesh that this bone is attached to
  92096. */
  92097. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92098. /**
  92099. * Scale the bone on the x, y and z axes (in local space)
  92100. * @param x The amount to scale the bone on the x axis
  92101. * @param y The amount to scale the bone on the y axis
  92102. * @param z The amount to scale the bone on the z axis
  92103. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92104. */
  92105. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92106. /**
  92107. * Set the bone scaling in local space
  92108. * @param scale defines the scaling vector
  92109. */
  92110. setScale(scale: Vector3): void;
  92111. /**
  92112. * Gets the current scaling in local space
  92113. * @returns the current scaling vector
  92114. */
  92115. getScale(): Vector3;
  92116. /**
  92117. * Gets the current scaling in local space and stores it in a target vector
  92118. * @param result defines the target vector
  92119. */
  92120. getScaleToRef(result: Vector3): void;
  92121. /**
  92122. * Set the yaw, pitch, and roll of the bone in local or world space
  92123. * @param yaw The rotation of the bone on the y axis
  92124. * @param pitch The rotation of the bone on the x axis
  92125. * @param roll The rotation of the bone on the z axis
  92126. * @param space The space that the axes of rotation are in
  92127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92128. */
  92129. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92130. /**
  92131. * Add a rotation to the bone on an axis in local or world space
  92132. * @param axis The axis to rotate the bone on
  92133. * @param amount The amount to rotate the bone
  92134. * @param space The space that the axis is in
  92135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92136. */
  92137. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92138. /**
  92139. * Set the rotation of the bone to a particular axis angle in local or world space
  92140. * @param axis The axis to rotate the bone on
  92141. * @param angle The angle that the bone should be rotated to
  92142. * @param space The space that the axis is in
  92143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92144. */
  92145. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92146. /**
  92147. * Set the euler rotation of the bone in local of world space
  92148. * @param rotation The euler rotation that the bone should be set to
  92149. * @param space The space that the rotation is in
  92150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92151. */
  92152. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92153. /**
  92154. * Set the quaternion rotation of the bone in local of world space
  92155. * @param quat The quaternion rotation that the bone should be set to
  92156. * @param space The space that the rotation is in
  92157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92158. */
  92159. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92160. /**
  92161. * Set the rotation matrix of the bone in local of world space
  92162. * @param rotMat The rotation matrix that the bone should be set to
  92163. * @param space The space that the rotation is in
  92164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92165. */
  92166. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92167. private _rotateWithMatrix;
  92168. private _getNegativeRotationToRef;
  92169. /**
  92170. * Get the position of the bone in local or world space
  92171. * @param space The space that the returned position is in
  92172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92173. * @returns The position of the bone
  92174. */
  92175. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92176. /**
  92177. * Copy the position of the bone to a vector3 in local or world space
  92178. * @param space The space that the returned position is in
  92179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92180. * @param result The vector3 to copy the position to
  92181. */
  92182. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92183. /**
  92184. * Get the absolute position of the bone (world space)
  92185. * @param mesh The mesh that this bone is attached to
  92186. * @returns The absolute position of the bone
  92187. */
  92188. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92189. /**
  92190. * Copy the absolute position of the bone (world space) to the result param
  92191. * @param mesh The mesh that this bone is attached to
  92192. * @param result The vector3 to copy the absolute position to
  92193. */
  92194. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92195. /**
  92196. * Compute the absolute transforms of this bone and its children
  92197. */
  92198. computeAbsoluteTransforms(): void;
  92199. /**
  92200. * Get the world direction from an axis that is in the local space of the bone
  92201. * @param localAxis The local direction that is used to compute the world direction
  92202. * @param mesh The mesh that this bone is attached to
  92203. * @returns The world direction
  92204. */
  92205. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92206. /**
  92207. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92208. * @param localAxis The local direction that is used to compute the world direction
  92209. * @param mesh The mesh that this bone is attached to
  92210. * @param result The vector3 that the world direction will be copied to
  92211. */
  92212. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92213. /**
  92214. * Get the euler rotation of the bone in local or world space
  92215. * @param space The space that the rotation should be in
  92216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92217. * @returns The euler rotation
  92218. */
  92219. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92220. /**
  92221. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92222. * @param space The space that the rotation should be in
  92223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92224. * @param result The vector3 that the rotation should be copied to
  92225. */
  92226. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92227. /**
  92228. * Get the quaternion rotation of the bone in either local or world space
  92229. * @param space The space that the rotation should be in
  92230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92231. * @returns The quaternion rotation
  92232. */
  92233. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92234. /**
  92235. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92236. * @param space The space that the rotation should be in
  92237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92238. * @param result The quaternion that the rotation should be copied to
  92239. */
  92240. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92241. /**
  92242. * Get the rotation matrix of the bone in local or world space
  92243. * @param space The space that the rotation should be in
  92244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92245. * @returns The rotation matrix
  92246. */
  92247. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92248. /**
  92249. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92250. * @param space The space that the rotation should be in
  92251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92252. * @param result The quaternion that the rotation should be copied to
  92253. */
  92254. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92255. /**
  92256. * Get the world position of a point that is in the local space of the bone
  92257. * @param position The local position
  92258. * @param mesh The mesh that this bone is attached to
  92259. * @returns The world position
  92260. */
  92261. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92262. /**
  92263. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92264. * @param position The local position
  92265. * @param mesh The mesh that this bone is attached to
  92266. * @param result The vector3 that the world position should be copied to
  92267. */
  92268. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92269. /**
  92270. * Get the local position of a point that is in world space
  92271. * @param position The world position
  92272. * @param mesh The mesh that this bone is attached to
  92273. * @returns The local position
  92274. */
  92275. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92276. /**
  92277. * Get the local position of a point that is in world space and copy it to the result param
  92278. * @param position The world position
  92279. * @param mesh The mesh that this bone is attached to
  92280. * @param result The vector3 that the local position should be copied to
  92281. */
  92282. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92283. }
  92284. }
  92285. declare module BABYLON {
  92286. /**
  92287. * Defines a runtime animation
  92288. */
  92289. export class RuntimeAnimation {
  92290. private _events;
  92291. /**
  92292. * The current frame of the runtime animation
  92293. */
  92294. private _currentFrame;
  92295. /**
  92296. * The animation used by the runtime animation
  92297. */
  92298. private _animation;
  92299. /**
  92300. * The target of the runtime animation
  92301. */
  92302. private _target;
  92303. /**
  92304. * The initiating animatable
  92305. */
  92306. private _host;
  92307. /**
  92308. * The original value of the runtime animation
  92309. */
  92310. private _originalValue;
  92311. /**
  92312. * The original blend value of the runtime animation
  92313. */
  92314. private _originalBlendValue;
  92315. /**
  92316. * The offsets cache of the runtime animation
  92317. */
  92318. private _offsetsCache;
  92319. /**
  92320. * The high limits cache of the runtime animation
  92321. */
  92322. private _highLimitsCache;
  92323. /**
  92324. * Specifies if the runtime animation has been stopped
  92325. */
  92326. private _stopped;
  92327. /**
  92328. * The blending factor of the runtime animation
  92329. */
  92330. private _blendingFactor;
  92331. /**
  92332. * The BabylonJS scene
  92333. */
  92334. private _scene;
  92335. /**
  92336. * The current value of the runtime animation
  92337. */
  92338. private _currentValue;
  92339. /** @hidden */
  92340. _animationState: _IAnimationState;
  92341. /**
  92342. * The active target of the runtime animation
  92343. */
  92344. private _activeTargets;
  92345. private _currentActiveTarget;
  92346. private _directTarget;
  92347. /**
  92348. * The target path of the runtime animation
  92349. */
  92350. private _targetPath;
  92351. /**
  92352. * The weight of the runtime animation
  92353. */
  92354. private _weight;
  92355. /**
  92356. * The ratio offset of the runtime animation
  92357. */
  92358. private _ratioOffset;
  92359. /**
  92360. * The previous delay of the runtime animation
  92361. */
  92362. private _previousDelay;
  92363. /**
  92364. * The previous ratio of the runtime animation
  92365. */
  92366. private _previousRatio;
  92367. private _enableBlending;
  92368. private _keys;
  92369. private _minFrame;
  92370. private _maxFrame;
  92371. private _minValue;
  92372. private _maxValue;
  92373. private _targetIsArray;
  92374. /**
  92375. * Gets the current frame of the runtime animation
  92376. */
  92377. get currentFrame(): number;
  92378. /**
  92379. * Gets the weight of the runtime animation
  92380. */
  92381. get weight(): number;
  92382. /**
  92383. * Gets the current value of the runtime animation
  92384. */
  92385. get currentValue(): any;
  92386. /**
  92387. * Gets the target path of the runtime animation
  92388. */
  92389. get targetPath(): string;
  92390. /**
  92391. * Gets the actual target of the runtime animation
  92392. */
  92393. get target(): any;
  92394. /**
  92395. * Gets the additive state of the runtime animation
  92396. */
  92397. get isAdditive(): boolean;
  92398. /** @hidden */
  92399. _onLoop: () => void;
  92400. /**
  92401. * Create a new RuntimeAnimation object
  92402. * @param target defines the target of the animation
  92403. * @param animation defines the source animation object
  92404. * @param scene defines the hosting scene
  92405. * @param host defines the initiating Animatable
  92406. */
  92407. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  92408. private _preparePath;
  92409. /**
  92410. * Gets the animation from the runtime animation
  92411. */
  92412. get animation(): Animation;
  92413. /**
  92414. * Resets the runtime animation to the beginning
  92415. * @param restoreOriginal defines whether to restore the target property to the original value
  92416. */
  92417. reset(restoreOriginal?: boolean): void;
  92418. /**
  92419. * Specifies if the runtime animation is stopped
  92420. * @returns Boolean specifying if the runtime animation is stopped
  92421. */
  92422. isStopped(): boolean;
  92423. /**
  92424. * Disposes of the runtime animation
  92425. */
  92426. dispose(): void;
  92427. /**
  92428. * Apply the interpolated value to the target
  92429. * @param currentValue defines the value computed by the animation
  92430. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  92431. */
  92432. setValue(currentValue: any, weight: number): void;
  92433. private _getOriginalValues;
  92434. private _setValue;
  92435. /**
  92436. * Gets the loop pmode of the runtime animation
  92437. * @returns Loop Mode
  92438. */
  92439. private _getCorrectLoopMode;
  92440. /**
  92441. * Move the current animation to a given frame
  92442. * @param frame defines the frame to move to
  92443. */
  92444. goToFrame(frame: number): void;
  92445. /**
  92446. * @hidden Internal use only
  92447. */
  92448. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  92449. /**
  92450. * Execute the current animation
  92451. * @param delay defines the delay to add to the current frame
  92452. * @param from defines the lower bound of the animation range
  92453. * @param to defines the upper bound of the animation range
  92454. * @param loop defines if the current animation must loop
  92455. * @param speedRatio defines the current speed ratio
  92456. * @param weight defines the weight of the animation (default is -1 so no weight)
  92457. * @param onLoop optional callback called when animation loops
  92458. * @returns a boolean indicating if the animation is running
  92459. */
  92460. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  92461. }
  92462. }
  92463. declare module BABYLON {
  92464. /**
  92465. * Class used to store an actual running animation
  92466. */
  92467. export class Animatable {
  92468. /** defines the target object */
  92469. target: any;
  92470. /** defines the starting frame number (default is 0) */
  92471. fromFrame: number;
  92472. /** defines the ending frame number (default is 100) */
  92473. toFrame: number;
  92474. /** defines if the animation must loop (default is false) */
  92475. loopAnimation: boolean;
  92476. /** defines a callback to call when animation ends if it is not looping */
  92477. onAnimationEnd?: (() => void) | null | undefined;
  92478. /** defines a callback to call when animation loops */
  92479. onAnimationLoop?: (() => void) | null | undefined;
  92480. /** defines whether the animation should be evaluated additively */
  92481. isAdditive: boolean;
  92482. private _localDelayOffset;
  92483. private _pausedDelay;
  92484. private _runtimeAnimations;
  92485. private _paused;
  92486. private _scene;
  92487. private _speedRatio;
  92488. private _weight;
  92489. private _syncRoot;
  92490. /**
  92491. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  92492. * This will only apply for non looping animation (default is true)
  92493. */
  92494. disposeOnEnd: boolean;
  92495. /**
  92496. * Gets a boolean indicating if the animation has started
  92497. */
  92498. animationStarted: boolean;
  92499. /**
  92500. * Observer raised when the animation ends
  92501. */
  92502. onAnimationEndObservable: Observable<Animatable>;
  92503. /**
  92504. * Observer raised when the animation loops
  92505. */
  92506. onAnimationLoopObservable: Observable<Animatable>;
  92507. /**
  92508. * Gets the root Animatable used to synchronize and normalize animations
  92509. */
  92510. get syncRoot(): Nullable<Animatable>;
  92511. /**
  92512. * Gets the current frame of the first RuntimeAnimation
  92513. * Used to synchronize Animatables
  92514. */
  92515. get masterFrame(): number;
  92516. /**
  92517. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  92518. */
  92519. get weight(): number;
  92520. set weight(value: number);
  92521. /**
  92522. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  92523. */
  92524. get speedRatio(): number;
  92525. set speedRatio(value: number);
  92526. /**
  92527. * Creates a new Animatable
  92528. * @param scene defines the hosting scene
  92529. * @param target defines the target object
  92530. * @param fromFrame defines the starting frame number (default is 0)
  92531. * @param toFrame defines the ending frame number (default is 100)
  92532. * @param loopAnimation defines if the animation must loop (default is false)
  92533. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  92534. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  92535. * @param animations defines a group of animation to add to the new Animatable
  92536. * @param onAnimationLoop defines a callback to call when animation loops
  92537. * @param isAdditive defines whether the animation should be evaluated additively
  92538. */
  92539. constructor(scene: Scene,
  92540. /** defines the target object */
  92541. target: any,
  92542. /** defines the starting frame number (default is 0) */
  92543. fromFrame?: number,
  92544. /** defines the ending frame number (default is 100) */
  92545. toFrame?: number,
  92546. /** defines if the animation must loop (default is false) */
  92547. loopAnimation?: boolean, speedRatio?: number,
  92548. /** defines a callback to call when animation ends if it is not looping */
  92549. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  92550. /** defines a callback to call when animation loops */
  92551. onAnimationLoop?: (() => void) | null | undefined,
  92552. /** defines whether the animation should be evaluated additively */
  92553. isAdditive?: boolean);
  92554. /**
  92555. * Synchronize and normalize current Animatable with a source Animatable
  92556. * This is useful when using animation weights and when animations are not of the same length
  92557. * @param root defines the root Animatable to synchronize with
  92558. * @returns the current Animatable
  92559. */
  92560. syncWith(root: Animatable): Animatable;
  92561. /**
  92562. * Gets the list of runtime animations
  92563. * @returns an array of RuntimeAnimation
  92564. */
  92565. getAnimations(): RuntimeAnimation[];
  92566. /**
  92567. * Adds more animations to the current animatable
  92568. * @param target defines the target of the animations
  92569. * @param animations defines the new animations to add
  92570. */
  92571. appendAnimations(target: any, animations: Animation[]): void;
  92572. /**
  92573. * Gets the source animation for a specific property
  92574. * @param property defines the propertyu to look for
  92575. * @returns null or the source animation for the given property
  92576. */
  92577. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  92578. /**
  92579. * Gets the runtime animation for a specific property
  92580. * @param property defines the propertyu to look for
  92581. * @returns null or the runtime animation for the given property
  92582. */
  92583. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  92584. /**
  92585. * Resets the animatable to its original state
  92586. */
  92587. reset(): void;
  92588. /**
  92589. * Allows the animatable to blend with current running animations
  92590. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92591. * @param blendingSpeed defines the blending speed to use
  92592. */
  92593. enableBlending(blendingSpeed: number): void;
  92594. /**
  92595. * Disable animation blending
  92596. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92597. */
  92598. disableBlending(): void;
  92599. /**
  92600. * Jump directly to a given frame
  92601. * @param frame defines the frame to jump to
  92602. */
  92603. goToFrame(frame: number): void;
  92604. /**
  92605. * Pause the animation
  92606. */
  92607. pause(): void;
  92608. /**
  92609. * Restart the animation
  92610. */
  92611. restart(): void;
  92612. private _raiseOnAnimationEnd;
  92613. /**
  92614. * Stop and delete the current animation
  92615. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  92616. * @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)
  92617. */
  92618. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  92619. /**
  92620. * Wait asynchronously for the animation to end
  92621. * @returns a promise which will be fullfilled when the animation ends
  92622. */
  92623. waitAsync(): Promise<Animatable>;
  92624. /** @hidden */
  92625. _animate(delay: number): boolean;
  92626. }
  92627. interface Scene {
  92628. /** @hidden */
  92629. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  92630. /** @hidden */
  92631. _processLateAnimationBindingsForMatrices(holder: {
  92632. totalWeight: number;
  92633. totalAdditiveWeight: number;
  92634. animations: RuntimeAnimation[];
  92635. additiveAnimations: RuntimeAnimation[];
  92636. originalValue: Matrix;
  92637. }): any;
  92638. /** @hidden */
  92639. _processLateAnimationBindingsForQuaternions(holder: {
  92640. totalWeight: number;
  92641. totalAdditiveWeight: number;
  92642. animations: RuntimeAnimation[];
  92643. additiveAnimations: RuntimeAnimation[];
  92644. originalValue: Quaternion;
  92645. }, refQuaternion: Quaternion): Quaternion;
  92646. /** @hidden */
  92647. _processLateAnimationBindings(): void;
  92648. /**
  92649. * Will start the animation sequence of a given target
  92650. * @param target defines the target
  92651. * @param from defines from which frame should animation start
  92652. * @param to defines until which frame should animation run.
  92653. * @param weight defines the weight to apply to the animation (1.0 by default)
  92654. * @param loop defines if the animation loops
  92655. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92656. * @param onAnimationEnd defines the function to be executed when the animation ends
  92657. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92658. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92659. * @param onAnimationLoop defines the callback to call when an animation loops
  92660. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92661. * @returns the animatable object created for this animation
  92662. */
  92663. 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;
  92664. /**
  92665. * Will start the animation sequence of a given target
  92666. * @param target defines the target
  92667. * @param from defines from which frame should animation start
  92668. * @param to defines until which frame should animation run.
  92669. * @param loop defines if the animation loops
  92670. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92671. * @param onAnimationEnd defines the function to be executed when the animation ends
  92672. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92673. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92674. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  92675. * @param onAnimationLoop defines the callback to call when an animation loops
  92676. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92677. * @returns the animatable object created for this animation
  92678. */
  92679. 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;
  92680. /**
  92681. * Will start the animation sequence of a given target and its hierarchy
  92682. * @param target defines the target
  92683. * @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.
  92684. * @param from defines from which frame should animation start
  92685. * @param to defines until which frame should animation run.
  92686. * @param loop defines if the animation loops
  92687. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92688. * @param onAnimationEnd defines the function to be executed when the animation ends
  92689. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92690. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92691. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92692. * @param onAnimationLoop defines the callback to call when an animation loops
  92693. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92694. * @returns the list of created animatables
  92695. */
  92696. 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[];
  92697. /**
  92698. * Begin a new animation on a given node
  92699. * @param target defines the target where the animation will take place
  92700. * @param animations defines the list of animations to start
  92701. * @param from defines the initial value
  92702. * @param to defines the final value
  92703. * @param loop defines if you want animation to loop (off by default)
  92704. * @param speedRatio defines the speed ratio to apply to all animations
  92705. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92706. * @param onAnimationLoop defines the callback to call when an animation loops
  92707. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92708. * @returns the list of created animatables
  92709. */
  92710. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  92711. /**
  92712. * Begin a new animation on a given node and its hierarchy
  92713. * @param target defines the root node where the animation will take place
  92714. * @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.
  92715. * @param animations defines the list of animations to start
  92716. * @param from defines the initial value
  92717. * @param to defines the final value
  92718. * @param loop defines if you want animation to loop (off by default)
  92719. * @param speedRatio defines the speed ratio to apply to all animations
  92720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92721. * @param onAnimationLoop defines the callback to call when an animation loops
  92722. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92723. * @returns the list of animatables created for all nodes
  92724. */
  92725. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  92726. /**
  92727. * Gets the animatable associated with a specific target
  92728. * @param target defines the target of the animatable
  92729. * @returns the required animatable if found
  92730. */
  92731. getAnimatableByTarget(target: any): Nullable<Animatable>;
  92732. /**
  92733. * Gets all animatables associated with a given target
  92734. * @param target defines the target to look animatables for
  92735. * @returns an array of Animatables
  92736. */
  92737. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  92738. /**
  92739. * Stops and removes all animations that have been applied to the scene
  92740. */
  92741. stopAllAnimations(): void;
  92742. /**
  92743. * Gets the current delta time used by animation engine
  92744. */
  92745. deltaTime: number;
  92746. }
  92747. interface Bone {
  92748. /**
  92749. * Copy an animation range from another bone
  92750. * @param source defines the source bone
  92751. * @param rangeName defines the range name to copy
  92752. * @param frameOffset defines the frame offset
  92753. * @param rescaleAsRequired defines if rescaling must be applied if required
  92754. * @param skelDimensionsRatio defines the scaling ratio
  92755. * @returns true if operation was successful
  92756. */
  92757. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  92758. }
  92759. }
  92760. declare module BABYLON {
  92761. /**
  92762. * Class used to handle skinning animations
  92763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92764. */
  92765. export class Skeleton implements IAnimatable {
  92766. /** defines the skeleton name */
  92767. name: string;
  92768. /** defines the skeleton Id */
  92769. id: string;
  92770. /**
  92771. * Defines the list of child bones
  92772. */
  92773. bones: Bone[];
  92774. /**
  92775. * Defines an estimate of the dimension of the skeleton at rest
  92776. */
  92777. dimensionsAtRest: Vector3;
  92778. /**
  92779. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  92780. */
  92781. needInitialSkinMatrix: boolean;
  92782. /**
  92783. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  92784. */
  92785. overrideMesh: Nullable<AbstractMesh>;
  92786. /**
  92787. * Gets the list of animations attached to this skeleton
  92788. */
  92789. animations: Array<Animation>;
  92790. private _scene;
  92791. private _isDirty;
  92792. private _transformMatrices;
  92793. private _transformMatrixTexture;
  92794. private _meshesWithPoseMatrix;
  92795. private _animatables;
  92796. private _identity;
  92797. private _synchronizedWithMesh;
  92798. private _ranges;
  92799. private _lastAbsoluteTransformsUpdateId;
  92800. private _canUseTextureForBones;
  92801. private _uniqueId;
  92802. /** @hidden */
  92803. _numBonesWithLinkedTransformNode: number;
  92804. /** @hidden */
  92805. _hasWaitingData: Nullable<boolean>;
  92806. /**
  92807. * Specifies if the skeleton should be serialized
  92808. */
  92809. doNotSerialize: boolean;
  92810. private _useTextureToStoreBoneMatrices;
  92811. /**
  92812. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  92813. * Please note that this option is not available if the hardware does not support it
  92814. */
  92815. get useTextureToStoreBoneMatrices(): boolean;
  92816. set useTextureToStoreBoneMatrices(value: boolean);
  92817. private _animationPropertiesOverride;
  92818. /**
  92819. * Gets or sets the animation properties override
  92820. */
  92821. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92822. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  92823. /**
  92824. * List of inspectable custom properties (used by the Inspector)
  92825. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92826. */
  92827. inspectableCustomProperties: IInspectable[];
  92828. /**
  92829. * An observable triggered before computing the skeleton's matrices
  92830. */
  92831. onBeforeComputeObservable: Observable<Skeleton>;
  92832. /**
  92833. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  92834. */
  92835. get isUsingTextureForMatrices(): boolean;
  92836. /**
  92837. * Gets the unique ID of this skeleton
  92838. */
  92839. get uniqueId(): number;
  92840. /**
  92841. * Creates a new skeleton
  92842. * @param name defines the skeleton name
  92843. * @param id defines the skeleton Id
  92844. * @param scene defines the hosting scene
  92845. */
  92846. constructor(
  92847. /** defines the skeleton name */
  92848. name: string,
  92849. /** defines the skeleton Id */
  92850. id: string, scene: Scene);
  92851. /**
  92852. * Gets the current object class name.
  92853. * @return the class name
  92854. */
  92855. getClassName(): string;
  92856. /**
  92857. * Returns an array containing the root bones
  92858. * @returns an array containing the root bones
  92859. */
  92860. getChildren(): Array<Bone>;
  92861. /**
  92862. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  92863. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  92864. * @returns a Float32Array containing matrices data
  92865. */
  92866. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  92867. /**
  92868. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  92869. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  92870. * @returns a raw texture containing the data
  92871. */
  92872. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  92873. /**
  92874. * Gets the current hosting scene
  92875. * @returns a scene object
  92876. */
  92877. getScene(): Scene;
  92878. /**
  92879. * Gets a string representing the current skeleton data
  92880. * @param fullDetails defines a boolean indicating if we want a verbose version
  92881. * @returns a string representing the current skeleton data
  92882. */
  92883. toString(fullDetails?: boolean): string;
  92884. /**
  92885. * Get bone's index searching by name
  92886. * @param name defines bone's name to search for
  92887. * @return the indice of the bone. Returns -1 if not found
  92888. */
  92889. getBoneIndexByName(name: string): number;
  92890. /**
  92891. * Creater a new animation range
  92892. * @param name defines the name of the range
  92893. * @param from defines the start key
  92894. * @param to defines the end key
  92895. */
  92896. createAnimationRange(name: string, from: number, to: number): void;
  92897. /**
  92898. * Delete a specific animation range
  92899. * @param name defines the name of the range
  92900. * @param deleteFrames defines if frames must be removed as well
  92901. */
  92902. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92903. /**
  92904. * Gets a specific animation range
  92905. * @param name defines the name of the range to look for
  92906. * @returns the requested animation range or null if not found
  92907. */
  92908. getAnimationRange(name: string): Nullable<AnimationRange>;
  92909. /**
  92910. * Gets the list of all animation ranges defined on this skeleton
  92911. * @returns an array
  92912. */
  92913. getAnimationRanges(): Nullable<AnimationRange>[];
  92914. /**
  92915. * Copy animation range from a source skeleton.
  92916. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  92917. * @param source defines the source skeleton
  92918. * @param name defines the name of the range to copy
  92919. * @param rescaleAsRequired defines if rescaling must be applied if required
  92920. * @returns true if operation was successful
  92921. */
  92922. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  92923. /**
  92924. * Forces the skeleton to go to rest pose
  92925. */
  92926. returnToRest(): void;
  92927. private _getHighestAnimationFrame;
  92928. /**
  92929. * Begin a specific animation range
  92930. * @param name defines the name of the range to start
  92931. * @param loop defines if looping must be turned on (false by default)
  92932. * @param speedRatio defines the speed ratio to apply (1 by default)
  92933. * @param onAnimationEnd defines a callback which will be called when animation will end
  92934. * @returns a new animatable
  92935. */
  92936. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92937. /**
  92938. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  92939. * @param skeleton defines the Skeleton containing the animation range to convert
  92940. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  92941. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  92942. * @returns the original skeleton
  92943. */
  92944. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  92945. /** @hidden */
  92946. _markAsDirty(): void;
  92947. /** @hidden */
  92948. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  92949. /** @hidden */
  92950. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  92951. private _computeTransformMatrices;
  92952. /**
  92953. * Build all resources required to render a skeleton
  92954. */
  92955. prepare(): void;
  92956. /**
  92957. * Gets the list of animatables currently running for this skeleton
  92958. * @returns an array of animatables
  92959. */
  92960. getAnimatables(): IAnimatable[];
  92961. /**
  92962. * Clone the current skeleton
  92963. * @param name defines the name of the new skeleton
  92964. * @param id defines the id of the new skeleton
  92965. * @returns the new skeleton
  92966. */
  92967. clone(name: string, id?: string): Skeleton;
  92968. /**
  92969. * Enable animation blending for this skeleton
  92970. * @param blendingSpeed defines the blending speed to apply
  92971. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92972. */
  92973. enableBlending(blendingSpeed?: number): void;
  92974. /**
  92975. * Releases all resources associated with the current skeleton
  92976. */
  92977. dispose(): void;
  92978. /**
  92979. * Serialize the skeleton in a JSON object
  92980. * @returns a JSON object
  92981. */
  92982. serialize(): any;
  92983. /**
  92984. * Creates a new skeleton from serialized data
  92985. * @param parsedSkeleton defines the serialized data
  92986. * @param scene defines the hosting scene
  92987. * @returns a new skeleton
  92988. */
  92989. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  92990. /**
  92991. * Compute all node absolute transforms
  92992. * @param forceUpdate defines if computation must be done even if cache is up to date
  92993. */
  92994. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  92995. /**
  92996. * Gets the root pose matrix
  92997. * @returns a matrix
  92998. */
  92999. getPoseMatrix(): Nullable<Matrix>;
  93000. /**
  93001. * Sorts bones per internal index
  93002. */
  93003. sortBones(): void;
  93004. private _sortBones;
  93005. }
  93006. }
  93007. declare module BABYLON {
  93008. /**
  93009. * Creates an instance based on a source mesh.
  93010. */
  93011. export class InstancedMesh extends AbstractMesh {
  93012. private _sourceMesh;
  93013. private _currentLOD;
  93014. /** @hidden */
  93015. _indexInSourceMeshInstanceArray: number;
  93016. constructor(name: string, source: Mesh);
  93017. /**
  93018. * Returns the string "InstancedMesh".
  93019. */
  93020. getClassName(): string;
  93021. /** Gets the list of lights affecting that mesh */
  93022. get lightSources(): Light[];
  93023. _resyncLightSources(): void;
  93024. _resyncLightSource(light: Light): void;
  93025. _removeLightSource(light: Light, dispose: boolean): void;
  93026. /**
  93027. * If the source mesh receives shadows
  93028. */
  93029. get receiveShadows(): boolean;
  93030. /**
  93031. * The material of the source mesh
  93032. */
  93033. get material(): Nullable<Material>;
  93034. /**
  93035. * Visibility of the source mesh
  93036. */
  93037. get visibility(): number;
  93038. /**
  93039. * Skeleton of the source mesh
  93040. */
  93041. get skeleton(): Nullable<Skeleton>;
  93042. /**
  93043. * Rendering ground id of the source mesh
  93044. */
  93045. get renderingGroupId(): number;
  93046. set renderingGroupId(value: number);
  93047. /**
  93048. * Returns the total number of vertices (integer).
  93049. */
  93050. getTotalVertices(): number;
  93051. /**
  93052. * Returns a positive integer : the total number of indices in this mesh geometry.
  93053. * @returns the numner of indices or zero if the mesh has no geometry.
  93054. */
  93055. getTotalIndices(): number;
  93056. /**
  93057. * The source mesh of the instance
  93058. */
  93059. get sourceMesh(): Mesh;
  93060. /**
  93061. * Is this node ready to be used/rendered
  93062. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93063. * @return {boolean} is it ready
  93064. */
  93065. isReady(completeCheck?: boolean): boolean;
  93066. /**
  93067. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93068. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93069. * @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.
  93070. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93071. */
  93072. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93073. /**
  93074. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93075. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93076. * The `data` are either a numeric array either a Float32Array.
  93077. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93078. * 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).
  93079. * Note that a new underlying VertexBuffer object is created each call.
  93080. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93081. *
  93082. * Possible `kind` values :
  93083. * - VertexBuffer.PositionKind
  93084. * - VertexBuffer.UVKind
  93085. * - VertexBuffer.UV2Kind
  93086. * - VertexBuffer.UV3Kind
  93087. * - VertexBuffer.UV4Kind
  93088. * - VertexBuffer.UV5Kind
  93089. * - VertexBuffer.UV6Kind
  93090. * - VertexBuffer.ColorKind
  93091. * - VertexBuffer.MatricesIndicesKind
  93092. * - VertexBuffer.MatricesIndicesExtraKind
  93093. * - VertexBuffer.MatricesWeightsKind
  93094. * - VertexBuffer.MatricesWeightsExtraKind
  93095. *
  93096. * Returns the Mesh.
  93097. */
  93098. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93099. /**
  93100. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93101. * If the mesh has no geometry, it is simply returned as it is.
  93102. * The `data` are either a numeric array either a Float32Array.
  93103. * No new underlying VertexBuffer object is created.
  93104. * 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.
  93105. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93106. *
  93107. * Possible `kind` values :
  93108. * - VertexBuffer.PositionKind
  93109. * - VertexBuffer.UVKind
  93110. * - VertexBuffer.UV2Kind
  93111. * - VertexBuffer.UV3Kind
  93112. * - VertexBuffer.UV4Kind
  93113. * - VertexBuffer.UV5Kind
  93114. * - VertexBuffer.UV6Kind
  93115. * - VertexBuffer.ColorKind
  93116. * - VertexBuffer.MatricesIndicesKind
  93117. * - VertexBuffer.MatricesIndicesExtraKind
  93118. * - VertexBuffer.MatricesWeightsKind
  93119. * - VertexBuffer.MatricesWeightsExtraKind
  93120. *
  93121. * Returns the Mesh.
  93122. */
  93123. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93124. /**
  93125. * Sets the mesh indices.
  93126. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93127. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93128. * This method creates a new index buffer each call.
  93129. * Returns the Mesh.
  93130. */
  93131. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93132. /**
  93133. * Boolean : True if the mesh owns the requested kind of data.
  93134. */
  93135. isVerticesDataPresent(kind: string): boolean;
  93136. /**
  93137. * Returns an array of indices (IndicesArray).
  93138. */
  93139. getIndices(): Nullable<IndicesArray>;
  93140. get _positions(): Nullable<Vector3[]>;
  93141. /**
  93142. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93143. * This means the mesh underlying bounding box and sphere are recomputed.
  93144. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93145. * @returns the current mesh
  93146. */
  93147. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93148. /** @hidden */
  93149. _preActivate(): InstancedMesh;
  93150. /** @hidden */
  93151. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93152. /** @hidden */
  93153. _postActivate(): void;
  93154. getWorldMatrix(): Matrix;
  93155. get isAnInstance(): boolean;
  93156. /**
  93157. * Returns the current associated LOD AbstractMesh.
  93158. */
  93159. getLOD(camera: Camera): AbstractMesh;
  93160. /** @hidden */
  93161. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93162. /** @hidden */
  93163. _syncSubMeshes(): InstancedMesh;
  93164. /** @hidden */
  93165. _generatePointsArray(): boolean;
  93166. /**
  93167. * Creates a new InstancedMesh from the current mesh.
  93168. * - name (string) : the cloned mesh name
  93169. * - newParent (optional Node) : the optional Node to parent the clone to.
  93170. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93171. *
  93172. * Returns the clone.
  93173. */
  93174. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93175. /**
  93176. * Disposes the InstancedMesh.
  93177. * Returns nothing.
  93178. */
  93179. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93180. }
  93181. interface Mesh {
  93182. /**
  93183. * Register a custom buffer that will be instanced
  93184. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93185. * @param kind defines the buffer kind
  93186. * @param stride defines the stride in floats
  93187. */
  93188. registerInstancedBuffer(kind: string, stride: number): void;
  93189. /** @hidden */
  93190. _userInstancedBuffersStorage: {
  93191. data: {
  93192. [key: string]: Float32Array;
  93193. };
  93194. sizes: {
  93195. [key: string]: number;
  93196. };
  93197. vertexBuffers: {
  93198. [key: string]: Nullable<VertexBuffer>;
  93199. };
  93200. strides: {
  93201. [key: string]: number;
  93202. };
  93203. };
  93204. }
  93205. interface AbstractMesh {
  93206. /**
  93207. * Object used to store instanced buffers defined by user
  93208. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93209. */
  93210. instancedBuffers: {
  93211. [key: string]: any;
  93212. };
  93213. }
  93214. }
  93215. declare module BABYLON {
  93216. /**
  93217. * Defines the options associated with the creation of a shader material.
  93218. */
  93219. export interface IShaderMaterialOptions {
  93220. /**
  93221. * Does the material work in alpha blend mode
  93222. */
  93223. needAlphaBlending: boolean;
  93224. /**
  93225. * Does the material work in alpha test mode
  93226. */
  93227. needAlphaTesting: boolean;
  93228. /**
  93229. * The list of attribute names used in the shader
  93230. */
  93231. attributes: string[];
  93232. /**
  93233. * The list of unifrom names used in the shader
  93234. */
  93235. uniforms: string[];
  93236. /**
  93237. * The list of UBO names used in the shader
  93238. */
  93239. uniformBuffers: string[];
  93240. /**
  93241. * The list of sampler names used in the shader
  93242. */
  93243. samplers: string[];
  93244. /**
  93245. * The list of defines used in the shader
  93246. */
  93247. defines: string[];
  93248. }
  93249. /**
  93250. * 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.
  93251. *
  93252. * This returned material effects how the mesh will look based on the code in the shaders.
  93253. *
  93254. * @see http://doc.babylonjs.com/how_to/shader_material
  93255. */
  93256. export class ShaderMaterial extends Material {
  93257. private _shaderPath;
  93258. private _options;
  93259. private _textures;
  93260. private _textureArrays;
  93261. private _floats;
  93262. private _ints;
  93263. private _floatsArrays;
  93264. private _colors3;
  93265. private _colors3Arrays;
  93266. private _colors4;
  93267. private _colors4Arrays;
  93268. private _vectors2;
  93269. private _vectors3;
  93270. private _vectors4;
  93271. private _matrices;
  93272. private _matrixArrays;
  93273. private _matrices3x3;
  93274. private _matrices2x2;
  93275. private _vectors2Arrays;
  93276. private _vectors3Arrays;
  93277. private _vectors4Arrays;
  93278. private _cachedWorldViewMatrix;
  93279. private _cachedWorldViewProjectionMatrix;
  93280. private _renderId;
  93281. private _multiview;
  93282. private _cachedDefines;
  93283. /**
  93284. * Instantiate a new shader material.
  93285. * 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.
  93286. * This returned material effects how the mesh will look based on the code in the shaders.
  93287. * @see http://doc.babylonjs.com/how_to/shader_material
  93288. * @param name Define the name of the material in the scene
  93289. * @param scene Define the scene the material belongs to
  93290. * @param shaderPath Defines the route to the shader code in one of three ways:
  93291. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93292. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93293. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93294. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93295. * @param options Define the options used to create the shader
  93296. */
  93297. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93298. /**
  93299. * Gets the shader path used to define the shader code
  93300. * It can be modified to trigger a new compilation
  93301. */
  93302. get shaderPath(): any;
  93303. /**
  93304. * Sets the shader path used to define the shader code
  93305. * It can be modified to trigger a new compilation
  93306. */
  93307. set shaderPath(shaderPath: any);
  93308. /**
  93309. * Gets the options used to compile the shader.
  93310. * They can be modified to trigger a new compilation
  93311. */
  93312. get options(): IShaderMaterialOptions;
  93313. /**
  93314. * Gets the current class name of the material e.g. "ShaderMaterial"
  93315. * Mainly use in serialization.
  93316. * @returns the class name
  93317. */
  93318. getClassName(): string;
  93319. /**
  93320. * Specifies if the material will require alpha blending
  93321. * @returns a boolean specifying if alpha blending is needed
  93322. */
  93323. needAlphaBlending(): boolean;
  93324. /**
  93325. * Specifies if this material should be rendered in alpha test mode
  93326. * @returns a boolean specifying if an alpha test is needed.
  93327. */
  93328. needAlphaTesting(): boolean;
  93329. private _checkUniform;
  93330. /**
  93331. * Set a texture in the shader.
  93332. * @param name Define the name of the uniform samplers as defined in the shader
  93333. * @param texture Define the texture to bind to this sampler
  93334. * @return the material itself allowing "fluent" like uniform updates
  93335. */
  93336. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93337. /**
  93338. * Set a texture array in the shader.
  93339. * @param name Define the name of the uniform sampler array as defined in the shader
  93340. * @param textures Define the list of textures to bind to this sampler
  93341. * @return the material itself allowing "fluent" like uniform updates
  93342. */
  93343. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  93344. /**
  93345. * Set a float in the shader.
  93346. * @param name Define the name of the uniform as defined in the shader
  93347. * @param value Define the value to give to the uniform
  93348. * @return the material itself allowing "fluent" like uniform updates
  93349. */
  93350. setFloat(name: string, value: number): ShaderMaterial;
  93351. /**
  93352. * Set a int in the shader.
  93353. * @param name Define the name of the uniform as defined in the shader
  93354. * @param value Define the value to give to the uniform
  93355. * @return the material itself allowing "fluent" like uniform updates
  93356. */
  93357. setInt(name: string, value: number): ShaderMaterial;
  93358. /**
  93359. * Set an array of floats in the shader.
  93360. * @param name Define the name of the uniform as defined in the shader
  93361. * @param value Define the value to give to the uniform
  93362. * @return the material itself allowing "fluent" like uniform updates
  93363. */
  93364. setFloats(name: string, value: number[]): ShaderMaterial;
  93365. /**
  93366. * Set a vec3 in the shader from a Color3.
  93367. * @param name Define the name of the uniform as defined in the shader
  93368. * @param value Define the value to give to the uniform
  93369. * @return the material itself allowing "fluent" like uniform updates
  93370. */
  93371. setColor3(name: string, value: Color3): ShaderMaterial;
  93372. /**
  93373. * Set a vec3 array in the shader from a Color3 array.
  93374. * @param name Define the name of the uniform as defined in the shader
  93375. * @param value Define the value to give to the uniform
  93376. * @return the material itself allowing "fluent" like uniform updates
  93377. */
  93378. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  93379. /**
  93380. * Set a vec4 in the shader from a Color4.
  93381. * @param name Define the name of the uniform as defined in the shader
  93382. * @param value Define the value to give to the uniform
  93383. * @return the material itself allowing "fluent" like uniform updates
  93384. */
  93385. setColor4(name: string, value: Color4): ShaderMaterial;
  93386. /**
  93387. * Set a vec4 array in the shader from a Color4 array.
  93388. * @param name Define the name of the uniform as defined in the shader
  93389. * @param value Define the value to give to the uniform
  93390. * @return the material itself allowing "fluent" like uniform updates
  93391. */
  93392. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  93393. /**
  93394. * Set a vec2 in the shader from a Vector2.
  93395. * @param name Define the name of the uniform as defined in the shader
  93396. * @param value Define the value to give to the uniform
  93397. * @return the material itself allowing "fluent" like uniform updates
  93398. */
  93399. setVector2(name: string, value: Vector2): ShaderMaterial;
  93400. /**
  93401. * Set a vec3 in the shader from a Vector3.
  93402. * @param name Define the name of the uniform as defined in the shader
  93403. * @param value Define the value to give to the uniform
  93404. * @return the material itself allowing "fluent" like uniform updates
  93405. */
  93406. setVector3(name: string, value: Vector3): ShaderMaterial;
  93407. /**
  93408. * Set a vec4 in the shader from a Vector4.
  93409. * @param name Define the name of the uniform as defined in the shader
  93410. * @param value Define the value to give to the uniform
  93411. * @return the material itself allowing "fluent" like uniform updates
  93412. */
  93413. setVector4(name: string, value: Vector4): ShaderMaterial;
  93414. /**
  93415. * Set a mat4 in the shader from a Matrix.
  93416. * @param name Define the name of the uniform as defined in the shader
  93417. * @param value Define the value to give to the uniform
  93418. * @return the material itself allowing "fluent" like uniform updates
  93419. */
  93420. setMatrix(name: string, value: Matrix): ShaderMaterial;
  93421. /**
  93422. * Set a float32Array in the shader from a matrix array.
  93423. * @param name Define the name of the uniform as defined in the shader
  93424. * @param value Define the value to give to the uniform
  93425. * @return the material itself allowing "fluent" like uniform updates
  93426. */
  93427. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  93428. /**
  93429. * Set a mat3 in the shader from a Float32Array.
  93430. * @param name Define the name of the uniform as defined in the shader
  93431. * @param value Define the value to give to the uniform
  93432. * @return the material itself allowing "fluent" like uniform updates
  93433. */
  93434. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  93435. /**
  93436. * Set a mat2 in the shader from a Float32Array.
  93437. * @param name Define the name of the uniform as defined in the shader
  93438. * @param value Define the value to give to the uniform
  93439. * @return the material itself allowing "fluent" like uniform updates
  93440. */
  93441. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  93442. /**
  93443. * Set a vec2 array in the shader from a number array.
  93444. * @param name Define the name of the uniform as defined in the shader
  93445. * @param value Define the value to give to the uniform
  93446. * @return the material itself allowing "fluent" like uniform updates
  93447. */
  93448. setArray2(name: string, value: number[]): ShaderMaterial;
  93449. /**
  93450. * Set a vec3 array in the shader from a number array.
  93451. * @param name Define the name of the uniform as defined in the shader
  93452. * @param value Define the value to give to the uniform
  93453. * @return the material itself allowing "fluent" like uniform updates
  93454. */
  93455. setArray3(name: string, value: number[]): ShaderMaterial;
  93456. /**
  93457. * Set a vec4 array in the shader from a number array.
  93458. * @param name Define the name of the uniform as defined in the shader
  93459. * @param value Define the value to give to the uniform
  93460. * @return the material itself allowing "fluent" like uniform updates
  93461. */
  93462. setArray4(name: string, value: number[]): ShaderMaterial;
  93463. private _checkCache;
  93464. /**
  93465. * Specifies that the submesh is ready to be used
  93466. * @param mesh defines the mesh to check
  93467. * @param subMesh defines which submesh to check
  93468. * @param useInstances specifies that instances should be used
  93469. * @returns a boolean indicating that the submesh is ready or not
  93470. */
  93471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93472. /**
  93473. * Checks if the material is ready to render the requested mesh
  93474. * @param mesh Define the mesh to render
  93475. * @param useInstances Define whether or not the material is used with instances
  93476. * @returns true if ready, otherwise false
  93477. */
  93478. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93479. /**
  93480. * Binds the world matrix to the material
  93481. * @param world defines the world transformation matrix
  93482. * @param effectOverride - If provided, use this effect instead of internal effect
  93483. */
  93484. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  93485. /**
  93486. * Binds the submesh to this material by preparing the effect and shader to draw
  93487. * @param world defines the world transformation matrix
  93488. * @param mesh defines the mesh containing the submesh
  93489. * @param subMesh defines the submesh to bind the material to
  93490. */
  93491. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93492. /**
  93493. * Binds the material to the mesh
  93494. * @param world defines the world transformation matrix
  93495. * @param mesh defines the mesh to bind the material to
  93496. * @param effectOverride - If provided, use this effect instead of internal effect
  93497. */
  93498. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  93499. protected _afterBind(mesh?: Mesh): void;
  93500. /**
  93501. * Gets the active textures from the material
  93502. * @returns an array of textures
  93503. */
  93504. getActiveTextures(): BaseTexture[];
  93505. /**
  93506. * Specifies if the material uses a texture
  93507. * @param texture defines the texture to check against the material
  93508. * @returns a boolean specifying if the material uses the texture
  93509. */
  93510. hasTexture(texture: BaseTexture): boolean;
  93511. /**
  93512. * Makes a duplicate of the material, and gives it a new name
  93513. * @param name defines the new name for the duplicated material
  93514. * @returns the cloned material
  93515. */
  93516. clone(name: string): ShaderMaterial;
  93517. /**
  93518. * Disposes the material
  93519. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93520. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93521. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93522. */
  93523. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93524. /**
  93525. * Serializes this material in a JSON representation
  93526. * @returns the serialized material object
  93527. */
  93528. serialize(): any;
  93529. /**
  93530. * Creates a shader material from parsed shader material data
  93531. * @param source defines the JSON represnetation of the material
  93532. * @param scene defines the hosting scene
  93533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93534. * @returns a new material
  93535. */
  93536. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93537. }
  93538. }
  93539. declare module BABYLON {
  93540. /** @hidden */
  93541. export var colorPixelShader: {
  93542. name: string;
  93543. shader: string;
  93544. };
  93545. }
  93546. declare module BABYLON {
  93547. /** @hidden */
  93548. export var colorVertexShader: {
  93549. name: string;
  93550. shader: string;
  93551. };
  93552. }
  93553. declare module BABYLON {
  93554. /**
  93555. * Line mesh
  93556. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93557. */
  93558. export class LinesMesh extends Mesh {
  93559. /**
  93560. * If vertex color should be applied to the mesh
  93561. */
  93562. readonly useVertexColor?: boolean | undefined;
  93563. /**
  93564. * If vertex alpha should be applied to the mesh
  93565. */
  93566. readonly useVertexAlpha?: boolean | undefined;
  93567. /**
  93568. * Color of the line (Default: White)
  93569. */
  93570. color: Color3;
  93571. /**
  93572. * Alpha of the line (Default: 1)
  93573. */
  93574. alpha: number;
  93575. /**
  93576. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93577. * This margin is expressed in world space coordinates, so its value may vary.
  93578. * Default value is 0.1
  93579. */
  93580. intersectionThreshold: number;
  93581. private _colorShader;
  93582. private color4;
  93583. /**
  93584. * Creates a new LinesMesh
  93585. * @param name defines the name
  93586. * @param scene defines the hosting scene
  93587. * @param parent defines the parent mesh if any
  93588. * @param source defines the optional source LinesMesh used to clone data from
  93589. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93590. * When false, achieved by calling a clone(), also passing False.
  93591. * This will make creation of children, recursive.
  93592. * @param useVertexColor defines if this LinesMesh supports vertex color
  93593. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  93594. */
  93595. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  93596. /**
  93597. * If vertex color should be applied to the mesh
  93598. */
  93599. useVertexColor?: boolean | undefined,
  93600. /**
  93601. * If vertex alpha should be applied to the mesh
  93602. */
  93603. useVertexAlpha?: boolean | undefined);
  93604. private _addClipPlaneDefine;
  93605. private _removeClipPlaneDefine;
  93606. isReady(): boolean;
  93607. /**
  93608. * Returns the string "LineMesh"
  93609. */
  93610. getClassName(): string;
  93611. /**
  93612. * @hidden
  93613. */
  93614. get material(): Material;
  93615. /**
  93616. * @hidden
  93617. */
  93618. set material(value: Material);
  93619. /**
  93620. * @hidden
  93621. */
  93622. get checkCollisions(): boolean;
  93623. /** @hidden */
  93624. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93625. /** @hidden */
  93626. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93627. /**
  93628. * Disposes of the line mesh
  93629. * @param doNotRecurse If children should be disposed
  93630. */
  93631. dispose(doNotRecurse?: boolean): void;
  93632. /**
  93633. * Returns a new LineMesh object cloned from the current one.
  93634. */
  93635. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  93636. /**
  93637. * Creates a new InstancedLinesMesh object from the mesh model.
  93638. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93639. * @param name defines the name of the new instance
  93640. * @returns a new InstancedLinesMesh
  93641. */
  93642. createInstance(name: string): InstancedLinesMesh;
  93643. }
  93644. /**
  93645. * Creates an instance based on a source LinesMesh
  93646. */
  93647. export class InstancedLinesMesh extends InstancedMesh {
  93648. /**
  93649. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93650. * This margin is expressed in world space coordinates, so its value may vary.
  93651. * Initilized with the intersectionThreshold value of the source LinesMesh
  93652. */
  93653. intersectionThreshold: number;
  93654. constructor(name: string, source: LinesMesh);
  93655. /**
  93656. * Returns the string "InstancedLinesMesh".
  93657. */
  93658. getClassName(): string;
  93659. }
  93660. }
  93661. declare module BABYLON {
  93662. /** @hidden */
  93663. export var linePixelShader: {
  93664. name: string;
  93665. shader: string;
  93666. };
  93667. }
  93668. declare module BABYLON {
  93669. /** @hidden */
  93670. export var lineVertexShader: {
  93671. name: string;
  93672. shader: string;
  93673. };
  93674. }
  93675. declare module BABYLON {
  93676. interface AbstractMesh {
  93677. /**
  93678. * Gets the edgesRenderer associated with the mesh
  93679. */
  93680. edgesRenderer: Nullable<EdgesRenderer>;
  93681. }
  93682. interface LinesMesh {
  93683. /**
  93684. * Enables the edge rendering mode on the mesh.
  93685. * This mode makes the mesh edges visible
  93686. * @param epsilon defines the maximal distance between two angles to detect a face
  93687. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93688. * @returns the currentAbstractMesh
  93689. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93690. */
  93691. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93692. }
  93693. interface InstancedLinesMesh {
  93694. /**
  93695. * Enables the edge rendering mode on the mesh.
  93696. * This mode makes the mesh edges visible
  93697. * @param epsilon defines the maximal distance between two angles to detect a face
  93698. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93699. * @returns the current InstancedLinesMesh
  93700. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93701. */
  93702. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  93703. }
  93704. /**
  93705. * Defines the minimum contract an Edges renderer should follow.
  93706. */
  93707. export interface IEdgesRenderer extends IDisposable {
  93708. /**
  93709. * Gets or sets a boolean indicating if the edgesRenderer is active
  93710. */
  93711. isEnabled: boolean;
  93712. /**
  93713. * Renders the edges of the attached mesh,
  93714. */
  93715. render(): void;
  93716. /**
  93717. * Checks wether or not the edges renderer is ready to render.
  93718. * @return true if ready, otherwise false.
  93719. */
  93720. isReady(): boolean;
  93721. }
  93722. /**
  93723. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  93724. */
  93725. export class EdgesRenderer implements IEdgesRenderer {
  93726. /**
  93727. * Define the size of the edges with an orthographic camera
  93728. */
  93729. edgesWidthScalerForOrthographic: number;
  93730. /**
  93731. * Define the size of the edges with a perspective camera
  93732. */
  93733. edgesWidthScalerForPerspective: number;
  93734. protected _source: AbstractMesh;
  93735. protected _linesPositions: number[];
  93736. protected _linesNormals: number[];
  93737. protected _linesIndices: number[];
  93738. protected _epsilon: number;
  93739. protected _indicesCount: number;
  93740. protected _lineShader: ShaderMaterial;
  93741. protected _ib: DataBuffer;
  93742. protected _buffers: {
  93743. [key: string]: Nullable<VertexBuffer>;
  93744. };
  93745. protected _checkVerticesInsteadOfIndices: boolean;
  93746. private _meshRebuildObserver;
  93747. private _meshDisposeObserver;
  93748. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  93749. isEnabled: boolean;
  93750. /**
  93751. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  93752. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  93753. * @param source Mesh used to create edges
  93754. * @param epsilon sum of angles in adjacency to check for edge
  93755. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  93756. * @param generateEdgesLines - should generate Lines or only prepare resources.
  93757. */
  93758. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  93759. protected _prepareRessources(): void;
  93760. /** @hidden */
  93761. _rebuild(): void;
  93762. /**
  93763. * Releases the required resources for the edges renderer
  93764. */
  93765. dispose(): void;
  93766. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  93767. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  93768. /**
  93769. * Checks if the pair of p0 and p1 is en edge
  93770. * @param faceIndex
  93771. * @param edge
  93772. * @param faceNormals
  93773. * @param p0
  93774. * @param p1
  93775. * @private
  93776. */
  93777. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  93778. /**
  93779. * push line into the position, normal and index buffer
  93780. * @protected
  93781. */
  93782. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  93783. /**
  93784. * Generates lines edges from adjacencjes
  93785. * @private
  93786. */
  93787. _generateEdgesLines(): void;
  93788. /**
  93789. * Checks wether or not the edges renderer is ready to render.
  93790. * @return true if ready, otherwise false.
  93791. */
  93792. isReady(): boolean;
  93793. /**
  93794. * Renders the edges of the attached mesh,
  93795. */
  93796. render(): void;
  93797. }
  93798. /**
  93799. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  93800. */
  93801. export class LineEdgesRenderer extends EdgesRenderer {
  93802. /**
  93803. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  93804. * @param source LineMesh used to generate edges
  93805. * @param epsilon not important (specified angle for edge detection)
  93806. * @param checkVerticesInsteadOfIndices not important for LineMesh
  93807. */
  93808. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  93809. /**
  93810. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  93811. */
  93812. _generateEdgesLines(): void;
  93813. }
  93814. }
  93815. declare module BABYLON {
  93816. /**
  93817. * This represents the object necessary to create a rendering group.
  93818. * This is exclusively used and created by the rendering manager.
  93819. * To modify the behavior, you use the available helpers in your scene or meshes.
  93820. * @hidden
  93821. */
  93822. export class RenderingGroup {
  93823. index: number;
  93824. private static _zeroVector;
  93825. private _scene;
  93826. private _opaqueSubMeshes;
  93827. private _transparentSubMeshes;
  93828. private _alphaTestSubMeshes;
  93829. private _depthOnlySubMeshes;
  93830. private _particleSystems;
  93831. private _spriteManagers;
  93832. private _opaqueSortCompareFn;
  93833. private _alphaTestSortCompareFn;
  93834. private _transparentSortCompareFn;
  93835. private _renderOpaque;
  93836. private _renderAlphaTest;
  93837. private _renderTransparent;
  93838. /** @hidden */
  93839. _edgesRenderers: SmartArray<IEdgesRenderer>;
  93840. onBeforeTransparentRendering: () => void;
  93841. /**
  93842. * Set the opaque sort comparison function.
  93843. * If null the sub meshes will be render in the order they were created
  93844. */
  93845. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93846. /**
  93847. * Set the alpha test sort comparison function.
  93848. * If null the sub meshes will be render in the order they were created
  93849. */
  93850. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93851. /**
  93852. * Set the transparent sort comparison function.
  93853. * If null the sub meshes will be render in the order they were created
  93854. */
  93855. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93856. /**
  93857. * Creates a new rendering group.
  93858. * @param index The rendering group index
  93859. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  93860. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  93861. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  93862. */
  93863. 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>);
  93864. /**
  93865. * Render all the sub meshes contained in the group.
  93866. * @param customRenderFunction Used to override the default render behaviour of the group.
  93867. * @returns true if rendered some submeshes.
  93868. */
  93869. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  93870. /**
  93871. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  93872. * @param subMeshes The submeshes to render
  93873. */
  93874. private renderOpaqueSorted;
  93875. /**
  93876. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  93877. * @param subMeshes The submeshes to render
  93878. */
  93879. private renderAlphaTestSorted;
  93880. /**
  93881. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  93882. * @param subMeshes The submeshes to render
  93883. */
  93884. private renderTransparentSorted;
  93885. /**
  93886. * Renders the submeshes in a specified order.
  93887. * @param subMeshes The submeshes to sort before render
  93888. * @param sortCompareFn The comparison function use to sort
  93889. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  93890. * @param transparent Specifies to activate blending if true
  93891. */
  93892. private static renderSorted;
  93893. /**
  93894. * Renders the submeshes in the order they were dispatched (no sort applied).
  93895. * @param subMeshes The submeshes to render
  93896. */
  93897. private static renderUnsorted;
  93898. /**
  93899. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93900. * are rendered back to front if in the same alpha index.
  93901. *
  93902. * @param a The first submesh
  93903. * @param b The second submesh
  93904. * @returns The result of the comparison
  93905. */
  93906. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  93907. /**
  93908. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93909. * are rendered back to front.
  93910. *
  93911. * @param a The first submesh
  93912. * @param b The second submesh
  93913. * @returns The result of the comparison
  93914. */
  93915. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  93916. /**
  93917. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93918. * are rendered front to back (prevent overdraw).
  93919. *
  93920. * @param a The first submesh
  93921. * @param b The second submesh
  93922. * @returns The result of the comparison
  93923. */
  93924. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  93925. /**
  93926. * Resets the different lists of submeshes to prepare a new frame.
  93927. */
  93928. prepare(): void;
  93929. dispose(): void;
  93930. /**
  93931. * Inserts the submesh in its correct queue depending on its material.
  93932. * @param subMesh The submesh to dispatch
  93933. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93934. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93935. */
  93936. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93937. dispatchSprites(spriteManager: ISpriteManager): void;
  93938. dispatchParticles(particleSystem: IParticleSystem): void;
  93939. private _renderParticles;
  93940. private _renderSprites;
  93941. }
  93942. }
  93943. declare module BABYLON {
  93944. /**
  93945. * Interface describing the different options available in the rendering manager
  93946. * regarding Auto Clear between groups.
  93947. */
  93948. export interface IRenderingManagerAutoClearSetup {
  93949. /**
  93950. * Defines whether or not autoclear is enable.
  93951. */
  93952. autoClear: boolean;
  93953. /**
  93954. * Defines whether or not to autoclear the depth buffer.
  93955. */
  93956. depth: boolean;
  93957. /**
  93958. * Defines whether or not to autoclear the stencil buffer.
  93959. */
  93960. stencil: boolean;
  93961. }
  93962. /**
  93963. * This class is used by the onRenderingGroupObservable
  93964. */
  93965. export class RenderingGroupInfo {
  93966. /**
  93967. * The Scene that being rendered
  93968. */
  93969. scene: Scene;
  93970. /**
  93971. * The camera currently used for the rendering pass
  93972. */
  93973. camera: Nullable<Camera>;
  93974. /**
  93975. * The ID of the renderingGroup being processed
  93976. */
  93977. renderingGroupId: number;
  93978. }
  93979. /**
  93980. * This is the manager responsible of all the rendering for meshes sprites and particles.
  93981. * It is enable to manage the different groups as well as the different necessary sort functions.
  93982. * This should not be used directly aside of the few static configurations
  93983. */
  93984. export class RenderingManager {
  93985. /**
  93986. * The max id used for rendering groups (not included)
  93987. */
  93988. static MAX_RENDERINGGROUPS: number;
  93989. /**
  93990. * The min id used for rendering groups (included)
  93991. */
  93992. static MIN_RENDERINGGROUPS: number;
  93993. /**
  93994. * Used to globally prevent autoclearing scenes.
  93995. */
  93996. static AUTOCLEAR: boolean;
  93997. /**
  93998. * @hidden
  93999. */
  94000. _useSceneAutoClearSetup: boolean;
  94001. private _scene;
  94002. private _renderingGroups;
  94003. private _depthStencilBufferAlreadyCleaned;
  94004. private _autoClearDepthStencil;
  94005. private _customOpaqueSortCompareFn;
  94006. private _customAlphaTestSortCompareFn;
  94007. private _customTransparentSortCompareFn;
  94008. private _renderingGroupInfo;
  94009. /**
  94010. * Instantiates a new rendering group for a particular scene
  94011. * @param scene Defines the scene the groups belongs to
  94012. */
  94013. constructor(scene: Scene);
  94014. private _clearDepthStencilBuffer;
  94015. /**
  94016. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94017. * @hidden
  94018. */
  94019. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94020. /**
  94021. * Resets the different information of the group to prepare a new frame
  94022. * @hidden
  94023. */
  94024. reset(): void;
  94025. /**
  94026. * Dispose and release the group and its associated resources.
  94027. * @hidden
  94028. */
  94029. dispose(): void;
  94030. /**
  94031. * Clear the info related to rendering groups preventing retention points during dispose.
  94032. */
  94033. freeRenderingGroups(): void;
  94034. private _prepareRenderingGroup;
  94035. /**
  94036. * Add a sprite manager to the rendering manager in order to render it this frame.
  94037. * @param spriteManager Define the sprite manager to render
  94038. */
  94039. dispatchSprites(spriteManager: ISpriteManager): void;
  94040. /**
  94041. * Add a particle system to the rendering manager in order to render it this frame.
  94042. * @param particleSystem Define the particle system to render
  94043. */
  94044. dispatchParticles(particleSystem: IParticleSystem): void;
  94045. /**
  94046. * Add a submesh to the manager in order to render it this frame
  94047. * @param subMesh The submesh to dispatch
  94048. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94049. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94050. */
  94051. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94052. /**
  94053. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94054. * This allowed control for front to back rendering or reversly depending of the special needs.
  94055. *
  94056. * @param renderingGroupId The rendering group id corresponding to its index
  94057. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94058. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94059. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94060. */
  94061. 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;
  94062. /**
  94063. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94064. *
  94065. * @param renderingGroupId The rendering group id corresponding to its index
  94066. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94067. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94068. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94069. */
  94070. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94071. /**
  94072. * Gets the current auto clear configuration for one rendering group of the rendering
  94073. * manager.
  94074. * @param index the rendering group index to get the information for
  94075. * @returns The auto clear setup for the requested rendering group
  94076. */
  94077. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94078. }
  94079. }
  94080. declare module BABYLON {
  94081. /**
  94082. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94083. */
  94084. export interface ICustomShaderOptions {
  94085. /**
  94086. * Gets or sets the custom shader name to use
  94087. */
  94088. shaderName: string;
  94089. /**
  94090. * The list of attribute names used in the shader
  94091. */
  94092. attributes?: string[];
  94093. /**
  94094. * The list of unifrom names used in the shader
  94095. */
  94096. uniforms?: string[];
  94097. /**
  94098. * The list of sampler names used in the shader
  94099. */
  94100. samplers?: string[];
  94101. /**
  94102. * The list of defines used in the shader
  94103. */
  94104. defines?: string[];
  94105. }
  94106. /**
  94107. * Interface to implement to create a shadow generator compatible with BJS.
  94108. */
  94109. export interface IShadowGenerator {
  94110. /**
  94111. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94112. * @returns The render target texture if present otherwise, null
  94113. */
  94114. getShadowMap(): Nullable<RenderTargetTexture>;
  94115. /**
  94116. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94117. * @param subMesh The submesh we want to render in the shadow map
  94118. * @param useInstances Defines wether will draw in the map using instances
  94119. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94120. * @returns true if ready otherwise, false
  94121. */
  94122. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94123. /**
  94124. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94125. * @param defines Defines of the material we want to update
  94126. * @param lightIndex Index of the light in the enabled light list of the material
  94127. */
  94128. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94129. /**
  94130. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94131. * defined in the generator but impacting the effect).
  94132. * It implies the unifroms available on the materials are the standard BJS ones.
  94133. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94134. * @param effect The effect we are binfing the information for
  94135. */
  94136. bindShadowLight(lightIndex: string, effect: Effect): void;
  94137. /**
  94138. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94139. * (eq to shadow prjection matrix * light transform matrix)
  94140. * @returns The transform matrix used to create the shadow map
  94141. */
  94142. getTransformMatrix(): Matrix;
  94143. /**
  94144. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94145. * Cube and 2D textures for instance.
  94146. */
  94147. recreateShadowMap(): void;
  94148. /**
  94149. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94150. * @param onCompiled Callback triggered at the and of the effects compilation
  94151. * @param options Sets of optional options forcing the compilation with different modes
  94152. */
  94153. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94154. useInstances: boolean;
  94155. }>): void;
  94156. /**
  94157. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94158. * @param options Sets of optional options forcing the compilation with different modes
  94159. * @returns A promise that resolves when the compilation completes
  94160. */
  94161. forceCompilationAsync(options?: Partial<{
  94162. useInstances: boolean;
  94163. }>): Promise<void>;
  94164. /**
  94165. * Serializes the shadow generator setup to a json object.
  94166. * @returns The serialized JSON object
  94167. */
  94168. serialize(): any;
  94169. /**
  94170. * Disposes the Shadow map and related Textures and effects.
  94171. */
  94172. dispose(): void;
  94173. }
  94174. /**
  94175. * Default implementation IShadowGenerator.
  94176. * This is the main object responsible of generating shadows in the framework.
  94177. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94178. */
  94179. export class ShadowGenerator implements IShadowGenerator {
  94180. /**
  94181. * Name of the shadow generator class
  94182. */
  94183. static CLASSNAME: string;
  94184. /**
  94185. * Shadow generator mode None: no filtering applied.
  94186. */
  94187. static readonly FILTER_NONE: number;
  94188. /**
  94189. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94190. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94191. */
  94192. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94193. /**
  94194. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94195. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94196. */
  94197. static readonly FILTER_POISSONSAMPLING: number;
  94198. /**
  94199. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94201. */
  94202. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94203. /**
  94204. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94205. * edge artifacts on steep falloff.
  94206. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94207. */
  94208. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94209. /**
  94210. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94211. * edge artifacts on steep falloff.
  94212. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94213. */
  94214. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94215. /**
  94216. * Shadow generator mode PCF: Percentage Closer Filtering
  94217. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94218. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94219. */
  94220. static readonly FILTER_PCF: number;
  94221. /**
  94222. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94223. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94224. * Contact Hardening
  94225. */
  94226. static readonly FILTER_PCSS: number;
  94227. /**
  94228. * Reserved for PCF and PCSS
  94229. * Highest Quality.
  94230. *
  94231. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94232. *
  94233. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94234. */
  94235. static readonly QUALITY_HIGH: number;
  94236. /**
  94237. * Reserved for PCF and PCSS
  94238. * Good tradeoff for quality/perf cross devices
  94239. *
  94240. * Execute PCF on a 3*3 kernel.
  94241. *
  94242. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94243. */
  94244. static readonly QUALITY_MEDIUM: number;
  94245. /**
  94246. * Reserved for PCF and PCSS
  94247. * The lowest quality but the fastest.
  94248. *
  94249. * Execute PCF on a 1*1 kernel.
  94250. *
  94251. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94252. */
  94253. static readonly QUALITY_LOW: number;
  94254. /** Gets or sets the custom shader name to use */
  94255. customShaderOptions: ICustomShaderOptions;
  94256. /**
  94257. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94258. */
  94259. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94260. /**
  94261. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94262. */
  94263. onAfterShadowMapRenderObservable: Observable<Effect>;
  94264. /**
  94265. * Observable triggered before a mesh is rendered in the shadow map.
  94266. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94267. */
  94268. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94269. /**
  94270. * Observable triggered after a mesh is rendered in the shadow map.
  94271. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94272. */
  94273. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94274. protected _bias: number;
  94275. /**
  94276. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94277. */
  94278. get bias(): number;
  94279. /**
  94280. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94281. */
  94282. set bias(bias: number);
  94283. protected _normalBias: number;
  94284. /**
  94285. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94286. */
  94287. get normalBias(): number;
  94288. /**
  94289. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94290. */
  94291. set normalBias(normalBias: number);
  94292. protected _blurBoxOffset: number;
  94293. /**
  94294. * Gets the blur box offset: offset applied during the blur pass.
  94295. * Only useful if useKernelBlur = false
  94296. */
  94297. get blurBoxOffset(): number;
  94298. /**
  94299. * Sets the blur box offset: offset applied during the blur pass.
  94300. * Only useful if useKernelBlur = false
  94301. */
  94302. set blurBoxOffset(value: number);
  94303. protected _blurScale: number;
  94304. /**
  94305. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94306. * 2 means half of the size.
  94307. */
  94308. get blurScale(): number;
  94309. /**
  94310. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  94311. * 2 means half of the size.
  94312. */
  94313. set blurScale(value: number);
  94314. protected _blurKernel: number;
  94315. /**
  94316. * Gets the blur kernel: kernel size of the blur pass.
  94317. * Only useful if useKernelBlur = true
  94318. */
  94319. get blurKernel(): number;
  94320. /**
  94321. * Sets the blur kernel: kernel size of the blur pass.
  94322. * Only useful if useKernelBlur = true
  94323. */
  94324. set blurKernel(value: number);
  94325. protected _useKernelBlur: boolean;
  94326. /**
  94327. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  94328. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94329. */
  94330. get useKernelBlur(): boolean;
  94331. /**
  94332. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  94333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94334. */
  94335. set useKernelBlur(value: boolean);
  94336. protected _depthScale: number;
  94337. /**
  94338. * Gets the depth scale used in ESM mode.
  94339. */
  94340. get depthScale(): number;
  94341. /**
  94342. * Sets the depth scale used in ESM mode.
  94343. * This can override the scale stored on the light.
  94344. */
  94345. set depthScale(value: number);
  94346. protected _validateFilter(filter: number): number;
  94347. protected _filter: number;
  94348. /**
  94349. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  94350. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94351. */
  94352. get filter(): number;
  94353. /**
  94354. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  94355. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94356. */
  94357. set filter(value: number);
  94358. /**
  94359. * Gets if the current filter is set to Poisson Sampling.
  94360. */
  94361. get usePoissonSampling(): boolean;
  94362. /**
  94363. * Sets the current filter to Poisson Sampling.
  94364. */
  94365. set usePoissonSampling(value: boolean);
  94366. /**
  94367. * Gets if the current filter is set to ESM.
  94368. */
  94369. get useExponentialShadowMap(): boolean;
  94370. /**
  94371. * Sets the current filter is to ESM.
  94372. */
  94373. set useExponentialShadowMap(value: boolean);
  94374. /**
  94375. * Gets if the current filter is set to filtered ESM.
  94376. */
  94377. get useBlurExponentialShadowMap(): boolean;
  94378. /**
  94379. * Gets if the current filter is set to filtered ESM.
  94380. */
  94381. set useBlurExponentialShadowMap(value: boolean);
  94382. /**
  94383. * Gets if the current filter is set to "close ESM" (using the inverse of the
  94384. * exponential to prevent steep falloff artifacts).
  94385. */
  94386. get useCloseExponentialShadowMap(): boolean;
  94387. /**
  94388. * Sets the current filter to "close ESM" (using the inverse of the
  94389. * exponential to prevent steep falloff artifacts).
  94390. */
  94391. set useCloseExponentialShadowMap(value: boolean);
  94392. /**
  94393. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  94394. * exponential to prevent steep falloff artifacts).
  94395. */
  94396. get useBlurCloseExponentialShadowMap(): boolean;
  94397. /**
  94398. * Sets the current filter to filtered "close ESM" (using the inverse of the
  94399. * exponential to prevent steep falloff artifacts).
  94400. */
  94401. set useBlurCloseExponentialShadowMap(value: boolean);
  94402. /**
  94403. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  94404. */
  94405. get usePercentageCloserFiltering(): boolean;
  94406. /**
  94407. * Sets the current filter to "PCF" (percentage closer filtering).
  94408. */
  94409. set usePercentageCloserFiltering(value: boolean);
  94410. protected _filteringQuality: number;
  94411. /**
  94412. * Gets the PCF or PCSS Quality.
  94413. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94414. */
  94415. get filteringQuality(): number;
  94416. /**
  94417. * Sets the PCF or PCSS Quality.
  94418. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94419. */
  94420. set filteringQuality(filteringQuality: number);
  94421. /**
  94422. * Gets if the current filter is set to "PCSS" (contact hardening).
  94423. */
  94424. get useContactHardeningShadow(): boolean;
  94425. /**
  94426. * Sets the current filter to "PCSS" (contact hardening).
  94427. */
  94428. set useContactHardeningShadow(value: boolean);
  94429. protected _contactHardeningLightSizeUVRatio: number;
  94430. /**
  94431. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94432. * Using a ratio helps keeping shape stability independently of the map size.
  94433. *
  94434. * It does not account for the light projection as it was having too much
  94435. * instability during the light setup or during light position changes.
  94436. *
  94437. * Only valid if useContactHardeningShadow is true.
  94438. */
  94439. get contactHardeningLightSizeUVRatio(): number;
  94440. /**
  94441. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94442. * Using a ratio helps keeping shape stability independently of the map size.
  94443. *
  94444. * It does not account for the light projection as it was having too much
  94445. * instability during the light setup or during light position changes.
  94446. *
  94447. * Only valid if useContactHardeningShadow is true.
  94448. */
  94449. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  94450. protected _darkness: number;
  94451. /** Gets or sets the actual darkness of a shadow */
  94452. get darkness(): number;
  94453. set darkness(value: number);
  94454. /**
  94455. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  94456. * 0 means strongest and 1 would means no shadow.
  94457. * @returns the darkness.
  94458. */
  94459. getDarkness(): number;
  94460. /**
  94461. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  94462. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  94463. * @returns the shadow generator allowing fluent coding.
  94464. */
  94465. setDarkness(darkness: number): ShadowGenerator;
  94466. protected _transparencyShadow: boolean;
  94467. /** Gets or sets the ability to have transparent shadow */
  94468. get transparencyShadow(): boolean;
  94469. set transparencyShadow(value: boolean);
  94470. /**
  94471. * Sets the ability to have transparent shadow (boolean).
  94472. * @param transparent True if transparent else False
  94473. * @returns the shadow generator allowing fluent coding
  94474. */
  94475. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  94476. /**
  94477. * Enables or disables shadows with varying strength based on the transparency
  94478. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  94479. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  94480. * mesh.visibility * alphaTexture.a
  94481. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  94482. */
  94483. enableSoftTransparentShadow: boolean;
  94484. protected _shadowMap: Nullable<RenderTargetTexture>;
  94485. protected _shadowMap2: Nullable<RenderTargetTexture>;
  94486. /**
  94487. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94488. * @returns The render target texture if present otherwise, null
  94489. */
  94490. getShadowMap(): Nullable<RenderTargetTexture>;
  94491. /**
  94492. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  94493. * @returns The render target texture if the shadow map is present otherwise, null
  94494. */
  94495. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  94496. /**
  94497. * Gets the class name of that object
  94498. * @returns "ShadowGenerator"
  94499. */
  94500. getClassName(): string;
  94501. /**
  94502. * Helper function to add a mesh and its descendants to the list of shadow casters.
  94503. * @param mesh Mesh to add
  94504. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  94505. * @returns the Shadow Generator itself
  94506. */
  94507. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94508. /**
  94509. * Helper function to remove a mesh and its descendants from the list of shadow casters
  94510. * @param mesh Mesh to remove
  94511. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  94512. * @returns the Shadow Generator itself
  94513. */
  94514. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94515. /**
  94516. * Controls the extent to which the shadows fade out at the edge of the frustum
  94517. */
  94518. frustumEdgeFalloff: number;
  94519. protected _light: IShadowLight;
  94520. /**
  94521. * Returns the associated light object.
  94522. * @returns the light generating the shadow
  94523. */
  94524. getLight(): IShadowLight;
  94525. /**
  94526. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  94527. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  94528. * It might on the other hand introduce peter panning.
  94529. */
  94530. forceBackFacesOnly: boolean;
  94531. protected _scene: Scene;
  94532. protected _lightDirection: Vector3;
  94533. protected _effect: Effect;
  94534. protected _viewMatrix: Matrix;
  94535. protected _projectionMatrix: Matrix;
  94536. protected _transformMatrix: Matrix;
  94537. protected _cachedPosition: Vector3;
  94538. protected _cachedDirection: Vector3;
  94539. protected _cachedDefines: string;
  94540. protected _currentRenderID: number;
  94541. protected _boxBlurPostprocess: Nullable<PostProcess>;
  94542. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  94543. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  94544. protected _blurPostProcesses: PostProcess[];
  94545. protected _mapSize: number;
  94546. protected _currentFaceIndex: number;
  94547. protected _currentFaceIndexCache: number;
  94548. protected _textureType: number;
  94549. protected _defaultTextureMatrix: Matrix;
  94550. protected _storedUniqueId: Nullable<number>;
  94551. /** @hidden */
  94552. static _SceneComponentInitialization: (scene: Scene) => void;
  94553. /**
  94554. * Creates a ShadowGenerator object.
  94555. * A ShadowGenerator is the required tool to use the shadows.
  94556. * Each light casting shadows needs to use its own ShadowGenerator.
  94557. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  94558. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  94559. * @param light The light object generating the shadows.
  94560. * @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.
  94561. */
  94562. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  94563. protected _initializeGenerator(): void;
  94564. protected _createTargetRenderTexture(): void;
  94565. protected _initializeShadowMap(): void;
  94566. protected _initializeBlurRTTAndPostProcesses(): void;
  94567. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  94568. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  94569. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  94570. protected _applyFilterValues(): void;
  94571. /**
  94572. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94573. * @param onCompiled Callback triggered at the and of the effects compilation
  94574. * @param options Sets of optional options forcing the compilation with different modes
  94575. */
  94576. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94577. useInstances: boolean;
  94578. }>): void;
  94579. /**
  94580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94581. * @param options Sets of optional options forcing the compilation with different modes
  94582. * @returns A promise that resolves when the compilation completes
  94583. */
  94584. forceCompilationAsync(options?: Partial<{
  94585. useInstances: boolean;
  94586. }>): Promise<void>;
  94587. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  94588. private _prepareShadowDefines;
  94589. /**
  94590. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94591. * @param subMesh The submesh we want to render in the shadow map
  94592. * @param useInstances Defines wether will draw in the map using instances
  94593. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94594. * @returns true if ready otherwise, false
  94595. */
  94596. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94597. /**
  94598. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94599. * @param defines Defines of the material we want to update
  94600. * @param lightIndex Index of the light in the enabled light list of the material
  94601. */
  94602. prepareDefines(defines: any, lightIndex: number): void;
  94603. /**
  94604. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94605. * defined in the generator but impacting the effect).
  94606. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94607. * @param effect The effect we are binfing the information for
  94608. */
  94609. bindShadowLight(lightIndex: string, effect: Effect): void;
  94610. /**
  94611. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94612. * (eq to shadow prjection matrix * light transform matrix)
  94613. * @returns The transform matrix used to create the shadow map
  94614. */
  94615. getTransformMatrix(): Matrix;
  94616. /**
  94617. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94618. * Cube and 2D textures for instance.
  94619. */
  94620. recreateShadowMap(): void;
  94621. protected _disposeBlurPostProcesses(): void;
  94622. protected _disposeRTTandPostProcesses(): void;
  94623. /**
  94624. * Disposes the ShadowGenerator.
  94625. * Returns nothing.
  94626. */
  94627. dispose(): void;
  94628. /**
  94629. * Serializes the shadow generator setup to a json object.
  94630. * @returns The serialized JSON object
  94631. */
  94632. serialize(): any;
  94633. /**
  94634. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  94635. * @param parsedShadowGenerator The JSON object to parse
  94636. * @param scene The scene to create the shadow map for
  94637. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  94638. * @returns The parsed shadow generator
  94639. */
  94640. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  94641. }
  94642. }
  94643. declare module BABYLON {
  94644. /**
  94645. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  94646. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  94647. * 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.
  94648. */
  94649. export abstract class Light extends Node {
  94650. /**
  94651. * Falloff Default: light is falling off following the material specification:
  94652. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  94653. */
  94654. static readonly FALLOFF_DEFAULT: number;
  94655. /**
  94656. * Falloff Physical: light is falling off following the inverse squared distance law.
  94657. */
  94658. static readonly FALLOFF_PHYSICAL: number;
  94659. /**
  94660. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  94661. * to enhance interoperability with other engines.
  94662. */
  94663. static readonly FALLOFF_GLTF: number;
  94664. /**
  94665. * Falloff Standard: light is falling off like in the standard material
  94666. * to enhance interoperability with other materials.
  94667. */
  94668. static readonly FALLOFF_STANDARD: number;
  94669. /**
  94670. * If every light affecting the material is in this lightmapMode,
  94671. * material.lightmapTexture adds or multiplies
  94672. * (depends on material.useLightmapAsShadowmap)
  94673. * after every other light calculations.
  94674. */
  94675. static readonly LIGHTMAP_DEFAULT: number;
  94676. /**
  94677. * material.lightmapTexture as only diffuse lighting from this light
  94678. * adds only specular lighting from this light
  94679. * adds dynamic shadows
  94680. */
  94681. static readonly LIGHTMAP_SPECULAR: number;
  94682. /**
  94683. * material.lightmapTexture as only lighting
  94684. * no light calculation from this light
  94685. * only adds dynamic shadows from this light
  94686. */
  94687. static readonly LIGHTMAP_SHADOWSONLY: number;
  94688. /**
  94689. * Each light type uses the default quantity according to its type:
  94690. * point/spot lights use luminous intensity
  94691. * directional lights use illuminance
  94692. */
  94693. static readonly INTENSITYMODE_AUTOMATIC: number;
  94694. /**
  94695. * lumen (lm)
  94696. */
  94697. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  94698. /**
  94699. * candela (lm/sr)
  94700. */
  94701. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  94702. /**
  94703. * lux (lm/m^2)
  94704. */
  94705. static readonly INTENSITYMODE_ILLUMINANCE: number;
  94706. /**
  94707. * nit (cd/m^2)
  94708. */
  94709. static readonly INTENSITYMODE_LUMINANCE: number;
  94710. /**
  94711. * Light type const id of the point light.
  94712. */
  94713. static readonly LIGHTTYPEID_POINTLIGHT: number;
  94714. /**
  94715. * Light type const id of the directional light.
  94716. */
  94717. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  94718. /**
  94719. * Light type const id of the spot light.
  94720. */
  94721. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  94722. /**
  94723. * Light type const id of the hemispheric light.
  94724. */
  94725. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  94726. /**
  94727. * Diffuse gives the basic color to an object.
  94728. */
  94729. diffuse: Color3;
  94730. /**
  94731. * Specular produces a highlight color on an object.
  94732. * Note: This is note affecting PBR materials.
  94733. */
  94734. specular: Color3;
  94735. /**
  94736. * Defines the falloff type for this light. This lets overrriding how punctual light are
  94737. * falling off base on range or angle.
  94738. * This can be set to any values in Light.FALLOFF_x.
  94739. *
  94740. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  94741. * other types of materials.
  94742. */
  94743. falloffType: number;
  94744. /**
  94745. * Strength of the light.
  94746. * Note: By default it is define in the framework own unit.
  94747. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  94748. */
  94749. intensity: number;
  94750. private _range;
  94751. protected _inverseSquaredRange: number;
  94752. /**
  94753. * Defines how far from the source the light is impacting in scene units.
  94754. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94755. */
  94756. get range(): number;
  94757. /**
  94758. * Defines how far from the source the light is impacting in scene units.
  94759. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94760. */
  94761. set range(value: number);
  94762. /**
  94763. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  94764. * of light.
  94765. */
  94766. private _photometricScale;
  94767. private _intensityMode;
  94768. /**
  94769. * Gets the photometric scale used to interpret the intensity.
  94770. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94771. */
  94772. get intensityMode(): number;
  94773. /**
  94774. * Sets the photometric scale used to interpret the intensity.
  94775. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94776. */
  94777. set intensityMode(value: number);
  94778. private _radius;
  94779. /**
  94780. * Gets the light radius used by PBR Materials to simulate soft area lights.
  94781. */
  94782. get radius(): number;
  94783. /**
  94784. * sets the light radius used by PBR Materials to simulate soft area lights.
  94785. */
  94786. set radius(value: number);
  94787. private _renderPriority;
  94788. /**
  94789. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  94790. * exceeding the number allowed of the materials.
  94791. */
  94792. renderPriority: number;
  94793. private _shadowEnabled;
  94794. /**
  94795. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94796. * the current shadow generator.
  94797. */
  94798. get shadowEnabled(): boolean;
  94799. /**
  94800. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94801. * the current shadow generator.
  94802. */
  94803. set shadowEnabled(value: boolean);
  94804. private _includedOnlyMeshes;
  94805. /**
  94806. * Gets the only meshes impacted by this light.
  94807. */
  94808. get includedOnlyMeshes(): AbstractMesh[];
  94809. /**
  94810. * Sets the only meshes impacted by this light.
  94811. */
  94812. set includedOnlyMeshes(value: AbstractMesh[]);
  94813. private _excludedMeshes;
  94814. /**
  94815. * Gets the meshes not impacted by this light.
  94816. */
  94817. get excludedMeshes(): AbstractMesh[];
  94818. /**
  94819. * Sets the meshes not impacted by this light.
  94820. */
  94821. set excludedMeshes(value: AbstractMesh[]);
  94822. private _excludeWithLayerMask;
  94823. /**
  94824. * Gets the layer id use to find what meshes are not impacted by the light.
  94825. * Inactive if 0
  94826. */
  94827. get excludeWithLayerMask(): number;
  94828. /**
  94829. * Sets the layer id use to find what meshes are not impacted by the light.
  94830. * Inactive if 0
  94831. */
  94832. set excludeWithLayerMask(value: number);
  94833. private _includeOnlyWithLayerMask;
  94834. /**
  94835. * Gets the layer id use to find what meshes are impacted by the light.
  94836. * Inactive if 0
  94837. */
  94838. get includeOnlyWithLayerMask(): number;
  94839. /**
  94840. * Sets the layer id use to find what meshes are impacted by the light.
  94841. * Inactive if 0
  94842. */
  94843. set includeOnlyWithLayerMask(value: number);
  94844. private _lightmapMode;
  94845. /**
  94846. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94847. */
  94848. get lightmapMode(): number;
  94849. /**
  94850. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94851. */
  94852. set lightmapMode(value: number);
  94853. /**
  94854. * Shadow generator associted to the light.
  94855. * @hidden Internal use only.
  94856. */
  94857. _shadowGenerator: Nullable<IShadowGenerator>;
  94858. /**
  94859. * @hidden Internal use only.
  94860. */
  94861. _excludedMeshesIds: string[];
  94862. /**
  94863. * @hidden Internal use only.
  94864. */
  94865. _includedOnlyMeshesIds: string[];
  94866. /**
  94867. * The current light unifom buffer.
  94868. * @hidden Internal use only.
  94869. */
  94870. _uniformBuffer: UniformBuffer;
  94871. /** @hidden */
  94872. _renderId: number;
  94873. /**
  94874. * Creates a Light object in the scene.
  94875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  94876. * @param name The firendly name of the light
  94877. * @param scene The scene the light belongs too
  94878. */
  94879. constructor(name: string, scene: Scene);
  94880. protected abstract _buildUniformLayout(): void;
  94881. /**
  94882. * Sets the passed Effect "effect" with the Light information.
  94883. * @param effect The effect to update
  94884. * @param lightIndex The index of the light in the effect to update
  94885. * @returns The light
  94886. */
  94887. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  94888. /**
  94889. * Sets the passed Effect "effect" with the Light textures.
  94890. * @param effect The effect to update
  94891. * @param lightIndex The index of the light in the effect to update
  94892. * @returns The light
  94893. */
  94894. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  94895. /**
  94896. * Binds the lights information from the scene to the effect for the given mesh.
  94897. * @param lightIndex Light index
  94898. * @param scene The scene where the light belongs to
  94899. * @param effect The effect we are binding the data to
  94900. * @param useSpecular Defines if specular is supported
  94901. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  94902. */
  94903. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  94904. /**
  94905. * Sets the passed Effect "effect" with the Light information.
  94906. * @param effect The effect to update
  94907. * @param lightDataUniformName The uniform used to store light data (position or direction)
  94908. * @returns The light
  94909. */
  94910. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  94911. /**
  94912. * Returns the string "Light".
  94913. * @returns the class name
  94914. */
  94915. getClassName(): string;
  94916. /** @hidden */
  94917. readonly _isLight: boolean;
  94918. /**
  94919. * Converts the light information to a readable string for debug purpose.
  94920. * @param fullDetails Supports for multiple levels of logging within scene loading
  94921. * @returns the human readable light info
  94922. */
  94923. toString(fullDetails?: boolean): string;
  94924. /** @hidden */
  94925. protected _syncParentEnabledState(): void;
  94926. /**
  94927. * Set the enabled state of this node.
  94928. * @param value - the new enabled state
  94929. */
  94930. setEnabled(value: boolean): void;
  94931. /**
  94932. * Returns the Light associated shadow generator if any.
  94933. * @return the associated shadow generator.
  94934. */
  94935. getShadowGenerator(): Nullable<IShadowGenerator>;
  94936. /**
  94937. * Returns a Vector3, the absolute light position in the World.
  94938. * @returns the world space position of the light
  94939. */
  94940. getAbsolutePosition(): Vector3;
  94941. /**
  94942. * Specifies if the light will affect the passed mesh.
  94943. * @param mesh The mesh to test against the light
  94944. * @return true the mesh is affected otherwise, false.
  94945. */
  94946. canAffectMesh(mesh: AbstractMesh): boolean;
  94947. /**
  94948. * Sort function to order lights for rendering.
  94949. * @param a First Light object to compare to second.
  94950. * @param b Second Light object to compare first.
  94951. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  94952. */
  94953. static CompareLightsPriority(a: Light, b: Light): number;
  94954. /**
  94955. * Releases resources associated with this node.
  94956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94958. */
  94959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94960. /**
  94961. * Returns the light type ID (integer).
  94962. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  94963. */
  94964. getTypeID(): number;
  94965. /**
  94966. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  94967. * @returns the scaled intensity in intensity mode unit
  94968. */
  94969. getScaledIntensity(): number;
  94970. /**
  94971. * Returns a new Light object, named "name", from the current one.
  94972. * @param name The name of the cloned light
  94973. * @param newParent The parent of this light, if it has one
  94974. * @returns the new created light
  94975. */
  94976. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  94977. /**
  94978. * Serializes the current light into a Serialization object.
  94979. * @returns the serialized object.
  94980. */
  94981. serialize(): any;
  94982. /**
  94983. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  94984. * This new light is named "name" and added to the passed scene.
  94985. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  94986. * @param name The friendly name of the light
  94987. * @param scene The scene the new light will belong to
  94988. * @returns the constructor function
  94989. */
  94990. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  94991. /**
  94992. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  94993. * @param parsedLight The JSON representation of the light
  94994. * @param scene The scene to create the parsed light in
  94995. * @returns the created light after parsing
  94996. */
  94997. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  94998. private _hookArrayForExcluded;
  94999. private _hookArrayForIncludedOnly;
  95000. private _resyncMeshes;
  95001. /**
  95002. * Forces the meshes to update their light related information in their rendering used effects
  95003. * @hidden Internal Use Only
  95004. */
  95005. _markMeshesAsLightDirty(): void;
  95006. /**
  95007. * Recomputes the cached photometric scale if needed.
  95008. */
  95009. private _computePhotometricScale;
  95010. /**
  95011. * Returns the Photometric Scale according to the light type and intensity mode.
  95012. */
  95013. private _getPhotometricScale;
  95014. /**
  95015. * Reorder the light in the scene according to their defined priority.
  95016. * @hidden Internal Use Only
  95017. */
  95018. _reorderLightsInScene(): void;
  95019. /**
  95020. * Prepares the list of defines specific to the light type.
  95021. * @param defines the list of defines
  95022. * @param lightIndex defines the index of the light for the effect
  95023. */
  95024. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95025. }
  95026. }
  95027. declare module BABYLON {
  95028. /**
  95029. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95030. * This is the base of the follow, arc rotate cameras and Free camera
  95031. * @see http://doc.babylonjs.com/features/cameras
  95032. */
  95033. export class TargetCamera extends Camera {
  95034. private static _RigCamTransformMatrix;
  95035. private static _TargetTransformMatrix;
  95036. private static _TargetFocalPoint;
  95037. /**
  95038. * Define the current direction the camera is moving to
  95039. */
  95040. cameraDirection: Vector3;
  95041. /**
  95042. * Define the current rotation the camera is rotating to
  95043. */
  95044. cameraRotation: Vector2;
  95045. /**
  95046. * When set, the up vector of the camera will be updated by the rotation of the camera
  95047. */
  95048. updateUpVectorFromRotation: boolean;
  95049. private _tmpQuaternion;
  95050. /**
  95051. * Define the current rotation of the camera
  95052. */
  95053. rotation: Vector3;
  95054. /**
  95055. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95056. */
  95057. rotationQuaternion: Quaternion;
  95058. /**
  95059. * Define the current speed of the camera
  95060. */
  95061. speed: number;
  95062. /**
  95063. * Add constraint to the camera to prevent it to move freely in all directions and
  95064. * around all axis.
  95065. */
  95066. noRotationConstraint: boolean;
  95067. /**
  95068. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95069. * panning
  95070. */
  95071. invertRotation: boolean;
  95072. /**
  95073. * Speed multiplier for inverse camera panning
  95074. */
  95075. inverseRotationSpeed: number;
  95076. /**
  95077. * Define the current target of the camera as an object or a position.
  95078. */
  95079. lockedTarget: any;
  95080. /** @hidden */
  95081. _currentTarget: Vector3;
  95082. /** @hidden */
  95083. _initialFocalDistance: number;
  95084. /** @hidden */
  95085. _viewMatrix: Matrix;
  95086. /** @hidden */
  95087. _camMatrix: Matrix;
  95088. /** @hidden */
  95089. _cameraTransformMatrix: Matrix;
  95090. /** @hidden */
  95091. _cameraRotationMatrix: Matrix;
  95092. /** @hidden */
  95093. _referencePoint: Vector3;
  95094. /** @hidden */
  95095. _transformedReferencePoint: Vector3;
  95096. protected _globalCurrentTarget: Vector3;
  95097. protected _globalCurrentUpVector: Vector3;
  95098. /** @hidden */
  95099. _reset: () => void;
  95100. private _defaultUp;
  95101. /**
  95102. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95103. * This is the base of the follow, arc rotate cameras and Free camera
  95104. * @see http://doc.babylonjs.com/features/cameras
  95105. * @param name Defines the name of the camera in the scene
  95106. * @param position Defines the start position of the camera in the scene
  95107. * @param scene Defines the scene the camera belongs to
  95108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95109. */
  95110. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95111. /**
  95112. * Gets the position in front of the camera at a given distance.
  95113. * @param distance The distance from the camera we want the position to be
  95114. * @returns the position
  95115. */
  95116. getFrontPosition(distance: number): Vector3;
  95117. /** @hidden */
  95118. _getLockedTargetPosition(): Nullable<Vector3>;
  95119. private _storedPosition;
  95120. private _storedRotation;
  95121. private _storedRotationQuaternion;
  95122. /**
  95123. * Store current camera state of the camera (fov, position, rotation, etc..)
  95124. * @returns the camera
  95125. */
  95126. storeState(): Camera;
  95127. /**
  95128. * Restored camera state. You must call storeState() first
  95129. * @returns whether it was successful or not
  95130. * @hidden
  95131. */
  95132. _restoreStateValues(): boolean;
  95133. /** @hidden */
  95134. _initCache(): void;
  95135. /** @hidden */
  95136. _updateCache(ignoreParentClass?: boolean): void;
  95137. /** @hidden */
  95138. _isSynchronizedViewMatrix(): boolean;
  95139. /** @hidden */
  95140. _computeLocalCameraSpeed(): number;
  95141. /**
  95142. * Defines the target the camera should look at.
  95143. * @param target Defines the new target as a Vector or a mesh
  95144. */
  95145. setTarget(target: Vector3): void;
  95146. /**
  95147. * Return the current target position of the camera. This value is expressed in local space.
  95148. * @returns the target position
  95149. */
  95150. getTarget(): Vector3;
  95151. /** @hidden */
  95152. _decideIfNeedsToMove(): boolean;
  95153. /** @hidden */
  95154. _updatePosition(): void;
  95155. /** @hidden */
  95156. _checkInputs(): void;
  95157. protected _updateCameraRotationMatrix(): void;
  95158. /**
  95159. * 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)
  95160. * @returns the current camera
  95161. */
  95162. private _rotateUpVectorWithCameraRotationMatrix;
  95163. private _cachedRotationZ;
  95164. private _cachedQuaternionRotationZ;
  95165. /** @hidden */
  95166. _getViewMatrix(): Matrix;
  95167. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95168. /**
  95169. * @hidden
  95170. */
  95171. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95172. /**
  95173. * @hidden
  95174. */
  95175. _updateRigCameras(): void;
  95176. private _getRigCamPositionAndTarget;
  95177. /**
  95178. * Gets the current object class name.
  95179. * @return the class name
  95180. */
  95181. getClassName(): string;
  95182. }
  95183. }
  95184. declare module BABYLON {
  95185. /**
  95186. * Gather the list of keyboard event types as constants.
  95187. */
  95188. export class KeyboardEventTypes {
  95189. /**
  95190. * The keydown event is fired when a key becomes active (pressed).
  95191. */
  95192. static readonly KEYDOWN: number;
  95193. /**
  95194. * The keyup event is fired when a key has been released.
  95195. */
  95196. static readonly KEYUP: number;
  95197. }
  95198. /**
  95199. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95200. */
  95201. export class KeyboardInfo {
  95202. /**
  95203. * Defines the type of event (KeyboardEventTypes)
  95204. */
  95205. type: number;
  95206. /**
  95207. * Defines the related dom event
  95208. */
  95209. event: KeyboardEvent;
  95210. /**
  95211. * Instantiates a new keyboard info.
  95212. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95213. * @param type Defines the type of event (KeyboardEventTypes)
  95214. * @param event Defines the related dom event
  95215. */
  95216. constructor(
  95217. /**
  95218. * Defines the type of event (KeyboardEventTypes)
  95219. */
  95220. type: number,
  95221. /**
  95222. * Defines the related dom event
  95223. */
  95224. event: KeyboardEvent);
  95225. }
  95226. /**
  95227. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95228. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95229. */
  95230. export class KeyboardInfoPre extends KeyboardInfo {
  95231. /**
  95232. * Defines the type of event (KeyboardEventTypes)
  95233. */
  95234. type: number;
  95235. /**
  95236. * Defines the related dom event
  95237. */
  95238. event: KeyboardEvent;
  95239. /**
  95240. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95241. */
  95242. skipOnPointerObservable: boolean;
  95243. /**
  95244. * Instantiates a new keyboard pre info.
  95245. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95246. * @param type Defines the type of event (KeyboardEventTypes)
  95247. * @param event Defines the related dom event
  95248. */
  95249. constructor(
  95250. /**
  95251. * Defines the type of event (KeyboardEventTypes)
  95252. */
  95253. type: number,
  95254. /**
  95255. * Defines the related dom event
  95256. */
  95257. event: KeyboardEvent);
  95258. }
  95259. }
  95260. declare module BABYLON {
  95261. /**
  95262. * Manage the keyboard inputs to control the movement of a free camera.
  95263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95264. */
  95265. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95266. /**
  95267. * Defines the camera the input is attached to.
  95268. */
  95269. camera: FreeCamera;
  95270. /**
  95271. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95272. */
  95273. keysUp: number[];
  95274. /**
  95275. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95276. */
  95277. keysUpward: number[];
  95278. /**
  95279. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95280. */
  95281. keysDown: number[];
  95282. /**
  95283. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95284. */
  95285. keysDownward: number[];
  95286. /**
  95287. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95288. */
  95289. keysLeft: number[];
  95290. /**
  95291. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95292. */
  95293. keysRight: number[];
  95294. private _keys;
  95295. private _onCanvasBlurObserver;
  95296. private _onKeyboardObserver;
  95297. private _engine;
  95298. private _scene;
  95299. /**
  95300. * Attach the input controls to a specific dom element to get the input from.
  95301. * @param element Defines the element the controls should be listened from
  95302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95303. */
  95304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95305. /**
  95306. * Detach the current controls from the specified dom element.
  95307. * @param element Defines the element to stop listening the inputs from
  95308. */
  95309. detachControl(element: Nullable<HTMLElement>): void;
  95310. /**
  95311. * Update the current camera state depending on the inputs that have been used this frame.
  95312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95313. */
  95314. checkInputs(): void;
  95315. /**
  95316. * Gets the class name of the current intput.
  95317. * @returns the class name
  95318. */
  95319. getClassName(): string;
  95320. /** @hidden */
  95321. _onLostFocus(): void;
  95322. /**
  95323. * Get the friendly name associated with the input class.
  95324. * @returns the input friendly name
  95325. */
  95326. getSimpleName(): string;
  95327. }
  95328. }
  95329. declare module BABYLON {
  95330. /**
  95331. * Gather the list of pointer event types as constants.
  95332. */
  95333. export class PointerEventTypes {
  95334. /**
  95335. * 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.
  95336. */
  95337. static readonly POINTERDOWN: number;
  95338. /**
  95339. * The pointerup event is fired when a pointer is no longer active.
  95340. */
  95341. static readonly POINTERUP: number;
  95342. /**
  95343. * The pointermove event is fired when a pointer changes coordinates.
  95344. */
  95345. static readonly POINTERMOVE: number;
  95346. /**
  95347. * The pointerwheel event is fired when a mouse wheel has been rotated.
  95348. */
  95349. static readonly POINTERWHEEL: number;
  95350. /**
  95351. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  95352. */
  95353. static readonly POINTERPICK: number;
  95354. /**
  95355. * The pointertap event is fired when a the object has been touched and released without drag.
  95356. */
  95357. static readonly POINTERTAP: number;
  95358. /**
  95359. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  95360. */
  95361. static readonly POINTERDOUBLETAP: number;
  95362. }
  95363. /**
  95364. * Base class of pointer info types.
  95365. */
  95366. export class PointerInfoBase {
  95367. /**
  95368. * Defines the type of event (PointerEventTypes)
  95369. */
  95370. type: number;
  95371. /**
  95372. * Defines the related dom event
  95373. */
  95374. event: PointerEvent | MouseWheelEvent;
  95375. /**
  95376. * Instantiates the base class of pointers info.
  95377. * @param type Defines the type of event (PointerEventTypes)
  95378. * @param event Defines the related dom event
  95379. */
  95380. constructor(
  95381. /**
  95382. * Defines the type of event (PointerEventTypes)
  95383. */
  95384. type: number,
  95385. /**
  95386. * Defines the related dom event
  95387. */
  95388. event: PointerEvent | MouseWheelEvent);
  95389. }
  95390. /**
  95391. * This class is used to store pointer related info for the onPrePointerObservable event.
  95392. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  95393. */
  95394. export class PointerInfoPre extends PointerInfoBase {
  95395. /**
  95396. * Ray from a pointer if availible (eg. 6dof controller)
  95397. */
  95398. ray: Nullable<Ray>;
  95399. /**
  95400. * Defines the local position of the pointer on the canvas.
  95401. */
  95402. localPosition: Vector2;
  95403. /**
  95404. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  95405. */
  95406. skipOnPointerObservable: boolean;
  95407. /**
  95408. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  95409. * @param type Defines the type of event (PointerEventTypes)
  95410. * @param event Defines the related dom event
  95411. * @param localX Defines the local x coordinates of the pointer when the event occured
  95412. * @param localY Defines the local y coordinates of the pointer when the event occured
  95413. */
  95414. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  95415. }
  95416. /**
  95417. * This type contains all the data related to a pointer event in Babylon.js.
  95418. * 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.
  95419. */
  95420. export class PointerInfo extends PointerInfoBase {
  95421. /**
  95422. * Defines the picking info associated to the info (if any)\
  95423. */
  95424. pickInfo: Nullable<PickingInfo>;
  95425. /**
  95426. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  95427. * @param type Defines the type of event (PointerEventTypes)
  95428. * @param event Defines the related dom event
  95429. * @param pickInfo Defines the picking info associated to the info (if any)\
  95430. */
  95431. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  95432. /**
  95433. * Defines the picking info associated to the info (if any)\
  95434. */
  95435. pickInfo: Nullable<PickingInfo>);
  95436. }
  95437. /**
  95438. * Data relating to a touch event on the screen.
  95439. */
  95440. export interface PointerTouch {
  95441. /**
  95442. * X coordinate of touch.
  95443. */
  95444. x: number;
  95445. /**
  95446. * Y coordinate of touch.
  95447. */
  95448. y: number;
  95449. /**
  95450. * Id of touch. Unique for each finger.
  95451. */
  95452. pointerId: number;
  95453. /**
  95454. * Event type passed from DOM.
  95455. */
  95456. type: any;
  95457. }
  95458. }
  95459. declare module BABYLON {
  95460. /**
  95461. * Manage the mouse inputs to control the movement of a free camera.
  95462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95463. */
  95464. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  95465. /**
  95466. * Define if touch is enabled in the mouse input
  95467. */
  95468. touchEnabled: boolean;
  95469. /**
  95470. * Defines the camera the input is attached to.
  95471. */
  95472. camera: FreeCamera;
  95473. /**
  95474. * Defines the buttons associated with the input to handle camera move.
  95475. */
  95476. buttons: number[];
  95477. /**
  95478. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  95479. */
  95480. angularSensibility: number;
  95481. private _pointerInput;
  95482. private _onMouseMove;
  95483. private _observer;
  95484. private previousPosition;
  95485. /**
  95486. * Observable for when a pointer move event occurs containing the move offset
  95487. */
  95488. onPointerMovedObservable: Observable<{
  95489. offsetX: number;
  95490. offsetY: number;
  95491. }>;
  95492. /**
  95493. * @hidden
  95494. * If the camera should be rotated automatically based on pointer movement
  95495. */
  95496. _allowCameraRotation: boolean;
  95497. /**
  95498. * Manage the mouse inputs to control the movement of a free camera.
  95499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95500. * @param touchEnabled Defines if touch is enabled or not
  95501. */
  95502. constructor(
  95503. /**
  95504. * Define if touch is enabled in the mouse input
  95505. */
  95506. touchEnabled?: boolean);
  95507. /**
  95508. * Attach the input controls to a specific dom element to get the input from.
  95509. * @param element Defines the element the controls should be listened from
  95510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95511. */
  95512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95513. /**
  95514. * Called on JS contextmenu event.
  95515. * Override this method to provide functionality.
  95516. */
  95517. protected onContextMenu(evt: PointerEvent): void;
  95518. /**
  95519. * Detach the current controls from the specified dom element.
  95520. * @param element Defines the element to stop listening the inputs from
  95521. */
  95522. detachControl(element: Nullable<HTMLElement>): void;
  95523. /**
  95524. * Gets the class name of the current intput.
  95525. * @returns the class name
  95526. */
  95527. getClassName(): string;
  95528. /**
  95529. * Get the friendly name associated with the input class.
  95530. * @returns the input friendly name
  95531. */
  95532. getSimpleName(): string;
  95533. }
  95534. }
  95535. declare module BABYLON {
  95536. /**
  95537. * Manage the touch inputs to control the movement of a free camera.
  95538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95539. */
  95540. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  95541. /**
  95542. * Defines the camera the input is attached to.
  95543. */
  95544. camera: FreeCamera;
  95545. /**
  95546. * Defines the touch sensibility for rotation.
  95547. * The higher the faster.
  95548. */
  95549. touchAngularSensibility: number;
  95550. /**
  95551. * Defines the touch sensibility for move.
  95552. * The higher the faster.
  95553. */
  95554. touchMoveSensibility: number;
  95555. private _offsetX;
  95556. private _offsetY;
  95557. private _pointerPressed;
  95558. private _pointerInput;
  95559. private _observer;
  95560. private _onLostFocus;
  95561. /**
  95562. * Attach the input controls to a specific dom element to get the input from.
  95563. * @param element Defines the element the controls should be listened from
  95564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95565. */
  95566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95567. /**
  95568. * Detach the current controls from the specified dom element.
  95569. * @param element Defines the element to stop listening the inputs from
  95570. */
  95571. detachControl(element: Nullable<HTMLElement>): void;
  95572. /**
  95573. * Update the current camera state depending on the inputs that have been used this frame.
  95574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95575. */
  95576. checkInputs(): void;
  95577. /**
  95578. * Gets the class name of the current intput.
  95579. * @returns the class name
  95580. */
  95581. getClassName(): string;
  95582. /**
  95583. * Get the friendly name associated with the input class.
  95584. * @returns the input friendly name
  95585. */
  95586. getSimpleName(): string;
  95587. }
  95588. }
  95589. declare module BABYLON {
  95590. /**
  95591. * Default Inputs manager for the FreeCamera.
  95592. * It groups all the default supported inputs for ease of use.
  95593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95594. */
  95595. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  95596. /**
  95597. * @hidden
  95598. */
  95599. _mouseInput: Nullable<FreeCameraMouseInput>;
  95600. /**
  95601. * Instantiates a new FreeCameraInputsManager.
  95602. * @param camera Defines the camera the inputs belong to
  95603. */
  95604. constructor(camera: FreeCamera);
  95605. /**
  95606. * Add keyboard input support to the input manager.
  95607. * @returns the current input manager
  95608. */
  95609. addKeyboard(): FreeCameraInputsManager;
  95610. /**
  95611. * Add mouse input support to the input manager.
  95612. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  95613. * @returns the current input manager
  95614. */
  95615. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  95616. /**
  95617. * Removes the mouse input support from the manager
  95618. * @returns the current input manager
  95619. */
  95620. removeMouse(): FreeCameraInputsManager;
  95621. /**
  95622. * Add touch input support to the input manager.
  95623. * @returns the current input manager
  95624. */
  95625. addTouch(): FreeCameraInputsManager;
  95626. /**
  95627. * Remove all attached input methods from a camera
  95628. */
  95629. clear(): void;
  95630. }
  95631. }
  95632. declare module BABYLON {
  95633. /**
  95634. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95635. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  95636. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95637. */
  95638. export class FreeCamera extends TargetCamera {
  95639. /**
  95640. * Define the collision ellipsoid of the camera.
  95641. * This is helpful to simulate a camera body like the player body around the camera
  95642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95643. */
  95644. ellipsoid: Vector3;
  95645. /**
  95646. * Define an offset for the position of the ellipsoid around the camera.
  95647. * This can be helpful to determine the center of the body near the gravity center of the body
  95648. * instead of its head.
  95649. */
  95650. ellipsoidOffset: Vector3;
  95651. /**
  95652. * Enable or disable collisions of the camera with the rest of the scene objects.
  95653. */
  95654. checkCollisions: boolean;
  95655. /**
  95656. * Enable or disable gravity on the camera.
  95657. */
  95658. applyGravity: boolean;
  95659. /**
  95660. * Define the input manager associated to the camera.
  95661. */
  95662. inputs: FreeCameraInputsManager;
  95663. /**
  95664. * Gets the input sensibility for a mouse input. (default is 2000.0)
  95665. * Higher values reduce sensitivity.
  95666. */
  95667. get angularSensibility(): number;
  95668. /**
  95669. * Sets the input sensibility for a mouse input. (default is 2000.0)
  95670. * Higher values reduce sensitivity.
  95671. */
  95672. set angularSensibility(value: number);
  95673. /**
  95674. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95675. */
  95676. get keysUp(): number[];
  95677. set keysUp(value: number[]);
  95678. /**
  95679. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95680. */
  95681. get keysUpward(): number[];
  95682. set keysUpward(value: number[]);
  95683. /**
  95684. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95685. */
  95686. get keysDown(): number[];
  95687. set keysDown(value: number[]);
  95688. /**
  95689. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95690. */
  95691. get keysDownward(): number[];
  95692. set keysDownward(value: number[]);
  95693. /**
  95694. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95695. */
  95696. get keysLeft(): number[];
  95697. set keysLeft(value: number[]);
  95698. /**
  95699. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95700. */
  95701. get keysRight(): number[];
  95702. set keysRight(value: number[]);
  95703. /**
  95704. * Event raised when the camera collide with a mesh in the scene.
  95705. */
  95706. onCollide: (collidedMesh: AbstractMesh) => void;
  95707. private _collider;
  95708. private _needMoveForGravity;
  95709. private _oldPosition;
  95710. private _diffPosition;
  95711. private _newPosition;
  95712. /** @hidden */
  95713. _localDirection: Vector3;
  95714. /** @hidden */
  95715. _transformedDirection: Vector3;
  95716. /**
  95717. * Instantiates a Free Camera.
  95718. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95719. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  95720. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95721. * @param name Define the name of the camera in the scene
  95722. * @param position Define the start position of the camera in the scene
  95723. * @param scene Define the scene the camera belongs to
  95724. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95725. */
  95726. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95727. /**
  95728. * Attached controls to the current camera.
  95729. * @param element Defines the element the controls should be listened from
  95730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95731. */
  95732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95733. /**
  95734. * Detach the current controls from the camera.
  95735. * The camera will stop reacting to inputs.
  95736. * @param element Defines the element to stop listening the inputs from
  95737. */
  95738. detachControl(element: HTMLElement): void;
  95739. private _collisionMask;
  95740. /**
  95741. * Define a collision mask to limit the list of object the camera can collide with
  95742. */
  95743. get collisionMask(): number;
  95744. set collisionMask(mask: number);
  95745. /** @hidden */
  95746. _collideWithWorld(displacement: Vector3): void;
  95747. private _onCollisionPositionChange;
  95748. /** @hidden */
  95749. _checkInputs(): void;
  95750. /** @hidden */
  95751. _decideIfNeedsToMove(): boolean;
  95752. /** @hidden */
  95753. _updatePosition(): void;
  95754. /**
  95755. * Destroy the camera and release the current resources hold by it.
  95756. */
  95757. dispose(): void;
  95758. /**
  95759. * Gets the current object class name.
  95760. * @return the class name
  95761. */
  95762. getClassName(): string;
  95763. }
  95764. }
  95765. declare module BABYLON {
  95766. /**
  95767. * Represents a gamepad control stick position
  95768. */
  95769. export class StickValues {
  95770. /**
  95771. * The x component of the control stick
  95772. */
  95773. x: number;
  95774. /**
  95775. * The y component of the control stick
  95776. */
  95777. y: number;
  95778. /**
  95779. * Initializes the gamepad x and y control stick values
  95780. * @param x The x component of the gamepad control stick value
  95781. * @param y The y component of the gamepad control stick value
  95782. */
  95783. constructor(
  95784. /**
  95785. * The x component of the control stick
  95786. */
  95787. x: number,
  95788. /**
  95789. * The y component of the control stick
  95790. */
  95791. y: number);
  95792. }
  95793. /**
  95794. * An interface which manages callbacks for gamepad button changes
  95795. */
  95796. export interface GamepadButtonChanges {
  95797. /**
  95798. * Called when a gamepad has been changed
  95799. */
  95800. changed: boolean;
  95801. /**
  95802. * Called when a gamepad press event has been triggered
  95803. */
  95804. pressChanged: boolean;
  95805. /**
  95806. * Called when a touch event has been triggered
  95807. */
  95808. touchChanged: boolean;
  95809. /**
  95810. * Called when a value has changed
  95811. */
  95812. valueChanged: boolean;
  95813. }
  95814. /**
  95815. * Represents a gamepad
  95816. */
  95817. export class Gamepad {
  95818. /**
  95819. * The id of the gamepad
  95820. */
  95821. id: string;
  95822. /**
  95823. * The index of the gamepad
  95824. */
  95825. index: number;
  95826. /**
  95827. * The browser gamepad
  95828. */
  95829. browserGamepad: any;
  95830. /**
  95831. * Specifies what type of gamepad this represents
  95832. */
  95833. type: number;
  95834. private _leftStick;
  95835. private _rightStick;
  95836. /** @hidden */
  95837. _isConnected: boolean;
  95838. private _leftStickAxisX;
  95839. private _leftStickAxisY;
  95840. private _rightStickAxisX;
  95841. private _rightStickAxisY;
  95842. /**
  95843. * Triggered when the left control stick has been changed
  95844. */
  95845. private _onleftstickchanged;
  95846. /**
  95847. * Triggered when the right control stick has been changed
  95848. */
  95849. private _onrightstickchanged;
  95850. /**
  95851. * Represents a gamepad controller
  95852. */
  95853. static GAMEPAD: number;
  95854. /**
  95855. * Represents a generic controller
  95856. */
  95857. static GENERIC: number;
  95858. /**
  95859. * Represents an XBox controller
  95860. */
  95861. static XBOX: number;
  95862. /**
  95863. * Represents a pose-enabled controller
  95864. */
  95865. static POSE_ENABLED: number;
  95866. /**
  95867. * Represents an Dual Shock controller
  95868. */
  95869. static DUALSHOCK: number;
  95870. /**
  95871. * Specifies whether the left control stick should be Y-inverted
  95872. */
  95873. protected _invertLeftStickY: boolean;
  95874. /**
  95875. * Specifies if the gamepad has been connected
  95876. */
  95877. get isConnected(): boolean;
  95878. /**
  95879. * Initializes the gamepad
  95880. * @param id The id of the gamepad
  95881. * @param index The index of the gamepad
  95882. * @param browserGamepad The browser gamepad
  95883. * @param leftStickX The x component of the left joystick
  95884. * @param leftStickY The y component of the left joystick
  95885. * @param rightStickX The x component of the right joystick
  95886. * @param rightStickY The y component of the right joystick
  95887. */
  95888. constructor(
  95889. /**
  95890. * The id of the gamepad
  95891. */
  95892. id: string,
  95893. /**
  95894. * The index of the gamepad
  95895. */
  95896. index: number,
  95897. /**
  95898. * The browser gamepad
  95899. */
  95900. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  95901. /**
  95902. * Callback triggered when the left joystick has changed
  95903. * @param callback
  95904. */
  95905. onleftstickchanged(callback: (values: StickValues) => void): void;
  95906. /**
  95907. * Callback triggered when the right joystick has changed
  95908. * @param callback
  95909. */
  95910. onrightstickchanged(callback: (values: StickValues) => void): void;
  95911. /**
  95912. * Gets the left joystick
  95913. */
  95914. get leftStick(): StickValues;
  95915. /**
  95916. * Sets the left joystick values
  95917. */
  95918. set leftStick(newValues: StickValues);
  95919. /**
  95920. * Gets the right joystick
  95921. */
  95922. get rightStick(): StickValues;
  95923. /**
  95924. * Sets the right joystick value
  95925. */
  95926. set rightStick(newValues: StickValues);
  95927. /**
  95928. * Updates the gamepad joystick positions
  95929. */
  95930. update(): void;
  95931. /**
  95932. * Disposes the gamepad
  95933. */
  95934. dispose(): void;
  95935. }
  95936. /**
  95937. * Represents a generic gamepad
  95938. */
  95939. export class GenericPad extends Gamepad {
  95940. private _buttons;
  95941. private _onbuttondown;
  95942. private _onbuttonup;
  95943. /**
  95944. * Observable triggered when a button has been pressed
  95945. */
  95946. onButtonDownObservable: Observable<number>;
  95947. /**
  95948. * Observable triggered when a button has been released
  95949. */
  95950. onButtonUpObservable: Observable<number>;
  95951. /**
  95952. * Callback triggered when a button has been pressed
  95953. * @param callback Called when a button has been pressed
  95954. */
  95955. onbuttondown(callback: (buttonPressed: number) => void): void;
  95956. /**
  95957. * Callback triggered when a button has been released
  95958. * @param callback Called when a button has been released
  95959. */
  95960. onbuttonup(callback: (buttonReleased: number) => void): void;
  95961. /**
  95962. * Initializes the generic gamepad
  95963. * @param id The id of the generic gamepad
  95964. * @param index The index of the generic gamepad
  95965. * @param browserGamepad The browser gamepad
  95966. */
  95967. constructor(id: string, index: number, browserGamepad: any);
  95968. private _setButtonValue;
  95969. /**
  95970. * Updates the generic gamepad
  95971. */
  95972. update(): void;
  95973. /**
  95974. * Disposes the generic gamepad
  95975. */
  95976. dispose(): void;
  95977. }
  95978. }
  95979. declare module BABYLON {
  95980. /**
  95981. * Defines the types of pose enabled controllers that are supported
  95982. */
  95983. export enum PoseEnabledControllerType {
  95984. /**
  95985. * HTC Vive
  95986. */
  95987. VIVE = 0,
  95988. /**
  95989. * Oculus Rift
  95990. */
  95991. OCULUS = 1,
  95992. /**
  95993. * Windows mixed reality
  95994. */
  95995. WINDOWS = 2,
  95996. /**
  95997. * Samsung gear VR
  95998. */
  95999. GEAR_VR = 3,
  96000. /**
  96001. * Google Daydream
  96002. */
  96003. DAYDREAM = 4,
  96004. /**
  96005. * Generic
  96006. */
  96007. GENERIC = 5
  96008. }
  96009. /**
  96010. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96011. */
  96012. export interface MutableGamepadButton {
  96013. /**
  96014. * Value of the button/trigger
  96015. */
  96016. value: number;
  96017. /**
  96018. * If the button/trigger is currently touched
  96019. */
  96020. touched: boolean;
  96021. /**
  96022. * If the button/trigger is currently pressed
  96023. */
  96024. pressed: boolean;
  96025. }
  96026. /**
  96027. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96028. * @hidden
  96029. */
  96030. export interface ExtendedGamepadButton extends GamepadButton {
  96031. /**
  96032. * If the button/trigger is currently pressed
  96033. */
  96034. readonly pressed: boolean;
  96035. /**
  96036. * If the button/trigger is currently touched
  96037. */
  96038. readonly touched: boolean;
  96039. /**
  96040. * Value of the button/trigger
  96041. */
  96042. readonly value: number;
  96043. }
  96044. /** @hidden */
  96045. export interface _GamePadFactory {
  96046. /**
  96047. * Returns whether or not the current gamepad can be created for this type of controller.
  96048. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96049. * @returns true if it can be created, otherwise false
  96050. */
  96051. canCreate(gamepadInfo: any): boolean;
  96052. /**
  96053. * Creates a new instance of the Gamepad.
  96054. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96055. * @returns the new gamepad instance
  96056. */
  96057. create(gamepadInfo: any): Gamepad;
  96058. }
  96059. /**
  96060. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96061. */
  96062. export class PoseEnabledControllerHelper {
  96063. /** @hidden */
  96064. static _ControllerFactories: _GamePadFactory[];
  96065. /** @hidden */
  96066. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96067. /**
  96068. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96069. * @param vrGamepad the gamepad to initialized
  96070. * @returns a vr controller of the type the gamepad identified as
  96071. */
  96072. static InitiateController(vrGamepad: any): Gamepad;
  96073. }
  96074. /**
  96075. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96076. */
  96077. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96078. /**
  96079. * If the controller is used in a webXR session
  96080. */
  96081. isXR: boolean;
  96082. private _deviceRoomPosition;
  96083. private _deviceRoomRotationQuaternion;
  96084. /**
  96085. * The device position in babylon space
  96086. */
  96087. devicePosition: Vector3;
  96088. /**
  96089. * The device rotation in babylon space
  96090. */
  96091. deviceRotationQuaternion: Quaternion;
  96092. /**
  96093. * The scale factor of the device in babylon space
  96094. */
  96095. deviceScaleFactor: number;
  96096. /**
  96097. * (Likely devicePosition should be used instead) The device position in its room space
  96098. */
  96099. position: Vector3;
  96100. /**
  96101. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96102. */
  96103. rotationQuaternion: Quaternion;
  96104. /**
  96105. * The type of controller (Eg. Windows mixed reality)
  96106. */
  96107. controllerType: PoseEnabledControllerType;
  96108. protected _calculatedPosition: Vector3;
  96109. private _calculatedRotation;
  96110. /**
  96111. * The raw pose from the device
  96112. */
  96113. rawPose: DevicePose;
  96114. private _trackPosition;
  96115. private _maxRotationDistFromHeadset;
  96116. private _draggedRoomRotation;
  96117. /**
  96118. * @hidden
  96119. */
  96120. _disableTrackPosition(fixedPosition: Vector3): void;
  96121. /**
  96122. * Internal, the mesh attached to the controller
  96123. * @hidden
  96124. */
  96125. _mesh: Nullable<AbstractMesh>;
  96126. private _poseControlledCamera;
  96127. private _leftHandSystemQuaternion;
  96128. /**
  96129. * Internal, matrix used to convert room space to babylon space
  96130. * @hidden
  96131. */
  96132. _deviceToWorld: Matrix;
  96133. /**
  96134. * Node to be used when casting a ray from the controller
  96135. * @hidden
  96136. */
  96137. _pointingPoseNode: Nullable<TransformNode>;
  96138. /**
  96139. * Name of the child mesh that can be used to cast a ray from the controller
  96140. */
  96141. static readonly POINTING_POSE: string;
  96142. /**
  96143. * Creates a new PoseEnabledController from a gamepad
  96144. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96145. */
  96146. constructor(browserGamepad: any);
  96147. private _workingMatrix;
  96148. /**
  96149. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96150. */
  96151. update(): void;
  96152. /**
  96153. * Updates only the pose device and mesh without doing any button event checking
  96154. */
  96155. protected _updatePoseAndMesh(): void;
  96156. /**
  96157. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96158. * @param poseData raw pose fromthe device
  96159. */
  96160. updateFromDevice(poseData: DevicePose): void;
  96161. /**
  96162. * @hidden
  96163. */
  96164. _meshAttachedObservable: Observable<AbstractMesh>;
  96165. /**
  96166. * Attaches a mesh to the controller
  96167. * @param mesh the mesh to be attached
  96168. */
  96169. attachToMesh(mesh: AbstractMesh): void;
  96170. /**
  96171. * Attaches the controllers mesh to a camera
  96172. * @param camera the camera the mesh should be attached to
  96173. */
  96174. attachToPoseControlledCamera(camera: TargetCamera): void;
  96175. /**
  96176. * Disposes of the controller
  96177. */
  96178. dispose(): void;
  96179. /**
  96180. * The mesh that is attached to the controller
  96181. */
  96182. get mesh(): Nullable<AbstractMesh>;
  96183. /**
  96184. * Gets the ray of the controller in the direction the controller is pointing
  96185. * @param length the length the resulting ray should be
  96186. * @returns a ray in the direction the controller is pointing
  96187. */
  96188. getForwardRay(length?: number): Ray;
  96189. }
  96190. }
  96191. declare module BABYLON {
  96192. /**
  96193. * Defines the WebVRController object that represents controllers tracked in 3D space
  96194. */
  96195. export abstract class WebVRController extends PoseEnabledController {
  96196. /**
  96197. * Internal, the default controller model for the controller
  96198. */
  96199. protected _defaultModel: Nullable<AbstractMesh>;
  96200. /**
  96201. * Fired when the trigger state has changed
  96202. */
  96203. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96204. /**
  96205. * Fired when the main button state has changed
  96206. */
  96207. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96208. /**
  96209. * Fired when the secondary button state has changed
  96210. */
  96211. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96212. /**
  96213. * Fired when the pad state has changed
  96214. */
  96215. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96216. /**
  96217. * Fired when controllers stick values have changed
  96218. */
  96219. onPadValuesChangedObservable: Observable<StickValues>;
  96220. /**
  96221. * Array of button availible on the controller
  96222. */
  96223. protected _buttons: Array<MutableGamepadButton>;
  96224. private _onButtonStateChange;
  96225. /**
  96226. * Fired when a controller button's state has changed
  96227. * @param callback the callback containing the button that was modified
  96228. */
  96229. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96230. /**
  96231. * X and Y axis corresponding to the controllers joystick
  96232. */
  96233. pad: StickValues;
  96234. /**
  96235. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96236. */
  96237. hand: string;
  96238. /**
  96239. * The default controller model for the controller
  96240. */
  96241. get defaultModel(): Nullable<AbstractMesh>;
  96242. /**
  96243. * Creates a new WebVRController from a gamepad
  96244. * @param vrGamepad the gamepad that the WebVRController should be created from
  96245. */
  96246. constructor(vrGamepad: any);
  96247. /**
  96248. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96249. */
  96250. update(): void;
  96251. /**
  96252. * Function to be called when a button is modified
  96253. */
  96254. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96255. /**
  96256. * Loads a mesh and attaches it to the controller
  96257. * @param scene the scene the mesh should be added to
  96258. * @param meshLoaded callback for when the mesh has been loaded
  96259. */
  96260. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96261. private _setButtonValue;
  96262. private _changes;
  96263. private _checkChanges;
  96264. /**
  96265. * Disposes of th webVRCOntroller
  96266. */
  96267. dispose(): void;
  96268. }
  96269. }
  96270. declare module BABYLON {
  96271. /**
  96272. * The HemisphericLight simulates the ambient environment light,
  96273. * so the passed direction is the light reflection direction, not the incoming direction.
  96274. */
  96275. export class HemisphericLight extends Light {
  96276. /**
  96277. * The groundColor is the light in the opposite direction to the one specified during creation.
  96278. * 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.
  96279. */
  96280. groundColor: Color3;
  96281. /**
  96282. * The light reflection direction, not the incoming direction.
  96283. */
  96284. direction: Vector3;
  96285. /**
  96286. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96287. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96288. * The HemisphericLight can't cast shadows.
  96289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96290. * @param name The friendly name of the light
  96291. * @param direction The direction of the light reflection
  96292. * @param scene The scene the light belongs to
  96293. */
  96294. constructor(name: string, direction: Vector3, scene: Scene);
  96295. protected _buildUniformLayout(): void;
  96296. /**
  96297. * Returns the string "HemisphericLight".
  96298. * @return The class name
  96299. */
  96300. getClassName(): string;
  96301. /**
  96302. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96303. * Returns the updated direction.
  96304. * @param target The target the direction should point to
  96305. * @return The computed direction
  96306. */
  96307. setDirectionToTarget(target: Vector3): Vector3;
  96308. /**
  96309. * Returns the shadow generator associated to the light.
  96310. * @returns Always null for hemispheric lights because it does not support shadows.
  96311. */
  96312. getShadowGenerator(): Nullable<IShadowGenerator>;
  96313. /**
  96314. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  96315. * @param effect The effect to update
  96316. * @param lightIndex The index of the light in the effect to update
  96317. * @returns The hemispheric light
  96318. */
  96319. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  96320. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  96321. /**
  96322. * Computes the world matrix of the node
  96323. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96324. * @param useWasUpdatedFlag defines a reserved property
  96325. * @returns the world matrix
  96326. */
  96327. computeWorldMatrix(): Matrix;
  96328. /**
  96329. * Returns the integer 3.
  96330. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96331. */
  96332. getTypeID(): number;
  96333. /**
  96334. * Prepares the list of defines specific to the light type.
  96335. * @param defines the list of defines
  96336. * @param lightIndex defines the index of the light for the effect
  96337. */
  96338. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96339. }
  96340. }
  96341. declare module BABYLON {
  96342. /** @hidden */
  96343. export var vrMultiviewToSingleviewPixelShader: {
  96344. name: string;
  96345. shader: string;
  96346. };
  96347. }
  96348. declare module BABYLON {
  96349. /**
  96350. * Renders to multiple views with a single draw call
  96351. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  96352. */
  96353. export class MultiviewRenderTarget extends RenderTargetTexture {
  96354. /**
  96355. * Creates a multiview render target
  96356. * @param scene scene used with the render target
  96357. * @param size the size of the render target (used for each view)
  96358. */
  96359. constructor(scene: Scene, size?: number | {
  96360. width: number;
  96361. height: number;
  96362. } | {
  96363. ratio: number;
  96364. });
  96365. /**
  96366. * @hidden
  96367. * @param faceIndex the face index, if its a cube texture
  96368. */
  96369. _bindFrameBuffer(faceIndex?: number): void;
  96370. /**
  96371. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96372. * @returns the view count
  96373. */
  96374. getViewCount(): number;
  96375. }
  96376. }
  96377. declare module BABYLON {
  96378. interface Engine {
  96379. /**
  96380. * Creates a new multiview render target
  96381. * @param width defines the width of the texture
  96382. * @param height defines the height of the texture
  96383. * @returns the created multiview texture
  96384. */
  96385. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  96386. /**
  96387. * Binds a multiview framebuffer to be drawn to
  96388. * @param multiviewTexture texture to bind
  96389. */
  96390. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  96391. }
  96392. interface Camera {
  96393. /**
  96394. * @hidden
  96395. * 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)
  96396. */
  96397. _useMultiviewToSingleView: boolean;
  96398. /**
  96399. * @hidden
  96400. * 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)
  96401. */
  96402. _multiviewTexture: Nullable<RenderTargetTexture>;
  96403. /**
  96404. * @hidden
  96405. * ensures the multiview texture of the camera exists and has the specified width/height
  96406. * @param width height to set on the multiview texture
  96407. * @param height width to set on the multiview texture
  96408. */
  96409. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  96410. }
  96411. interface Scene {
  96412. /** @hidden */
  96413. _transformMatrixR: Matrix;
  96414. /** @hidden */
  96415. _multiviewSceneUbo: Nullable<UniformBuffer>;
  96416. /** @hidden */
  96417. _createMultiviewUbo(): void;
  96418. /** @hidden */
  96419. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  96420. /** @hidden */
  96421. _renderMultiviewToSingleView(camera: Camera): void;
  96422. }
  96423. }
  96424. declare module BABYLON {
  96425. /**
  96426. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  96427. * This will not be used for webXR as it supports displaying texture arrays directly
  96428. */
  96429. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  96430. /**
  96431. * Initializes a VRMultiviewToSingleview
  96432. * @param name name of the post process
  96433. * @param camera camera to be applied to
  96434. * @param scaleFactor scaling factor to the size of the output texture
  96435. */
  96436. constructor(name: string, camera: Camera, scaleFactor: number);
  96437. }
  96438. }
  96439. declare module BABYLON {
  96440. /**
  96441. * Interface used to define additional presentation attributes
  96442. */
  96443. export interface IVRPresentationAttributes {
  96444. /**
  96445. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  96446. */
  96447. highRefreshRate: boolean;
  96448. /**
  96449. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  96450. */
  96451. foveationLevel: number;
  96452. }
  96453. interface Engine {
  96454. /** @hidden */
  96455. _vrDisplay: any;
  96456. /** @hidden */
  96457. _vrSupported: boolean;
  96458. /** @hidden */
  96459. _oldSize: Size;
  96460. /** @hidden */
  96461. _oldHardwareScaleFactor: number;
  96462. /** @hidden */
  96463. _vrExclusivePointerMode: boolean;
  96464. /** @hidden */
  96465. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  96466. /** @hidden */
  96467. _onVRDisplayPointerRestricted: () => void;
  96468. /** @hidden */
  96469. _onVRDisplayPointerUnrestricted: () => void;
  96470. /** @hidden */
  96471. _onVrDisplayConnect: Nullable<(display: any) => void>;
  96472. /** @hidden */
  96473. _onVrDisplayDisconnect: Nullable<() => void>;
  96474. /** @hidden */
  96475. _onVrDisplayPresentChange: Nullable<() => void>;
  96476. /**
  96477. * Observable signaled when VR display mode changes
  96478. */
  96479. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  96480. /**
  96481. * Observable signaled when VR request present is complete
  96482. */
  96483. onVRRequestPresentComplete: Observable<boolean>;
  96484. /**
  96485. * Observable signaled when VR request present starts
  96486. */
  96487. onVRRequestPresentStart: Observable<Engine>;
  96488. /**
  96489. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  96490. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  96491. */
  96492. isInVRExclusivePointerMode: boolean;
  96493. /**
  96494. * Gets a boolean indicating if a webVR device was detected
  96495. * @returns true if a webVR device was detected
  96496. */
  96497. isVRDevicePresent(): boolean;
  96498. /**
  96499. * Gets the current webVR device
  96500. * @returns the current webVR device (or null)
  96501. */
  96502. getVRDevice(): any;
  96503. /**
  96504. * Initializes a webVR display and starts listening to display change events
  96505. * The onVRDisplayChangedObservable will be notified upon these changes
  96506. * @returns A promise containing a VRDisplay and if vr is supported
  96507. */
  96508. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  96509. /** @hidden */
  96510. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  96511. /**
  96512. * Gets or sets the presentation attributes used to configure VR rendering
  96513. */
  96514. vrPresentationAttributes?: IVRPresentationAttributes;
  96515. /**
  96516. * Call this function to switch to webVR mode
  96517. * Will do nothing if webVR is not supported or if there is no webVR device
  96518. * @param options the webvr options provided to the camera. mainly used for multiview
  96519. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96520. */
  96521. enableVR(options: WebVROptions): void;
  96522. /** @hidden */
  96523. _onVRFullScreenTriggered(): void;
  96524. }
  96525. }
  96526. declare module BABYLON {
  96527. /**
  96528. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  96529. * IMPORTANT!! The data is right-hand data.
  96530. * @export
  96531. * @interface DevicePose
  96532. */
  96533. export interface DevicePose {
  96534. /**
  96535. * The position of the device, values in array are [x,y,z].
  96536. */
  96537. readonly position: Nullable<Float32Array>;
  96538. /**
  96539. * The linearVelocity of the device, values in array are [x,y,z].
  96540. */
  96541. readonly linearVelocity: Nullable<Float32Array>;
  96542. /**
  96543. * The linearAcceleration of the device, values in array are [x,y,z].
  96544. */
  96545. readonly linearAcceleration: Nullable<Float32Array>;
  96546. /**
  96547. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  96548. */
  96549. readonly orientation: Nullable<Float32Array>;
  96550. /**
  96551. * The angularVelocity of the device, values in array are [x,y,z].
  96552. */
  96553. readonly angularVelocity: Nullable<Float32Array>;
  96554. /**
  96555. * The angularAcceleration of the device, values in array are [x,y,z].
  96556. */
  96557. readonly angularAcceleration: Nullable<Float32Array>;
  96558. }
  96559. /**
  96560. * Interface representing a pose controlled object in Babylon.
  96561. * A pose controlled object has both regular pose values as well as pose values
  96562. * from an external device such as a VR head mounted display
  96563. */
  96564. export interface PoseControlled {
  96565. /**
  96566. * The position of the object in babylon space.
  96567. */
  96568. position: Vector3;
  96569. /**
  96570. * The rotation quaternion of the object in babylon space.
  96571. */
  96572. rotationQuaternion: Quaternion;
  96573. /**
  96574. * The position of the device in babylon space.
  96575. */
  96576. devicePosition?: Vector3;
  96577. /**
  96578. * The rotation quaternion of the device in babylon space.
  96579. */
  96580. deviceRotationQuaternion: Quaternion;
  96581. /**
  96582. * The raw pose coming from the device.
  96583. */
  96584. rawPose: Nullable<DevicePose>;
  96585. /**
  96586. * The scale of the device to be used when translating from device space to babylon space.
  96587. */
  96588. deviceScaleFactor: number;
  96589. /**
  96590. * Updates the poseControlled values based on the input device pose.
  96591. * @param poseData the pose data to update the object with
  96592. */
  96593. updateFromDevice(poseData: DevicePose): void;
  96594. }
  96595. /**
  96596. * Set of options to customize the webVRCamera
  96597. */
  96598. export interface WebVROptions {
  96599. /**
  96600. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  96601. */
  96602. trackPosition?: boolean;
  96603. /**
  96604. * Sets the scale of the vrDevice in babylon space. (default: 1)
  96605. */
  96606. positionScale?: number;
  96607. /**
  96608. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  96609. */
  96610. displayName?: string;
  96611. /**
  96612. * Should the native controller meshes be initialized. (default: true)
  96613. */
  96614. controllerMeshes?: boolean;
  96615. /**
  96616. * Creating a default HemiLight only on controllers. (default: true)
  96617. */
  96618. defaultLightingOnControllers?: boolean;
  96619. /**
  96620. * If you don't want to use the default VR button of the helper. (default: false)
  96621. */
  96622. useCustomVRButton?: boolean;
  96623. /**
  96624. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  96625. */
  96626. customVRButton?: HTMLButtonElement;
  96627. /**
  96628. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  96629. */
  96630. rayLength?: number;
  96631. /**
  96632. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  96633. */
  96634. defaultHeight?: number;
  96635. /**
  96636. * If multiview should be used if availible (default: false)
  96637. */
  96638. useMultiview?: boolean;
  96639. }
  96640. /**
  96641. * This represents a WebVR camera.
  96642. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  96643. * @example http://doc.babylonjs.com/how_to/webvr_camera
  96644. */
  96645. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  96646. private webVROptions;
  96647. /**
  96648. * @hidden
  96649. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  96650. */
  96651. _vrDevice: any;
  96652. /**
  96653. * The rawPose of the vrDevice.
  96654. */
  96655. rawPose: Nullable<DevicePose>;
  96656. private _onVREnabled;
  96657. private _specsVersion;
  96658. private _attached;
  96659. private _frameData;
  96660. protected _descendants: Array<Node>;
  96661. private _deviceRoomPosition;
  96662. /** @hidden */
  96663. _deviceRoomRotationQuaternion: Quaternion;
  96664. private _standingMatrix;
  96665. /**
  96666. * Represents device position in babylon space.
  96667. */
  96668. devicePosition: Vector3;
  96669. /**
  96670. * Represents device rotation in babylon space.
  96671. */
  96672. deviceRotationQuaternion: Quaternion;
  96673. /**
  96674. * The scale of the device to be used when translating from device space to babylon space.
  96675. */
  96676. deviceScaleFactor: number;
  96677. private _deviceToWorld;
  96678. private _worldToDevice;
  96679. /**
  96680. * References to the webVR controllers for the vrDevice.
  96681. */
  96682. controllers: Array<WebVRController>;
  96683. /**
  96684. * Emits an event when a controller is attached.
  96685. */
  96686. onControllersAttachedObservable: Observable<WebVRController[]>;
  96687. /**
  96688. * Emits an event when a controller's mesh has been loaded;
  96689. */
  96690. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96691. /**
  96692. * Emits an event when the HMD's pose has been updated.
  96693. */
  96694. onPoseUpdatedFromDeviceObservable: Observable<any>;
  96695. private _poseSet;
  96696. /**
  96697. * If the rig cameras be used as parent instead of this camera.
  96698. */
  96699. rigParenting: boolean;
  96700. private _lightOnControllers;
  96701. private _defaultHeight?;
  96702. /**
  96703. * Instantiates a WebVRFreeCamera.
  96704. * @param name The name of the WebVRFreeCamera
  96705. * @param position The starting anchor position for the camera
  96706. * @param scene The scene the camera belongs to
  96707. * @param webVROptions a set of customizable options for the webVRCamera
  96708. */
  96709. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  96710. /**
  96711. * Gets the device distance from the ground in meters.
  96712. * @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.
  96713. */
  96714. deviceDistanceToRoomGround(): number;
  96715. /**
  96716. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96717. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  96718. */
  96719. useStandingMatrix(callback?: (bool: boolean) => void): void;
  96720. /**
  96721. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96722. * @returns A promise with a boolean set to if the standing matrix is supported.
  96723. */
  96724. useStandingMatrixAsync(): Promise<boolean>;
  96725. /**
  96726. * Disposes the camera
  96727. */
  96728. dispose(): void;
  96729. /**
  96730. * Gets a vrController by name.
  96731. * @param name The name of the controller to retreive
  96732. * @returns the controller matching the name specified or null if not found
  96733. */
  96734. getControllerByName(name: string): Nullable<WebVRController>;
  96735. private _leftController;
  96736. /**
  96737. * The controller corresponding to the users left hand.
  96738. */
  96739. get leftController(): Nullable<WebVRController>;
  96740. private _rightController;
  96741. /**
  96742. * The controller corresponding to the users right hand.
  96743. */
  96744. get rightController(): Nullable<WebVRController>;
  96745. /**
  96746. * Casts a ray forward from the vrCamera's gaze.
  96747. * @param length Length of the ray (default: 100)
  96748. * @returns the ray corresponding to the gaze
  96749. */
  96750. getForwardRay(length?: number): Ray;
  96751. /**
  96752. * @hidden
  96753. * Updates the camera based on device's frame data
  96754. */
  96755. _checkInputs(): void;
  96756. /**
  96757. * Updates the poseControlled values based on the input device pose.
  96758. * @param poseData Pose coming from the device
  96759. */
  96760. updateFromDevice(poseData: DevicePose): void;
  96761. private _htmlElementAttached;
  96762. private _detachIfAttached;
  96763. /**
  96764. * WebVR's attach control will start broadcasting frames to the device.
  96765. * Note that in certain browsers (chrome for example) this function must be called
  96766. * within a user-interaction callback. Example:
  96767. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  96768. *
  96769. * @param element html element to attach the vrDevice to
  96770. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  96771. */
  96772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96773. /**
  96774. * Detaches the camera from the html element and disables VR
  96775. *
  96776. * @param element html element to detach from
  96777. */
  96778. detachControl(element: HTMLElement): void;
  96779. /**
  96780. * @returns the name of this class
  96781. */
  96782. getClassName(): string;
  96783. /**
  96784. * Calls resetPose on the vrDisplay
  96785. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  96786. */
  96787. resetToCurrentRotation(): void;
  96788. /**
  96789. * @hidden
  96790. * Updates the rig cameras (left and right eye)
  96791. */
  96792. _updateRigCameras(): void;
  96793. private _workingVector;
  96794. private _oneVector;
  96795. private _workingMatrix;
  96796. private updateCacheCalled;
  96797. private _correctPositionIfNotTrackPosition;
  96798. /**
  96799. * @hidden
  96800. * Updates the cached values of the camera
  96801. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  96802. */
  96803. _updateCache(ignoreParentClass?: boolean): void;
  96804. /**
  96805. * @hidden
  96806. * Get current device position in babylon world
  96807. */
  96808. _computeDevicePosition(): void;
  96809. /**
  96810. * Updates the current device position and rotation in the babylon world
  96811. */
  96812. update(): void;
  96813. /**
  96814. * @hidden
  96815. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  96816. * @returns an identity matrix
  96817. */
  96818. _getViewMatrix(): Matrix;
  96819. private _tmpMatrix;
  96820. /**
  96821. * This function is called by the two RIG cameras.
  96822. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  96823. * @hidden
  96824. */
  96825. _getWebVRViewMatrix(): Matrix;
  96826. /** @hidden */
  96827. _getWebVRProjectionMatrix(): Matrix;
  96828. private _onGamepadConnectedObserver;
  96829. private _onGamepadDisconnectedObserver;
  96830. private _updateCacheWhenTrackingDisabledObserver;
  96831. /**
  96832. * Initializes the controllers and their meshes
  96833. */
  96834. initControllers(): void;
  96835. }
  96836. }
  96837. declare module BABYLON {
  96838. /**
  96839. * "Static Class" containing the most commonly used helper while dealing with material for
  96840. * rendering purpose.
  96841. *
  96842. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  96843. *
  96844. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96845. */
  96846. export class MaterialHelper {
  96847. /**
  96848. * Bind the current view position to an effect.
  96849. * @param effect The effect to be bound
  96850. * @param scene The scene the eyes position is used from
  96851. * @param variableName name of the shader variable that will hold the eye position
  96852. */
  96853. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  96854. /**
  96855. * Helps preparing the defines values about the UVs in used in the effect.
  96856. * UVs are shared as much as we can accross channels in the shaders.
  96857. * @param texture The texture we are preparing the UVs for
  96858. * @param defines The defines to update
  96859. * @param key The channel key "diffuse", "specular"... used in the shader
  96860. */
  96861. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  96862. /**
  96863. * Binds a texture matrix value to its corrsponding uniform
  96864. * @param texture The texture to bind the matrix for
  96865. * @param uniformBuffer The uniform buffer receivin the data
  96866. * @param key The channel key "diffuse", "specular"... used in the shader
  96867. */
  96868. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  96869. /**
  96870. * Gets the current status of the fog (should it be enabled?)
  96871. * @param mesh defines the mesh to evaluate for fog support
  96872. * @param scene defines the hosting scene
  96873. * @returns true if fog must be enabled
  96874. */
  96875. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  96876. /**
  96877. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  96878. * @param mesh defines the current mesh
  96879. * @param scene defines the current scene
  96880. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  96881. * @param pointsCloud defines if point cloud rendering has to be turned on
  96882. * @param fogEnabled defines if fog has to be turned on
  96883. * @param alphaTest defines if alpha testing has to be turned on
  96884. * @param defines defines the current list of defines
  96885. */
  96886. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  96887. /**
  96888. * Helper used to prepare the list of defines associated with frame values for shader compilation
  96889. * @param scene defines the current scene
  96890. * @param engine defines the current engine
  96891. * @param defines specifies the list of active defines
  96892. * @param useInstances defines if instances have to be turned on
  96893. * @param useClipPlane defines if clip plane have to be turned on
  96894. */
  96895. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  96896. /**
  96897. * Prepares the defines for bones
  96898. * @param mesh The mesh containing the geometry data we will draw
  96899. * @param defines The defines to update
  96900. */
  96901. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  96902. /**
  96903. * Prepares the defines for morph targets
  96904. * @param mesh The mesh containing the geometry data we will draw
  96905. * @param defines The defines to update
  96906. */
  96907. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  96908. /**
  96909. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  96910. * @param mesh The mesh containing the geometry data we will draw
  96911. * @param defines The defines to update
  96912. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  96913. * @param useBones Precise whether bones should be used or not (override mesh info)
  96914. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  96915. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  96916. * @returns false if defines are considered not dirty and have not been checked
  96917. */
  96918. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  96919. /**
  96920. * Prepares the defines related to multiview
  96921. * @param scene The scene we are intending to draw
  96922. * @param defines The defines to update
  96923. */
  96924. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  96925. /**
  96926. * Prepares the defines related to the light information passed in parameter
  96927. * @param scene The scene we are intending to draw
  96928. * @param mesh The mesh the effect is compiling for
  96929. * @param light The light the effect is compiling for
  96930. * @param lightIndex The index of the light
  96931. * @param defines The defines to update
  96932. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  96933. * @param state Defines the current state regarding what is needed (normals, etc...)
  96934. */
  96935. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  96936. needNormals: boolean;
  96937. needRebuild: boolean;
  96938. shadowEnabled: boolean;
  96939. specularEnabled: boolean;
  96940. lightmapMode: boolean;
  96941. }): void;
  96942. /**
  96943. * Prepares the defines related to the light information passed in parameter
  96944. * @param scene The scene we are intending to draw
  96945. * @param mesh The mesh the effect is compiling for
  96946. * @param defines The defines to update
  96947. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  96948. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  96949. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  96950. * @returns true if normals will be required for the rest of the effect
  96951. */
  96952. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  96953. /**
  96954. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  96955. * @param lightIndex defines the light index
  96956. * @param uniformsList The uniform list
  96957. * @param samplersList The sampler list
  96958. * @param projectedLightTexture defines if projected texture must be used
  96959. * @param uniformBuffersList defines an optional list of uniform buffers
  96960. */
  96961. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  96962. /**
  96963. * Prepares the uniforms and samplers list to be used in the effect
  96964. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  96965. * @param samplersList The sampler list
  96966. * @param defines The defines helping in the list generation
  96967. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  96968. */
  96969. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  96970. /**
  96971. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  96972. * @param defines The defines to update while falling back
  96973. * @param fallbacks The authorized effect fallbacks
  96974. * @param maxSimultaneousLights The maximum number of lights allowed
  96975. * @param rank the current rank of the Effect
  96976. * @returns The newly affected rank
  96977. */
  96978. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  96979. private static _TmpMorphInfluencers;
  96980. /**
  96981. * Prepares the list of attributes required for morph targets according to the effect defines.
  96982. * @param attribs The current list of supported attribs
  96983. * @param mesh The mesh to prepare the morph targets attributes for
  96984. * @param influencers The number of influencers
  96985. */
  96986. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  96987. /**
  96988. * Prepares the list of attributes required for morph targets according to the effect defines.
  96989. * @param attribs The current list of supported attribs
  96990. * @param mesh The mesh to prepare the morph targets attributes for
  96991. * @param defines The current Defines of the effect
  96992. */
  96993. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  96994. /**
  96995. * Prepares the list of attributes required for bones according to the effect defines.
  96996. * @param attribs The current list of supported attribs
  96997. * @param mesh The mesh to prepare the bones attributes for
  96998. * @param defines The current Defines of the effect
  96999. * @param fallbacks The current efffect fallback strategy
  97000. */
  97001. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97002. /**
  97003. * Check and prepare the list of attributes required for instances according to the effect defines.
  97004. * @param attribs The current list of supported attribs
  97005. * @param defines The current MaterialDefines of the effect
  97006. */
  97007. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97008. /**
  97009. * Add the list of attributes required for instances to the attribs array.
  97010. * @param attribs The current list of supported attribs
  97011. */
  97012. static PushAttributesForInstances(attribs: string[]): void;
  97013. /**
  97014. * Binds the light information to the effect.
  97015. * @param light The light containing the generator
  97016. * @param effect The effect we are binding the data to
  97017. * @param lightIndex The light index in the effect used to render
  97018. */
  97019. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97020. /**
  97021. * Binds the lights information from the scene to the effect for the given mesh.
  97022. * @param light Light to bind
  97023. * @param lightIndex Light index
  97024. * @param scene The scene where the light belongs to
  97025. * @param effect The effect we are binding the data to
  97026. * @param useSpecular Defines if specular is supported
  97027. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97028. */
  97029. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97030. /**
  97031. * Binds the lights information from the scene to the effect for the given mesh.
  97032. * @param scene The scene the lights belongs to
  97033. * @param mesh The mesh we are binding the information to render
  97034. * @param effect The effect we are binding the data to
  97035. * @param defines The generated defines for the effect
  97036. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97037. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97038. */
  97039. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97040. private static _tempFogColor;
  97041. /**
  97042. * Binds the fog information from the scene to the effect for the given mesh.
  97043. * @param scene The scene the lights belongs to
  97044. * @param mesh The mesh we are binding the information to render
  97045. * @param effect The effect we are binding the data to
  97046. * @param linearSpace Defines if the fog effect is applied in linear space
  97047. */
  97048. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97049. /**
  97050. * Binds the bones information from the mesh to the effect.
  97051. * @param mesh The mesh we are binding the information to render
  97052. * @param effect The effect we are binding the data to
  97053. */
  97054. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97055. /**
  97056. * Binds the morph targets information from the mesh to the effect.
  97057. * @param abstractMesh The mesh we are binding the information to render
  97058. * @param effect The effect we are binding the data to
  97059. */
  97060. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97061. /**
  97062. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97063. * @param defines The generated defines used in the effect
  97064. * @param effect The effect we are binding the data to
  97065. * @param scene The scene we are willing to render with logarithmic scale for
  97066. */
  97067. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97068. /**
  97069. * Binds the clip plane information from the scene to the effect.
  97070. * @param scene The scene the clip plane information are extracted from
  97071. * @param effect The effect we are binding the data to
  97072. */
  97073. static BindClipPlane(effect: Effect, scene: Scene): void;
  97074. }
  97075. }
  97076. declare module BABYLON {
  97077. /**
  97078. * Block used to expose an input value
  97079. */
  97080. export class InputBlock extends NodeMaterialBlock {
  97081. private _mode;
  97082. private _associatedVariableName;
  97083. private _storedValue;
  97084. private _valueCallback;
  97085. private _type;
  97086. private _animationType;
  97087. /** Gets or set a value used to limit the range of float values */
  97088. min: number;
  97089. /** Gets or set a value used to limit the range of float values */
  97090. max: number;
  97091. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97092. isBoolean: boolean;
  97093. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97094. matrixMode: number;
  97095. /** @hidden */
  97096. _systemValue: Nullable<NodeMaterialSystemValues>;
  97097. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97098. visibleInInspector: boolean;
  97099. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97100. isConstant: boolean;
  97101. /** Gets or sets the group to use to display this block in the Inspector */
  97102. groupInInspector: string;
  97103. /** Gets an observable raised when the value is changed */
  97104. onValueChangedObservable: Observable<InputBlock>;
  97105. /**
  97106. * Gets or sets the connection point type (default is float)
  97107. */
  97108. get type(): NodeMaterialBlockConnectionPointTypes;
  97109. /**
  97110. * Creates a new InputBlock
  97111. * @param name defines the block name
  97112. * @param target defines the target of that block (Vertex by default)
  97113. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97114. */
  97115. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97116. /**
  97117. * Gets the output component
  97118. */
  97119. get output(): NodeMaterialConnectionPoint;
  97120. /**
  97121. * Set the source of this connection point to a vertex attribute
  97122. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97123. * @returns the current connection point
  97124. */
  97125. setAsAttribute(attributeName?: string): InputBlock;
  97126. /**
  97127. * Set the source of this connection point to a system value
  97128. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97129. * @returns the current connection point
  97130. */
  97131. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97132. /**
  97133. * Gets or sets the value of that point.
  97134. * Please note that this value will be ignored if valueCallback is defined
  97135. */
  97136. get value(): any;
  97137. set value(value: any);
  97138. /**
  97139. * Gets or sets a callback used to get the value of that point.
  97140. * Please note that setting this value will force the connection point to ignore the value property
  97141. */
  97142. get valueCallback(): () => any;
  97143. set valueCallback(value: () => any);
  97144. /**
  97145. * Gets or sets the associated variable name in the shader
  97146. */
  97147. get associatedVariableName(): string;
  97148. set associatedVariableName(value: string);
  97149. /** Gets or sets the type of animation applied to the input */
  97150. get animationType(): AnimatedInputBlockTypes;
  97151. set animationType(value: AnimatedInputBlockTypes);
  97152. /**
  97153. * Gets a boolean indicating that this connection point not defined yet
  97154. */
  97155. get isUndefined(): boolean;
  97156. /**
  97157. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97158. * In this case the connection point name must be the name of the uniform to use.
  97159. * Can only be set on inputs
  97160. */
  97161. get isUniform(): boolean;
  97162. set isUniform(value: boolean);
  97163. /**
  97164. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97165. * In this case the connection point name must be the name of the attribute to use
  97166. * Can only be set on inputs
  97167. */
  97168. get isAttribute(): boolean;
  97169. set isAttribute(value: boolean);
  97170. /**
  97171. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97172. * Can only be set on exit points
  97173. */
  97174. get isVarying(): boolean;
  97175. set isVarying(value: boolean);
  97176. /**
  97177. * Gets a boolean indicating that the current connection point is a system value
  97178. */
  97179. get isSystemValue(): boolean;
  97180. /**
  97181. * Gets or sets the current well known value or null if not defined as a system value
  97182. */
  97183. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97184. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97185. /**
  97186. * Gets the current class name
  97187. * @returns the class name
  97188. */
  97189. getClassName(): string;
  97190. /**
  97191. * Animate the input if animationType !== None
  97192. * @param scene defines the rendering scene
  97193. */
  97194. animate(scene: Scene): void;
  97195. private _emitDefine;
  97196. initialize(state: NodeMaterialBuildState): void;
  97197. /**
  97198. * Set the input block to its default value (based on its type)
  97199. */
  97200. setDefaultValue(): void;
  97201. private _emitConstant;
  97202. /** @hidden */
  97203. get _noContextSwitch(): boolean;
  97204. private _emit;
  97205. /** @hidden */
  97206. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97207. /** @hidden */
  97208. _transmit(effect: Effect, scene: Scene): void;
  97209. protected _buildBlock(state: NodeMaterialBuildState): void;
  97210. protected _dumpPropertiesCode(): string;
  97211. dispose(): void;
  97212. serialize(): any;
  97213. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97214. }
  97215. }
  97216. declare module BABYLON {
  97217. /**
  97218. * Enum used to define the compatibility state between two connection points
  97219. */
  97220. export enum NodeMaterialConnectionPointCompatibilityStates {
  97221. /** Points are compatibles */
  97222. Compatible = 0,
  97223. /** Points are incompatible because of their types */
  97224. TypeIncompatible = 1,
  97225. /** Points are incompatible because of their targets (vertex vs fragment) */
  97226. TargetIncompatible = 2
  97227. }
  97228. /**
  97229. * Defines the direction of a connection point
  97230. */
  97231. export enum NodeMaterialConnectionPointDirection {
  97232. /** Input */
  97233. Input = 0,
  97234. /** Output */
  97235. Output = 1
  97236. }
  97237. /**
  97238. * Defines a connection point for a block
  97239. */
  97240. export class NodeMaterialConnectionPoint {
  97241. /** @hidden */
  97242. _ownerBlock: NodeMaterialBlock;
  97243. /** @hidden */
  97244. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97245. private _endpoints;
  97246. private _associatedVariableName;
  97247. private _direction;
  97248. /** @hidden */
  97249. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97250. /** @hidden */
  97251. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97252. private _type;
  97253. /** @hidden */
  97254. _enforceAssociatedVariableName: boolean;
  97255. /** Gets the direction of the point */
  97256. get direction(): NodeMaterialConnectionPointDirection;
  97257. /** Indicates that this connection point needs dual validation before being connected to another point */
  97258. needDualDirectionValidation: boolean;
  97259. /**
  97260. * Gets or sets the additional types supported by this connection point
  97261. */
  97262. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97263. /**
  97264. * Gets or sets the additional types excluded by this connection point
  97265. */
  97266. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97267. /**
  97268. * Observable triggered when this point is connected
  97269. */
  97270. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97271. /**
  97272. * Gets or sets the associated variable name in the shader
  97273. */
  97274. get associatedVariableName(): string;
  97275. set associatedVariableName(value: string);
  97276. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97277. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97278. /**
  97279. * Gets or sets the connection point type (default is float)
  97280. */
  97281. get type(): NodeMaterialBlockConnectionPointTypes;
  97282. set type(value: NodeMaterialBlockConnectionPointTypes);
  97283. /**
  97284. * Gets or sets the connection point name
  97285. */
  97286. name: string;
  97287. /**
  97288. * Gets or sets the connection point name
  97289. */
  97290. displayName: string;
  97291. /**
  97292. * Gets or sets a boolean indicating that this connection point can be omitted
  97293. */
  97294. isOptional: boolean;
  97295. /**
  97296. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97297. */
  97298. define: string;
  97299. /** @hidden */
  97300. _prioritizeVertex: boolean;
  97301. private _target;
  97302. /** Gets or sets the target of that connection point */
  97303. get target(): NodeMaterialBlockTargets;
  97304. set target(value: NodeMaterialBlockTargets);
  97305. /**
  97306. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97307. */
  97308. get isConnected(): boolean;
  97309. /**
  97310. * Gets a boolean indicating that the current point is connected to an input block
  97311. */
  97312. get isConnectedToInputBlock(): boolean;
  97313. /**
  97314. * Gets a the connected input block (if any)
  97315. */
  97316. get connectInputBlock(): Nullable<InputBlock>;
  97317. /** Get the other side of the connection (if any) */
  97318. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97319. /** Get the block that owns this connection point */
  97320. get ownerBlock(): NodeMaterialBlock;
  97321. /** Get the block connected on the other side of this connection (if any) */
  97322. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97323. /** Get the block connected on the endpoints of this connection (if any) */
  97324. get connectedBlocks(): Array<NodeMaterialBlock>;
  97325. /** Gets the list of connected endpoints */
  97326. get endpoints(): NodeMaterialConnectionPoint[];
  97327. /** Gets a boolean indicating if that output point is connected to at least one input */
  97328. get hasEndpoints(): boolean;
  97329. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97330. get isConnectedInVertexShader(): boolean;
  97331. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97332. get isConnectedInFragmentShader(): boolean;
  97333. /**
  97334. * Creates a block suitable to be used as an input for this input point.
  97335. * If null is returned, a block based on the point type will be created.
  97336. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  97337. */
  97338. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97339. /**
  97340. * Creates a new connection point
  97341. * @param name defines the connection point name
  97342. * @param ownerBlock defines the block hosting this connection point
  97343. * @param direction defines the direction of the connection point
  97344. */
  97345. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97346. /**
  97347. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97348. * @returns the class name
  97349. */
  97350. getClassName(): string;
  97351. /**
  97352. * Gets a boolean indicating if the current point can be connected to another point
  97353. * @param connectionPoint defines the other connection point
  97354. * @returns a boolean
  97355. */
  97356. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97357. /**
  97358. * Gets a number indicating if the current point can be connected to another point
  97359. * @param connectionPoint defines the other connection point
  97360. * @returns a number defining the compatibility state
  97361. */
  97362. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97363. /**
  97364. * Connect this point to another connection point
  97365. * @param connectionPoint defines the other connection point
  97366. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97367. * @returns the current connection point
  97368. */
  97369. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97370. /**
  97371. * Disconnect this point from one of his endpoint
  97372. * @param endpoint defines the other connection point
  97373. * @returns the current connection point
  97374. */
  97375. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97376. /**
  97377. * Serializes this point in a JSON representation
  97378. * @param isInput defines if the connection point is an input (default is true)
  97379. * @returns the serialized point object
  97380. */
  97381. serialize(isInput?: boolean): any;
  97382. /**
  97383. * Release resources
  97384. */
  97385. dispose(): void;
  97386. }
  97387. }
  97388. declare module BABYLON {
  97389. /**
  97390. * Enum used to define the material modes
  97391. */
  97392. export enum NodeMaterialModes {
  97393. /** Regular material */
  97394. Material = 0,
  97395. /** For post process */
  97396. PostProcess = 1,
  97397. /** For particle system */
  97398. Particle = 2
  97399. }
  97400. }
  97401. declare module BABYLON {
  97402. /**
  97403. * Block used to read a texture from a sampler
  97404. */
  97405. export class TextureBlock extends NodeMaterialBlock {
  97406. private _defineName;
  97407. private _linearDefineName;
  97408. private _gammaDefineName;
  97409. private _tempTextureRead;
  97410. private _samplerName;
  97411. private _transformedUVName;
  97412. private _textureTransformName;
  97413. private _textureInfoName;
  97414. private _mainUVName;
  97415. private _mainUVDefineName;
  97416. private _fragmentOnly;
  97417. /**
  97418. * Gets or sets the texture associated with the node
  97419. */
  97420. texture: Nullable<Texture>;
  97421. /**
  97422. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97423. */
  97424. convertToGammaSpace: boolean;
  97425. /**
  97426. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97427. */
  97428. convertToLinearSpace: boolean;
  97429. /**
  97430. * Create a new TextureBlock
  97431. * @param name defines the block name
  97432. */
  97433. constructor(name: string, fragmentOnly?: boolean);
  97434. /**
  97435. * Gets the current class name
  97436. * @returns the class name
  97437. */
  97438. getClassName(): string;
  97439. /**
  97440. * Gets the uv input component
  97441. */
  97442. get uv(): NodeMaterialConnectionPoint;
  97443. /**
  97444. * Gets the rgba output component
  97445. */
  97446. get rgba(): NodeMaterialConnectionPoint;
  97447. /**
  97448. * Gets the rgb output component
  97449. */
  97450. get rgb(): NodeMaterialConnectionPoint;
  97451. /**
  97452. * Gets the r output component
  97453. */
  97454. get r(): NodeMaterialConnectionPoint;
  97455. /**
  97456. * Gets the g output component
  97457. */
  97458. get g(): NodeMaterialConnectionPoint;
  97459. /**
  97460. * Gets the b output component
  97461. */
  97462. get b(): NodeMaterialConnectionPoint;
  97463. /**
  97464. * Gets the a output component
  97465. */
  97466. get a(): NodeMaterialConnectionPoint;
  97467. get target(): NodeMaterialBlockTargets;
  97468. autoConfigure(material: NodeMaterial): void;
  97469. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97471. isReady(): boolean;
  97472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97473. private get _isMixed();
  97474. private _injectVertexCode;
  97475. private _writeTextureRead;
  97476. private _writeOutput;
  97477. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97478. protected _dumpPropertiesCode(): string;
  97479. serialize(): any;
  97480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97481. }
  97482. }
  97483. declare module BABYLON {
  97484. /** @hidden */
  97485. export var reflectionFunction: {
  97486. name: string;
  97487. shader: string;
  97488. };
  97489. }
  97490. declare module BABYLON {
  97491. /**
  97492. * Base block used to read a reflection texture from a sampler
  97493. */
  97494. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97495. /** @hidden */
  97496. _define3DName: string;
  97497. /** @hidden */
  97498. _defineCubicName: string;
  97499. /** @hidden */
  97500. _defineExplicitName: string;
  97501. /** @hidden */
  97502. _defineProjectionName: string;
  97503. /** @hidden */
  97504. _defineLocalCubicName: string;
  97505. /** @hidden */
  97506. _defineSphericalName: string;
  97507. /** @hidden */
  97508. _definePlanarName: string;
  97509. /** @hidden */
  97510. _defineEquirectangularName: string;
  97511. /** @hidden */
  97512. _defineMirroredEquirectangularFixedName: string;
  97513. /** @hidden */
  97514. _defineEquirectangularFixedName: string;
  97515. /** @hidden */
  97516. _defineSkyboxName: string;
  97517. /** @hidden */
  97518. _defineOppositeZ: string;
  97519. /** @hidden */
  97520. _cubeSamplerName: string;
  97521. /** @hidden */
  97522. _2DSamplerName: string;
  97523. protected _positionUVWName: string;
  97524. protected _directionWName: string;
  97525. protected _reflectionVectorName: string;
  97526. /** @hidden */
  97527. _reflectionCoordsName: string;
  97528. /** @hidden */
  97529. _reflectionMatrixName: string;
  97530. protected _reflectionColorName: string;
  97531. /**
  97532. * Gets or sets the texture associated with the node
  97533. */
  97534. texture: Nullable<BaseTexture>;
  97535. /**
  97536. * Create a new ReflectionTextureBaseBlock
  97537. * @param name defines the block name
  97538. */
  97539. constructor(name: string);
  97540. /**
  97541. * Gets the current class name
  97542. * @returns the class name
  97543. */
  97544. getClassName(): string;
  97545. /**
  97546. * Gets the world position input component
  97547. */
  97548. abstract get position(): NodeMaterialConnectionPoint;
  97549. /**
  97550. * Gets the world position input component
  97551. */
  97552. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97553. /**
  97554. * Gets the world normal input component
  97555. */
  97556. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97557. /**
  97558. * Gets the world input component
  97559. */
  97560. abstract get world(): NodeMaterialConnectionPoint;
  97561. /**
  97562. * Gets the camera (or eye) position component
  97563. */
  97564. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97565. /**
  97566. * Gets the view input component
  97567. */
  97568. abstract get view(): NodeMaterialConnectionPoint;
  97569. protected _getTexture(): Nullable<BaseTexture>;
  97570. autoConfigure(material: NodeMaterial): void;
  97571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97572. isReady(): boolean;
  97573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97574. /**
  97575. * Gets the code to inject in the vertex shader
  97576. * @param state current state of the node material building
  97577. * @returns the shader code
  97578. */
  97579. handleVertexSide(state: NodeMaterialBuildState): string;
  97580. /**
  97581. * Handles the inits for the fragment code path
  97582. * @param state node material build state
  97583. */
  97584. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97585. /**
  97586. * Generates the reflection coords code for the fragment code path
  97587. * @param worldNormalVarName name of the world normal variable
  97588. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97589. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97590. * @returns the shader code
  97591. */
  97592. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97593. /**
  97594. * Generates the reflection color code for the fragment code path
  97595. * @param lodVarName name of the lod variable
  97596. * @param swizzleLookupTexture swizzle to use for the final color variable
  97597. * @returns the shader code
  97598. */
  97599. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97600. /**
  97601. * Generates the code corresponding to the connected output points
  97602. * @param state node material build state
  97603. * @param varName name of the variable to output
  97604. * @returns the shader code
  97605. */
  97606. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97607. protected _buildBlock(state: NodeMaterialBuildState): this;
  97608. protected _dumpPropertiesCode(): string;
  97609. serialize(): any;
  97610. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97611. }
  97612. }
  97613. declare module BABYLON {
  97614. /**
  97615. * Defines a connection point to be used for points with a custom object type
  97616. */
  97617. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97618. private _blockType;
  97619. private _blockName;
  97620. private _nameForCheking?;
  97621. /**
  97622. * Creates a new connection point
  97623. * @param name defines the connection point name
  97624. * @param ownerBlock defines the block hosting this connection point
  97625. * @param direction defines the direction of the connection point
  97626. */
  97627. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97628. /**
  97629. * Gets a number indicating if the current point can be connected to another point
  97630. * @param connectionPoint defines the other connection point
  97631. * @returns a number defining the compatibility state
  97632. */
  97633. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97634. /**
  97635. * Creates a block suitable to be used as an input for this input point.
  97636. * If null is returned, a block based on the point type will be created.
  97637. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  97638. */
  97639. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97640. }
  97641. }
  97642. declare module BABYLON {
  97643. /**
  97644. * Enum defining the type of properties that can be edited in the property pages in the NME
  97645. */
  97646. export enum PropertyTypeForEdition {
  97647. /** property is a boolean */
  97648. Boolean = 0,
  97649. /** property is a float */
  97650. Float = 1,
  97651. /** property is a Vector2 */
  97652. Vector2 = 2,
  97653. /** property is a list of values */
  97654. List = 3
  97655. }
  97656. /**
  97657. * Interface that defines an option in a variable of type list
  97658. */
  97659. export interface IEditablePropertyListOption {
  97660. /** label of the option */
  97661. "label": string;
  97662. /** value of the option */
  97663. "value": number;
  97664. }
  97665. /**
  97666. * Interface that defines the options available for an editable property
  97667. */
  97668. export interface IEditablePropertyOption {
  97669. /** min value */
  97670. "min"?: number;
  97671. /** max value */
  97672. "max"?: number;
  97673. /** notifiers: indicates which actions to take when the property is changed */
  97674. "notifiers"?: {
  97675. /** the material should be rebuilt */
  97676. "rebuild"?: boolean;
  97677. /** the preview should be updated */
  97678. "update"?: boolean;
  97679. };
  97680. /** list of the options for a variable of type list */
  97681. "options"?: IEditablePropertyListOption[];
  97682. }
  97683. /**
  97684. * Interface that describes an editable property
  97685. */
  97686. export interface IPropertyDescriptionForEdition {
  97687. /** name of the property */
  97688. "propertyName": string;
  97689. /** display name of the property */
  97690. "displayName": string;
  97691. /** type of the property */
  97692. "type": PropertyTypeForEdition;
  97693. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97694. "groupName": string;
  97695. /** options for the property */
  97696. "options": IEditablePropertyOption;
  97697. }
  97698. /**
  97699. * Decorator that flags a property in a node material block as being editable
  97700. */
  97701. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97702. }
  97703. declare module BABYLON {
  97704. /**
  97705. * Block used to implement the refraction part of the sub surface module of the PBR material
  97706. */
  97707. export class RefractionBlock extends NodeMaterialBlock {
  97708. /** @hidden */
  97709. _define3DName: string;
  97710. /** @hidden */
  97711. _refractionMatrixName: string;
  97712. /** @hidden */
  97713. _defineLODRefractionAlpha: string;
  97714. /** @hidden */
  97715. _defineLinearSpecularRefraction: string;
  97716. /** @hidden */
  97717. _defineOppositeZ: string;
  97718. /** @hidden */
  97719. _cubeSamplerName: string;
  97720. /** @hidden */
  97721. _2DSamplerName: string;
  97722. /** @hidden */
  97723. _vRefractionMicrosurfaceInfosName: string;
  97724. /** @hidden */
  97725. _vRefractionInfosName: string;
  97726. private _scene;
  97727. /**
  97728. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  97729. * Materials half opaque for instance using refraction could benefit from this control.
  97730. */
  97731. linkRefractionWithTransparency: boolean;
  97732. /**
  97733. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  97734. */
  97735. invertRefractionY: boolean;
  97736. /**
  97737. * Gets or sets the texture associated with the node
  97738. */
  97739. texture: Nullable<BaseTexture>;
  97740. /**
  97741. * Create a new RefractionBlock
  97742. * @param name defines the block name
  97743. */
  97744. constructor(name: string);
  97745. /**
  97746. * Gets the current class name
  97747. * @returns the class name
  97748. */
  97749. getClassName(): string;
  97750. /**
  97751. * Gets the intensity input component
  97752. */
  97753. get intensity(): NodeMaterialConnectionPoint;
  97754. /**
  97755. * Gets the index of refraction input component
  97756. */
  97757. get indexOfRefraction(): NodeMaterialConnectionPoint;
  97758. /**
  97759. * Gets the tint at distance input component
  97760. */
  97761. get tintAtDistance(): NodeMaterialConnectionPoint;
  97762. /**
  97763. * Gets the view input component
  97764. */
  97765. get view(): NodeMaterialConnectionPoint;
  97766. /**
  97767. * Gets the refraction object output component
  97768. */
  97769. get refraction(): NodeMaterialConnectionPoint;
  97770. /**
  97771. * Returns true if the block has a texture
  97772. */
  97773. get hasTexture(): boolean;
  97774. protected _getTexture(): Nullable<BaseTexture>;
  97775. autoConfigure(material: NodeMaterial): void;
  97776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97777. isReady(): boolean;
  97778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  97779. /**
  97780. * Gets the main code of the block (fragment side)
  97781. * @param state current state of the node material building
  97782. * @returns the shader code
  97783. */
  97784. getCode(state: NodeMaterialBuildState): string;
  97785. protected _buildBlock(state: NodeMaterialBuildState): this;
  97786. protected _dumpPropertiesCode(): string;
  97787. serialize(): any;
  97788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97789. }
  97790. }
  97791. declare module BABYLON {
  97792. /**
  97793. * Base block used as input for post process
  97794. */
  97795. export class CurrentScreenBlock extends NodeMaterialBlock {
  97796. private _samplerName;
  97797. private _linearDefineName;
  97798. private _gammaDefineName;
  97799. private _mainUVName;
  97800. private _tempTextureRead;
  97801. /**
  97802. * Gets or sets the texture associated with the node
  97803. */
  97804. texture: Nullable<BaseTexture>;
  97805. /**
  97806. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97807. */
  97808. convertToGammaSpace: boolean;
  97809. /**
  97810. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97811. */
  97812. convertToLinearSpace: boolean;
  97813. /**
  97814. * Create a new CurrentScreenBlock
  97815. * @param name defines the block name
  97816. */
  97817. constructor(name: string);
  97818. /**
  97819. * Gets the current class name
  97820. * @returns the class name
  97821. */
  97822. getClassName(): string;
  97823. /**
  97824. * Gets the uv input component
  97825. */
  97826. get uv(): NodeMaterialConnectionPoint;
  97827. /**
  97828. * Gets the rgba output component
  97829. */
  97830. get rgba(): NodeMaterialConnectionPoint;
  97831. /**
  97832. * Gets the rgb output component
  97833. */
  97834. get rgb(): NodeMaterialConnectionPoint;
  97835. /**
  97836. * Gets the r output component
  97837. */
  97838. get r(): NodeMaterialConnectionPoint;
  97839. /**
  97840. * Gets the g output component
  97841. */
  97842. get g(): NodeMaterialConnectionPoint;
  97843. /**
  97844. * Gets the b output component
  97845. */
  97846. get b(): NodeMaterialConnectionPoint;
  97847. /**
  97848. * Gets the a output component
  97849. */
  97850. get a(): NodeMaterialConnectionPoint;
  97851. /**
  97852. * Initialize the block and prepare the context for build
  97853. * @param state defines the state that will be used for the build
  97854. */
  97855. initialize(state: NodeMaterialBuildState): void;
  97856. get target(): NodeMaterialBlockTargets;
  97857. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97858. isReady(): boolean;
  97859. private _injectVertexCode;
  97860. private _writeTextureRead;
  97861. private _writeOutput;
  97862. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97863. serialize(): any;
  97864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97865. }
  97866. }
  97867. declare module BABYLON {
  97868. /**
  97869. * Base block used for the particle texture
  97870. */
  97871. export class ParticleTextureBlock extends NodeMaterialBlock {
  97872. private _samplerName;
  97873. private _linearDefineName;
  97874. private _gammaDefineName;
  97875. private _tempTextureRead;
  97876. /**
  97877. * Gets or sets the texture associated with the node
  97878. */
  97879. texture: Nullable<BaseTexture>;
  97880. /**
  97881. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97882. */
  97883. convertToGammaSpace: boolean;
  97884. /**
  97885. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97886. */
  97887. convertToLinearSpace: boolean;
  97888. /**
  97889. * Create a new ParticleTextureBlock
  97890. * @param name defines the block name
  97891. */
  97892. constructor(name: string);
  97893. /**
  97894. * Gets the current class name
  97895. * @returns the class name
  97896. */
  97897. getClassName(): string;
  97898. /**
  97899. * Gets the uv input component
  97900. */
  97901. get uv(): NodeMaterialConnectionPoint;
  97902. /**
  97903. * Gets the rgba output component
  97904. */
  97905. get rgba(): NodeMaterialConnectionPoint;
  97906. /**
  97907. * Gets the rgb output component
  97908. */
  97909. get rgb(): NodeMaterialConnectionPoint;
  97910. /**
  97911. * Gets the r output component
  97912. */
  97913. get r(): NodeMaterialConnectionPoint;
  97914. /**
  97915. * Gets the g output component
  97916. */
  97917. get g(): NodeMaterialConnectionPoint;
  97918. /**
  97919. * Gets the b output component
  97920. */
  97921. get b(): NodeMaterialConnectionPoint;
  97922. /**
  97923. * Gets the a output component
  97924. */
  97925. get a(): NodeMaterialConnectionPoint;
  97926. /**
  97927. * Initialize the block and prepare the context for build
  97928. * @param state defines the state that will be used for the build
  97929. */
  97930. initialize(state: NodeMaterialBuildState): void;
  97931. autoConfigure(material: NodeMaterial): void;
  97932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97933. isReady(): boolean;
  97934. private _writeOutput;
  97935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97936. serialize(): any;
  97937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97938. }
  97939. }
  97940. declare module BABYLON {
  97941. /**
  97942. * Class used to store shared data between 2 NodeMaterialBuildState
  97943. */
  97944. export class NodeMaterialBuildStateSharedData {
  97945. /**
  97946. * Gets the list of emitted varyings
  97947. */
  97948. temps: string[];
  97949. /**
  97950. * Gets the list of emitted varyings
  97951. */
  97952. varyings: string[];
  97953. /**
  97954. * Gets the varying declaration string
  97955. */
  97956. varyingDeclaration: string;
  97957. /**
  97958. * Input blocks
  97959. */
  97960. inputBlocks: InputBlock[];
  97961. /**
  97962. * Input blocks
  97963. */
  97964. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  97965. /**
  97966. * Bindable blocks (Blocks that need to set data to the effect)
  97967. */
  97968. bindableBlocks: NodeMaterialBlock[];
  97969. /**
  97970. * List of blocks that can provide a compilation fallback
  97971. */
  97972. blocksWithFallbacks: NodeMaterialBlock[];
  97973. /**
  97974. * List of blocks that can provide a define update
  97975. */
  97976. blocksWithDefines: NodeMaterialBlock[];
  97977. /**
  97978. * List of blocks that can provide a repeatable content
  97979. */
  97980. repeatableContentBlocks: NodeMaterialBlock[];
  97981. /**
  97982. * List of blocks that can provide a dynamic list of uniforms
  97983. */
  97984. dynamicUniformBlocks: NodeMaterialBlock[];
  97985. /**
  97986. * List of blocks that can block the isReady function for the material
  97987. */
  97988. blockingBlocks: NodeMaterialBlock[];
  97989. /**
  97990. * Gets the list of animated inputs
  97991. */
  97992. animatedInputs: InputBlock[];
  97993. /**
  97994. * Build Id used to avoid multiple recompilations
  97995. */
  97996. buildId: number;
  97997. /** List of emitted variables */
  97998. variableNames: {
  97999. [key: string]: number;
  98000. };
  98001. /** List of emitted defines */
  98002. defineNames: {
  98003. [key: string]: number;
  98004. };
  98005. /** Should emit comments? */
  98006. emitComments: boolean;
  98007. /** Emit build activity */
  98008. verbose: boolean;
  98009. /** Gets or sets the hosting scene */
  98010. scene: Scene;
  98011. /**
  98012. * Gets the compilation hints emitted at compilation time
  98013. */
  98014. hints: {
  98015. needWorldViewMatrix: boolean;
  98016. needWorldViewProjectionMatrix: boolean;
  98017. needAlphaBlending: boolean;
  98018. needAlphaTesting: boolean;
  98019. };
  98020. /**
  98021. * List of compilation checks
  98022. */
  98023. checks: {
  98024. emitVertex: boolean;
  98025. emitFragment: boolean;
  98026. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98027. };
  98028. /**
  98029. * Is vertex program allowed to be empty?
  98030. */
  98031. allowEmptyVertexProgram: boolean;
  98032. /** Creates a new shared data */
  98033. constructor();
  98034. /**
  98035. * Emits console errors and exceptions if there is a failing check
  98036. */
  98037. emitErrors(): void;
  98038. }
  98039. }
  98040. declare module BABYLON {
  98041. /**
  98042. * Class used to store node based material build state
  98043. */
  98044. export class NodeMaterialBuildState {
  98045. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98046. supportUniformBuffers: boolean;
  98047. /**
  98048. * Gets the list of emitted attributes
  98049. */
  98050. attributes: string[];
  98051. /**
  98052. * Gets the list of emitted uniforms
  98053. */
  98054. uniforms: string[];
  98055. /**
  98056. * Gets the list of emitted constants
  98057. */
  98058. constants: string[];
  98059. /**
  98060. * Gets the list of emitted samplers
  98061. */
  98062. samplers: string[];
  98063. /**
  98064. * Gets the list of emitted functions
  98065. */
  98066. functions: {
  98067. [key: string]: string;
  98068. };
  98069. /**
  98070. * Gets the list of emitted extensions
  98071. */
  98072. extensions: {
  98073. [key: string]: string;
  98074. };
  98075. /**
  98076. * Gets the target of the compilation state
  98077. */
  98078. target: NodeMaterialBlockTargets;
  98079. /**
  98080. * Gets the list of emitted counters
  98081. */
  98082. counters: {
  98083. [key: string]: number;
  98084. };
  98085. /**
  98086. * Shared data between multiple NodeMaterialBuildState instances
  98087. */
  98088. sharedData: NodeMaterialBuildStateSharedData;
  98089. /** @hidden */
  98090. _vertexState: NodeMaterialBuildState;
  98091. /** @hidden */
  98092. _attributeDeclaration: string;
  98093. /** @hidden */
  98094. _uniformDeclaration: string;
  98095. /** @hidden */
  98096. _constantDeclaration: string;
  98097. /** @hidden */
  98098. _samplerDeclaration: string;
  98099. /** @hidden */
  98100. _varyingTransfer: string;
  98101. /** @hidden */
  98102. _injectAtEnd: string;
  98103. private _repeatableContentAnchorIndex;
  98104. /** @hidden */
  98105. _builtCompilationString: string;
  98106. /**
  98107. * Gets the emitted compilation strings
  98108. */
  98109. compilationString: string;
  98110. /**
  98111. * Finalize the compilation strings
  98112. * @param state defines the current compilation state
  98113. */
  98114. finalize(state: NodeMaterialBuildState): void;
  98115. /** @hidden */
  98116. get _repeatableContentAnchor(): string;
  98117. /** @hidden */
  98118. _getFreeVariableName(prefix: string): string;
  98119. /** @hidden */
  98120. _getFreeDefineName(prefix: string): string;
  98121. /** @hidden */
  98122. _excludeVariableName(name: string): void;
  98123. /** @hidden */
  98124. _emit2DSampler(name: string): void;
  98125. /** @hidden */
  98126. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98127. /** @hidden */
  98128. _emitExtension(name: string, extension: string, define?: string): void;
  98129. /** @hidden */
  98130. _emitFunction(name: string, code: string, comments: string): void;
  98131. /** @hidden */
  98132. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98133. replaceStrings?: {
  98134. search: RegExp;
  98135. replace: string;
  98136. }[];
  98137. repeatKey?: string;
  98138. }): string;
  98139. /** @hidden */
  98140. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98141. repeatKey?: string;
  98142. removeAttributes?: boolean;
  98143. removeUniforms?: boolean;
  98144. removeVaryings?: boolean;
  98145. removeIfDef?: boolean;
  98146. replaceStrings?: {
  98147. search: RegExp;
  98148. replace: string;
  98149. }[];
  98150. }, storeKey?: string): void;
  98151. /** @hidden */
  98152. _registerTempVariable(name: string): boolean;
  98153. /** @hidden */
  98154. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98155. /** @hidden */
  98156. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98157. /** @hidden */
  98158. _emitFloat(value: number): string;
  98159. }
  98160. }
  98161. declare module BABYLON {
  98162. /**
  98163. * Helper class used to generate session unique ID
  98164. */
  98165. export class UniqueIdGenerator {
  98166. private static _UniqueIdCounter;
  98167. /**
  98168. * Gets an unique (relatively to the current scene) Id
  98169. */
  98170. static get UniqueId(): number;
  98171. }
  98172. }
  98173. declare module BABYLON {
  98174. /**
  98175. * Defines a block that can be used inside a node based material
  98176. */
  98177. export class NodeMaterialBlock {
  98178. private _buildId;
  98179. private _buildTarget;
  98180. private _target;
  98181. private _isFinalMerger;
  98182. private _isInput;
  98183. protected _isUnique: boolean;
  98184. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98185. inputsAreExclusive: boolean;
  98186. /** @hidden */
  98187. _codeVariableName: string;
  98188. /** @hidden */
  98189. _inputs: NodeMaterialConnectionPoint[];
  98190. /** @hidden */
  98191. _outputs: NodeMaterialConnectionPoint[];
  98192. /** @hidden */
  98193. _preparationId: number;
  98194. /**
  98195. * Gets or sets the name of the block
  98196. */
  98197. name: string;
  98198. /**
  98199. * Gets or sets the unique id of the node
  98200. */
  98201. uniqueId: number;
  98202. /**
  98203. * Gets or sets the comments associated with this block
  98204. */
  98205. comments: string;
  98206. /**
  98207. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98208. */
  98209. get isUnique(): boolean;
  98210. /**
  98211. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98212. */
  98213. get isFinalMerger(): boolean;
  98214. /**
  98215. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98216. */
  98217. get isInput(): boolean;
  98218. /**
  98219. * Gets or sets the build Id
  98220. */
  98221. get buildId(): number;
  98222. set buildId(value: number);
  98223. /**
  98224. * Gets or sets the target of the block
  98225. */
  98226. get target(): NodeMaterialBlockTargets;
  98227. set target(value: NodeMaterialBlockTargets);
  98228. /**
  98229. * Gets the list of input points
  98230. */
  98231. get inputs(): NodeMaterialConnectionPoint[];
  98232. /** Gets the list of output points */
  98233. get outputs(): NodeMaterialConnectionPoint[];
  98234. /**
  98235. * Find an input by its name
  98236. * @param name defines the name of the input to look for
  98237. * @returns the input or null if not found
  98238. */
  98239. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98240. /**
  98241. * Find an output by its name
  98242. * @param name defines the name of the outputto look for
  98243. * @returns the output or null if not found
  98244. */
  98245. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98246. /**
  98247. * Creates a new NodeMaterialBlock
  98248. * @param name defines the block name
  98249. * @param target defines the target of that block (Vertex by default)
  98250. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98251. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98252. */
  98253. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98254. /**
  98255. * Initialize the block and prepare the context for build
  98256. * @param state defines the state that will be used for the build
  98257. */
  98258. initialize(state: NodeMaterialBuildState): void;
  98259. /**
  98260. * Bind data to effect. Will only be called for blocks with isBindable === true
  98261. * @param effect defines the effect to bind data to
  98262. * @param nodeMaterial defines the hosting NodeMaterial
  98263. * @param mesh defines the mesh that will be rendered
  98264. * @param subMesh defines the submesh that will be rendered
  98265. */
  98266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98267. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98268. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98269. protected _writeFloat(value: number): string;
  98270. /**
  98271. * Gets the current class name e.g. "NodeMaterialBlock"
  98272. * @returns the class name
  98273. */
  98274. getClassName(): string;
  98275. /**
  98276. * Register a new input. Must be called inside a block constructor
  98277. * @param name defines the connection point name
  98278. * @param type defines the connection point type
  98279. * @param isOptional defines a boolean indicating that this input can be omitted
  98280. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98281. * @param point an already created connection point. If not provided, create a new one
  98282. * @returns the current block
  98283. */
  98284. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98285. /**
  98286. * Register a new output. Must be called inside a block constructor
  98287. * @param name defines the connection point name
  98288. * @param type defines the connection point type
  98289. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98290. * @param point an already created connection point. If not provided, create a new one
  98291. * @returns the current block
  98292. */
  98293. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98294. /**
  98295. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98296. * @param forOutput defines an optional connection point to check compatibility with
  98297. * @returns the first available input or null
  98298. */
  98299. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98300. /**
  98301. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98302. * @param forBlock defines an optional block to check compatibility with
  98303. * @returns the first available input or null
  98304. */
  98305. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98306. /**
  98307. * Gets the sibling of the given output
  98308. * @param current defines the current output
  98309. * @returns the next output in the list or null
  98310. */
  98311. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98312. /**
  98313. * Connect current block with another block
  98314. * @param other defines the block to connect with
  98315. * @param options define the various options to help pick the right connections
  98316. * @returns the current block
  98317. */
  98318. connectTo(other: NodeMaterialBlock, options?: {
  98319. input?: string;
  98320. output?: string;
  98321. outputSwizzle?: string;
  98322. }): this | undefined;
  98323. protected _buildBlock(state: NodeMaterialBuildState): void;
  98324. /**
  98325. * Add uniforms, samplers and uniform buffers at compilation time
  98326. * @param state defines the state to update
  98327. * @param nodeMaterial defines the node material requesting the update
  98328. * @param defines defines the material defines to update
  98329. * @param uniformBuffers defines the list of uniform buffer names
  98330. */
  98331. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98332. /**
  98333. * Add potential fallbacks if shader compilation fails
  98334. * @param mesh defines the mesh to be rendered
  98335. * @param fallbacks defines the current prioritized list of fallbacks
  98336. */
  98337. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98338. /**
  98339. * Initialize defines for shader compilation
  98340. * @param mesh defines the mesh to be rendered
  98341. * @param nodeMaterial defines the node material requesting the update
  98342. * @param defines defines the material defines to update
  98343. * @param useInstances specifies that instances should be used
  98344. */
  98345. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98346. /**
  98347. * Update defines for shader compilation
  98348. * @param mesh defines the mesh to be rendered
  98349. * @param nodeMaterial defines the node material requesting the update
  98350. * @param defines defines the material defines to update
  98351. * @param useInstances specifies that instances should be used
  98352. */
  98353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98354. /**
  98355. * Lets the block try to connect some inputs automatically
  98356. * @param material defines the hosting NodeMaterial
  98357. */
  98358. autoConfigure(material: NodeMaterial): void;
  98359. /**
  98360. * Function called when a block is declared as repeatable content generator
  98361. * @param vertexShaderState defines the current compilation state for the vertex shader
  98362. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98363. * @param mesh defines the mesh to be rendered
  98364. * @param defines defines the material defines to update
  98365. */
  98366. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98367. /**
  98368. * Checks if the block is ready
  98369. * @param mesh defines the mesh to be rendered
  98370. * @param nodeMaterial defines the node material requesting the update
  98371. * @param defines defines the material defines to update
  98372. * @param useInstances specifies that instances should be used
  98373. * @returns true if the block is ready
  98374. */
  98375. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98376. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  98377. private _processBuild;
  98378. /**
  98379. * Compile the current node and generate the shader code
  98380. * @param state defines the current compilation state (uniforms, samplers, current string)
  98381. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98382. * @returns true if already built
  98383. */
  98384. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98385. protected _inputRename(name: string): string;
  98386. protected _outputRename(name: string): string;
  98387. protected _dumpPropertiesCode(): string;
  98388. /** @hidden */
  98389. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98390. /** @hidden */
  98391. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98392. /**
  98393. * Clone the current block to a new identical block
  98394. * @param scene defines the hosting scene
  98395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98396. * @returns a copy of the current block
  98397. */
  98398. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98399. /**
  98400. * Serializes this block in a JSON representation
  98401. * @returns the serialized block object
  98402. */
  98403. serialize(): any;
  98404. /** @hidden */
  98405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98406. private _deserializePortDisplayNames;
  98407. /**
  98408. * Release resources
  98409. */
  98410. dispose(): void;
  98411. }
  98412. }
  98413. declare module BABYLON {
  98414. /**
  98415. * Base class of materials working in push mode in babylon JS
  98416. * @hidden
  98417. */
  98418. export class PushMaterial extends Material {
  98419. protected _activeEffect: Effect;
  98420. protected _normalMatrix: Matrix;
  98421. /**
  98422. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98423. * This means that the material can keep using a previous shader while a new one is being compiled.
  98424. * This is mostly used when shader parallel compilation is supported (true by default)
  98425. */
  98426. allowShaderHotSwapping: boolean;
  98427. constructor(name: string, scene: Scene);
  98428. getEffect(): Effect;
  98429. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98430. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98431. /**
  98432. * Binds the given world matrix to the active effect
  98433. *
  98434. * @param world the matrix to bind
  98435. */
  98436. bindOnlyWorldMatrix(world: Matrix): void;
  98437. /**
  98438. * Binds the given normal matrix to the active effect
  98439. *
  98440. * @param normalMatrix the matrix to bind
  98441. */
  98442. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98443. bind(world: Matrix, mesh?: Mesh): void;
  98444. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98445. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98446. }
  98447. }
  98448. declare module BABYLON {
  98449. /**
  98450. * Root class for all node material optimizers
  98451. */
  98452. export class NodeMaterialOptimizer {
  98453. /**
  98454. * Function used to optimize a NodeMaterial graph
  98455. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98456. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98457. */
  98458. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98459. }
  98460. }
  98461. declare module BABYLON {
  98462. /**
  98463. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98464. */
  98465. export class TransformBlock extends NodeMaterialBlock {
  98466. /**
  98467. * Defines the value to use to complement W value to transform it to a Vector4
  98468. */
  98469. complementW: number;
  98470. /**
  98471. * Defines the value to use to complement z value to transform it to a Vector4
  98472. */
  98473. complementZ: number;
  98474. /**
  98475. * Creates a new TransformBlock
  98476. * @param name defines the block name
  98477. */
  98478. constructor(name: string);
  98479. /**
  98480. * Gets the current class name
  98481. * @returns the class name
  98482. */
  98483. getClassName(): string;
  98484. /**
  98485. * Gets the vector input
  98486. */
  98487. get vector(): NodeMaterialConnectionPoint;
  98488. /**
  98489. * Gets the output component
  98490. */
  98491. get output(): NodeMaterialConnectionPoint;
  98492. /**
  98493. * Gets the xyz output component
  98494. */
  98495. get xyz(): NodeMaterialConnectionPoint;
  98496. /**
  98497. * Gets the matrix transform input
  98498. */
  98499. get transform(): NodeMaterialConnectionPoint;
  98500. protected _buildBlock(state: NodeMaterialBuildState): this;
  98501. serialize(): any;
  98502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98503. protected _dumpPropertiesCode(): string;
  98504. }
  98505. }
  98506. declare module BABYLON {
  98507. /**
  98508. * Block used to output the vertex position
  98509. */
  98510. export class VertexOutputBlock extends NodeMaterialBlock {
  98511. /**
  98512. * Creates a new VertexOutputBlock
  98513. * @param name defines the block name
  98514. */
  98515. constructor(name: string);
  98516. /**
  98517. * Gets the current class name
  98518. * @returns the class name
  98519. */
  98520. getClassName(): string;
  98521. /**
  98522. * Gets the vector input component
  98523. */
  98524. get vector(): NodeMaterialConnectionPoint;
  98525. protected _buildBlock(state: NodeMaterialBuildState): this;
  98526. }
  98527. }
  98528. declare module BABYLON {
  98529. /**
  98530. * Block used to output the final color
  98531. */
  98532. export class FragmentOutputBlock extends NodeMaterialBlock {
  98533. /**
  98534. * Create a new FragmentOutputBlock
  98535. * @param name defines the block name
  98536. */
  98537. constructor(name: string);
  98538. /**
  98539. * Gets the current class name
  98540. * @returns the class name
  98541. */
  98542. getClassName(): string;
  98543. /**
  98544. * Gets the rgba input component
  98545. */
  98546. get rgba(): NodeMaterialConnectionPoint;
  98547. /**
  98548. * Gets the rgb input component
  98549. */
  98550. get rgb(): NodeMaterialConnectionPoint;
  98551. /**
  98552. * Gets the a input component
  98553. */
  98554. get a(): NodeMaterialConnectionPoint;
  98555. protected _buildBlock(state: NodeMaterialBuildState): this;
  98556. }
  98557. }
  98558. declare module BABYLON {
  98559. /**
  98560. * Block used for the particle ramp gradient section
  98561. */
  98562. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98563. /**
  98564. * Create a new ParticleRampGradientBlock
  98565. * @param name defines the block name
  98566. */
  98567. constructor(name: string);
  98568. /**
  98569. * Gets the current class name
  98570. * @returns the class name
  98571. */
  98572. getClassName(): string;
  98573. /**
  98574. * Gets the color input component
  98575. */
  98576. get color(): NodeMaterialConnectionPoint;
  98577. /**
  98578. * Gets the rampColor output component
  98579. */
  98580. get rampColor(): NodeMaterialConnectionPoint;
  98581. /**
  98582. * Initialize the block and prepare the context for build
  98583. * @param state defines the state that will be used for the build
  98584. */
  98585. initialize(state: NodeMaterialBuildState): void;
  98586. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98587. }
  98588. }
  98589. declare module BABYLON {
  98590. /**
  98591. * Block used for the particle blend multiply section
  98592. */
  98593. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98594. /**
  98595. * Create a new ParticleBlendMultiplyBlock
  98596. * @param name defines the block name
  98597. */
  98598. constructor(name: string);
  98599. /**
  98600. * Gets the current class name
  98601. * @returns the class name
  98602. */
  98603. getClassName(): string;
  98604. /**
  98605. * Gets the color input component
  98606. */
  98607. get color(): NodeMaterialConnectionPoint;
  98608. /**
  98609. * Gets the alphaTexture input component
  98610. */
  98611. get alphaTexture(): NodeMaterialConnectionPoint;
  98612. /**
  98613. * Gets the alphaColor input component
  98614. */
  98615. get alphaColor(): NodeMaterialConnectionPoint;
  98616. /**
  98617. * Gets the blendColor output component
  98618. */
  98619. get blendColor(): NodeMaterialConnectionPoint;
  98620. /**
  98621. * Initialize the block and prepare the context for build
  98622. * @param state defines the state that will be used for the build
  98623. */
  98624. initialize(state: NodeMaterialBuildState): void;
  98625. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98626. }
  98627. }
  98628. declare module BABYLON {
  98629. /**
  98630. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98631. */
  98632. export class VectorMergerBlock extends NodeMaterialBlock {
  98633. /**
  98634. * Create a new VectorMergerBlock
  98635. * @param name defines the block name
  98636. */
  98637. constructor(name: string);
  98638. /**
  98639. * Gets the current class name
  98640. * @returns the class name
  98641. */
  98642. getClassName(): string;
  98643. /**
  98644. * Gets the xyz component (input)
  98645. */
  98646. get xyzIn(): NodeMaterialConnectionPoint;
  98647. /**
  98648. * Gets the xy component (input)
  98649. */
  98650. get xyIn(): NodeMaterialConnectionPoint;
  98651. /**
  98652. * Gets the x component (input)
  98653. */
  98654. get x(): NodeMaterialConnectionPoint;
  98655. /**
  98656. * Gets the y component (input)
  98657. */
  98658. get y(): NodeMaterialConnectionPoint;
  98659. /**
  98660. * Gets the z component (input)
  98661. */
  98662. get z(): NodeMaterialConnectionPoint;
  98663. /**
  98664. * Gets the w component (input)
  98665. */
  98666. get w(): NodeMaterialConnectionPoint;
  98667. /**
  98668. * Gets the xyzw component (output)
  98669. */
  98670. get xyzw(): NodeMaterialConnectionPoint;
  98671. /**
  98672. * Gets the xyz component (output)
  98673. */
  98674. get xyzOut(): NodeMaterialConnectionPoint;
  98675. /**
  98676. * Gets the xy component (output)
  98677. */
  98678. get xyOut(): NodeMaterialConnectionPoint;
  98679. /**
  98680. * Gets the xy component (output)
  98681. * @deprecated Please use xyOut instead.
  98682. */
  98683. get xy(): NodeMaterialConnectionPoint;
  98684. /**
  98685. * Gets the xyz component (output)
  98686. * @deprecated Please use xyzOut instead.
  98687. */
  98688. get xyz(): NodeMaterialConnectionPoint;
  98689. protected _buildBlock(state: NodeMaterialBuildState): this;
  98690. }
  98691. }
  98692. declare module BABYLON {
  98693. /**
  98694. * Block used to remap a float from a range to a new one
  98695. */
  98696. export class RemapBlock extends NodeMaterialBlock {
  98697. /**
  98698. * Gets or sets the source range
  98699. */
  98700. sourceRange: Vector2;
  98701. /**
  98702. * Gets or sets the target range
  98703. */
  98704. targetRange: Vector2;
  98705. /**
  98706. * Creates a new RemapBlock
  98707. * @param name defines the block name
  98708. */
  98709. constructor(name: string);
  98710. /**
  98711. * Gets the current class name
  98712. * @returns the class name
  98713. */
  98714. getClassName(): string;
  98715. /**
  98716. * Gets the input component
  98717. */
  98718. get input(): NodeMaterialConnectionPoint;
  98719. /**
  98720. * Gets the source min input component
  98721. */
  98722. get sourceMin(): NodeMaterialConnectionPoint;
  98723. /**
  98724. * Gets the source max input component
  98725. */
  98726. get sourceMax(): NodeMaterialConnectionPoint;
  98727. /**
  98728. * Gets the target min input component
  98729. */
  98730. get targetMin(): NodeMaterialConnectionPoint;
  98731. /**
  98732. * Gets the target max input component
  98733. */
  98734. get targetMax(): NodeMaterialConnectionPoint;
  98735. /**
  98736. * Gets the output component
  98737. */
  98738. get output(): NodeMaterialConnectionPoint;
  98739. protected _buildBlock(state: NodeMaterialBuildState): this;
  98740. protected _dumpPropertiesCode(): string;
  98741. serialize(): any;
  98742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98743. }
  98744. }
  98745. declare module BABYLON {
  98746. /**
  98747. * Block used to multiply 2 values
  98748. */
  98749. export class MultiplyBlock extends NodeMaterialBlock {
  98750. /**
  98751. * Creates a new MultiplyBlock
  98752. * @param name defines the block name
  98753. */
  98754. constructor(name: string);
  98755. /**
  98756. * Gets the current class name
  98757. * @returns the class name
  98758. */
  98759. getClassName(): string;
  98760. /**
  98761. * Gets the left operand input component
  98762. */
  98763. get left(): NodeMaterialConnectionPoint;
  98764. /**
  98765. * Gets the right operand input component
  98766. */
  98767. get right(): NodeMaterialConnectionPoint;
  98768. /**
  98769. * Gets the output component
  98770. */
  98771. get output(): NodeMaterialConnectionPoint;
  98772. protected _buildBlock(state: NodeMaterialBuildState): this;
  98773. }
  98774. }
  98775. declare module BABYLON {
  98776. /**
  98777. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98778. */
  98779. export class ColorSplitterBlock extends NodeMaterialBlock {
  98780. /**
  98781. * Create a new ColorSplitterBlock
  98782. * @param name defines the block name
  98783. */
  98784. constructor(name: string);
  98785. /**
  98786. * Gets the current class name
  98787. * @returns the class name
  98788. */
  98789. getClassName(): string;
  98790. /**
  98791. * Gets the rgba component (input)
  98792. */
  98793. get rgba(): NodeMaterialConnectionPoint;
  98794. /**
  98795. * Gets the rgb component (input)
  98796. */
  98797. get rgbIn(): NodeMaterialConnectionPoint;
  98798. /**
  98799. * Gets the rgb component (output)
  98800. */
  98801. get rgbOut(): NodeMaterialConnectionPoint;
  98802. /**
  98803. * Gets the r component (output)
  98804. */
  98805. get r(): NodeMaterialConnectionPoint;
  98806. /**
  98807. * Gets the g component (output)
  98808. */
  98809. get g(): NodeMaterialConnectionPoint;
  98810. /**
  98811. * Gets the b component (output)
  98812. */
  98813. get b(): NodeMaterialConnectionPoint;
  98814. /**
  98815. * Gets the a component (output)
  98816. */
  98817. get a(): NodeMaterialConnectionPoint;
  98818. protected _inputRename(name: string): string;
  98819. protected _outputRename(name: string): string;
  98820. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98821. }
  98822. }
  98823. declare module BABYLON {
  98824. /**
  98825. * Interface used to configure the node material editor
  98826. */
  98827. export interface INodeMaterialEditorOptions {
  98828. /** Define the URl to load node editor script */
  98829. editorURL?: string;
  98830. }
  98831. /** @hidden */
  98832. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98833. NORMAL: boolean;
  98834. TANGENT: boolean;
  98835. UV1: boolean;
  98836. /** BONES */
  98837. NUM_BONE_INFLUENCERS: number;
  98838. BonesPerMesh: number;
  98839. BONETEXTURE: boolean;
  98840. /** MORPH TARGETS */
  98841. MORPHTARGETS: boolean;
  98842. MORPHTARGETS_NORMAL: boolean;
  98843. MORPHTARGETS_TANGENT: boolean;
  98844. MORPHTARGETS_UV: boolean;
  98845. NUM_MORPH_INFLUENCERS: number;
  98846. /** IMAGE PROCESSING */
  98847. IMAGEPROCESSING: boolean;
  98848. VIGNETTE: boolean;
  98849. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98850. VIGNETTEBLENDMODEOPAQUE: boolean;
  98851. TONEMAPPING: boolean;
  98852. TONEMAPPING_ACES: boolean;
  98853. CONTRAST: boolean;
  98854. EXPOSURE: boolean;
  98855. COLORCURVES: boolean;
  98856. COLORGRADING: boolean;
  98857. COLORGRADING3D: boolean;
  98858. SAMPLER3DGREENDEPTH: boolean;
  98859. SAMPLER3DBGRMAP: boolean;
  98860. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98861. /** MISC. */
  98862. BUMPDIRECTUV: number;
  98863. constructor();
  98864. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98865. }
  98866. /**
  98867. * Class used to configure NodeMaterial
  98868. */
  98869. export interface INodeMaterialOptions {
  98870. /**
  98871. * Defines if blocks should emit comments
  98872. */
  98873. emitComments: boolean;
  98874. }
  98875. /**
  98876. * Class used to create a node based material built by assembling shader blocks
  98877. */
  98878. export class NodeMaterial extends PushMaterial {
  98879. private static _BuildIdGenerator;
  98880. private _options;
  98881. private _vertexCompilationState;
  98882. private _fragmentCompilationState;
  98883. private _sharedData;
  98884. private _buildId;
  98885. private _buildWasSuccessful;
  98886. private _cachedWorldViewMatrix;
  98887. private _cachedWorldViewProjectionMatrix;
  98888. private _optimizers;
  98889. private _animationFrame;
  98890. /** Define the Url to load node editor script */
  98891. static EditorURL: string;
  98892. /** Define the Url to load snippets */
  98893. static SnippetUrl: string;
  98894. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98895. static IgnoreTexturesAtLoadTime: boolean;
  98896. private BJSNODEMATERIALEDITOR;
  98897. /** Get the inspector from bundle or global */
  98898. private _getGlobalNodeMaterialEditor;
  98899. /**
  98900. * Snippet ID if the material was created from the snippet server
  98901. */
  98902. snippetId: string;
  98903. /**
  98904. * Gets or sets data used by visual editor
  98905. * @see https://nme.babylonjs.com
  98906. */
  98907. editorData: any;
  98908. /**
  98909. * 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)
  98910. */
  98911. ignoreAlpha: boolean;
  98912. /**
  98913. * Defines the maximum number of lights that can be used in the material
  98914. */
  98915. maxSimultaneousLights: number;
  98916. /**
  98917. * Observable raised when the material is built
  98918. */
  98919. onBuildObservable: Observable<NodeMaterial>;
  98920. /**
  98921. * Gets or sets the root nodes of the material vertex shader
  98922. */
  98923. _vertexOutputNodes: NodeMaterialBlock[];
  98924. /**
  98925. * Gets or sets the root nodes of the material fragment (pixel) shader
  98926. */
  98927. _fragmentOutputNodes: NodeMaterialBlock[];
  98928. /** Gets or sets options to control the node material overall behavior */
  98929. get options(): INodeMaterialOptions;
  98930. set options(options: INodeMaterialOptions);
  98931. /**
  98932. * Default configuration related to image processing available in the standard Material.
  98933. */
  98934. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98935. /**
  98936. * Gets the image processing configuration used either in this material.
  98937. */
  98938. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98939. /**
  98940. * Sets the Default image processing configuration used either in the this material.
  98941. *
  98942. * If sets to null, the scene one is in use.
  98943. */
  98944. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98945. /**
  98946. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  98947. */
  98948. attachedBlocks: NodeMaterialBlock[];
  98949. /**
  98950. * Specifies the mode of the node material
  98951. * @hidden
  98952. */
  98953. _mode: NodeMaterialModes;
  98954. /**
  98955. * Gets the mode property
  98956. */
  98957. get mode(): NodeMaterialModes;
  98958. /**
  98959. * Create a new node based material
  98960. * @param name defines the material name
  98961. * @param scene defines the hosting scene
  98962. * @param options defines creation option
  98963. */
  98964. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  98965. /**
  98966. * Gets the current class name of the material e.g. "NodeMaterial"
  98967. * @returns the class name
  98968. */
  98969. getClassName(): string;
  98970. /**
  98971. * Keep track of the image processing observer to allow dispose and replace.
  98972. */
  98973. private _imageProcessingObserver;
  98974. /**
  98975. * Attaches a new image processing configuration to the Standard Material.
  98976. * @param configuration
  98977. */
  98978. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98979. /**
  98980. * Get a block by its name
  98981. * @param name defines the name of the block to retrieve
  98982. * @returns the required block or null if not found
  98983. */
  98984. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  98985. /**
  98986. * Get a block by its name
  98987. * @param predicate defines the predicate used to find the good candidate
  98988. * @returns the required block or null if not found
  98989. */
  98990. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  98991. /**
  98992. * Get an input block by its name
  98993. * @param predicate defines the predicate used to find the good candidate
  98994. * @returns the required input block or null if not found
  98995. */
  98996. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  98997. /**
  98998. * Gets the list of input blocks attached to this material
  98999. * @returns an array of InputBlocks
  99000. */
  99001. getInputBlocks(): InputBlock[];
  99002. /**
  99003. * Adds a new optimizer to the list of optimizers
  99004. * @param optimizer defines the optimizers to add
  99005. * @returns the current material
  99006. */
  99007. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99008. /**
  99009. * Remove an optimizer from the list of optimizers
  99010. * @param optimizer defines the optimizers to remove
  99011. * @returns the current material
  99012. */
  99013. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99014. /**
  99015. * Add a new block to the list of output nodes
  99016. * @param node defines the node to add
  99017. * @returns the current material
  99018. */
  99019. addOutputNode(node: NodeMaterialBlock): this;
  99020. /**
  99021. * Remove a block from the list of root nodes
  99022. * @param node defines the node to remove
  99023. * @returns the current material
  99024. */
  99025. removeOutputNode(node: NodeMaterialBlock): this;
  99026. private _addVertexOutputNode;
  99027. private _removeVertexOutputNode;
  99028. private _addFragmentOutputNode;
  99029. private _removeFragmentOutputNode;
  99030. /**
  99031. * Specifies if the material will require alpha blending
  99032. * @returns a boolean specifying if alpha blending is needed
  99033. */
  99034. needAlphaBlending(): boolean;
  99035. /**
  99036. * Specifies if this material should be rendered in alpha test mode
  99037. * @returns a boolean specifying if an alpha test is needed.
  99038. */
  99039. needAlphaTesting(): boolean;
  99040. private _initializeBlock;
  99041. private _resetDualBlocks;
  99042. /**
  99043. * Remove a block from the current node material
  99044. * @param block defines the block to remove
  99045. */
  99046. removeBlock(block: NodeMaterialBlock): void;
  99047. /**
  99048. * Build the material and generates the inner effect
  99049. * @param verbose defines if the build should log activity
  99050. */
  99051. build(verbose?: boolean): void;
  99052. /**
  99053. * Runs an otpimization phase to try to improve the shader code
  99054. */
  99055. optimize(): void;
  99056. private _prepareDefinesForAttributes;
  99057. /**
  99058. * Create a post process from the material
  99059. * @param camera The camera to apply the render pass to.
  99060. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99062. * @param engine The engine which the post process will be applied. (default: current engine)
  99063. * @param reusable If the post process can be reused on the same frame. (default: false)
  99064. * @param textureType Type of textures used when performing the post process. (default: 0)
  99065. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99066. * @returns the post process created
  99067. */
  99068. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99069. private _createEffectForParticles;
  99070. /**
  99071. * Create the effect to be used as the custom effect for a particle system
  99072. * @param particleSystem Particle system to create the effect for
  99073. * @param onCompiled defines a function to call when the effect creation is successful
  99074. * @param onError defines a function to call when the effect creation has failed
  99075. */
  99076. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99077. private _processDefines;
  99078. /**
  99079. * Get if the submesh is ready to be used and all its information available.
  99080. * Child classes can use it to update shaders
  99081. * @param mesh defines the mesh to check
  99082. * @param subMesh defines which submesh to check
  99083. * @param useInstances specifies that instances should be used
  99084. * @returns a boolean indicating that the submesh is ready or not
  99085. */
  99086. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99087. /**
  99088. * Get a string representing the shaders built by the current node graph
  99089. */
  99090. get compiledShaders(): string;
  99091. /**
  99092. * Binds the world matrix to the material
  99093. * @param world defines the world transformation matrix
  99094. */
  99095. bindOnlyWorldMatrix(world: Matrix): void;
  99096. /**
  99097. * Binds the submesh to this material by preparing the effect and shader to draw
  99098. * @param world defines the world transformation matrix
  99099. * @param mesh defines the mesh containing the submesh
  99100. * @param subMesh defines the submesh to bind the material to
  99101. */
  99102. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99103. /**
  99104. * Gets the active textures from the material
  99105. * @returns an array of textures
  99106. */
  99107. getActiveTextures(): BaseTexture[];
  99108. /**
  99109. * Gets the list of texture blocks
  99110. * @returns an array of texture blocks
  99111. */
  99112. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99113. /**
  99114. * Specifies if the material uses a texture
  99115. * @param texture defines the texture to check against the material
  99116. * @returns a boolean specifying if the material uses the texture
  99117. */
  99118. hasTexture(texture: BaseTexture): boolean;
  99119. /**
  99120. * Disposes the material
  99121. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99122. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99123. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99124. */
  99125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99126. /** Creates the node editor window. */
  99127. private _createNodeEditor;
  99128. /**
  99129. * Launch the node material editor
  99130. * @param config Define the configuration of the editor
  99131. * @return a promise fulfilled when the node editor is visible
  99132. */
  99133. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99134. /**
  99135. * Clear the current material
  99136. */
  99137. clear(): void;
  99138. /**
  99139. * Clear the current material and set it to a default state
  99140. */
  99141. setToDefault(): void;
  99142. /**
  99143. * Clear the current material and set it to a default state for post process
  99144. */
  99145. setToDefaultPostProcess(): void;
  99146. /**
  99147. * Clear the current material and set it to a default state for particle
  99148. */
  99149. setToDefaultParticle(): void;
  99150. /**
  99151. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99152. * @param url defines the url to load from
  99153. * @returns a promise that will fullfil when the material is fully loaded
  99154. */
  99155. loadAsync(url: string): Promise<void>;
  99156. private _gatherBlocks;
  99157. /**
  99158. * Generate a string containing the code declaration required to create an equivalent of this material
  99159. * @returns a string
  99160. */
  99161. generateCode(): string;
  99162. /**
  99163. * Serializes this material in a JSON representation
  99164. * @returns the serialized material object
  99165. */
  99166. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99167. private _restoreConnections;
  99168. /**
  99169. * Clear the current graph and load a new one from a serialization object
  99170. * @param source defines the JSON representation of the material
  99171. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99172. */
  99173. loadFromSerialization(source: any, rootUrl?: string): void;
  99174. /**
  99175. * Makes a duplicate of the current material.
  99176. * @param name - name to use for the new material.
  99177. */
  99178. clone(name: string): NodeMaterial;
  99179. /**
  99180. * Creates a node material from parsed material data
  99181. * @param source defines the JSON representation of the material
  99182. * @param scene defines the hosting scene
  99183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99184. * @returns a new node material
  99185. */
  99186. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99187. /**
  99188. * Creates a node material from a snippet saved in a remote file
  99189. * @param name defines the name of the material to create
  99190. * @param url defines the url to load from
  99191. * @param scene defines the hosting scene
  99192. * @returns a promise that will resolve to the new node material
  99193. */
  99194. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99195. /**
  99196. * Creates a node material from a snippet saved by the node material editor
  99197. * @param snippetId defines the snippet to load
  99198. * @param scene defines the hosting scene
  99199. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99200. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99201. * @returns a promise that will resolve to the new node material
  99202. */
  99203. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99204. /**
  99205. * Creates a new node material set to default basic configuration
  99206. * @param name defines the name of the material
  99207. * @param scene defines the hosting scene
  99208. * @returns a new NodeMaterial
  99209. */
  99210. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99211. }
  99212. }
  99213. declare module BABYLON {
  99214. /**
  99215. * Size options for a post process
  99216. */
  99217. export type PostProcessOptions = {
  99218. width: number;
  99219. height: number;
  99220. };
  99221. /**
  99222. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99223. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99224. */
  99225. export class PostProcess {
  99226. /** Name of the PostProcess. */
  99227. name: string;
  99228. /**
  99229. * Gets or sets the unique id of the post process
  99230. */
  99231. uniqueId: number;
  99232. /**
  99233. * Width of the texture to apply the post process on
  99234. */
  99235. width: number;
  99236. /**
  99237. * Height of the texture to apply the post process on
  99238. */
  99239. height: number;
  99240. /**
  99241. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99242. */
  99243. nodeMaterialSource: Nullable<NodeMaterial>;
  99244. /**
  99245. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99246. * @hidden
  99247. */
  99248. _outputTexture: Nullable<InternalTexture>;
  99249. /**
  99250. * Sampling mode used by the shader
  99251. * See https://doc.babylonjs.com/classes/3.1/texture
  99252. */
  99253. renderTargetSamplingMode: number;
  99254. /**
  99255. * Clear color to use when screen clearing
  99256. */
  99257. clearColor: Color4;
  99258. /**
  99259. * If the buffer needs to be cleared before applying the post process. (default: true)
  99260. * Should be set to false if shader will overwrite all previous pixels.
  99261. */
  99262. autoClear: boolean;
  99263. /**
  99264. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99265. */
  99266. alphaMode: number;
  99267. /**
  99268. * Sets the setAlphaBlendConstants of the babylon engine
  99269. */
  99270. alphaConstants: Color4;
  99271. /**
  99272. * Animations to be used for the post processing
  99273. */
  99274. animations: Animation[];
  99275. /**
  99276. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99277. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99278. */
  99279. enablePixelPerfectMode: boolean;
  99280. /**
  99281. * Force the postprocess to be applied without taking in account viewport
  99282. */
  99283. forceFullscreenViewport: boolean;
  99284. /**
  99285. * List of inspectable custom properties (used by the Inspector)
  99286. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99287. */
  99288. inspectableCustomProperties: IInspectable[];
  99289. /**
  99290. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99291. *
  99292. * | Value | Type | Description |
  99293. * | ----- | ----------------------------------- | ----------- |
  99294. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99295. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99296. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99297. *
  99298. */
  99299. scaleMode: number;
  99300. /**
  99301. * Force textures to be a power of two (default: false)
  99302. */
  99303. alwaysForcePOT: boolean;
  99304. private _samples;
  99305. /**
  99306. * Number of sample textures (default: 1)
  99307. */
  99308. get samples(): number;
  99309. set samples(n: number);
  99310. /**
  99311. * Modify the scale of the post process to be the same as the viewport (default: false)
  99312. */
  99313. adaptScaleToCurrentViewport: boolean;
  99314. private _camera;
  99315. private _scene;
  99316. private _engine;
  99317. private _options;
  99318. private _reusable;
  99319. private _textureType;
  99320. private _textureFormat;
  99321. /**
  99322. * Smart array of input and output textures for the post process.
  99323. * @hidden
  99324. */
  99325. _textures: SmartArray<InternalTexture>;
  99326. /**
  99327. * The index in _textures that corresponds to the output texture.
  99328. * @hidden
  99329. */
  99330. _currentRenderTextureInd: number;
  99331. private _effect;
  99332. private _samplers;
  99333. private _fragmentUrl;
  99334. private _vertexUrl;
  99335. private _parameters;
  99336. private _scaleRatio;
  99337. protected _indexParameters: any;
  99338. private _shareOutputWithPostProcess;
  99339. private _texelSize;
  99340. private _forcedOutputTexture;
  99341. /**
  99342. * Returns the fragment url or shader name used in the post process.
  99343. * @returns the fragment url or name in the shader store.
  99344. */
  99345. getEffectName(): string;
  99346. /**
  99347. * An event triggered when the postprocess is activated.
  99348. */
  99349. onActivateObservable: Observable<Camera>;
  99350. private _onActivateObserver;
  99351. /**
  99352. * A function that is added to the onActivateObservable
  99353. */
  99354. set onActivate(callback: Nullable<(camera: Camera) => void>);
  99355. /**
  99356. * An event triggered when the postprocess changes its size.
  99357. */
  99358. onSizeChangedObservable: Observable<PostProcess>;
  99359. private _onSizeChangedObserver;
  99360. /**
  99361. * A function that is added to the onSizeChangedObservable
  99362. */
  99363. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  99364. /**
  99365. * An event triggered when the postprocess applies its effect.
  99366. */
  99367. onApplyObservable: Observable<Effect>;
  99368. private _onApplyObserver;
  99369. /**
  99370. * A function that is added to the onApplyObservable
  99371. */
  99372. set onApply(callback: (effect: Effect) => void);
  99373. /**
  99374. * An event triggered before rendering the postprocess
  99375. */
  99376. onBeforeRenderObservable: Observable<Effect>;
  99377. private _onBeforeRenderObserver;
  99378. /**
  99379. * A function that is added to the onBeforeRenderObservable
  99380. */
  99381. set onBeforeRender(callback: (effect: Effect) => void);
  99382. /**
  99383. * An event triggered after rendering the postprocess
  99384. */
  99385. onAfterRenderObservable: Observable<Effect>;
  99386. private _onAfterRenderObserver;
  99387. /**
  99388. * A function that is added to the onAfterRenderObservable
  99389. */
  99390. set onAfterRender(callback: (efect: Effect) => void);
  99391. /**
  99392. * 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
  99393. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  99394. */
  99395. get inputTexture(): InternalTexture;
  99396. set inputTexture(value: InternalTexture);
  99397. /**
  99398. * Gets the camera which post process is applied to.
  99399. * @returns The camera the post process is applied to.
  99400. */
  99401. getCamera(): Camera;
  99402. /**
  99403. * Gets the texel size of the postprocess.
  99404. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  99405. */
  99406. get texelSize(): Vector2;
  99407. /**
  99408. * Creates a new instance PostProcess
  99409. * @param name The name of the PostProcess.
  99410. * @param fragmentUrl The url of the fragment shader to be used.
  99411. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  99412. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  99413. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99414. * @param camera The camera to apply the render pass to.
  99415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99416. * @param engine The engine which the post process will be applied. (default: current engine)
  99417. * @param reusable If the post process can be reused on the same frame. (default: false)
  99418. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  99419. * @param textureType Type of textures used when performing the post process. (default: 0)
  99420. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  99421. * @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
  99422. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  99423. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99424. */
  99425. constructor(
  99426. /** Name of the PostProcess. */
  99427. 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);
  99428. /**
  99429. * Gets a string idenfifying the name of the class
  99430. * @returns "PostProcess" string
  99431. */
  99432. getClassName(): string;
  99433. /**
  99434. * Gets the engine which this post process belongs to.
  99435. * @returns The engine the post process was enabled with.
  99436. */
  99437. getEngine(): Engine;
  99438. /**
  99439. * The effect that is created when initializing the post process.
  99440. * @returns The created effect corresponding the the postprocess.
  99441. */
  99442. getEffect(): Effect;
  99443. /**
  99444. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  99445. * @param postProcess The post process to share the output with.
  99446. * @returns This post process.
  99447. */
  99448. shareOutputWith(postProcess: PostProcess): PostProcess;
  99449. /**
  99450. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  99451. * This should be called if the post process that shares output with this post process is disabled/disposed.
  99452. */
  99453. useOwnOutput(): void;
  99454. /**
  99455. * Updates the effect with the current post process compile time values and recompiles the shader.
  99456. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99457. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99458. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99459. * @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
  99460. * @param onCompiled Called when the shader has been compiled.
  99461. * @param onError Called if there is an error when compiling a shader.
  99462. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  99463. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  99464. */
  99465. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  99466. /**
  99467. * The post process is reusable if it can be used multiple times within one frame.
  99468. * @returns If the post process is reusable
  99469. */
  99470. isReusable(): boolean;
  99471. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  99472. markTextureDirty(): void;
  99473. /**
  99474. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  99475. * 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.
  99476. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  99477. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  99478. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  99479. * @returns The target texture that was bound to be written to.
  99480. */
  99481. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  99482. /**
  99483. * If the post process is supported.
  99484. */
  99485. get isSupported(): boolean;
  99486. /**
  99487. * The aspect ratio of the output texture.
  99488. */
  99489. get aspectRatio(): number;
  99490. /**
  99491. * Get a value indicating if the post-process is ready to be used
  99492. * @returns true if the post-process is ready (shader is compiled)
  99493. */
  99494. isReady(): boolean;
  99495. /**
  99496. * Binds all textures and uniforms to the shader, this will be run on every pass.
  99497. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  99498. */
  99499. apply(): Nullable<Effect>;
  99500. private _disposeTextures;
  99501. /**
  99502. * Disposes the post process.
  99503. * @param camera The camera to dispose the post process on.
  99504. */
  99505. dispose(camera?: Camera): void;
  99506. }
  99507. }
  99508. declare module BABYLON {
  99509. /** @hidden */
  99510. export var kernelBlurVaryingDeclaration: {
  99511. name: string;
  99512. shader: string;
  99513. };
  99514. }
  99515. declare module BABYLON {
  99516. /** @hidden */
  99517. export var kernelBlurFragment: {
  99518. name: string;
  99519. shader: string;
  99520. };
  99521. }
  99522. declare module BABYLON {
  99523. /** @hidden */
  99524. export var kernelBlurFragment2: {
  99525. name: string;
  99526. shader: string;
  99527. };
  99528. }
  99529. declare module BABYLON {
  99530. /** @hidden */
  99531. export var kernelBlurPixelShader: {
  99532. name: string;
  99533. shader: string;
  99534. };
  99535. }
  99536. declare module BABYLON {
  99537. /** @hidden */
  99538. export var kernelBlurVertex: {
  99539. name: string;
  99540. shader: string;
  99541. };
  99542. }
  99543. declare module BABYLON {
  99544. /** @hidden */
  99545. export var kernelBlurVertexShader: {
  99546. name: string;
  99547. shader: string;
  99548. };
  99549. }
  99550. declare module BABYLON {
  99551. /**
  99552. * The Blur Post Process which blurs an image based on a kernel and direction.
  99553. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  99554. */
  99555. export class BlurPostProcess extends PostProcess {
  99556. /** The direction in which to blur the image. */
  99557. direction: Vector2;
  99558. private blockCompilation;
  99559. protected _kernel: number;
  99560. protected _idealKernel: number;
  99561. protected _packedFloat: boolean;
  99562. private _staticDefines;
  99563. /**
  99564. * Sets the length in pixels of the blur sample region
  99565. */
  99566. set kernel(v: number);
  99567. /**
  99568. * Gets the length in pixels of the blur sample region
  99569. */
  99570. get kernel(): number;
  99571. /**
  99572. * Sets wether or not the blur needs to unpack/repack floats
  99573. */
  99574. set packedFloat(v: boolean);
  99575. /**
  99576. * Gets wether or not the blur is unpacking/repacking floats
  99577. */
  99578. get packedFloat(): boolean;
  99579. /**
  99580. * Creates a new instance BlurPostProcess
  99581. * @param name The name of the effect.
  99582. * @param direction The direction in which to blur the image.
  99583. * @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.
  99584. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99585. * @param camera The camera to apply the render pass to.
  99586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99587. * @param engine The engine which the post process will be applied. (default: current engine)
  99588. * @param reusable If the post process can be reused on the same frame. (default: false)
  99589. * @param textureType Type of textures used when performing the post process. (default: 0)
  99590. * @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)
  99591. */
  99592. constructor(name: string,
  99593. /** The direction in which to blur the image. */
  99594. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  99595. /**
  99596. * Updates the effect with the current post process compile time values and recompiles the shader.
  99597. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99598. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99599. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99600. * @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
  99601. * @param onCompiled Called when the shader has been compiled.
  99602. * @param onError Called if there is an error when compiling a shader.
  99603. */
  99604. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99605. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99606. /**
  99607. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  99608. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  99609. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  99610. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  99611. * The gaps between physical kernels are compensated for in the weighting of the samples
  99612. * @param idealKernel Ideal blur kernel.
  99613. * @return Nearest best kernel.
  99614. */
  99615. protected _nearestBestKernel(idealKernel: number): number;
  99616. /**
  99617. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  99618. * @param x The point on the Gaussian distribution to sample.
  99619. * @return the value of the Gaussian function at x.
  99620. */
  99621. protected _gaussianWeight(x: number): number;
  99622. /**
  99623. * Generates a string that can be used as a floating point number in GLSL.
  99624. * @param x Value to print.
  99625. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  99626. * @return GLSL float string.
  99627. */
  99628. protected _glslFloat(x: number, decimalFigures?: number): string;
  99629. }
  99630. }
  99631. declare module BABYLON {
  99632. /**
  99633. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99634. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99635. * You can then easily use it as a reflectionTexture on a flat surface.
  99636. * In case the surface is not a plane, please consider relying on reflection probes.
  99637. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99638. */
  99639. export class MirrorTexture extends RenderTargetTexture {
  99640. private scene;
  99641. /**
  99642. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  99643. * 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.
  99644. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99645. */
  99646. mirrorPlane: Plane;
  99647. /**
  99648. * Define the blur ratio used to blur the reflection if needed.
  99649. */
  99650. set blurRatio(value: number);
  99651. get blurRatio(): number;
  99652. /**
  99653. * Define the adaptive blur kernel used to blur the reflection if needed.
  99654. * This will autocompute the closest best match for the `blurKernel`
  99655. */
  99656. set adaptiveBlurKernel(value: number);
  99657. /**
  99658. * Define the blur kernel used to blur the reflection if needed.
  99659. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99660. */
  99661. set blurKernel(value: number);
  99662. /**
  99663. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  99664. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99665. */
  99666. set blurKernelX(value: number);
  99667. get blurKernelX(): number;
  99668. /**
  99669. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  99670. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99671. */
  99672. set blurKernelY(value: number);
  99673. get blurKernelY(): number;
  99674. private _autoComputeBlurKernel;
  99675. protected _onRatioRescale(): void;
  99676. private _updateGammaSpace;
  99677. private _imageProcessingConfigChangeObserver;
  99678. private _transformMatrix;
  99679. private _mirrorMatrix;
  99680. private _savedViewMatrix;
  99681. private _blurX;
  99682. private _blurY;
  99683. private _adaptiveBlurKernel;
  99684. private _blurKernelX;
  99685. private _blurKernelY;
  99686. private _blurRatio;
  99687. /**
  99688. * Instantiates a Mirror Texture.
  99689. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99690. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99691. * You can then easily use it as a reflectionTexture on a flat surface.
  99692. * In case the surface is not a plane, please consider relying on reflection probes.
  99693. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99694. * @param name
  99695. * @param size
  99696. * @param scene
  99697. * @param generateMipMaps
  99698. * @param type
  99699. * @param samplingMode
  99700. * @param generateDepthBuffer
  99701. */
  99702. constructor(name: string, size: number | {
  99703. width: number;
  99704. height: number;
  99705. } | {
  99706. ratio: number;
  99707. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  99708. private _preparePostProcesses;
  99709. /**
  99710. * Clone the mirror texture.
  99711. * @returns the cloned texture
  99712. */
  99713. clone(): MirrorTexture;
  99714. /**
  99715. * Serialize the texture to a JSON representation you could use in Parse later on
  99716. * @returns the serialized JSON representation
  99717. */
  99718. serialize(): any;
  99719. /**
  99720. * Dispose the texture and release its associated resources.
  99721. */
  99722. dispose(): void;
  99723. }
  99724. }
  99725. declare module BABYLON {
  99726. /**
  99727. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  99728. * @see http://doc.babylonjs.com/babylon101/materials#texture
  99729. */
  99730. export class Texture extends BaseTexture {
  99731. /**
  99732. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  99733. */
  99734. static SerializeBuffers: boolean;
  99735. /** @hidden */
  99736. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  99737. /** @hidden */
  99738. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  99739. /** @hidden */
  99740. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  99741. /** nearest is mag = nearest and min = nearest and mip = linear */
  99742. static readonly NEAREST_SAMPLINGMODE: number;
  99743. /** nearest is mag = nearest and min = nearest and mip = linear */
  99744. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  99745. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99746. static readonly BILINEAR_SAMPLINGMODE: number;
  99747. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99748. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  99749. /** Trilinear is mag = linear and min = linear and mip = linear */
  99750. static readonly TRILINEAR_SAMPLINGMODE: number;
  99751. /** Trilinear is mag = linear and min = linear and mip = linear */
  99752. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  99753. /** mag = nearest and min = nearest and mip = nearest */
  99754. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  99755. /** mag = nearest and min = linear and mip = nearest */
  99756. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  99757. /** mag = nearest and min = linear and mip = linear */
  99758. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  99759. /** mag = nearest and min = linear and mip = none */
  99760. static readonly NEAREST_LINEAR: number;
  99761. /** mag = nearest and min = nearest and mip = none */
  99762. static readonly NEAREST_NEAREST: number;
  99763. /** mag = linear and min = nearest and mip = nearest */
  99764. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  99765. /** mag = linear and min = nearest and mip = linear */
  99766. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  99767. /** mag = linear and min = linear and mip = none */
  99768. static readonly LINEAR_LINEAR: number;
  99769. /** mag = linear and min = nearest and mip = none */
  99770. static readonly LINEAR_NEAREST: number;
  99771. /** Explicit coordinates mode */
  99772. static readonly EXPLICIT_MODE: number;
  99773. /** Spherical coordinates mode */
  99774. static readonly SPHERICAL_MODE: number;
  99775. /** Planar coordinates mode */
  99776. static readonly PLANAR_MODE: number;
  99777. /** Cubic coordinates mode */
  99778. static readonly CUBIC_MODE: number;
  99779. /** Projection coordinates mode */
  99780. static readonly PROJECTION_MODE: number;
  99781. /** Inverse Cubic coordinates mode */
  99782. static readonly SKYBOX_MODE: number;
  99783. /** Inverse Cubic coordinates mode */
  99784. static readonly INVCUBIC_MODE: number;
  99785. /** Equirectangular coordinates mode */
  99786. static readonly EQUIRECTANGULAR_MODE: number;
  99787. /** Equirectangular Fixed coordinates mode */
  99788. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  99789. /** Equirectangular Fixed Mirrored coordinates mode */
  99790. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99791. /** Texture is not repeating outside of 0..1 UVs */
  99792. static readonly CLAMP_ADDRESSMODE: number;
  99793. /** Texture is repeating outside of 0..1 UVs */
  99794. static readonly WRAP_ADDRESSMODE: number;
  99795. /** Texture is repeating and mirrored */
  99796. static readonly MIRROR_ADDRESSMODE: number;
  99797. /**
  99798. * 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
  99799. */
  99800. static UseSerializedUrlIfAny: boolean;
  99801. /**
  99802. * Define the url of the texture.
  99803. */
  99804. url: Nullable<string>;
  99805. /**
  99806. * Define an offset on the texture to offset the u coordinates of the UVs
  99807. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  99808. */
  99809. uOffset: number;
  99810. /**
  99811. * Define an offset on the texture to offset the v coordinates of the UVs
  99812. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  99813. */
  99814. vOffset: number;
  99815. /**
  99816. * Define an offset on the texture to scale the u coordinates of the UVs
  99817. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  99818. */
  99819. uScale: number;
  99820. /**
  99821. * Define an offset on the texture to scale the v coordinates of the UVs
  99822. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  99823. */
  99824. vScale: number;
  99825. /**
  99826. * Define an offset on the texture to rotate around the u coordinates of the UVs
  99827. * @see http://doc.babylonjs.com/how_to/more_materials
  99828. */
  99829. uAng: number;
  99830. /**
  99831. * Define an offset on the texture to rotate around the v coordinates of the UVs
  99832. * @see http://doc.babylonjs.com/how_to/more_materials
  99833. */
  99834. vAng: number;
  99835. /**
  99836. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  99837. * @see http://doc.babylonjs.com/how_to/more_materials
  99838. */
  99839. wAng: number;
  99840. /**
  99841. * Defines the center of rotation (U)
  99842. */
  99843. uRotationCenter: number;
  99844. /**
  99845. * Defines the center of rotation (V)
  99846. */
  99847. vRotationCenter: number;
  99848. /**
  99849. * Defines the center of rotation (W)
  99850. */
  99851. wRotationCenter: number;
  99852. /**
  99853. * Are mip maps generated for this texture or not.
  99854. */
  99855. get noMipmap(): boolean;
  99856. /**
  99857. * List of inspectable custom properties (used by the Inspector)
  99858. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99859. */
  99860. inspectableCustomProperties: Nullable<IInspectable[]>;
  99861. private _noMipmap;
  99862. /** @hidden */
  99863. _invertY: boolean;
  99864. private _rowGenerationMatrix;
  99865. private _cachedTextureMatrix;
  99866. private _projectionModeMatrix;
  99867. private _t0;
  99868. private _t1;
  99869. private _t2;
  99870. private _cachedUOffset;
  99871. private _cachedVOffset;
  99872. private _cachedUScale;
  99873. private _cachedVScale;
  99874. private _cachedUAng;
  99875. private _cachedVAng;
  99876. private _cachedWAng;
  99877. private _cachedProjectionMatrixId;
  99878. private _cachedCoordinatesMode;
  99879. /** @hidden */
  99880. protected _initialSamplingMode: number;
  99881. /** @hidden */
  99882. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  99883. private _deleteBuffer;
  99884. protected _format: Nullable<number>;
  99885. private _delayedOnLoad;
  99886. private _delayedOnError;
  99887. private _mimeType?;
  99888. /**
  99889. * Observable triggered once the texture has been loaded.
  99890. */
  99891. onLoadObservable: Observable<Texture>;
  99892. protected _isBlocking: boolean;
  99893. /**
  99894. * Is the texture preventing material to render while loading.
  99895. * If false, a default texture will be used instead of the loading one during the preparation step.
  99896. */
  99897. set isBlocking(value: boolean);
  99898. get isBlocking(): boolean;
  99899. /**
  99900. * Get the current sampling mode associated with the texture.
  99901. */
  99902. get samplingMode(): number;
  99903. /**
  99904. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  99905. */
  99906. get invertY(): boolean;
  99907. /**
  99908. * Instantiates a new texture.
  99909. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  99910. * @see http://doc.babylonjs.com/babylon101/materials#texture
  99911. * @param url defines the url of the picture to load as a texture
  99912. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99913. * @param noMipmap defines if the texture will require mip maps or not
  99914. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  99915. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  99916. * @param onLoad defines a callback triggered when the texture has been loaded
  99917. * @param onError defines a callback triggered when an error occurred during the loading session
  99918. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  99919. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  99920. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  99921. * @param mimeType defines an optional mime type information
  99922. */
  99923. 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);
  99924. /**
  99925. * Update the url (and optional buffer) of this texture if url was null during construction.
  99926. * @param url the url of the texture
  99927. * @param buffer the buffer of the texture (defaults to null)
  99928. * @param onLoad callback called when the texture is loaded (defaults to null)
  99929. */
  99930. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  99931. /**
  99932. * Finish the loading sequence of a texture flagged as delayed load.
  99933. * @hidden
  99934. */
  99935. delayLoad(): void;
  99936. private _prepareRowForTextureGeneration;
  99937. /**
  99938. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  99939. * @returns the transform matrix of the texture.
  99940. */
  99941. getTextureMatrix(uBase?: number): Matrix;
  99942. /**
  99943. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  99944. * @returns The reflection texture transform
  99945. */
  99946. getReflectionTextureMatrix(): Matrix;
  99947. /**
  99948. * Clones the texture.
  99949. * @returns the cloned texture
  99950. */
  99951. clone(): Texture;
  99952. /**
  99953. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  99954. * @returns The JSON representation of the texture
  99955. */
  99956. serialize(): any;
  99957. /**
  99958. * Get the current class name of the texture useful for serialization or dynamic coding.
  99959. * @returns "Texture"
  99960. */
  99961. getClassName(): string;
  99962. /**
  99963. * Dispose the texture and release its associated resources.
  99964. */
  99965. dispose(): void;
  99966. /**
  99967. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  99968. * @param parsedTexture Define the JSON representation of the texture
  99969. * @param scene Define the scene the parsed texture should be instantiated in
  99970. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  99971. * @returns The parsed texture if successful
  99972. */
  99973. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  99974. /**
  99975. * Creates a texture from its base 64 representation.
  99976. * @param data Define the base64 payload without the data: prefix
  99977. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  99978. * @param scene Define the scene the texture should belong to
  99979. * @param noMipmap Forces the texture to not create mip map information if true
  99980. * @param invertY define if the texture needs to be inverted on the y axis during loading
  99981. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  99982. * @param onLoad define a callback triggered when the texture has been loaded
  99983. * @param onError define a callback triggered when an error occurred during the loading session
  99984. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  99985. * @returns the created texture
  99986. */
  99987. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  99988. /**
  99989. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  99990. * @param data Define the base64 payload without the data: prefix
  99991. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  99992. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  99993. * @param scene Define the scene the texture should belong to
  99994. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  99995. * @param noMipmap Forces the texture to not create mip map information if true
  99996. * @param invertY define if the texture needs to be inverted on the y axis during loading
  99997. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  99998. * @param onLoad define a callback triggered when the texture has been loaded
  99999. * @param onError define a callback triggered when an error occurred during the loading session
  100000. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100001. * @returns the created texture
  100002. */
  100003. 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;
  100004. }
  100005. }
  100006. declare module BABYLON {
  100007. /**
  100008. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100009. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100010. */
  100011. export class PostProcessManager {
  100012. private _scene;
  100013. private _indexBuffer;
  100014. private _vertexBuffers;
  100015. /**
  100016. * Creates a new instance PostProcess
  100017. * @param scene The scene that the post process is associated with.
  100018. */
  100019. constructor(scene: Scene);
  100020. private _prepareBuffers;
  100021. private _buildIndexBuffer;
  100022. /**
  100023. * Rebuilds the vertex buffers of the manager.
  100024. * @hidden
  100025. */
  100026. _rebuild(): void;
  100027. /**
  100028. * Prepares a frame to be run through a post process.
  100029. * @param sourceTexture The input texture to the post procesess. (default: null)
  100030. * @param postProcesses An array of post processes to be run. (default: null)
  100031. * @returns True if the post processes were able to be run.
  100032. * @hidden
  100033. */
  100034. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100035. /**
  100036. * Manually render a set of post processes to a texture.
  100037. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100038. * @param postProcesses An array of post processes to be run.
  100039. * @param targetTexture The target texture to render to.
  100040. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100041. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100042. * @param lodLevel defines which lod of the texture to render to
  100043. */
  100044. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100045. /**
  100046. * Finalize the result of the output of the postprocesses.
  100047. * @param doNotPresent If true the result will not be displayed to the screen.
  100048. * @param targetTexture The target texture to render to.
  100049. * @param faceIndex The index of the face to bind the target texture to.
  100050. * @param postProcesses The array of post processes to render.
  100051. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100052. * @hidden
  100053. */
  100054. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100055. /**
  100056. * Disposes of the post process manager.
  100057. */
  100058. dispose(): void;
  100059. }
  100060. }
  100061. declare module BABYLON {
  100062. /**
  100063. * This Helps creating a texture that will be created from a camera in your scene.
  100064. * It is basically a dynamic texture that could be used to create special effects for instance.
  100065. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100066. */
  100067. export class RenderTargetTexture extends Texture {
  100068. isCube: boolean;
  100069. /**
  100070. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100071. */
  100072. static readonly REFRESHRATE_RENDER_ONCE: number;
  100073. /**
  100074. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100075. */
  100076. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100077. /**
  100078. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100079. * the central point of your effect and can save a lot of performances.
  100080. */
  100081. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100082. /**
  100083. * Use this predicate to dynamically define the list of mesh you want to render.
  100084. * If set, the renderList property will be overwritten.
  100085. */
  100086. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100087. private _renderList;
  100088. /**
  100089. * Use this list to define the list of mesh you want to render.
  100090. */
  100091. get renderList(): Nullable<Array<AbstractMesh>>;
  100092. set renderList(value: Nullable<Array<AbstractMesh>>);
  100093. /**
  100094. * Use this function to overload the renderList array at rendering time.
  100095. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100096. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100097. * the cube (if the RTT is a cube, else layerOrFace=0).
  100098. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100099. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100100. * hold dummy elements!
  100101. */
  100102. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100103. private _hookArray;
  100104. /**
  100105. * Define if particles should be rendered in your texture.
  100106. */
  100107. renderParticles: boolean;
  100108. /**
  100109. * Define if sprites should be rendered in your texture.
  100110. */
  100111. renderSprites: boolean;
  100112. /**
  100113. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100114. */
  100115. coordinatesMode: number;
  100116. /**
  100117. * Define the camera used to render the texture.
  100118. */
  100119. activeCamera: Nullable<Camera>;
  100120. /**
  100121. * Override the mesh isReady function with your own one.
  100122. */
  100123. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100124. /**
  100125. * Override the render function of the texture with your own one.
  100126. */
  100127. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100128. /**
  100129. * Define if camera post processes should be use while rendering the texture.
  100130. */
  100131. useCameraPostProcesses: boolean;
  100132. /**
  100133. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100134. */
  100135. ignoreCameraViewport: boolean;
  100136. private _postProcessManager;
  100137. private _postProcesses;
  100138. private _resizeObserver;
  100139. /**
  100140. * An event triggered when the texture is unbind.
  100141. */
  100142. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100143. /**
  100144. * An event triggered when the texture is unbind.
  100145. */
  100146. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100147. private _onAfterUnbindObserver;
  100148. /**
  100149. * Set a after unbind callback in the texture.
  100150. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100151. */
  100152. set onAfterUnbind(callback: () => void);
  100153. /**
  100154. * An event triggered before rendering the texture
  100155. */
  100156. onBeforeRenderObservable: Observable<number>;
  100157. private _onBeforeRenderObserver;
  100158. /**
  100159. * Set a before render callback in the texture.
  100160. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100161. */
  100162. set onBeforeRender(callback: (faceIndex: number) => void);
  100163. /**
  100164. * An event triggered after rendering the texture
  100165. */
  100166. onAfterRenderObservable: Observable<number>;
  100167. private _onAfterRenderObserver;
  100168. /**
  100169. * Set a after render callback in the texture.
  100170. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100171. */
  100172. set onAfterRender(callback: (faceIndex: number) => void);
  100173. /**
  100174. * An event triggered after the texture clear
  100175. */
  100176. onClearObservable: Observable<Engine>;
  100177. private _onClearObserver;
  100178. /**
  100179. * Set a clear callback in the texture.
  100180. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100181. */
  100182. set onClear(callback: (Engine: Engine) => void);
  100183. /**
  100184. * An event triggered when the texture is resized.
  100185. */
  100186. onResizeObservable: Observable<RenderTargetTexture>;
  100187. /**
  100188. * Define the clear color of the Render Target if it should be different from the scene.
  100189. */
  100190. clearColor: Color4;
  100191. protected _size: number | {
  100192. width: number;
  100193. height: number;
  100194. layers?: number;
  100195. };
  100196. protected _initialSizeParameter: number | {
  100197. width: number;
  100198. height: number;
  100199. } | {
  100200. ratio: number;
  100201. };
  100202. protected _sizeRatio: Nullable<number>;
  100203. /** @hidden */
  100204. _generateMipMaps: boolean;
  100205. protected _renderingManager: RenderingManager;
  100206. /** @hidden */
  100207. _waitingRenderList: string[];
  100208. protected _doNotChangeAspectRatio: boolean;
  100209. protected _currentRefreshId: number;
  100210. protected _refreshRate: number;
  100211. protected _textureMatrix: Matrix;
  100212. protected _samples: number;
  100213. protected _renderTargetOptions: RenderTargetCreationOptions;
  100214. /**
  100215. * Gets render target creation options that were used.
  100216. */
  100217. get renderTargetOptions(): RenderTargetCreationOptions;
  100218. protected _onRatioRescale(): void;
  100219. /**
  100220. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100221. * It must define where the camera used to render the texture is set
  100222. */
  100223. boundingBoxPosition: Vector3;
  100224. private _boundingBoxSize;
  100225. /**
  100226. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100227. * When defined, the cubemap will switch to local mode
  100228. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100229. * @example https://www.babylonjs-playground.com/#RNASML
  100230. */
  100231. set boundingBoxSize(value: Vector3);
  100232. get boundingBoxSize(): Vector3;
  100233. /**
  100234. * In case the RTT has been created with a depth texture, get the associated
  100235. * depth texture.
  100236. * Otherwise, return null.
  100237. */
  100238. get depthStencilTexture(): Nullable<InternalTexture>;
  100239. /**
  100240. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100241. * or used a shadow, depth texture...
  100242. * @param name The friendly name of the texture
  100243. * @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)
  100244. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100245. * @param generateMipMaps True if mip maps need to be generated after render.
  100246. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100247. * @param type The type of the buffer in the RTT (int, half float, float...)
  100248. * @param isCube True if a cube texture needs to be created
  100249. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100250. * @param generateDepthBuffer True to generate a depth buffer
  100251. * @param generateStencilBuffer True to generate a stencil buffer
  100252. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100253. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100254. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100255. */
  100256. constructor(name: string, size: number | {
  100257. width: number;
  100258. height: number;
  100259. layers?: number;
  100260. } | {
  100261. ratio: number;
  100262. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100263. /**
  100264. * Creates a depth stencil texture.
  100265. * This is only available in WebGL 2 or with the depth texture extension available.
  100266. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100267. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100268. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100269. */
  100270. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100271. private _processSizeParameter;
  100272. /**
  100273. * Define the number of samples to use in case of MSAA.
  100274. * It defaults to one meaning no MSAA has been enabled.
  100275. */
  100276. get samples(): number;
  100277. set samples(value: number);
  100278. /**
  100279. * Resets the refresh counter of the texture and start bak from scratch.
  100280. * Could be useful to regenerate the texture if it is setup to render only once.
  100281. */
  100282. resetRefreshCounter(): void;
  100283. /**
  100284. * Define the refresh rate of the texture or the rendering frequency.
  100285. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100286. */
  100287. get refreshRate(): number;
  100288. set refreshRate(value: number);
  100289. /**
  100290. * Adds a post process to the render target rendering passes.
  100291. * @param postProcess define the post process to add
  100292. */
  100293. addPostProcess(postProcess: PostProcess): void;
  100294. /**
  100295. * Clear all the post processes attached to the render target
  100296. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100297. */
  100298. clearPostProcesses(dispose?: boolean): void;
  100299. /**
  100300. * Remove one of the post process from the list of attached post processes to the texture
  100301. * @param postProcess define the post process to remove from the list
  100302. */
  100303. removePostProcess(postProcess: PostProcess): void;
  100304. /** @hidden */
  100305. _shouldRender(): boolean;
  100306. /**
  100307. * Gets the actual render size of the texture.
  100308. * @returns the width of the render size
  100309. */
  100310. getRenderSize(): number;
  100311. /**
  100312. * Gets the actual render width of the texture.
  100313. * @returns the width of the render size
  100314. */
  100315. getRenderWidth(): number;
  100316. /**
  100317. * Gets the actual render height of the texture.
  100318. * @returns the height of the render size
  100319. */
  100320. getRenderHeight(): number;
  100321. /**
  100322. * Gets the actual number of layers of the texture.
  100323. * @returns the number of layers
  100324. */
  100325. getRenderLayers(): number;
  100326. /**
  100327. * Get if the texture can be rescaled or not.
  100328. */
  100329. get canRescale(): boolean;
  100330. /**
  100331. * Resize the texture using a ratio.
  100332. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  100333. */
  100334. scale(ratio: number): void;
  100335. /**
  100336. * Get the texture reflection matrix used to rotate/transform the reflection.
  100337. * @returns the reflection matrix
  100338. */
  100339. getReflectionTextureMatrix(): Matrix;
  100340. /**
  100341. * Resize the texture to a new desired size.
  100342. * Be carrefull as it will recreate all the data in the new texture.
  100343. * @param size Define the new size. It can be:
  100344. * - a number for squared texture,
  100345. * - an object containing { width: number, height: number }
  100346. * - or an object containing a ratio { ratio: number }
  100347. */
  100348. resize(size: number | {
  100349. width: number;
  100350. height: number;
  100351. } | {
  100352. ratio: number;
  100353. }): void;
  100354. private _defaultRenderListPrepared;
  100355. /**
  100356. * Renders all the objects from the render list into the texture.
  100357. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  100358. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  100359. */
  100360. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  100361. private _bestReflectionRenderTargetDimension;
  100362. private _prepareRenderingManager;
  100363. /**
  100364. * @hidden
  100365. * @param faceIndex face index to bind to if this is a cubetexture
  100366. * @param layer defines the index of the texture to bind in the array
  100367. */
  100368. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  100369. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  100370. private renderToTarget;
  100371. /**
  100372. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100373. * This allowed control for front to back rendering or reversly depending of the special needs.
  100374. *
  100375. * @param renderingGroupId The rendering group id corresponding to its index
  100376. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100377. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100378. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100379. */
  100380. 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;
  100381. /**
  100382. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100383. *
  100384. * @param renderingGroupId The rendering group id corresponding to its index
  100385. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100386. */
  100387. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  100388. /**
  100389. * Clones the texture.
  100390. * @returns the cloned texture
  100391. */
  100392. clone(): RenderTargetTexture;
  100393. /**
  100394. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100395. * @returns The JSON representation of the texture
  100396. */
  100397. serialize(): any;
  100398. /**
  100399. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  100400. */
  100401. disposeFramebufferObjects(): void;
  100402. /**
  100403. * Dispose the texture and release its associated resources.
  100404. */
  100405. dispose(): void;
  100406. /** @hidden */
  100407. _rebuild(): void;
  100408. /**
  100409. * Clear the info related to rendering groups preventing retention point in material dispose.
  100410. */
  100411. freeRenderingGroups(): void;
  100412. /**
  100413. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100414. * @returns the view count
  100415. */
  100416. getViewCount(): number;
  100417. }
  100418. }
  100419. declare module BABYLON {
  100420. /**
  100421. * Class used to manipulate GUIDs
  100422. */
  100423. export class GUID {
  100424. /**
  100425. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100426. * Be aware Math.random() could cause collisions, but:
  100427. * "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"
  100428. * @returns a pseudo random id
  100429. */
  100430. static RandomId(): string;
  100431. }
  100432. }
  100433. declare module BABYLON {
  100434. /**
  100435. * Options to be used when creating a shadow depth material
  100436. */
  100437. export interface IIOptionShadowDepthMaterial {
  100438. /** Variables in the vertex shader code that need to have their names remapped.
  100439. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  100440. * "var_name" should be either: worldPos or vNormalW
  100441. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  100442. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  100443. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  100444. */
  100445. remappedVariables?: string[];
  100446. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  100447. standalone?: boolean;
  100448. }
  100449. /**
  100450. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  100451. */
  100452. export class ShadowDepthWrapper {
  100453. private _scene;
  100454. private _options?;
  100455. private _baseMaterial;
  100456. private _onEffectCreatedObserver;
  100457. private _subMeshToEffect;
  100458. private _subMeshToDepthEffect;
  100459. private _meshes;
  100460. /** @hidden */
  100461. _matriceNames: any;
  100462. /** Gets the standalone status of the wrapper */
  100463. get standalone(): boolean;
  100464. /** Gets the base material the wrapper is built upon */
  100465. get baseMaterial(): Material;
  100466. /**
  100467. * Instantiate a new shadow depth wrapper.
  100468. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  100469. * generate the shadow depth map. For more information, please refer to the documentation:
  100470. * https://doc.babylonjs.com/babylon101/shadows
  100471. * @param baseMaterial Material to wrap
  100472. * @param scene Define the scene the material belongs to
  100473. * @param options Options used to create the wrapper
  100474. */
  100475. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  100476. /**
  100477. * Gets the effect to use to generate the depth map
  100478. * @param subMesh subMesh to get the effect for
  100479. * @param shadowGenerator shadow generator to get the effect for
  100480. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  100481. */
  100482. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  100483. /**
  100484. * Specifies that the submesh is ready to be used for depth rendering
  100485. * @param subMesh submesh to check
  100486. * @param defines the list of defines to take into account when checking the effect
  100487. * @param shadowGenerator combined with subMesh, it defines the effect to check
  100488. * @param useInstances specifies that instances should be used
  100489. * @returns a boolean indicating that the submesh is ready or not
  100490. */
  100491. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  100492. /**
  100493. * Disposes the resources
  100494. */
  100495. dispose(): void;
  100496. private _makeEffect;
  100497. }
  100498. }
  100499. declare module BABYLON {
  100500. /**
  100501. * Options for compiling materials.
  100502. */
  100503. export interface IMaterialCompilationOptions {
  100504. /**
  100505. * Defines whether clip planes are enabled.
  100506. */
  100507. clipPlane: boolean;
  100508. /**
  100509. * Defines whether instances are enabled.
  100510. */
  100511. useInstances: boolean;
  100512. }
  100513. /**
  100514. * Base class for the main features of a material in Babylon.js
  100515. */
  100516. export class Material implements IAnimatable {
  100517. /**
  100518. * Returns the triangle fill mode
  100519. */
  100520. static readonly TriangleFillMode: number;
  100521. /**
  100522. * Returns the wireframe mode
  100523. */
  100524. static readonly WireFrameFillMode: number;
  100525. /**
  100526. * Returns the point fill mode
  100527. */
  100528. static readonly PointFillMode: number;
  100529. /**
  100530. * Returns the point list draw mode
  100531. */
  100532. static readonly PointListDrawMode: number;
  100533. /**
  100534. * Returns the line list draw mode
  100535. */
  100536. static readonly LineListDrawMode: number;
  100537. /**
  100538. * Returns the line loop draw mode
  100539. */
  100540. static readonly LineLoopDrawMode: number;
  100541. /**
  100542. * Returns the line strip draw mode
  100543. */
  100544. static readonly LineStripDrawMode: number;
  100545. /**
  100546. * Returns the triangle strip draw mode
  100547. */
  100548. static readonly TriangleStripDrawMode: number;
  100549. /**
  100550. * Returns the triangle fan draw mode
  100551. */
  100552. static readonly TriangleFanDrawMode: number;
  100553. /**
  100554. * Stores the clock-wise side orientation
  100555. */
  100556. static readonly ClockWiseSideOrientation: number;
  100557. /**
  100558. * Stores the counter clock-wise side orientation
  100559. */
  100560. static readonly CounterClockWiseSideOrientation: number;
  100561. /**
  100562. * The dirty texture flag value
  100563. */
  100564. static readonly TextureDirtyFlag: number;
  100565. /**
  100566. * The dirty light flag value
  100567. */
  100568. static readonly LightDirtyFlag: number;
  100569. /**
  100570. * The dirty fresnel flag value
  100571. */
  100572. static readonly FresnelDirtyFlag: number;
  100573. /**
  100574. * The dirty attribute flag value
  100575. */
  100576. static readonly AttributesDirtyFlag: number;
  100577. /**
  100578. * The dirty misc flag value
  100579. */
  100580. static readonly MiscDirtyFlag: number;
  100581. /**
  100582. * The all dirty flag value
  100583. */
  100584. static readonly AllDirtyFlag: number;
  100585. /**
  100586. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100587. */
  100588. static readonly MATERIAL_OPAQUE: number;
  100589. /**
  100590. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100591. */
  100592. static readonly MATERIAL_ALPHATEST: number;
  100593. /**
  100594. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100595. */
  100596. static readonly MATERIAL_ALPHABLEND: number;
  100597. /**
  100598. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100599. * They are also discarded below the alpha cutoff threshold to improve performances.
  100600. */
  100601. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  100602. /**
  100603. * Custom callback helping to override the default shader used in the material.
  100604. */
  100605. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  100606. /**
  100607. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  100608. */
  100609. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  100610. /**
  100611. * The ID of the material
  100612. */
  100613. id: string;
  100614. /**
  100615. * Gets or sets the unique id of the material
  100616. */
  100617. uniqueId: number;
  100618. /**
  100619. * The name of the material
  100620. */
  100621. name: string;
  100622. /**
  100623. * Gets or sets user defined metadata
  100624. */
  100625. metadata: any;
  100626. /**
  100627. * For internal use only. Please do not use.
  100628. */
  100629. reservedDataStore: any;
  100630. /**
  100631. * Specifies if the ready state should be checked on each call
  100632. */
  100633. checkReadyOnEveryCall: boolean;
  100634. /**
  100635. * Specifies if the ready state should be checked once
  100636. */
  100637. checkReadyOnlyOnce: boolean;
  100638. /**
  100639. * The state of the material
  100640. */
  100641. state: string;
  100642. /**
  100643. * The alpha value of the material
  100644. */
  100645. protected _alpha: number;
  100646. /**
  100647. * List of inspectable custom properties (used by the Inspector)
  100648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100649. */
  100650. inspectableCustomProperties: IInspectable[];
  100651. /**
  100652. * Sets the alpha value of the material
  100653. */
  100654. set alpha(value: number);
  100655. /**
  100656. * Gets the alpha value of the material
  100657. */
  100658. get alpha(): number;
  100659. /**
  100660. * Specifies if back face culling is enabled
  100661. */
  100662. protected _backFaceCulling: boolean;
  100663. /**
  100664. * Sets the back-face culling state
  100665. */
  100666. set backFaceCulling(value: boolean);
  100667. /**
  100668. * Gets the back-face culling state
  100669. */
  100670. get backFaceCulling(): boolean;
  100671. /**
  100672. * Stores the value for side orientation
  100673. */
  100674. sideOrientation: number;
  100675. /**
  100676. * Callback triggered when the material is compiled
  100677. */
  100678. onCompiled: Nullable<(effect: Effect) => void>;
  100679. /**
  100680. * Callback triggered when an error occurs
  100681. */
  100682. onError: Nullable<(effect: Effect, errors: string) => void>;
  100683. /**
  100684. * Callback triggered to get the render target textures
  100685. */
  100686. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  100687. /**
  100688. * Gets a boolean indicating that current material needs to register RTT
  100689. */
  100690. get hasRenderTargetTextures(): boolean;
  100691. /**
  100692. * Specifies if the material should be serialized
  100693. */
  100694. doNotSerialize: boolean;
  100695. /**
  100696. * @hidden
  100697. */
  100698. _storeEffectOnSubMeshes: boolean;
  100699. /**
  100700. * Stores the animations for the material
  100701. */
  100702. animations: Nullable<Array<Animation>>;
  100703. /**
  100704. * An event triggered when the material is disposed
  100705. */
  100706. onDisposeObservable: Observable<Material>;
  100707. /**
  100708. * An observer which watches for dispose events
  100709. */
  100710. private _onDisposeObserver;
  100711. private _onUnBindObservable;
  100712. /**
  100713. * Called during a dispose event
  100714. */
  100715. set onDispose(callback: () => void);
  100716. private _onBindObservable;
  100717. /**
  100718. * An event triggered when the material is bound
  100719. */
  100720. get onBindObservable(): Observable<AbstractMesh>;
  100721. /**
  100722. * An observer which watches for bind events
  100723. */
  100724. private _onBindObserver;
  100725. /**
  100726. * Called during a bind event
  100727. */
  100728. set onBind(callback: (Mesh: AbstractMesh) => void);
  100729. /**
  100730. * An event triggered when the material is unbound
  100731. */
  100732. get onUnBindObservable(): Observable<Material>;
  100733. protected _onEffectCreatedObservable: Nullable<Observable<{
  100734. effect: Effect;
  100735. subMesh: Nullable<SubMesh>;
  100736. }>>;
  100737. /**
  100738. * An event triggered when the effect is (re)created
  100739. */
  100740. get onEffectCreatedObservable(): Observable<{
  100741. effect: Effect;
  100742. subMesh: Nullable<SubMesh>;
  100743. }>;
  100744. /**
  100745. * Stores the value of the alpha mode
  100746. */
  100747. private _alphaMode;
  100748. /**
  100749. * Sets the value of the alpha mode.
  100750. *
  100751. * | Value | Type | Description |
  100752. * | --- | --- | --- |
  100753. * | 0 | ALPHA_DISABLE | |
  100754. * | 1 | ALPHA_ADD | |
  100755. * | 2 | ALPHA_COMBINE | |
  100756. * | 3 | ALPHA_SUBTRACT | |
  100757. * | 4 | ALPHA_MULTIPLY | |
  100758. * | 5 | ALPHA_MAXIMIZED | |
  100759. * | 6 | ALPHA_ONEONE | |
  100760. * | 7 | ALPHA_PREMULTIPLIED | |
  100761. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  100762. * | 9 | ALPHA_INTERPOLATE | |
  100763. * | 10 | ALPHA_SCREENMODE | |
  100764. *
  100765. */
  100766. set alphaMode(value: number);
  100767. /**
  100768. * Gets the value of the alpha mode
  100769. */
  100770. get alphaMode(): number;
  100771. /**
  100772. * Stores the state of the need depth pre-pass value
  100773. */
  100774. private _needDepthPrePass;
  100775. /**
  100776. * Sets the need depth pre-pass value
  100777. */
  100778. set needDepthPrePass(value: boolean);
  100779. /**
  100780. * Gets the depth pre-pass value
  100781. */
  100782. get needDepthPrePass(): boolean;
  100783. /**
  100784. * Specifies if depth writing should be disabled
  100785. */
  100786. disableDepthWrite: boolean;
  100787. /**
  100788. * Specifies if color writing should be disabled
  100789. */
  100790. disableColorWrite: boolean;
  100791. /**
  100792. * Specifies if depth writing should be forced
  100793. */
  100794. forceDepthWrite: boolean;
  100795. /**
  100796. * Specifies the depth function that should be used. 0 means the default engine function
  100797. */
  100798. depthFunction: number;
  100799. /**
  100800. * Specifies if there should be a separate pass for culling
  100801. */
  100802. separateCullingPass: boolean;
  100803. /**
  100804. * Stores the state specifing if fog should be enabled
  100805. */
  100806. private _fogEnabled;
  100807. /**
  100808. * Sets the state for enabling fog
  100809. */
  100810. set fogEnabled(value: boolean);
  100811. /**
  100812. * Gets the value of the fog enabled state
  100813. */
  100814. get fogEnabled(): boolean;
  100815. /**
  100816. * Stores the size of points
  100817. */
  100818. pointSize: number;
  100819. /**
  100820. * Stores the z offset value
  100821. */
  100822. zOffset: number;
  100823. get wireframe(): boolean;
  100824. /**
  100825. * Sets the state of wireframe mode
  100826. */
  100827. set wireframe(value: boolean);
  100828. /**
  100829. * Gets the value specifying if point clouds are enabled
  100830. */
  100831. get pointsCloud(): boolean;
  100832. /**
  100833. * Sets the state of point cloud mode
  100834. */
  100835. set pointsCloud(value: boolean);
  100836. /**
  100837. * Gets the material fill mode
  100838. */
  100839. get fillMode(): number;
  100840. /**
  100841. * Sets the material fill mode
  100842. */
  100843. set fillMode(value: number);
  100844. /**
  100845. * @hidden
  100846. * Stores the effects for the material
  100847. */
  100848. _effect: Nullable<Effect>;
  100849. /**
  100850. * Specifies if uniform buffers should be used
  100851. */
  100852. private _useUBO;
  100853. /**
  100854. * Stores a reference to the scene
  100855. */
  100856. private _scene;
  100857. /**
  100858. * Stores the fill mode state
  100859. */
  100860. private _fillMode;
  100861. /**
  100862. * Specifies if the depth write state should be cached
  100863. */
  100864. private _cachedDepthWriteState;
  100865. /**
  100866. * Specifies if the color write state should be cached
  100867. */
  100868. private _cachedColorWriteState;
  100869. /**
  100870. * Specifies if the depth function state should be cached
  100871. */
  100872. private _cachedDepthFunctionState;
  100873. /**
  100874. * Stores the uniform buffer
  100875. */
  100876. protected _uniformBuffer: UniformBuffer;
  100877. /** @hidden */
  100878. _indexInSceneMaterialArray: number;
  100879. /** @hidden */
  100880. meshMap: Nullable<{
  100881. [id: string]: AbstractMesh | undefined;
  100882. }>;
  100883. /**
  100884. * Creates a material instance
  100885. * @param name defines the name of the material
  100886. * @param scene defines the scene to reference
  100887. * @param doNotAdd specifies if the material should be added to the scene
  100888. */
  100889. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  100890. /**
  100891. * Returns a string representation of the current material
  100892. * @param fullDetails defines a boolean indicating which levels of logging is desired
  100893. * @returns a string with material information
  100894. */
  100895. toString(fullDetails?: boolean): string;
  100896. /**
  100897. * Gets the class name of the material
  100898. * @returns a string with the class name of the material
  100899. */
  100900. getClassName(): string;
  100901. /**
  100902. * Specifies if updates for the material been locked
  100903. */
  100904. get isFrozen(): boolean;
  100905. /**
  100906. * Locks updates for the material
  100907. */
  100908. freeze(): void;
  100909. /**
  100910. * Unlocks updates for the material
  100911. */
  100912. unfreeze(): void;
  100913. /**
  100914. * Specifies if the material is ready to be used
  100915. * @param mesh defines the mesh to check
  100916. * @param useInstances specifies if instances should be used
  100917. * @returns a boolean indicating if the material is ready to be used
  100918. */
  100919. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100920. /**
  100921. * Specifies that the submesh is ready to be used
  100922. * @param mesh defines the mesh to check
  100923. * @param subMesh defines which submesh to check
  100924. * @param useInstances specifies that instances should be used
  100925. * @returns a boolean indicating that the submesh is ready or not
  100926. */
  100927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  100928. /**
  100929. * Returns the material effect
  100930. * @returns the effect associated with the material
  100931. */
  100932. getEffect(): Nullable<Effect>;
  100933. /**
  100934. * Returns the current scene
  100935. * @returns a Scene
  100936. */
  100937. getScene(): Scene;
  100938. /**
  100939. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100940. */
  100941. protected _forceAlphaTest: boolean;
  100942. /**
  100943. * The transparency mode of the material.
  100944. */
  100945. protected _transparencyMode: Nullable<number>;
  100946. /**
  100947. * Gets the current transparency mode.
  100948. */
  100949. get transparencyMode(): Nullable<number>;
  100950. /**
  100951. * Sets the transparency mode of the material.
  100952. *
  100953. * | Value | Type | Description |
  100954. * | ----- | ----------------------------------- | ----------- |
  100955. * | 0 | OPAQUE | |
  100956. * | 1 | ALPHATEST | |
  100957. * | 2 | ALPHABLEND | |
  100958. * | 3 | ALPHATESTANDBLEND | |
  100959. *
  100960. */
  100961. set transparencyMode(value: Nullable<number>);
  100962. /**
  100963. * Returns true if alpha blending should be disabled.
  100964. */
  100965. protected get _disableAlphaBlending(): boolean;
  100966. /**
  100967. * Specifies whether or not this material should be rendered in alpha blend mode.
  100968. * @returns a boolean specifying if alpha blending is needed
  100969. */
  100970. needAlphaBlending(): boolean;
  100971. /**
  100972. * Specifies if the mesh will require alpha blending
  100973. * @param mesh defines the mesh to check
  100974. * @returns a boolean specifying if alpha blending is needed for the mesh
  100975. */
  100976. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100977. /**
  100978. * Specifies whether or not this material should be rendered in alpha test mode.
  100979. * @returns a boolean specifying if an alpha test is needed.
  100980. */
  100981. needAlphaTesting(): boolean;
  100982. /**
  100983. * Specifies if material alpha testing should be turned on for the mesh
  100984. * @param mesh defines the mesh to check
  100985. */
  100986. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  100987. /**
  100988. * Gets the texture used for the alpha test
  100989. * @returns the texture to use for alpha testing
  100990. */
  100991. getAlphaTestTexture(): Nullable<BaseTexture>;
  100992. /**
  100993. * Marks the material to indicate that it needs to be re-calculated
  100994. */
  100995. markDirty(): void;
  100996. /** @hidden */
  100997. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  100998. /**
  100999. * Binds the material to the mesh
  101000. * @param world defines the world transformation matrix
  101001. * @param mesh defines the mesh to bind the material to
  101002. */
  101003. bind(world: Matrix, mesh?: Mesh): void;
  101004. /**
  101005. * Binds the submesh to the material
  101006. * @param world defines the world transformation matrix
  101007. * @param mesh defines the mesh containing the submesh
  101008. * @param subMesh defines the submesh to bind the material to
  101009. */
  101010. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101011. /**
  101012. * Binds the world matrix to the material
  101013. * @param world defines the world transformation matrix
  101014. */
  101015. bindOnlyWorldMatrix(world: Matrix): void;
  101016. /**
  101017. * Binds the scene's uniform buffer to the effect.
  101018. * @param effect defines the effect to bind to the scene uniform buffer
  101019. * @param sceneUbo defines the uniform buffer storing scene data
  101020. */
  101021. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101022. /**
  101023. * Binds the view matrix to the effect
  101024. * @param effect defines the effect to bind the view matrix to
  101025. */
  101026. bindView(effect: Effect): void;
  101027. /**
  101028. * Binds the view projection matrix to the effect
  101029. * @param effect defines the effect to bind the view projection matrix to
  101030. */
  101031. bindViewProjection(effect: Effect): void;
  101032. /**
  101033. * Processes to execute after binding the material to a mesh
  101034. * @param mesh defines the rendered mesh
  101035. */
  101036. protected _afterBind(mesh?: Mesh): void;
  101037. /**
  101038. * Unbinds the material from the mesh
  101039. */
  101040. unbind(): void;
  101041. /**
  101042. * Gets the active textures from the material
  101043. * @returns an array of textures
  101044. */
  101045. getActiveTextures(): BaseTexture[];
  101046. /**
  101047. * Specifies if the material uses a texture
  101048. * @param texture defines the texture to check against the material
  101049. * @returns a boolean specifying if the material uses the texture
  101050. */
  101051. hasTexture(texture: BaseTexture): boolean;
  101052. /**
  101053. * Makes a duplicate of the material, and gives it a new name
  101054. * @param name defines the new name for the duplicated material
  101055. * @returns the cloned material
  101056. */
  101057. clone(name: string): Nullable<Material>;
  101058. /**
  101059. * Gets the meshes bound to the material
  101060. * @returns an array of meshes bound to the material
  101061. */
  101062. getBindedMeshes(): AbstractMesh[];
  101063. /**
  101064. * Force shader compilation
  101065. * @param mesh defines the mesh associated with this material
  101066. * @param onCompiled defines a function to execute once the material is compiled
  101067. * @param options defines the options to configure the compilation
  101068. * @param onError defines a function to execute if the material fails compiling
  101069. */
  101070. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101071. /**
  101072. * Force shader compilation
  101073. * @param mesh defines the mesh that will use this material
  101074. * @param options defines additional options for compiling the shaders
  101075. * @returns a promise that resolves when the compilation completes
  101076. */
  101077. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101078. private static readonly _AllDirtyCallBack;
  101079. private static readonly _ImageProcessingDirtyCallBack;
  101080. private static readonly _TextureDirtyCallBack;
  101081. private static readonly _FresnelDirtyCallBack;
  101082. private static readonly _MiscDirtyCallBack;
  101083. private static readonly _LightsDirtyCallBack;
  101084. private static readonly _AttributeDirtyCallBack;
  101085. private static _FresnelAndMiscDirtyCallBack;
  101086. private static _TextureAndMiscDirtyCallBack;
  101087. private static readonly _DirtyCallbackArray;
  101088. private static readonly _RunDirtyCallBacks;
  101089. /**
  101090. * Marks a define in the material to indicate that it needs to be re-computed
  101091. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101092. */
  101093. markAsDirty(flag: number): void;
  101094. /**
  101095. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101096. * @param func defines a function which checks material defines against the submeshes
  101097. */
  101098. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101099. /**
  101100. * Indicates that we need to re-calculated for all submeshes
  101101. */
  101102. protected _markAllSubMeshesAsAllDirty(): void;
  101103. /**
  101104. * Indicates that image processing needs to be re-calculated for all submeshes
  101105. */
  101106. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101107. /**
  101108. * Indicates that textures need to be re-calculated for all submeshes
  101109. */
  101110. protected _markAllSubMeshesAsTexturesDirty(): void;
  101111. /**
  101112. * Indicates that fresnel needs to be re-calculated for all submeshes
  101113. */
  101114. protected _markAllSubMeshesAsFresnelDirty(): void;
  101115. /**
  101116. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101117. */
  101118. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101119. /**
  101120. * Indicates that lights need to be re-calculated for all submeshes
  101121. */
  101122. protected _markAllSubMeshesAsLightsDirty(): void;
  101123. /**
  101124. * Indicates that attributes need to be re-calculated for all submeshes
  101125. */
  101126. protected _markAllSubMeshesAsAttributesDirty(): void;
  101127. /**
  101128. * Indicates that misc needs to be re-calculated for all submeshes
  101129. */
  101130. protected _markAllSubMeshesAsMiscDirty(): void;
  101131. /**
  101132. * Indicates that textures and misc need to be re-calculated for all submeshes
  101133. */
  101134. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101135. /**
  101136. * Disposes the material
  101137. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101138. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101139. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101140. */
  101141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101142. /** @hidden */
  101143. private releaseVertexArrayObject;
  101144. /**
  101145. * Serializes this material
  101146. * @returns the serialized material object
  101147. */
  101148. serialize(): any;
  101149. /**
  101150. * Creates a material from parsed material data
  101151. * @param parsedMaterial defines parsed material data
  101152. * @param scene defines the hosting scene
  101153. * @param rootUrl defines the root URL to use to load textures
  101154. * @returns a new material
  101155. */
  101156. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101157. }
  101158. }
  101159. declare module BABYLON {
  101160. /**
  101161. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101162. * separate meshes. This can be use to improve performances.
  101163. * @see http://doc.babylonjs.com/how_to/multi_materials
  101164. */
  101165. export class MultiMaterial extends Material {
  101166. private _subMaterials;
  101167. /**
  101168. * Gets or Sets the list of Materials used within the multi material.
  101169. * They need to be ordered according to the submeshes order in the associated mesh
  101170. */
  101171. get subMaterials(): Nullable<Material>[];
  101172. set subMaterials(value: Nullable<Material>[]);
  101173. /**
  101174. * Function used to align with Node.getChildren()
  101175. * @returns the list of Materials used within the multi material
  101176. */
  101177. getChildren(): Nullable<Material>[];
  101178. /**
  101179. * Instantiates a new Multi Material
  101180. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101181. * separate meshes. This can be use to improve performances.
  101182. * @see http://doc.babylonjs.com/how_to/multi_materials
  101183. * @param name Define the name in the scene
  101184. * @param scene Define the scene the material belongs to
  101185. */
  101186. constructor(name: string, scene: Scene);
  101187. private _hookArray;
  101188. /**
  101189. * Get one of the submaterial by its index in the submaterials array
  101190. * @param index The index to look the sub material at
  101191. * @returns The Material if the index has been defined
  101192. */
  101193. getSubMaterial(index: number): Nullable<Material>;
  101194. /**
  101195. * Get the list of active textures for the whole sub materials list.
  101196. * @returns All the textures that will be used during the rendering
  101197. */
  101198. getActiveTextures(): BaseTexture[];
  101199. /**
  101200. * Gets the current class name of the material e.g. "MultiMaterial"
  101201. * Mainly use in serialization.
  101202. * @returns the class name
  101203. */
  101204. getClassName(): string;
  101205. /**
  101206. * Checks if the material is ready to render the requested sub mesh
  101207. * @param mesh Define the mesh the submesh belongs to
  101208. * @param subMesh Define the sub mesh to look readyness for
  101209. * @param useInstances Define whether or not the material is used with instances
  101210. * @returns true if ready, otherwise false
  101211. */
  101212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  101213. /**
  101214. * Clones the current material and its related sub materials
  101215. * @param name Define the name of the newly cloned material
  101216. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101217. * @returns the cloned material
  101218. */
  101219. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101220. /**
  101221. * Serializes the materials into a JSON representation.
  101222. * @returns the JSON representation
  101223. */
  101224. serialize(): any;
  101225. /**
  101226. * Dispose the material and release its associated resources
  101227. * @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)
  101228. * @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)
  101229. * @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)
  101230. */
  101231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101232. /**
  101233. * Creates a MultiMaterial from parsed MultiMaterial data.
  101234. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101235. * @param scene defines the hosting scene
  101236. * @returns a new MultiMaterial
  101237. */
  101238. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101239. }
  101240. }
  101241. declare module BABYLON {
  101242. /**
  101243. * Base class for submeshes
  101244. */
  101245. export class BaseSubMesh {
  101246. /** @hidden */
  101247. _materialDefines: Nullable<MaterialDefines>;
  101248. /** @hidden */
  101249. _materialEffect: Nullable<Effect>;
  101250. /** @hidden */
  101251. _effectOverride: Nullable<Effect>;
  101252. /**
  101253. * Gets material defines used by the effect associated to the sub mesh
  101254. */
  101255. get materialDefines(): Nullable<MaterialDefines>;
  101256. /**
  101257. * Sets material defines used by the effect associated to the sub mesh
  101258. */
  101259. set materialDefines(defines: Nullable<MaterialDefines>);
  101260. /**
  101261. * Gets associated effect
  101262. */
  101263. get effect(): Nullable<Effect>;
  101264. /**
  101265. * Sets associated effect (effect used to render this submesh)
  101266. * @param effect defines the effect to associate with
  101267. * @param defines defines the set of defines used to compile this effect
  101268. */
  101269. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101270. }
  101271. /**
  101272. * Defines a subdivision inside a mesh
  101273. */
  101274. export class SubMesh extends BaseSubMesh implements ICullable {
  101275. /** the material index to use */
  101276. materialIndex: number;
  101277. /** vertex index start */
  101278. verticesStart: number;
  101279. /** vertices count */
  101280. verticesCount: number;
  101281. /** index start */
  101282. indexStart: number;
  101283. /** indices count */
  101284. indexCount: number;
  101285. /** @hidden */
  101286. _linesIndexCount: number;
  101287. private _mesh;
  101288. private _renderingMesh;
  101289. private _boundingInfo;
  101290. private _linesIndexBuffer;
  101291. /** @hidden */
  101292. _lastColliderWorldVertices: Nullable<Vector3[]>;
  101293. /** @hidden */
  101294. _trianglePlanes: Plane[];
  101295. /** @hidden */
  101296. _lastColliderTransformMatrix: Nullable<Matrix>;
  101297. /** @hidden */
  101298. _renderId: number;
  101299. /** @hidden */
  101300. _alphaIndex: number;
  101301. /** @hidden */
  101302. _distanceToCamera: number;
  101303. /** @hidden */
  101304. _id: number;
  101305. private _currentMaterial;
  101306. /**
  101307. * Add a new submesh to a mesh
  101308. * @param materialIndex defines the material index to use
  101309. * @param verticesStart defines vertex index start
  101310. * @param verticesCount defines vertices count
  101311. * @param indexStart defines index start
  101312. * @param indexCount defines indices count
  101313. * @param mesh defines the parent mesh
  101314. * @param renderingMesh defines an optional rendering mesh
  101315. * @param createBoundingBox defines if bounding box should be created for this submesh
  101316. * @returns the new submesh
  101317. */
  101318. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  101319. /**
  101320. * Creates a new submesh
  101321. * @param materialIndex defines the material index to use
  101322. * @param verticesStart defines vertex index start
  101323. * @param verticesCount defines vertices count
  101324. * @param indexStart defines index start
  101325. * @param indexCount defines indices count
  101326. * @param mesh defines the parent mesh
  101327. * @param renderingMesh defines an optional rendering mesh
  101328. * @param createBoundingBox defines if bounding box should be created for this submesh
  101329. */
  101330. constructor(
  101331. /** the material index to use */
  101332. materialIndex: number,
  101333. /** vertex index start */
  101334. verticesStart: number,
  101335. /** vertices count */
  101336. verticesCount: number,
  101337. /** index start */
  101338. indexStart: number,
  101339. /** indices count */
  101340. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  101341. /**
  101342. * Returns true if this submesh covers the entire parent mesh
  101343. * @ignorenaming
  101344. */
  101345. get IsGlobal(): boolean;
  101346. /**
  101347. * Returns the submesh BoudingInfo object
  101348. * @returns current bounding info (or mesh's one if the submesh is global)
  101349. */
  101350. getBoundingInfo(): BoundingInfo;
  101351. /**
  101352. * Sets the submesh BoundingInfo
  101353. * @param boundingInfo defines the new bounding info to use
  101354. * @returns the SubMesh
  101355. */
  101356. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  101357. /**
  101358. * Returns the mesh of the current submesh
  101359. * @return the parent mesh
  101360. */
  101361. getMesh(): AbstractMesh;
  101362. /**
  101363. * Returns the rendering mesh of the submesh
  101364. * @returns the rendering mesh (could be different from parent mesh)
  101365. */
  101366. getRenderingMesh(): Mesh;
  101367. /**
  101368. * Returns the submesh material
  101369. * @returns null or the current material
  101370. */
  101371. getMaterial(): Nullable<Material>;
  101372. /**
  101373. * Sets a new updated BoundingInfo object to the submesh
  101374. * @param data defines an optional position array to use to determine the bounding info
  101375. * @returns the SubMesh
  101376. */
  101377. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  101378. /** @hidden */
  101379. _checkCollision(collider: Collider): boolean;
  101380. /**
  101381. * Updates the submesh BoundingInfo
  101382. * @param world defines the world matrix to use to update the bounding info
  101383. * @returns the submesh
  101384. */
  101385. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  101386. /**
  101387. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  101388. * @param frustumPlanes defines the frustum planes
  101389. * @returns true if the submesh is intersecting with the frustum
  101390. */
  101391. isInFrustum(frustumPlanes: Plane[]): boolean;
  101392. /**
  101393. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  101394. * @param frustumPlanes defines the frustum planes
  101395. * @returns true if the submesh is inside the frustum
  101396. */
  101397. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101398. /**
  101399. * Renders the submesh
  101400. * @param enableAlphaMode defines if alpha needs to be used
  101401. * @returns the submesh
  101402. */
  101403. render(enableAlphaMode: boolean): SubMesh;
  101404. /**
  101405. * @hidden
  101406. */
  101407. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  101408. /**
  101409. * Checks if the submesh intersects with a ray
  101410. * @param ray defines the ray to test
  101411. * @returns true is the passed ray intersects the submesh bounding box
  101412. */
  101413. canIntersects(ray: Ray): boolean;
  101414. /**
  101415. * Intersects current submesh with a ray
  101416. * @param ray defines the ray to test
  101417. * @param positions defines mesh's positions array
  101418. * @param indices defines mesh's indices array
  101419. * @param fastCheck defines if the first intersection will be used (and not the closest)
  101420. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101421. * @returns intersection info or null if no intersection
  101422. */
  101423. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  101424. /** @hidden */
  101425. private _intersectLines;
  101426. /** @hidden */
  101427. private _intersectUnIndexedLines;
  101428. /** @hidden */
  101429. private _intersectTriangles;
  101430. /** @hidden */
  101431. private _intersectUnIndexedTriangles;
  101432. /** @hidden */
  101433. _rebuild(): void;
  101434. /**
  101435. * Creates a new submesh from the passed mesh
  101436. * @param newMesh defines the new hosting mesh
  101437. * @param newRenderingMesh defines an optional rendering mesh
  101438. * @returns the new submesh
  101439. */
  101440. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  101441. /**
  101442. * Release associated resources
  101443. */
  101444. dispose(): void;
  101445. /**
  101446. * Gets the class name
  101447. * @returns the string "SubMesh".
  101448. */
  101449. getClassName(): string;
  101450. /**
  101451. * Creates a new submesh from indices data
  101452. * @param materialIndex the index of the main mesh material
  101453. * @param startIndex the index where to start the copy in the mesh indices array
  101454. * @param indexCount the number of indices to copy then from the startIndex
  101455. * @param mesh the main mesh to create the submesh from
  101456. * @param renderingMesh the optional rendering mesh
  101457. * @returns a new submesh
  101458. */
  101459. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  101460. }
  101461. }
  101462. declare module BABYLON {
  101463. /**
  101464. * Class used to represent data loading progression
  101465. */
  101466. export class SceneLoaderFlags {
  101467. private static _ForceFullSceneLoadingForIncremental;
  101468. private static _ShowLoadingScreen;
  101469. private static _CleanBoneMatrixWeights;
  101470. private static _loggingLevel;
  101471. /**
  101472. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101473. */
  101474. static get ForceFullSceneLoadingForIncremental(): boolean;
  101475. static set ForceFullSceneLoadingForIncremental(value: boolean);
  101476. /**
  101477. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101478. */
  101479. static get ShowLoadingScreen(): boolean;
  101480. static set ShowLoadingScreen(value: boolean);
  101481. /**
  101482. * Defines the current logging level (while loading the scene)
  101483. * @ignorenaming
  101484. */
  101485. static get loggingLevel(): number;
  101486. static set loggingLevel(value: number);
  101487. /**
  101488. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101489. */
  101490. static get CleanBoneMatrixWeights(): boolean;
  101491. static set CleanBoneMatrixWeights(value: boolean);
  101492. }
  101493. }
  101494. declare module BABYLON {
  101495. /**
  101496. * Class used to store geometry data (vertex buffers + index buffer)
  101497. */
  101498. export class Geometry implements IGetSetVerticesData {
  101499. /**
  101500. * Gets or sets the ID of the geometry
  101501. */
  101502. id: string;
  101503. /**
  101504. * Gets or sets the unique ID of the geometry
  101505. */
  101506. uniqueId: number;
  101507. /**
  101508. * Gets the delay loading state of the geometry (none by default which means not delayed)
  101509. */
  101510. delayLoadState: number;
  101511. /**
  101512. * Gets the file containing the data to load when running in delay load state
  101513. */
  101514. delayLoadingFile: Nullable<string>;
  101515. /**
  101516. * Callback called when the geometry is updated
  101517. */
  101518. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  101519. private _scene;
  101520. private _engine;
  101521. private _meshes;
  101522. private _totalVertices;
  101523. /** @hidden */
  101524. _indices: IndicesArray;
  101525. /** @hidden */
  101526. _vertexBuffers: {
  101527. [key: string]: VertexBuffer;
  101528. };
  101529. private _isDisposed;
  101530. private _extend;
  101531. private _boundingBias;
  101532. /** @hidden */
  101533. _delayInfo: Array<string>;
  101534. private _indexBuffer;
  101535. private _indexBufferIsUpdatable;
  101536. /** @hidden */
  101537. _boundingInfo: Nullable<BoundingInfo>;
  101538. /** @hidden */
  101539. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  101540. /** @hidden */
  101541. _softwareSkinningFrameId: number;
  101542. private _vertexArrayObjects;
  101543. private _updatable;
  101544. /** @hidden */
  101545. _positions: Nullable<Vector3[]>;
  101546. /**
  101547. * 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
  101548. */
  101549. get boundingBias(): Vector2;
  101550. /**
  101551. * 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
  101552. */
  101553. set boundingBias(value: Vector2);
  101554. /**
  101555. * Static function used to attach a new empty geometry to a mesh
  101556. * @param mesh defines the mesh to attach the geometry to
  101557. * @returns the new Geometry
  101558. */
  101559. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  101560. /** Get the list of meshes using this geometry */
  101561. get meshes(): Mesh[];
  101562. /**
  101563. * Creates a new geometry
  101564. * @param id defines the unique ID
  101565. * @param scene defines the hosting scene
  101566. * @param vertexData defines the VertexData used to get geometry data
  101567. * @param updatable defines if geometry must be updatable (false by default)
  101568. * @param mesh defines the mesh that will be associated with the geometry
  101569. */
  101570. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  101571. /**
  101572. * Gets the current extend of the geometry
  101573. */
  101574. get extend(): {
  101575. minimum: Vector3;
  101576. maximum: Vector3;
  101577. };
  101578. /**
  101579. * Gets the hosting scene
  101580. * @returns the hosting Scene
  101581. */
  101582. getScene(): Scene;
  101583. /**
  101584. * Gets the hosting engine
  101585. * @returns the hosting Engine
  101586. */
  101587. getEngine(): Engine;
  101588. /**
  101589. * Defines if the geometry is ready to use
  101590. * @returns true if the geometry is ready to be used
  101591. */
  101592. isReady(): boolean;
  101593. /**
  101594. * Gets a value indicating that the geometry should not be serialized
  101595. */
  101596. get doNotSerialize(): boolean;
  101597. /** @hidden */
  101598. _rebuild(): void;
  101599. /**
  101600. * Affects all geometry data in one call
  101601. * @param vertexData defines the geometry data
  101602. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  101603. */
  101604. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  101605. /**
  101606. * Set specific vertex data
  101607. * @param kind defines the data kind (Position, normal, etc...)
  101608. * @param data defines the vertex data to use
  101609. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101610. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101611. */
  101612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  101613. /**
  101614. * Removes a specific vertex data
  101615. * @param kind defines the data kind (Position, normal, etc...)
  101616. */
  101617. removeVerticesData(kind: string): void;
  101618. /**
  101619. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  101620. * @param buffer defines the vertex buffer to use
  101621. * @param totalVertices defines the total number of vertices for position kind (could be null)
  101622. */
  101623. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  101624. /**
  101625. * Update a specific vertex buffer
  101626. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  101627. * It will do nothing if the buffer is not updatable
  101628. * @param kind defines the data kind (Position, normal, etc...)
  101629. * @param data defines the data to use
  101630. * @param offset defines the offset in the target buffer where to store the data
  101631. * @param useBytes set to true if the offset is in bytes
  101632. */
  101633. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  101634. /**
  101635. * Update a specific vertex buffer
  101636. * This function will create a new buffer if the current one is not updatable
  101637. * @param kind defines the data kind (Position, normal, etc...)
  101638. * @param data defines the data to use
  101639. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  101640. */
  101641. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  101642. private _updateBoundingInfo;
  101643. /** @hidden */
  101644. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  101645. /**
  101646. * Gets total number of vertices
  101647. * @returns the total number of vertices
  101648. */
  101649. getTotalVertices(): number;
  101650. /**
  101651. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101652. * @param kind defines the data kind (Position, normal, etc...)
  101653. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101654. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101655. * @returns a float array containing vertex data
  101656. */
  101657. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101658. /**
  101659. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  101660. * @param kind defines the data kind (Position, normal, etc...)
  101661. * @returns true if the vertex buffer with the specified kind is updatable
  101662. */
  101663. isVertexBufferUpdatable(kind: string): boolean;
  101664. /**
  101665. * Gets a specific vertex buffer
  101666. * @param kind defines the data kind (Position, normal, etc...)
  101667. * @returns a VertexBuffer
  101668. */
  101669. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  101670. /**
  101671. * Returns all vertex buffers
  101672. * @return an object holding all vertex buffers indexed by kind
  101673. */
  101674. getVertexBuffers(): Nullable<{
  101675. [key: string]: VertexBuffer;
  101676. }>;
  101677. /**
  101678. * Gets a boolean indicating if specific vertex buffer is present
  101679. * @param kind defines the data kind (Position, normal, etc...)
  101680. * @returns true if data is present
  101681. */
  101682. isVerticesDataPresent(kind: string): boolean;
  101683. /**
  101684. * Gets a list of all attached data kinds (Position, normal, etc...)
  101685. * @returns a list of string containing all kinds
  101686. */
  101687. getVerticesDataKinds(): string[];
  101688. /**
  101689. * Update index buffer
  101690. * @param indices defines the indices to store in the index buffer
  101691. * @param offset defines the offset in the target buffer where to store the data
  101692. * @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)
  101693. */
  101694. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  101695. /**
  101696. * Creates a new index buffer
  101697. * @param indices defines the indices to store in the index buffer
  101698. * @param totalVertices defines the total number of vertices (could be null)
  101699. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  101700. */
  101701. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  101702. /**
  101703. * Return the total number of indices
  101704. * @returns the total number of indices
  101705. */
  101706. getTotalIndices(): number;
  101707. /**
  101708. * Gets the index buffer array
  101709. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101711. * @returns the index buffer array
  101712. */
  101713. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101714. /**
  101715. * Gets the index buffer
  101716. * @return the index buffer
  101717. */
  101718. getIndexBuffer(): Nullable<DataBuffer>;
  101719. /** @hidden */
  101720. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  101721. /**
  101722. * Release the associated resources for a specific mesh
  101723. * @param mesh defines the source mesh
  101724. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  101725. */
  101726. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  101727. /**
  101728. * Apply current geometry to a given mesh
  101729. * @param mesh defines the mesh to apply geometry to
  101730. */
  101731. applyToMesh(mesh: Mesh): void;
  101732. private _updateExtend;
  101733. private _applyToMesh;
  101734. private notifyUpdate;
  101735. /**
  101736. * Load the geometry if it was flagged as delay loaded
  101737. * @param scene defines the hosting scene
  101738. * @param onLoaded defines a callback called when the geometry is loaded
  101739. */
  101740. load(scene: Scene, onLoaded?: () => void): void;
  101741. private _queueLoad;
  101742. /**
  101743. * Invert the geometry to move from a right handed system to a left handed one.
  101744. */
  101745. toLeftHanded(): void;
  101746. /** @hidden */
  101747. _resetPointsArrayCache(): void;
  101748. /** @hidden */
  101749. _generatePointsArray(): boolean;
  101750. /**
  101751. * Gets a value indicating if the geometry is disposed
  101752. * @returns true if the geometry was disposed
  101753. */
  101754. isDisposed(): boolean;
  101755. private _disposeVertexArrayObjects;
  101756. /**
  101757. * Free all associated resources
  101758. */
  101759. dispose(): void;
  101760. /**
  101761. * Clone the current geometry into a new geometry
  101762. * @param id defines the unique ID of the new geometry
  101763. * @returns a new geometry object
  101764. */
  101765. copy(id: string): Geometry;
  101766. /**
  101767. * Serialize the current geometry info (and not the vertices data) into a JSON object
  101768. * @return a JSON representation of the current geometry data (without the vertices data)
  101769. */
  101770. serialize(): any;
  101771. private toNumberArray;
  101772. /**
  101773. * Serialize all vertices data into a JSON oject
  101774. * @returns a JSON representation of the current geometry data
  101775. */
  101776. serializeVerticeData(): any;
  101777. /**
  101778. * Extracts a clone of a mesh geometry
  101779. * @param mesh defines the source mesh
  101780. * @param id defines the unique ID of the new geometry object
  101781. * @returns the new geometry object
  101782. */
  101783. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  101784. /**
  101785. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  101786. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101787. * Be aware Math.random() could cause collisions, but:
  101788. * "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"
  101789. * @returns a string containing a new GUID
  101790. */
  101791. static RandomId(): string;
  101792. /** @hidden */
  101793. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  101794. private static _CleanMatricesWeights;
  101795. /**
  101796. * Create a new geometry from persisted data (Using .babylon file format)
  101797. * @param parsedVertexData defines the persisted data
  101798. * @param scene defines the hosting scene
  101799. * @param rootUrl defines the root url to use to load assets (like delayed data)
  101800. * @returns the new geometry object
  101801. */
  101802. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  101803. }
  101804. }
  101805. declare module BABYLON {
  101806. /**
  101807. * Define an interface for all classes that will get and set the data on vertices
  101808. */
  101809. export interface IGetSetVerticesData {
  101810. /**
  101811. * Gets a boolean indicating if specific vertex data is present
  101812. * @param kind defines the vertex data kind to use
  101813. * @returns true is data kind is present
  101814. */
  101815. isVerticesDataPresent(kind: string): boolean;
  101816. /**
  101817. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101818. * @param kind defines the data kind (Position, normal, etc...)
  101819. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101820. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101821. * @returns a float array containing vertex data
  101822. */
  101823. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101824. /**
  101825. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  101826. * @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.
  101827. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101828. * @returns the indices array or an empty array if the mesh has no geometry
  101829. */
  101830. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101831. /**
  101832. * Set specific vertex data
  101833. * @param kind defines the data kind (Position, normal, etc...)
  101834. * @param data defines the vertex data to use
  101835. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101836. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101837. */
  101838. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  101839. /**
  101840. * Update a specific associated vertex buffer
  101841. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101842. * - VertexBuffer.PositionKind
  101843. * - VertexBuffer.UVKind
  101844. * - VertexBuffer.UV2Kind
  101845. * - VertexBuffer.UV3Kind
  101846. * - VertexBuffer.UV4Kind
  101847. * - VertexBuffer.UV5Kind
  101848. * - VertexBuffer.UV6Kind
  101849. * - VertexBuffer.ColorKind
  101850. * - VertexBuffer.MatricesIndicesKind
  101851. * - VertexBuffer.MatricesIndicesExtraKind
  101852. * - VertexBuffer.MatricesWeightsKind
  101853. * - VertexBuffer.MatricesWeightsExtraKind
  101854. * @param data defines the data source
  101855. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  101856. * @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)
  101857. */
  101858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  101859. /**
  101860. * Creates a new index buffer
  101861. * @param indices defines the indices to store in the index buffer
  101862. * @param totalVertices defines the total number of vertices (could be null)
  101863. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  101864. */
  101865. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  101866. }
  101867. /**
  101868. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  101869. */
  101870. export class VertexData {
  101871. /**
  101872. * Mesh side orientation : usually the external or front surface
  101873. */
  101874. static readonly FRONTSIDE: number;
  101875. /**
  101876. * Mesh side orientation : usually the internal or back surface
  101877. */
  101878. static readonly BACKSIDE: number;
  101879. /**
  101880. * Mesh side orientation : both internal and external or front and back surfaces
  101881. */
  101882. static readonly DOUBLESIDE: number;
  101883. /**
  101884. * Mesh side orientation : by default, `FRONTSIDE`
  101885. */
  101886. static readonly DEFAULTSIDE: number;
  101887. /**
  101888. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  101889. */
  101890. positions: Nullable<FloatArray>;
  101891. /**
  101892. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  101893. */
  101894. normals: Nullable<FloatArray>;
  101895. /**
  101896. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  101897. */
  101898. tangents: Nullable<FloatArray>;
  101899. /**
  101900. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101901. */
  101902. uvs: Nullable<FloatArray>;
  101903. /**
  101904. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101905. */
  101906. uvs2: Nullable<FloatArray>;
  101907. /**
  101908. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101909. */
  101910. uvs3: Nullable<FloatArray>;
  101911. /**
  101912. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101913. */
  101914. uvs4: Nullable<FloatArray>;
  101915. /**
  101916. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101917. */
  101918. uvs5: Nullable<FloatArray>;
  101919. /**
  101920. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101921. */
  101922. uvs6: Nullable<FloatArray>;
  101923. /**
  101924. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  101925. */
  101926. colors: Nullable<FloatArray>;
  101927. /**
  101928. * 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).
  101929. */
  101930. matricesIndices: Nullable<FloatArray>;
  101931. /**
  101932. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  101933. */
  101934. matricesWeights: Nullable<FloatArray>;
  101935. /**
  101936. * An array extending the number of possible indices
  101937. */
  101938. matricesIndicesExtra: Nullable<FloatArray>;
  101939. /**
  101940. * An array extending the number of possible weights when the number of indices is extended
  101941. */
  101942. matricesWeightsExtra: Nullable<FloatArray>;
  101943. /**
  101944. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  101945. */
  101946. indices: Nullable<IndicesArray>;
  101947. /**
  101948. * Uses the passed data array to set the set the values for the specified kind of data
  101949. * @param data a linear array of floating numbers
  101950. * @param kind the type of data that is being set, eg positions, colors etc
  101951. */
  101952. set(data: FloatArray, kind: string): void;
  101953. /**
  101954. * Associates the vertexData to the passed Mesh.
  101955. * Sets it as updatable or not (default `false`)
  101956. * @param mesh the mesh the vertexData is applied to
  101957. * @param updatable when used and having the value true allows new data to update the vertexData
  101958. * @returns the VertexData
  101959. */
  101960. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  101961. /**
  101962. * Associates the vertexData to the passed Geometry.
  101963. * Sets it as updatable or not (default `false`)
  101964. * @param geometry the geometry the vertexData is applied to
  101965. * @param updatable when used and having the value true allows new data to update the vertexData
  101966. * @returns VertexData
  101967. */
  101968. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  101969. /**
  101970. * Updates the associated mesh
  101971. * @param mesh the mesh to be updated
  101972. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  101973. * @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
  101974. * @returns VertexData
  101975. */
  101976. updateMesh(mesh: Mesh): VertexData;
  101977. /**
  101978. * Updates the associated geometry
  101979. * @param geometry the geometry to be updated
  101980. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  101981. * @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
  101982. * @returns VertexData.
  101983. */
  101984. updateGeometry(geometry: Geometry): VertexData;
  101985. private _applyTo;
  101986. private _update;
  101987. /**
  101988. * Transforms each position and each normal of the vertexData according to the passed Matrix
  101989. * @param matrix the transforming matrix
  101990. * @returns the VertexData
  101991. */
  101992. transform(matrix: Matrix): VertexData;
  101993. /**
  101994. * Merges the passed VertexData into the current one
  101995. * @param other the VertexData to be merged into the current one
  101996. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  101997. * @returns the modified VertexData
  101998. */
  101999. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102000. private _mergeElement;
  102001. private _validate;
  102002. /**
  102003. * Serializes the VertexData
  102004. * @returns a serialized object
  102005. */
  102006. serialize(): any;
  102007. /**
  102008. * Extracts the vertexData from a mesh
  102009. * @param mesh the mesh from which to extract the VertexData
  102010. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102011. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102012. * @returns the object VertexData associated to the passed mesh
  102013. */
  102014. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102015. /**
  102016. * Extracts the vertexData from the geometry
  102017. * @param geometry the geometry from which to extract the VertexData
  102018. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102019. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102020. * @returns the object VertexData associated to the passed mesh
  102021. */
  102022. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102023. private static _ExtractFrom;
  102024. /**
  102025. * Creates the VertexData for a Ribbon
  102026. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102027. * * pathArray array of paths, each of which an array of successive Vector3
  102028. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102029. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102030. * * 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
  102031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102032. * * 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)
  102033. * * 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)
  102034. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102035. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102036. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102037. * @returns the VertexData of the ribbon
  102038. */
  102039. static CreateRibbon(options: {
  102040. pathArray: Vector3[][];
  102041. closeArray?: boolean;
  102042. closePath?: boolean;
  102043. offset?: number;
  102044. sideOrientation?: number;
  102045. frontUVs?: Vector4;
  102046. backUVs?: Vector4;
  102047. invertUV?: boolean;
  102048. uvs?: Vector2[];
  102049. colors?: Color4[];
  102050. }): VertexData;
  102051. /**
  102052. * Creates the VertexData for a box
  102053. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102054. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102055. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102056. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102057. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102058. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102059. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102061. * * 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)
  102062. * * 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)
  102063. * @returns the VertexData of the box
  102064. */
  102065. static CreateBox(options: {
  102066. size?: number;
  102067. width?: number;
  102068. height?: number;
  102069. depth?: number;
  102070. faceUV?: Vector4[];
  102071. faceColors?: Color4[];
  102072. sideOrientation?: number;
  102073. frontUVs?: Vector4;
  102074. backUVs?: Vector4;
  102075. }): VertexData;
  102076. /**
  102077. * Creates the VertexData for a tiled box
  102078. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102079. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102080. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102081. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102083. * @returns the VertexData of the box
  102084. */
  102085. static CreateTiledBox(options: {
  102086. pattern?: number;
  102087. width?: number;
  102088. height?: number;
  102089. depth?: number;
  102090. tileSize?: number;
  102091. tileWidth?: number;
  102092. tileHeight?: number;
  102093. alignHorizontal?: number;
  102094. alignVertical?: number;
  102095. faceUV?: Vector4[];
  102096. faceColors?: Color4[];
  102097. sideOrientation?: number;
  102098. }): VertexData;
  102099. /**
  102100. * Creates the VertexData for a tiled plane
  102101. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102102. * * pattern a limited pattern arrangement depending on the number
  102103. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102104. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102105. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102107. * * 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)
  102108. * * 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)
  102109. * @returns the VertexData of the tiled plane
  102110. */
  102111. static CreateTiledPlane(options: {
  102112. pattern?: number;
  102113. tileSize?: number;
  102114. tileWidth?: number;
  102115. tileHeight?: number;
  102116. size?: number;
  102117. width?: number;
  102118. height?: number;
  102119. alignHorizontal?: number;
  102120. alignVertical?: number;
  102121. sideOrientation?: number;
  102122. frontUVs?: Vector4;
  102123. backUVs?: Vector4;
  102124. }): VertexData;
  102125. /**
  102126. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102127. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102128. * * segments sets the number of horizontal strips optional, default 32
  102129. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102130. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102131. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102132. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102133. * * 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
  102134. * * 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
  102135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102136. * * 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)
  102137. * * 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)
  102138. * @returns the VertexData of the ellipsoid
  102139. */
  102140. static CreateSphere(options: {
  102141. segments?: number;
  102142. diameter?: number;
  102143. diameterX?: number;
  102144. diameterY?: number;
  102145. diameterZ?: number;
  102146. arc?: number;
  102147. slice?: number;
  102148. sideOrientation?: number;
  102149. frontUVs?: Vector4;
  102150. backUVs?: Vector4;
  102151. }): VertexData;
  102152. /**
  102153. * Creates the VertexData for a cylinder, cone or prism
  102154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102155. * * height sets the height (y direction) of the cylinder, optional, default 2
  102156. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102157. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102158. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102159. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102160. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102161. * * 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
  102162. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102163. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102164. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102165. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102167. * * 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)
  102168. * * 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)
  102169. * @returns the VertexData of the cylinder, cone or prism
  102170. */
  102171. static CreateCylinder(options: {
  102172. height?: number;
  102173. diameterTop?: number;
  102174. diameterBottom?: number;
  102175. diameter?: number;
  102176. tessellation?: number;
  102177. subdivisions?: number;
  102178. arc?: number;
  102179. faceColors?: Color4[];
  102180. faceUV?: Vector4[];
  102181. hasRings?: boolean;
  102182. enclose?: boolean;
  102183. sideOrientation?: number;
  102184. frontUVs?: Vector4;
  102185. backUVs?: Vector4;
  102186. }): VertexData;
  102187. /**
  102188. * Creates the VertexData for a torus
  102189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102190. * * diameter the diameter of the torus, optional default 1
  102191. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102192. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102194. * * 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)
  102195. * * 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)
  102196. * @returns the VertexData of the torus
  102197. */
  102198. static CreateTorus(options: {
  102199. diameter?: number;
  102200. thickness?: number;
  102201. tessellation?: number;
  102202. sideOrientation?: number;
  102203. frontUVs?: Vector4;
  102204. backUVs?: Vector4;
  102205. }): VertexData;
  102206. /**
  102207. * Creates the VertexData of the LineSystem
  102208. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102209. * - lines an array of lines, each line being an array of successive Vector3
  102210. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102211. * @returns the VertexData of the LineSystem
  102212. */
  102213. static CreateLineSystem(options: {
  102214. lines: Vector3[][];
  102215. colors?: Nullable<Color4[][]>;
  102216. }): VertexData;
  102217. /**
  102218. * Create the VertexData for a DashedLines
  102219. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102220. * - points an array successive Vector3
  102221. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102222. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102223. * - dashNb the intended total number of dashes, optional, default 200
  102224. * @returns the VertexData for the DashedLines
  102225. */
  102226. static CreateDashedLines(options: {
  102227. points: Vector3[];
  102228. dashSize?: number;
  102229. gapSize?: number;
  102230. dashNb?: number;
  102231. }): VertexData;
  102232. /**
  102233. * Creates the VertexData for a Ground
  102234. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102235. * - width the width (x direction) of the ground, optional, default 1
  102236. * - height the height (z direction) of the ground, optional, default 1
  102237. * - subdivisions the number of subdivisions per side, optional, default 1
  102238. * @returns the VertexData of the Ground
  102239. */
  102240. static CreateGround(options: {
  102241. width?: number;
  102242. height?: number;
  102243. subdivisions?: number;
  102244. subdivisionsX?: number;
  102245. subdivisionsY?: number;
  102246. }): VertexData;
  102247. /**
  102248. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102249. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102250. * * xmin the ground minimum X coordinate, optional, default -1
  102251. * * zmin the ground minimum Z coordinate, optional, default -1
  102252. * * xmax the ground maximum X coordinate, optional, default 1
  102253. * * zmax the ground maximum Z coordinate, optional, default 1
  102254. * * 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}
  102255. * * 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}
  102256. * @returns the VertexData of the TiledGround
  102257. */
  102258. static CreateTiledGround(options: {
  102259. xmin: number;
  102260. zmin: number;
  102261. xmax: number;
  102262. zmax: number;
  102263. subdivisions?: {
  102264. w: number;
  102265. h: number;
  102266. };
  102267. precision?: {
  102268. w: number;
  102269. h: number;
  102270. };
  102271. }): VertexData;
  102272. /**
  102273. * Creates the VertexData of the Ground designed from a heightmap
  102274. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102275. * * width the width (x direction) of the ground
  102276. * * height the height (z direction) of the ground
  102277. * * subdivisions the number of subdivisions per side
  102278. * * minHeight the minimum altitude on the ground, optional, default 0
  102279. * * maxHeight the maximum altitude on the ground, optional default 1
  102280. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102281. * * buffer the array holding the image color data
  102282. * * bufferWidth the width of image
  102283. * * bufferHeight the height of image
  102284. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102285. * @returns the VertexData of the Ground designed from a heightmap
  102286. */
  102287. static CreateGroundFromHeightMap(options: {
  102288. width: number;
  102289. height: number;
  102290. subdivisions: number;
  102291. minHeight: number;
  102292. maxHeight: number;
  102293. colorFilter: Color3;
  102294. buffer: Uint8Array;
  102295. bufferWidth: number;
  102296. bufferHeight: number;
  102297. alphaFilter: number;
  102298. }): VertexData;
  102299. /**
  102300. * Creates the VertexData for a Plane
  102301. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102302. * * size sets the width and height of the plane to the value of size, optional default 1
  102303. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102304. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102306. * * 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)
  102307. * * 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)
  102308. * @returns the VertexData of the box
  102309. */
  102310. static CreatePlane(options: {
  102311. size?: number;
  102312. width?: number;
  102313. height?: number;
  102314. sideOrientation?: number;
  102315. frontUVs?: Vector4;
  102316. backUVs?: Vector4;
  102317. }): VertexData;
  102318. /**
  102319. * Creates the VertexData of the Disc or regular Polygon
  102320. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102321. * * radius the radius of the disc, optional default 0.5
  102322. * * tessellation the number of polygon sides, optional, default 64
  102323. * * 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
  102324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102325. * * 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)
  102326. * * 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)
  102327. * @returns the VertexData of the box
  102328. */
  102329. static CreateDisc(options: {
  102330. radius?: number;
  102331. tessellation?: number;
  102332. arc?: number;
  102333. sideOrientation?: number;
  102334. frontUVs?: Vector4;
  102335. backUVs?: Vector4;
  102336. }): VertexData;
  102337. /**
  102338. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102339. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102340. * @param polygon a mesh built from polygonTriangulation.build()
  102341. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102342. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102343. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102344. * @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)
  102345. * @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)
  102346. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  102347. * @returns the VertexData of the Polygon
  102348. */
  102349. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  102350. /**
  102351. * Creates the VertexData of the IcoSphere
  102352. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102353. * * radius the radius of the IcoSphere, optional default 1
  102354. * * radiusX allows stretching in the x direction, optional, default radius
  102355. * * radiusY allows stretching in the y direction, optional, default radius
  102356. * * radiusZ allows stretching in the z direction, optional, default radius
  102357. * * flat when true creates a flat shaded mesh, optional, default true
  102358. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102360. * * 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)
  102361. * * 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)
  102362. * @returns the VertexData of the IcoSphere
  102363. */
  102364. static CreateIcoSphere(options: {
  102365. radius?: number;
  102366. radiusX?: number;
  102367. radiusY?: number;
  102368. radiusZ?: number;
  102369. flat?: boolean;
  102370. subdivisions?: number;
  102371. sideOrientation?: number;
  102372. frontUVs?: Vector4;
  102373. backUVs?: Vector4;
  102374. }): VertexData;
  102375. /**
  102376. * Creates the VertexData for a Polyhedron
  102377. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102378. * * type provided types are:
  102379. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102380. * * 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)
  102381. * * size the size of the IcoSphere, optional default 1
  102382. * * sizeX allows stretching in the x direction, optional, default size
  102383. * * sizeY allows stretching in the y direction, optional, default size
  102384. * * sizeZ allows stretching in the z direction, optional, default size
  102385. * * 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
  102386. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102387. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102388. * * flat when true creates a flat shaded mesh, optional, default true
  102389. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102391. * * 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)
  102392. * * 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)
  102393. * @returns the VertexData of the Polyhedron
  102394. */
  102395. static CreatePolyhedron(options: {
  102396. type?: number;
  102397. size?: number;
  102398. sizeX?: number;
  102399. sizeY?: number;
  102400. sizeZ?: number;
  102401. custom?: any;
  102402. faceUV?: Vector4[];
  102403. faceColors?: Color4[];
  102404. flat?: boolean;
  102405. sideOrientation?: number;
  102406. frontUVs?: Vector4;
  102407. backUVs?: Vector4;
  102408. }): VertexData;
  102409. /**
  102410. * Creates the VertexData for a TorusKnot
  102411. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102412. * * radius the radius of the torus knot, optional, default 2
  102413. * * tube the thickness of the tube, optional, default 0.5
  102414. * * radialSegments the number of sides on each tube segments, optional, default 32
  102415. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102416. * * p the number of windings around the z axis, optional, default 2
  102417. * * q the number of windings around the x axis, optional, default 3
  102418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102419. * * 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)
  102420. * * 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)
  102421. * @returns the VertexData of the Torus Knot
  102422. */
  102423. static CreateTorusKnot(options: {
  102424. radius?: number;
  102425. tube?: number;
  102426. radialSegments?: number;
  102427. tubularSegments?: number;
  102428. p?: number;
  102429. q?: number;
  102430. sideOrientation?: number;
  102431. frontUVs?: Vector4;
  102432. backUVs?: Vector4;
  102433. }): VertexData;
  102434. /**
  102435. * Compute normals for given positions and indices
  102436. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102437. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102438. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102439. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102440. * * facetNormals : optional array of facet normals (vector3)
  102441. * * facetPositions : optional array of facet positions (vector3)
  102442. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102443. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102444. * * bInfo : optional bounding info, required for facetPartitioning computation
  102445. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102446. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102447. * * useRightHandedSystem: optional boolean to for right handed system computation
  102448. * * depthSort : optional boolean to enable the facet depth sort computation
  102449. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102450. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102451. */
  102452. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  102453. facetNormals?: any;
  102454. facetPositions?: any;
  102455. facetPartitioning?: any;
  102456. ratio?: number;
  102457. bInfo?: any;
  102458. bbSize?: Vector3;
  102459. subDiv?: any;
  102460. useRightHandedSystem?: boolean;
  102461. depthSort?: boolean;
  102462. distanceTo?: Vector3;
  102463. depthSortedFacets?: any;
  102464. }): void;
  102465. /** @hidden */
  102466. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  102467. /**
  102468. * Applies VertexData created from the imported parameters to the geometry
  102469. * @param parsedVertexData the parsed data from an imported file
  102470. * @param geometry the geometry to apply the VertexData to
  102471. */
  102472. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  102473. }
  102474. }
  102475. declare module BABYLON {
  102476. /**
  102477. * Defines a target to use with MorphTargetManager
  102478. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102479. */
  102480. export class MorphTarget implements IAnimatable {
  102481. /** defines the name of the target */
  102482. name: string;
  102483. /**
  102484. * Gets or sets the list of animations
  102485. */
  102486. animations: Animation[];
  102487. private _scene;
  102488. private _positions;
  102489. private _normals;
  102490. private _tangents;
  102491. private _uvs;
  102492. private _influence;
  102493. private _uniqueId;
  102494. /**
  102495. * Observable raised when the influence changes
  102496. */
  102497. onInfluenceChanged: Observable<boolean>;
  102498. /** @hidden */
  102499. _onDataLayoutChanged: Observable<void>;
  102500. /**
  102501. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102502. */
  102503. get influence(): number;
  102504. set influence(influence: number);
  102505. /**
  102506. * Gets or sets the id of the morph Target
  102507. */
  102508. id: string;
  102509. private _animationPropertiesOverride;
  102510. /**
  102511. * Gets or sets the animation properties override
  102512. */
  102513. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102514. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102515. /**
  102516. * Creates a new MorphTarget
  102517. * @param name defines the name of the target
  102518. * @param influence defines the influence to use
  102519. * @param scene defines the scene the morphtarget belongs to
  102520. */
  102521. constructor(
  102522. /** defines the name of the target */
  102523. name: string, influence?: number, scene?: Nullable<Scene>);
  102524. /**
  102525. * Gets the unique ID of this manager
  102526. */
  102527. get uniqueId(): number;
  102528. /**
  102529. * Gets a boolean defining if the target contains position data
  102530. */
  102531. get hasPositions(): boolean;
  102532. /**
  102533. * Gets a boolean defining if the target contains normal data
  102534. */
  102535. get hasNormals(): boolean;
  102536. /**
  102537. * Gets a boolean defining if the target contains tangent data
  102538. */
  102539. get hasTangents(): boolean;
  102540. /**
  102541. * Gets a boolean defining if the target contains texture coordinates data
  102542. */
  102543. get hasUVs(): boolean;
  102544. /**
  102545. * Affects position data to this target
  102546. * @param data defines the position data to use
  102547. */
  102548. setPositions(data: Nullable<FloatArray>): void;
  102549. /**
  102550. * Gets the position data stored in this target
  102551. * @returns a FloatArray containing the position data (or null if not present)
  102552. */
  102553. getPositions(): Nullable<FloatArray>;
  102554. /**
  102555. * Affects normal data to this target
  102556. * @param data defines the normal data to use
  102557. */
  102558. setNormals(data: Nullable<FloatArray>): void;
  102559. /**
  102560. * Gets the normal data stored in this target
  102561. * @returns a FloatArray containing the normal data (or null if not present)
  102562. */
  102563. getNormals(): Nullable<FloatArray>;
  102564. /**
  102565. * Affects tangent data to this target
  102566. * @param data defines the tangent data to use
  102567. */
  102568. setTangents(data: Nullable<FloatArray>): void;
  102569. /**
  102570. * Gets the tangent data stored in this target
  102571. * @returns a FloatArray containing the tangent data (or null if not present)
  102572. */
  102573. getTangents(): Nullable<FloatArray>;
  102574. /**
  102575. * Affects texture coordinates data to this target
  102576. * @param data defines the texture coordinates data to use
  102577. */
  102578. setUVs(data: Nullable<FloatArray>): void;
  102579. /**
  102580. * Gets the texture coordinates data stored in this target
  102581. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  102582. */
  102583. getUVs(): Nullable<FloatArray>;
  102584. /**
  102585. * Clone the current target
  102586. * @returns a new MorphTarget
  102587. */
  102588. clone(): MorphTarget;
  102589. /**
  102590. * Serializes the current target into a Serialization object
  102591. * @returns the serialized object
  102592. */
  102593. serialize(): any;
  102594. /**
  102595. * Returns the string "MorphTarget"
  102596. * @returns "MorphTarget"
  102597. */
  102598. getClassName(): string;
  102599. /**
  102600. * Creates a new target from serialized data
  102601. * @param serializationObject defines the serialized data to use
  102602. * @returns a new MorphTarget
  102603. */
  102604. static Parse(serializationObject: any): MorphTarget;
  102605. /**
  102606. * Creates a MorphTarget from mesh data
  102607. * @param mesh defines the source mesh
  102608. * @param name defines the name to use for the new target
  102609. * @param influence defines the influence to attach to the target
  102610. * @returns a new MorphTarget
  102611. */
  102612. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  102613. }
  102614. }
  102615. declare module BABYLON {
  102616. /**
  102617. * This class is used to deform meshes using morphing between different targets
  102618. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102619. */
  102620. export class MorphTargetManager {
  102621. private _targets;
  102622. private _targetInfluenceChangedObservers;
  102623. private _targetDataLayoutChangedObservers;
  102624. private _activeTargets;
  102625. private _scene;
  102626. private _influences;
  102627. private _supportsNormals;
  102628. private _supportsTangents;
  102629. private _supportsUVs;
  102630. private _vertexCount;
  102631. private _uniqueId;
  102632. private _tempInfluences;
  102633. /**
  102634. * Gets or sets a boolean indicating if normals must be morphed
  102635. */
  102636. enableNormalMorphing: boolean;
  102637. /**
  102638. * Gets or sets a boolean indicating if tangents must be morphed
  102639. */
  102640. enableTangentMorphing: boolean;
  102641. /**
  102642. * Gets or sets a boolean indicating if UV must be morphed
  102643. */
  102644. enableUVMorphing: boolean;
  102645. /**
  102646. * Creates a new MorphTargetManager
  102647. * @param scene defines the current scene
  102648. */
  102649. constructor(scene?: Nullable<Scene>);
  102650. /**
  102651. * Gets the unique ID of this manager
  102652. */
  102653. get uniqueId(): number;
  102654. /**
  102655. * Gets the number of vertices handled by this manager
  102656. */
  102657. get vertexCount(): number;
  102658. /**
  102659. * Gets a boolean indicating if this manager supports morphing of normals
  102660. */
  102661. get supportsNormals(): boolean;
  102662. /**
  102663. * Gets a boolean indicating if this manager supports morphing of tangents
  102664. */
  102665. get supportsTangents(): boolean;
  102666. /**
  102667. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  102668. */
  102669. get supportsUVs(): boolean;
  102670. /**
  102671. * Gets the number of targets stored in this manager
  102672. */
  102673. get numTargets(): number;
  102674. /**
  102675. * Gets the number of influencers (ie. the number of targets with influences > 0)
  102676. */
  102677. get numInfluencers(): number;
  102678. /**
  102679. * Gets the list of influences (one per target)
  102680. */
  102681. get influences(): Float32Array;
  102682. /**
  102683. * Gets the active target at specified index. An active target is a target with an influence > 0
  102684. * @param index defines the index to check
  102685. * @returns the requested target
  102686. */
  102687. getActiveTarget(index: number): MorphTarget;
  102688. /**
  102689. * Gets the target at specified index
  102690. * @param index defines the index to check
  102691. * @returns the requested target
  102692. */
  102693. getTarget(index: number): MorphTarget;
  102694. /**
  102695. * Add a new target to this manager
  102696. * @param target defines the target to add
  102697. */
  102698. addTarget(target: MorphTarget): void;
  102699. /**
  102700. * Removes a target from the manager
  102701. * @param target defines the target to remove
  102702. */
  102703. removeTarget(target: MorphTarget): void;
  102704. /**
  102705. * Clone the current manager
  102706. * @returns a new MorphTargetManager
  102707. */
  102708. clone(): MorphTargetManager;
  102709. /**
  102710. * Serializes the current manager into a Serialization object
  102711. * @returns the serialized object
  102712. */
  102713. serialize(): any;
  102714. private _syncActiveTargets;
  102715. /**
  102716. * Syncrhonize the targets with all the meshes using this morph target manager
  102717. */
  102718. synchronize(): void;
  102719. /**
  102720. * Creates a new MorphTargetManager from serialized data
  102721. * @param serializationObject defines the serialized data
  102722. * @param scene defines the hosting scene
  102723. * @returns the new MorphTargetManager
  102724. */
  102725. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  102726. }
  102727. }
  102728. declare module BABYLON {
  102729. /**
  102730. * Class used to represent a specific level of detail of a mesh
  102731. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  102732. */
  102733. export class MeshLODLevel {
  102734. /** Defines the distance where this level should start being displayed */
  102735. distance: number;
  102736. /** Defines the mesh to use to render this level */
  102737. mesh: Nullable<Mesh>;
  102738. /**
  102739. * Creates a new LOD level
  102740. * @param distance defines the distance where this level should star being displayed
  102741. * @param mesh defines the mesh to use to render this level
  102742. */
  102743. constructor(
  102744. /** Defines the distance where this level should start being displayed */
  102745. distance: number,
  102746. /** Defines the mesh to use to render this level */
  102747. mesh: Nullable<Mesh>);
  102748. }
  102749. }
  102750. declare module BABYLON {
  102751. /**
  102752. * Mesh representing the gorund
  102753. */
  102754. export class GroundMesh extends Mesh {
  102755. /** If octree should be generated */
  102756. generateOctree: boolean;
  102757. private _heightQuads;
  102758. /** @hidden */
  102759. _subdivisionsX: number;
  102760. /** @hidden */
  102761. _subdivisionsY: number;
  102762. /** @hidden */
  102763. _width: number;
  102764. /** @hidden */
  102765. _height: number;
  102766. /** @hidden */
  102767. _minX: number;
  102768. /** @hidden */
  102769. _maxX: number;
  102770. /** @hidden */
  102771. _minZ: number;
  102772. /** @hidden */
  102773. _maxZ: number;
  102774. constructor(name: string, scene: Scene);
  102775. /**
  102776. * "GroundMesh"
  102777. * @returns "GroundMesh"
  102778. */
  102779. getClassName(): string;
  102780. /**
  102781. * The minimum of x and y subdivisions
  102782. */
  102783. get subdivisions(): number;
  102784. /**
  102785. * X subdivisions
  102786. */
  102787. get subdivisionsX(): number;
  102788. /**
  102789. * Y subdivisions
  102790. */
  102791. get subdivisionsY(): number;
  102792. /**
  102793. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  102794. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  102795. * @param chunksCount the number of subdivisions for x and y
  102796. * @param octreeBlocksSize (Default: 32)
  102797. */
  102798. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  102799. /**
  102800. * Returns a height (y) value in the Worl system :
  102801. * the ground altitude at the coordinates (x, z) expressed in the World system.
  102802. * @param x x coordinate
  102803. * @param z z coordinate
  102804. * @returns the ground y position if (x, z) are outside the ground surface.
  102805. */
  102806. getHeightAtCoordinates(x: number, z: number): number;
  102807. /**
  102808. * Returns a normalized vector (Vector3) orthogonal to the ground
  102809. * at the ground coordinates (x, z) expressed in the World system.
  102810. * @param x x coordinate
  102811. * @param z z coordinate
  102812. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  102813. */
  102814. getNormalAtCoordinates(x: number, z: number): Vector3;
  102815. /**
  102816. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  102817. * at the ground coordinates (x, z) expressed in the World system.
  102818. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  102819. * @param x x coordinate
  102820. * @param z z coordinate
  102821. * @param ref vector to store the result
  102822. * @returns the GroundMesh.
  102823. */
  102824. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  102825. /**
  102826. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  102827. * if the ground has been updated.
  102828. * This can be used in the render loop.
  102829. * @returns the GroundMesh.
  102830. */
  102831. updateCoordinateHeights(): GroundMesh;
  102832. private _getFacetAt;
  102833. private _initHeightQuads;
  102834. private _computeHeightQuads;
  102835. /**
  102836. * Serializes this ground mesh
  102837. * @param serializationObject object to write serialization to
  102838. */
  102839. serialize(serializationObject: any): void;
  102840. /**
  102841. * Parses a serialized ground mesh
  102842. * @param parsedMesh the serialized mesh
  102843. * @param scene the scene to create the ground mesh in
  102844. * @returns the created ground mesh
  102845. */
  102846. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  102847. }
  102848. }
  102849. declare module BABYLON {
  102850. /**
  102851. * Interface for Physics-Joint data
  102852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  102853. */
  102854. export interface PhysicsJointData {
  102855. /**
  102856. * The main pivot of the joint
  102857. */
  102858. mainPivot?: Vector3;
  102859. /**
  102860. * The connected pivot of the joint
  102861. */
  102862. connectedPivot?: Vector3;
  102863. /**
  102864. * The main axis of the joint
  102865. */
  102866. mainAxis?: Vector3;
  102867. /**
  102868. * The connected axis of the joint
  102869. */
  102870. connectedAxis?: Vector3;
  102871. /**
  102872. * The collision of the joint
  102873. */
  102874. collision?: boolean;
  102875. /**
  102876. * Native Oimo/Cannon/Energy data
  102877. */
  102878. nativeParams?: any;
  102879. }
  102880. /**
  102881. * This is a holder class for the physics joint created by the physics plugin
  102882. * It holds a set of functions to control the underlying joint
  102883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  102884. */
  102885. export class PhysicsJoint {
  102886. /**
  102887. * The type of the physics joint
  102888. */
  102889. type: number;
  102890. /**
  102891. * The data for the physics joint
  102892. */
  102893. jointData: PhysicsJointData;
  102894. private _physicsJoint;
  102895. protected _physicsPlugin: IPhysicsEnginePlugin;
  102896. /**
  102897. * Initializes the physics joint
  102898. * @param type The type of the physics joint
  102899. * @param jointData The data for the physics joint
  102900. */
  102901. constructor(
  102902. /**
  102903. * The type of the physics joint
  102904. */
  102905. type: number,
  102906. /**
  102907. * The data for the physics joint
  102908. */
  102909. jointData: PhysicsJointData);
  102910. /**
  102911. * Gets the physics joint
  102912. */
  102913. get physicsJoint(): any;
  102914. /**
  102915. * Sets the physics joint
  102916. */
  102917. set physicsJoint(newJoint: any);
  102918. /**
  102919. * Sets the physics plugin
  102920. */
  102921. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  102922. /**
  102923. * Execute a function that is physics-plugin specific.
  102924. * @param {Function} func the function that will be executed.
  102925. * It accepts two parameters: the physics world and the physics joint
  102926. */
  102927. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  102928. /**
  102929. * Distance-Joint type
  102930. */
  102931. static DistanceJoint: number;
  102932. /**
  102933. * Hinge-Joint type
  102934. */
  102935. static HingeJoint: number;
  102936. /**
  102937. * Ball-and-Socket joint type
  102938. */
  102939. static BallAndSocketJoint: number;
  102940. /**
  102941. * Wheel-Joint type
  102942. */
  102943. static WheelJoint: number;
  102944. /**
  102945. * Slider-Joint type
  102946. */
  102947. static SliderJoint: number;
  102948. /**
  102949. * Prismatic-Joint type
  102950. */
  102951. static PrismaticJoint: number;
  102952. /**
  102953. * Universal-Joint type
  102954. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  102955. */
  102956. static UniversalJoint: number;
  102957. /**
  102958. * Hinge-Joint 2 type
  102959. */
  102960. static Hinge2Joint: number;
  102961. /**
  102962. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  102963. */
  102964. static PointToPointJoint: number;
  102965. /**
  102966. * Spring-Joint type
  102967. */
  102968. static SpringJoint: number;
  102969. /**
  102970. * Lock-Joint type
  102971. */
  102972. static LockJoint: number;
  102973. }
  102974. /**
  102975. * A class representing a physics distance joint
  102976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  102977. */
  102978. export class DistanceJoint extends PhysicsJoint {
  102979. /**
  102980. *
  102981. * @param jointData The data for the Distance-Joint
  102982. */
  102983. constructor(jointData: DistanceJointData);
  102984. /**
  102985. * Update the predefined distance.
  102986. * @param maxDistance The maximum preferred distance
  102987. * @param minDistance The minimum preferred distance
  102988. */
  102989. updateDistance(maxDistance: number, minDistance?: number): void;
  102990. }
  102991. /**
  102992. * Represents a Motor-Enabled Joint
  102993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  102994. */
  102995. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  102996. /**
  102997. * Initializes the Motor-Enabled Joint
  102998. * @param type The type of the joint
  102999. * @param jointData The physica joint data for the joint
  103000. */
  103001. constructor(type: number, jointData: PhysicsJointData);
  103002. /**
  103003. * Set the motor values.
  103004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103005. * @param force the force to apply
  103006. * @param maxForce max force for this motor.
  103007. */
  103008. setMotor(force?: number, maxForce?: number): void;
  103009. /**
  103010. * Set the motor's limits.
  103011. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103012. * @param upperLimit The upper limit of the motor
  103013. * @param lowerLimit The lower limit of the motor
  103014. */
  103015. setLimit(upperLimit: number, lowerLimit?: number): void;
  103016. }
  103017. /**
  103018. * This class represents a single physics Hinge-Joint
  103019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103020. */
  103021. export class HingeJoint extends MotorEnabledJoint {
  103022. /**
  103023. * Initializes the Hinge-Joint
  103024. * @param jointData The joint data for the Hinge-Joint
  103025. */
  103026. constructor(jointData: PhysicsJointData);
  103027. /**
  103028. * Set the motor values.
  103029. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103030. * @param {number} force the force to apply
  103031. * @param {number} maxForce max force for this motor.
  103032. */
  103033. setMotor(force?: number, maxForce?: number): void;
  103034. /**
  103035. * Set the motor's limits.
  103036. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103037. * @param upperLimit The upper limit of the motor
  103038. * @param lowerLimit The lower limit of the motor
  103039. */
  103040. setLimit(upperLimit: number, lowerLimit?: number): void;
  103041. }
  103042. /**
  103043. * This class represents a dual hinge physics joint (same as wheel joint)
  103044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103045. */
  103046. export class Hinge2Joint extends MotorEnabledJoint {
  103047. /**
  103048. * Initializes the Hinge2-Joint
  103049. * @param jointData The joint data for the Hinge2-Joint
  103050. */
  103051. constructor(jointData: PhysicsJointData);
  103052. /**
  103053. * Set the motor values.
  103054. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103055. * @param {number} targetSpeed the speed the motor is to reach
  103056. * @param {number} maxForce max force for this motor.
  103057. * @param {motorIndex} the motor's index, 0 or 1.
  103058. */
  103059. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103060. /**
  103061. * Set the motor limits.
  103062. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103063. * @param {number} upperLimit the upper limit
  103064. * @param {number} lowerLimit lower limit
  103065. * @param {motorIndex} the motor's index, 0 or 1.
  103066. */
  103067. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103068. }
  103069. /**
  103070. * Interface for a motor enabled joint
  103071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103072. */
  103073. export interface IMotorEnabledJoint {
  103074. /**
  103075. * Physics joint
  103076. */
  103077. physicsJoint: any;
  103078. /**
  103079. * Sets the motor of the motor-enabled joint
  103080. * @param force The force of the motor
  103081. * @param maxForce The maximum force of the motor
  103082. * @param motorIndex The index of the motor
  103083. */
  103084. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103085. /**
  103086. * Sets the limit of the motor
  103087. * @param upperLimit The upper limit of the motor
  103088. * @param lowerLimit The lower limit of the motor
  103089. * @param motorIndex The index of the motor
  103090. */
  103091. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103092. }
  103093. /**
  103094. * Joint data for a Distance-Joint
  103095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103096. */
  103097. export interface DistanceJointData extends PhysicsJointData {
  103098. /**
  103099. * Max distance the 2 joint objects can be apart
  103100. */
  103101. maxDistance: number;
  103102. }
  103103. /**
  103104. * Joint data from a spring joint
  103105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103106. */
  103107. export interface SpringJointData extends PhysicsJointData {
  103108. /**
  103109. * Length of the spring
  103110. */
  103111. length: number;
  103112. /**
  103113. * Stiffness of the spring
  103114. */
  103115. stiffness: number;
  103116. /**
  103117. * Damping of the spring
  103118. */
  103119. damping: number;
  103120. /** this callback will be called when applying the force to the impostors. */
  103121. forceApplicationCallback: () => void;
  103122. }
  103123. }
  103124. declare module BABYLON {
  103125. /**
  103126. * Holds the data for the raycast result
  103127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103128. */
  103129. export class PhysicsRaycastResult {
  103130. private _hasHit;
  103131. private _hitDistance;
  103132. private _hitNormalWorld;
  103133. private _hitPointWorld;
  103134. private _rayFromWorld;
  103135. private _rayToWorld;
  103136. /**
  103137. * Gets if there was a hit
  103138. */
  103139. get hasHit(): boolean;
  103140. /**
  103141. * Gets the distance from the hit
  103142. */
  103143. get hitDistance(): number;
  103144. /**
  103145. * Gets the hit normal/direction in the world
  103146. */
  103147. get hitNormalWorld(): Vector3;
  103148. /**
  103149. * Gets the hit point in the world
  103150. */
  103151. get hitPointWorld(): Vector3;
  103152. /**
  103153. * Gets the ray "start point" of the ray in the world
  103154. */
  103155. get rayFromWorld(): Vector3;
  103156. /**
  103157. * Gets the ray "end point" of the ray in the world
  103158. */
  103159. get rayToWorld(): Vector3;
  103160. /**
  103161. * Sets the hit data (normal & point in world space)
  103162. * @param hitNormalWorld defines the normal in world space
  103163. * @param hitPointWorld defines the point in world space
  103164. */
  103165. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103166. /**
  103167. * Sets the distance from the start point to the hit point
  103168. * @param distance
  103169. */
  103170. setHitDistance(distance: number): void;
  103171. /**
  103172. * Calculates the distance manually
  103173. */
  103174. calculateHitDistance(): void;
  103175. /**
  103176. * Resets all the values to default
  103177. * @param from The from point on world space
  103178. * @param to The to point on world space
  103179. */
  103180. reset(from?: Vector3, to?: Vector3): void;
  103181. }
  103182. /**
  103183. * Interface for the size containing width and height
  103184. */
  103185. interface IXYZ {
  103186. /**
  103187. * X
  103188. */
  103189. x: number;
  103190. /**
  103191. * Y
  103192. */
  103193. y: number;
  103194. /**
  103195. * Z
  103196. */
  103197. z: number;
  103198. }
  103199. }
  103200. declare module BABYLON {
  103201. /**
  103202. * Interface used to describe a physics joint
  103203. */
  103204. export interface PhysicsImpostorJoint {
  103205. /** Defines the main impostor to which the joint is linked */
  103206. mainImpostor: PhysicsImpostor;
  103207. /** Defines the impostor that is connected to the main impostor using this joint */
  103208. connectedImpostor: PhysicsImpostor;
  103209. /** Defines the joint itself */
  103210. joint: PhysicsJoint;
  103211. }
  103212. /** @hidden */
  103213. export interface IPhysicsEnginePlugin {
  103214. world: any;
  103215. name: string;
  103216. setGravity(gravity: Vector3): void;
  103217. setTimeStep(timeStep: number): void;
  103218. getTimeStep(): number;
  103219. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103220. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103221. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103222. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103223. removePhysicsBody(impostor: PhysicsImpostor): void;
  103224. generateJoint(joint: PhysicsImpostorJoint): void;
  103225. removeJoint(joint: PhysicsImpostorJoint): void;
  103226. isSupported(): boolean;
  103227. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103228. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103229. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103230. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103231. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103232. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103233. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103234. getBodyMass(impostor: PhysicsImpostor): number;
  103235. getBodyFriction(impostor: PhysicsImpostor): number;
  103236. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103237. getBodyRestitution(impostor: PhysicsImpostor): number;
  103238. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103239. getBodyPressure?(impostor: PhysicsImpostor): number;
  103240. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103241. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103242. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103243. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103244. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103245. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103246. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103247. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103248. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103249. sleepBody(impostor: PhysicsImpostor): void;
  103250. wakeUpBody(impostor: PhysicsImpostor): void;
  103251. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103252. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103253. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103254. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103255. getRadius(impostor: PhysicsImpostor): number;
  103256. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103257. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103258. dispose(): void;
  103259. }
  103260. /**
  103261. * Interface used to define a physics engine
  103262. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103263. */
  103264. export interface IPhysicsEngine {
  103265. /**
  103266. * Gets the gravity vector used by the simulation
  103267. */
  103268. gravity: Vector3;
  103269. /**
  103270. * Sets the gravity vector used by the simulation
  103271. * @param gravity defines the gravity vector to use
  103272. */
  103273. setGravity(gravity: Vector3): void;
  103274. /**
  103275. * Set the time step of the physics engine.
  103276. * Default is 1/60.
  103277. * To slow it down, enter 1/600 for example.
  103278. * To speed it up, 1/30
  103279. * @param newTimeStep the new timestep to apply to this world.
  103280. */
  103281. setTimeStep(newTimeStep: number): void;
  103282. /**
  103283. * Get the time step of the physics engine.
  103284. * @returns the current time step
  103285. */
  103286. getTimeStep(): number;
  103287. /**
  103288. * Set the sub time step of the physics engine.
  103289. * Default is 0 meaning there is no sub steps
  103290. * To increase physics resolution precision, set a small value (like 1 ms)
  103291. * @param subTimeStep defines the new sub timestep used for physics resolution.
  103292. */
  103293. setSubTimeStep(subTimeStep: number): void;
  103294. /**
  103295. * Get the sub time step of the physics engine.
  103296. * @returns the current sub time step
  103297. */
  103298. getSubTimeStep(): number;
  103299. /**
  103300. * Release all resources
  103301. */
  103302. dispose(): void;
  103303. /**
  103304. * Gets the name of the current physics plugin
  103305. * @returns the name of the plugin
  103306. */
  103307. getPhysicsPluginName(): string;
  103308. /**
  103309. * Adding a new impostor for the impostor tracking.
  103310. * This will be done by the impostor itself.
  103311. * @param impostor the impostor to add
  103312. */
  103313. addImpostor(impostor: PhysicsImpostor): void;
  103314. /**
  103315. * Remove an impostor from the engine.
  103316. * This impostor and its mesh will not longer be updated by the physics engine.
  103317. * @param impostor the impostor to remove
  103318. */
  103319. removeImpostor(impostor: PhysicsImpostor): void;
  103320. /**
  103321. * Add a joint to the physics engine
  103322. * @param mainImpostor defines the main impostor to which the joint is added.
  103323. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103324. * @param joint defines the joint that will connect both impostors.
  103325. */
  103326. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103327. /**
  103328. * Removes a joint from the simulation
  103329. * @param mainImpostor defines the impostor used with the joint
  103330. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103331. * @param joint defines the joint to remove
  103332. */
  103333. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103334. /**
  103335. * Gets the current plugin used to run the simulation
  103336. * @returns current plugin
  103337. */
  103338. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103339. /**
  103340. * Gets the list of physic impostors
  103341. * @returns an array of PhysicsImpostor
  103342. */
  103343. getImpostors(): Array<PhysicsImpostor>;
  103344. /**
  103345. * Gets the impostor for a physics enabled object
  103346. * @param object defines the object impersonated by the impostor
  103347. * @returns the PhysicsImpostor or null if not found
  103348. */
  103349. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103350. /**
  103351. * Gets the impostor for a physics body object
  103352. * @param body defines physics body used by the impostor
  103353. * @returns the PhysicsImpostor or null if not found
  103354. */
  103355. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103356. /**
  103357. * Does a raycast in the physics world
  103358. * @param from when should the ray start?
  103359. * @param to when should the ray end?
  103360. * @returns PhysicsRaycastResult
  103361. */
  103362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103363. /**
  103364. * Called by the scene. No need to call it.
  103365. * @param delta defines the timespam between frames
  103366. */
  103367. _step(delta: number): void;
  103368. }
  103369. }
  103370. declare module BABYLON {
  103371. /**
  103372. * The interface for the physics imposter parameters
  103373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103374. */
  103375. export interface PhysicsImpostorParameters {
  103376. /**
  103377. * The mass of the physics imposter
  103378. */
  103379. mass: number;
  103380. /**
  103381. * The friction of the physics imposter
  103382. */
  103383. friction?: number;
  103384. /**
  103385. * The coefficient of restitution of the physics imposter
  103386. */
  103387. restitution?: number;
  103388. /**
  103389. * The native options of the physics imposter
  103390. */
  103391. nativeOptions?: any;
  103392. /**
  103393. * Specifies if the parent should be ignored
  103394. */
  103395. ignoreParent?: boolean;
  103396. /**
  103397. * Specifies if bi-directional transformations should be disabled
  103398. */
  103399. disableBidirectionalTransformation?: boolean;
  103400. /**
  103401. * The pressure inside the physics imposter, soft object only
  103402. */
  103403. pressure?: number;
  103404. /**
  103405. * The stiffness the physics imposter, soft object only
  103406. */
  103407. stiffness?: number;
  103408. /**
  103409. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  103410. */
  103411. velocityIterations?: number;
  103412. /**
  103413. * The number of iterations used in maintaining consistent vertex positions, soft object only
  103414. */
  103415. positionIterations?: number;
  103416. /**
  103417. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  103418. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  103419. * Add to fix multiple points
  103420. */
  103421. fixedPoints?: number;
  103422. /**
  103423. * The collision margin around a soft object
  103424. */
  103425. margin?: number;
  103426. /**
  103427. * The collision margin around a soft object
  103428. */
  103429. damping?: number;
  103430. /**
  103431. * The path for a rope based on an extrusion
  103432. */
  103433. path?: any;
  103434. /**
  103435. * The shape of an extrusion used for a rope based on an extrusion
  103436. */
  103437. shape?: any;
  103438. }
  103439. /**
  103440. * Interface for a physics-enabled object
  103441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103442. */
  103443. export interface IPhysicsEnabledObject {
  103444. /**
  103445. * The position of the physics-enabled object
  103446. */
  103447. position: Vector3;
  103448. /**
  103449. * The rotation of the physics-enabled object
  103450. */
  103451. rotationQuaternion: Nullable<Quaternion>;
  103452. /**
  103453. * The scale of the physics-enabled object
  103454. */
  103455. scaling: Vector3;
  103456. /**
  103457. * The rotation of the physics-enabled object
  103458. */
  103459. rotation?: Vector3;
  103460. /**
  103461. * The parent of the physics-enabled object
  103462. */
  103463. parent?: any;
  103464. /**
  103465. * The bounding info of the physics-enabled object
  103466. * @returns The bounding info of the physics-enabled object
  103467. */
  103468. getBoundingInfo(): BoundingInfo;
  103469. /**
  103470. * Computes the world matrix
  103471. * @param force Specifies if the world matrix should be computed by force
  103472. * @returns A world matrix
  103473. */
  103474. computeWorldMatrix(force: boolean): Matrix;
  103475. /**
  103476. * Gets the world matrix
  103477. * @returns A world matrix
  103478. */
  103479. getWorldMatrix?(): Matrix;
  103480. /**
  103481. * Gets the child meshes
  103482. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  103483. * @returns An array of abstract meshes
  103484. */
  103485. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  103486. /**
  103487. * Gets the vertex data
  103488. * @param kind The type of vertex data
  103489. * @returns A nullable array of numbers, or a float32 array
  103490. */
  103491. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  103492. /**
  103493. * Gets the indices from the mesh
  103494. * @returns A nullable array of index arrays
  103495. */
  103496. getIndices?(): Nullable<IndicesArray>;
  103497. /**
  103498. * Gets the scene from the mesh
  103499. * @returns the indices array or null
  103500. */
  103501. getScene?(): Scene;
  103502. /**
  103503. * Gets the absolute position from the mesh
  103504. * @returns the absolute position
  103505. */
  103506. getAbsolutePosition(): Vector3;
  103507. /**
  103508. * Gets the absolute pivot point from the mesh
  103509. * @returns the absolute pivot point
  103510. */
  103511. getAbsolutePivotPoint(): Vector3;
  103512. /**
  103513. * Rotates the mesh
  103514. * @param axis The axis of rotation
  103515. * @param amount The amount of rotation
  103516. * @param space The space of the rotation
  103517. * @returns The rotation transform node
  103518. */
  103519. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  103520. /**
  103521. * Translates the mesh
  103522. * @param axis The axis of translation
  103523. * @param distance The distance of translation
  103524. * @param space The space of the translation
  103525. * @returns The transform node
  103526. */
  103527. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  103528. /**
  103529. * Sets the absolute position of the mesh
  103530. * @param absolutePosition The absolute position of the mesh
  103531. * @returns The transform node
  103532. */
  103533. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  103534. /**
  103535. * Gets the class name of the mesh
  103536. * @returns The class name
  103537. */
  103538. getClassName(): string;
  103539. }
  103540. /**
  103541. * Represents a physics imposter
  103542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103543. */
  103544. export class PhysicsImpostor {
  103545. /**
  103546. * The physics-enabled object used as the physics imposter
  103547. */
  103548. object: IPhysicsEnabledObject;
  103549. /**
  103550. * The type of the physics imposter
  103551. */
  103552. type: number;
  103553. private _options;
  103554. private _scene?;
  103555. /**
  103556. * The default object size of the imposter
  103557. */
  103558. static DEFAULT_OBJECT_SIZE: Vector3;
  103559. /**
  103560. * The identity quaternion of the imposter
  103561. */
  103562. static IDENTITY_QUATERNION: Quaternion;
  103563. /** @hidden */
  103564. _pluginData: any;
  103565. private _physicsEngine;
  103566. private _physicsBody;
  103567. private _bodyUpdateRequired;
  103568. private _onBeforePhysicsStepCallbacks;
  103569. private _onAfterPhysicsStepCallbacks;
  103570. /** @hidden */
  103571. _onPhysicsCollideCallbacks: Array<{
  103572. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  103573. otherImpostors: Array<PhysicsImpostor>;
  103574. }>;
  103575. private _deltaPosition;
  103576. private _deltaRotation;
  103577. private _deltaRotationConjugated;
  103578. /** @hidden */
  103579. _isFromLine: boolean;
  103580. private _parent;
  103581. private _isDisposed;
  103582. private static _tmpVecs;
  103583. private static _tmpQuat;
  103584. /**
  103585. * Specifies if the physics imposter is disposed
  103586. */
  103587. get isDisposed(): boolean;
  103588. /**
  103589. * Gets the mass of the physics imposter
  103590. */
  103591. get mass(): number;
  103592. set mass(value: number);
  103593. /**
  103594. * Gets the coefficient of friction
  103595. */
  103596. get friction(): number;
  103597. /**
  103598. * Sets the coefficient of friction
  103599. */
  103600. set friction(value: number);
  103601. /**
  103602. * Gets the coefficient of restitution
  103603. */
  103604. get restitution(): number;
  103605. /**
  103606. * Sets the coefficient of restitution
  103607. */
  103608. set restitution(value: number);
  103609. /**
  103610. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  103611. */
  103612. get pressure(): number;
  103613. /**
  103614. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  103615. */
  103616. set pressure(value: number);
  103617. /**
  103618. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103619. */
  103620. get stiffness(): number;
  103621. /**
  103622. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103623. */
  103624. set stiffness(value: number);
  103625. /**
  103626. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103627. */
  103628. get velocityIterations(): number;
  103629. /**
  103630. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103631. */
  103632. set velocityIterations(value: number);
  103633. /**
  103634. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103635. */
  103636. get positionIterations(): number;
  103637. /**
  103638. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103639. */
  103640. set positionIterations(value: number);
  103641. /**
  103642. * The unique id of the physics imposter
  103643. * set by the physics engine when adding this impostor to the array
  103644. */
  103645. uniqueId: number;
  103646. /**
  103647. * @hidden
  103648. */
  103649. soft: boolean;
  103650. /**
  103651. * @hidden
  103652. */
  103653. segments: number;
  103654. private _joints;
  103655. /**
  103656. * Initializes the physics imposter
  103657. * @param object The physics-enabled object used as the physics imposter
  103658. * @param type The type of the physics imposter
  103659. * @param _options The options for the physics imposter
  103660. * @param _scene The Babylon scene
  103661. */
  103662. constructor(
  103663. /**
  103664. * The physics-enabled object used as the physics imposter
  103665. */
  103666. object: IPhysicsEnabledObject,
  103667. /**
  103668. * The type of the physics imposter
  103669. */
  103670. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  103671. /**
  103672. * This function will completly initialize this impostor.
  103673. * It will create a new body - but only if this mesh has no parent.
  103674. * If it has, this impostor will not be used other than to define the impostor
  103675. * of the child mesh.
  103676. * @hidden
  103677. */
  103678. _init(): void;
  103679. private _getPhysicsParent;
  103680. /**
  103681. * Should a new body be generated.
  103682. * @returns boolean specifying if body initialization is required
  103683. */
  103684. isBodyInitRequired(): boolean;
  103685. /**
  103686. * Sets the updated scaling
  103687. * @param updated Specifies if the scaling is updated
  103688. */
  103689. setScalingUpdated(): void;
  103690. /**
  103691. * Force a regeneration of this or the parent's impostor's body.
  103692. * Use under cautious - This will remove all joints already implemented.
  103693. */
  103694. forceUpdate(): void;
  103695. /**
  103696. * Gets the body that holds this impostor. Either its own, or its parent.
  103697. */
  103698. get physicsBody(): any;
  103699. /**
  103700. * Get the parent of the physics imposter
  103701. * @returns Physics imposter or null
  103702. */
  103703. get parent(): Nullable<PhysicsImpostor>;
  103704. /**
  103705. * Sets the parent of the physics imposter
  103706. */
  103707. set parent(value: Nullable<PhysicsImpostor>);
  103708. /**
  103709. * Set the physics body. Used mainly by the physics engine/plugin
  103710. */
  103711. set physicsBody(physicsBody: any);
  103712. /**
  103713. * Resets the update flags
  103714. */
  103715. resetUpdateFlags(): void;
  103716. /**
  103717. * Gets the object extend size
  103718. * @returns the object extend size
  103719. */
  103720. getObjectExtendSize(): Vector3;
  103721. /**
  103722. * Gets the object center
  103723. * @returns The object center
  103724. */
  103725. getObjectCenter(): Vector3;
  103726. /**
  103727. * Get a specific parameter from the options parameters
  103728. * @param paramName The object parameter name
  103729. * @returns The object parameter
  103730. */
  103731. getParam(paramName: string): any;
  103732. /**
  103733. * Sets a specific parameter in the options given to the physics plugin
  103734. * @param paramName The parameter name
  103735. * @param value The value of the parameter
  103736. */
  103737. setParam(paramName: string, value: number): void;
  103738. /**
  103739. * Specifically change the body's mass option. Won't recreate the physics body object
  103740. * @param mass The mass of the physics imposter
  103741. */
  103742. setMass(mass: number): void;
  103743. /**
  103744. * Gets the linear velocity
  103745. * @returns linear velocity or null
  103746. */
  103747. getLinearVelocity(): Nullable<Vector3>;
  103748. /**
  103749. * Sets the linear velocity
  103750. * @param velocity linear velocity or null
  103751. */
  103752. setLinearVelocity(velocity: Nullable<Vector3>): void;
  103753. /**
  103754. * Gets the angular velocity
  103755. * @returns angular velocity or null
  103756. */
  103757. getAngularVelocity(): Nullable<Vector3>;
  103758. /**
  103759. * Sets the angular velocity
  103760. * @param velocity The velocity or null
  103761. */
  103762. setAngularVelocity(velocity: Nullable<Vector3>): void;
  103763. /**
  103764. * Execute a function with the physics plugin native code
  103765. * Provide a function the will have two variables - the world object and the physics body object
  103766. * @param func The function to execute with the physics plugin native code
  103767. */
  103768. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  103769. /**
  103770. * Register a function that will be executed before the physics world is stepping forward
  103771. * @param func The function to execute before the physics world is stepped forward
  103772. */
  103773. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103774. /**
  103775. * Unregister a function that will be executed before the physics world is stepping forward
  103776. * @param func The function to execute before the physics world is stepped forward
  103777. */
  103778. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103779. /**
  103780. * Register a function that will be executed after the physics step
  103781. * @param func The function to execute after physics step
  103782. */
  103783. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103784. /**
  103785. * Unregisters a function that will be executed after the physics step
  103786. * @param func The function to execute after physics step
  103787. */
  103788. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103789. /**
  103790. * register a function that will be executed when this impostor collides against a different body
  103791. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  103792. * @param func Callback that is executed on collision
  103793. */
  103794. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  103795. /**
  103796. * Unregisters the physics imposter on contact
  103797. * @param collideAgainst The physics object to collide against
  103798. * @param func Callback to execute on collision
  103799. */
  103800. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  103801. private _tmpQuat;
  103802. private _tmpQuat2;
  103803. /**
  103804. * Get the parent rotation
  103805. * @returns The parent rotation
  103806. */
  103807. getParentsRotation(): Quaternion;
  103808. /**
  103809. * this function is executed by the physics engine.
  103810. */
  103811. beforeStep: () => void;
  103812. /**
  103813. * this function is executed by the physics engine
  103814. */
  103815. afterStep: () => void;
  103816. /**
  103817. * Legacy collision detection event support
  103818. */
  103819. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  103820. /**
  103821. * event and body object due to cannon's event-based architecture.
  103822. */
  103823. onCollide: (e: {
  103824. body: any;
  103825. }) => void;
  103826. /**
  103827. * Apply a force
  103828. * @param force The force to apply
  103829. * @param contactPoint The contact point for the force
  103830. * @returns The physics imposter
  103831. */
  103832. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  103833. /**
  103834. * Apply an impulse
  103835. * @param force The impulse force
  103836. * @param contactPoint The contact point for the impulse force
  103837. * @returns The physics imposter
  103838. */
  103839. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  103840. /**
  103841. * A help function to create a joint
  103842. * @param otherImpostor A physics imposter used to create a joint
  103843. * @param jointType The type of joint
  103844. * @param jointData The data for the joint
  103845. * @returns The physics imposter
  103846. */
  103847. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  103848. /**
  103849. * Add a joint to this impostor with a different impostor
  103850. * @param otherImpostor A physics imposter used to add a joint
  103851. * @param joint The joint to add
  103852. * @returns The physics imposter
  103853. */
  103854. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  103855. /**
  103856. * Add an anchor to a cloth impostor
  103857. * @param otherImpostor rigid impostor to anchor to
  103858. * @param width ratio across width from 0 to 1
  103859. * @param height ratio up height from 0 to 1
  103860. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  103861. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  103862. * @returns impostor the soft imposter
  103863. */
  103864. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  103865. /**
  103866. * Add a hook to a rope impostor
  103867. * @param otherImpostor rigid impostor to anchor to
  103868. * @param length ratio across rope from 0 to 1
  103869. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  103870. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  103871. * @returns impostor the rope imposter
  103872. */
  103873. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  103874. /**
  103875. * Will keep this body still, in a sleep mode.
  103876. * @returns the physics imposter
  103877. */
  103878. sleep(): PhysicsImpostor;
  103879. /**
  103880. * Wake the body up.
  103881. * @returns The physics imposter
  103882. */
  103883. wakeUp(): PhysicsImpostor;
  103884. /**
  103885. * Clones the physics imposter
  103886. * @param newObject The physics imposter clones to this physics-enabled object
  103887. * @returns A nullable physics imposter
  103888. */
  103889. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103890. /**
  103891. * Disposes the physics imposter
  103892. */
  103893. dispose(): void;
  103894. /**
  103895. * Sets the delta position
  103896. * @param position The delta position amount
  103897. */
  103898. setDeltaPosition(position: Vector3): void;
  103899. /**
  103900. * Sets the delta rotation
  103901. * @param rotation The delta rotation amount
  103902. */
  103903. setDeltaRotation(rotation: Quaternion): void;
  103904. /**
  103905. * Gets the box size of the physics imposter and stores the result in the input parameter
  103906. * @param result Stores the box size
  103907. * @returns The physics imposter
  103908. */
  103909. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  103910. /**
  103911. * Gets the radius of the physics imposter
  103912. * @returns Radius of the physics imposter
  103913. */
  103914. getRadius(): number;
  103915. /**
  103916. * Sync a bone with this impostor
  103917. * @param bone The bone to sync to the impostor.
  103918. * @param boneMesh The mesh that the bone is influencing.
  103919. * @param jointPivot The pivot of the joint / bone in local space.
  103920. * @param distToJoint Optional distance from the impostor to the joint.
  103921. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  103922. */
  103923. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  103924. /**
  103925. * Sync impostor to a bone
  103926. * @param bone The bone that the impostor will be synced to.
  103927. * @param boneMesh The mesh that the bone is influencing.
  103928. * @param jointPivot The pivot of the joint / bone in local space.
  103929. * @param distToJoint Optional distance from the impostor to the joint.
  103930. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  103931. * @param boneAxis Optional vector3 axis the bone is aligned with
  103932. */
  103933. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  103934. /**
  103935. * No-Imposter type
  103936. */
  103937. static NoImpostor: number;
  103938. /**
  103939. * Sphere-Imposter type
  103940. */
  103941. static SphereImpostor: number;
  103942. /**
  103943. * Box-Imposter type
  103944. */
  103945. static BoxImpostor: number;
  103946. /**
  103947. * Plane-Imposter type
  103948. */
  103949. static PlaneImpostor: number;
  103950. /**
  103951. * Mesh-imposter type
  103952. */
  103953. static MeshImpostor: number;
  103954. /**
  103955. * Capsule-Impostor type (Ammo.js plugin only)
  103956. */
  103957. static CapsuleImpostor: number;
  103958. /**
  103959. * Cylinder-Imposter type
  103960. */
  103961. static CylinderImpostor: number;
  103962. /**
  103963. * Particle-Imposter type
  103964. */
  103965. static ParticleImpostor: number;
  103966. /**
  103967. * Heightmap-Imposter type
  103968. */
  103969. static HeightmapImpostor: number;
  103970. /**
  103971. * ConvexHull-Impostor type (Ammo.js plugin only)
  103972. */
  103973. static ConvexHullImpostor: number;
  103974. /**
  103975. * Custom-Imposter type (Ammo.js plugin only)
  103976. */
  103977. static CustomImpostor: number;
  103978. /**
  103979. * Rope-Imposter type
  103980. */
  103981. static RopeImpostor: number;
  103982. /**
  103983. * Cloth-Imposter type
  103984. */
  103985. static ClothImpostor: number;
  103986. /**
  103987. * Softbody-Imposter type
  103988. */
  103989. static SoftbodyImpostor: number;
  103990. }
  103991. }
  103992. declare module BABYLON {
  103993. /**
  103994. * @hidden
  103995. **/
  103996. export class _CreationDataStorage {
  103997. closePath?: boolean;
  103998. closeArray?: boolean;
  103999. idx: number[];
  104000. dashSize: number;
  104001. gapSize: number;
  104002. path3D: Path3D;
  104003. pathArray: Vector3[][];
  104004. arc: number;
  104005. radius: number;
  104006. cap: number;
  104007. tessellation: number;
  104008. }
  104009. /**
  104010. * @hidden
  104011. **/
  104012. class _InstanceDataStorage {
  104013. visibleInstances: any;
  104014. batchCache: _InstancesBatch;
  104015. instancesBufferSize: number;
  104016. instancesBuffer: Nullable<Buffer>;
  104017. instancesData: Float32Array;
  104018. overridenInstanceCount: number;
  104019. isFrozen: boolean;
  104020. previousBatch: Nullable<_InstancesBatch>;
  104021. hardwareInstancedRendering: boolean;
  104022. sideOrientation: number;
  104023. manualUpdate: boolean;
  104024. }
  104025. /**
  104026. * @hidden
  104027. **/
  104028. export class _InstancesBatch {
  104029. mustReturn: boolean;
  104030. visibleInstances: Nullable<InstancedMesh[]>[];
  104031. renderSelf: boolean[];
  104032. hardwareInstancedRendering: boolean[];
  104033. }
  104034. /**
  104035. * Class used to represent renderable models
  104036. */
  104037. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104038. /**
  104039. * Mesh side orientation : usually the external or front surface
  104040. */
  104041. static readonly FRONTSIDE: number;
  104042. /**
  104043. * Mesh side orientation : usually the internal or back surface
  104044. */
  104045. static readonly BACKSIDE: number;
  104046. /**
  104047. * Mesh side orientation : both internal and external or front and back surfaces
  104048. */
  104049. static readonly DOUBLESIDE: number;
  104050. /**
  104051. * Mesh side orientation : by default, `FRONTSIDE`
  104052. */
  104053. static readonly DEFAULTSIDE: number;
  104054. /**
  104055. * Mesh cap setting : no cap
  104056. */
  104057. static readonly NO_CAP: number;
  104058. /**
  104059. * Mesh cap setting : one cap at the beginning of the mesh
  104060. */
  104061. static readonly CAP_START: number;
  104062. /**
  104063. * Mesh cap setting : one cap at the end of the mesh
  104064. */
  104065. static readonly CAP_END: number;
  104066. /**
  104067. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104068. */
  104069. static readonly CAP_ALL: number;
  104070. /**
  104071. * Mesh pattern setting : no flip or rotate
  104072. */
  104073. static readonly NO_FLIP: number;
  104074. /**
  104075. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104076. */
  104077. static readonly FLIP_TILE: number;
  104078. /**
  104079. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104080. */
  104081. static readonly ROTATE_TILE: number;
  104082. /**
  104083. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104084. */
  104085. static readonly FLIP_ROW: number;
  104086. /**
  104087. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104088. */
  104089. static readonly ROTATE_ROW: number;
  104090. /**
  104091. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104092. */
  104093. static readonly FLIP_N_ROTATE_TILE: number;
  104094. /**
  104095. * Mesh pattern setting : rotate pattern and rotate
  104096. */
  104097. static readonly FLIP_N_ROTATE_ROW: number;
  104098. /**
  104099. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104100. */
  104101. static readonly CENTER: number;
  104102. /**
  104103. * Mesh tile positioning : part tiles on left
  104104. */
  104105. static readonly LEFT: number;
  104106. /**
  104107. * Mesh tile positioning : part tiles on right
  104108. */
  104109. static readonly RIGHT: number;
  104110. /**
  104111. * Mesh tile positioning : part tiles on top
  104112. */
  104113. static readonly TOP: number;
  104114. /**
  104115. * Mesh tile positioning : part tiles on bottom
  104116. */
  104117. static readonly BOTTOM: number;
  104118. /**
  104119. * Gets the default side orientation.
  104120. * @param orientation the orientation to value to attempt to get
  104121. * @returns the default orientation
  104122. * @hidden
  104123. */
  104124. static _GetDefaultSideOrientation(orientation?: number): number;
  104125. private _internalMeshDataInfo;
  104126. /**
  104127. * An event triggered before rendering the mesh
  104128. */
  104129. get onBeforeRenderObservable(): Observable<Mesh>;
  104130. /**
  104131. * An event triggered before binding the mesh
  104132. */
  104133. get onBeforeBindObservable(): Observable<Mesh>;
  104134. /**
  104135. * An event triggered after rendering the mesh
  104136. */
  104137. get onAfterRenderObservable(): Observable<Mesh>;
  104138. /**
  104139. * An event triggered before drawing the mesh
  104140. */
  104141. get onBeforeDrawObservable(): Observable<Mesh>;
  104142. private _onBeforeDrawObserver;
  104143. /**
  104144. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104145. */
  104146. set onBeforeDraw(callback: () => void);
  104147. get hasInstances(): boolean;
  104148. /**
  104149. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104150. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104151. */
  104152. delayLoadState: number;
  104153. /**
  104154. * Gets the list of instances created from this mesh
  104155. * it is not supposed to be modified manually.
  104156. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104158. */
  104159. instances: InstancedMesh[];
  104160. /**
  104161. * Gets the file containing delay loading data for this mesh
  104162. */
  104163. delayLoadingFile: string;
  104164. /** @hidden */
  104165. _binaryInfo: any;
  104166. /**
  104167. * User defined function used to change how LOD level selection is done
  104168. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104169. */
  104170. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104171. /**
  104172. * Gets or sets the morph target manager
  104173. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104174. */
  104175. get morphTargetManager(): Nullable<MorphTargetManager>;
  104176. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104177. /** @hidden */
  104178. _creationDataStorage: Nullable<_CreationDataStorage>;
  104179. /** @hidden */
  104180. _geometry: Nullable<Geometry>;
  104181. /** @hidden */
  104182. _delayInfo: Array<string>;
  104183. /** @hidden */
  104184. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104185. /** @hidden */
  104186. _instanceDataStorage: _InstanceDataStorage;
  104187. private _effectiveMaterial;
  104188. /** @hidden */
  104189. _shouldGenerateFlatShading: boolean;
  104190. /** @hidden */
  104191. _originalBuilderSideOrientation: number;
  104192. /**
  104193. * Use this property to change the original side orientation defined at construction time
  104194. */
  104195. overrideMaterialSideOrientation: Nullable<number>;
  104196. /**
  104197. * Gets the source mesh (the one used to clone this one from)
  104198. */
  104199. get source(): Nullable<Mesh>;
  104200. /**
  104201. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104202. */
  104203. get isUnIndexed(): boolean;
  104204. set isUnIndexed(value: boolean);
  104205. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104206. get worldMatrixInstancedBuffer(): Float32Array;
  104207. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104208. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104209. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104210. /**
  104211. * @constructor
  104212. * @param name The value used by scene.getMeshByName() to do a lookup.
  104213. * @param scene The scene to add this mesh to.
  104214. * @param parent The parent of this mesh, if it has one
  104215. * @param source An optional Mesh from which geometry is shared, cloned.
  104216. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104217. * When false, achieved by calling a clone(), also passing False.
  104218. * This will make creation of children, recursive.
  104219. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104220. */
  104221. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104222. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104223. doNotInstantiate: boolean;
  104224. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104225. /**
  104226. * Gets the class name
  104227. * @returns the string "Mesh".
  104228. */
  104229. getClassName(): string;
  104230. /** @hidden */
  104231. get _isMesh(): boolean;
  104232. /**
  104233. * Returns a description of this mesh
  104234. * @param fullDetails define if full details about this mesh must be used
  104235. * @returns a descriptive string representing this mesh
  104236. */
  104237. toString(fullDetails?: boolean): string;
  104238. /** @hidden */
  104239. _unBindEffect(): void;
  104240. /**
  104241. * Gets a boolean indicating if this mesh has LOD
  104242. */
  104243. get hasLODLevels(): boolean;
  104244. /**
  104245. * Gets the list of MeshLODLevel associated with the current mesh
  104246. * @returns an array of MeshLODLevel
  104247. */
  104248. getLODLevels(): MeshLODLevel[];
  104249. private _sortLODLevels;
  104250. /**
  104251. * Add a mesh as LOD level triggered at the given distance.
  104252. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104253. * @param distance The distance from the center of the object to show this level
  104254. * @param mesh The mesh to be added as LOD level (can be null)
  104255. * @return This mesh (for chaining)
  104256. */
  104257. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104258. /**
  104259. * Returns the LOD level mesh at the passed distance or null if not found.
  104260. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104261. * @param distance The distance from the center of the object to show this level
  104262. * @returns a Mesh or `null`
  104263. */
  104264. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  104265. /**
  104266. * Remove a mesh from the LOD array
  104267. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104268. * @param mesh defines the mesh to be removed
  104269. * @return This mesh (for chaining)
  104270. */
  104271. removeLODLevel(mesh: Mesh): Mesh;
  104272. /**
  104273. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  104274. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104275. * @param camera defines the camera to use to compute distance
  104276. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  104277. * @return This mesh (for chaining)
  104278. */
  104279. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  104280. /**
  104281. * Gets the mesh internal Geometry object
  104282. */
  104283. get geometry(): Nullable<Geometry>;
  104284. /**
  104285. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  104286. * @returns the total number of vertices
  104287. */
  104288. getTotalVertices(): number;
  104289. /**
  104290. * Returns the content of an associated vertex buffer
  104291. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104292. * - VertexBuffer.PositionKind
  104293. * - VertexBuffer.UVKind
  104294. * - VertexBuffer.UV2Kind
  104295. * - VertexBuffer.UV3Kind
  104296. * - VertexBuffer.UV4Kind
  104297. * - VertexBuffer.UV5Kind
  104298. * - VertexBuffer.UV6Kind
  104299. * - VertexBuffer.ColorKind
  104300. * - VertexBuffer.MatricesIndicesKind
  104301. * - VertexBuffer.MatricesIndicesExtraKind
  104302. * - VertexBuffer.MatricesWeightsKind
  104303. * - VertexBuffer.MatricesWeightsExtraKind
  104304. * @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
  104305. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  104306. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  104307. */
  104308. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104309. /**
  104310. * Returns the mesh VertexBuffer object from the requested `kind`
  104311. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104312. * - VertexBuffer.PositionKind
  104313. * - VertexBuffer.NormalKind
  104314. * - VertexBuffer.UVKind
  104315. * - VertexBuffer.UV2Kind
  104316. * - VertexBuffer.UV3Kind
  104317. * - VertexBuffer.UV4Kind
  104318. * - VertexBuffer.UV5Kind
  104319. * - VertexBuffer.UV6Kind
  104320. * - VertexBuffer.ColorKind
  104321. * - VertexBuffer.MatricesIndicesKind
  104322. * - VertexBuffer.MatricesIndicesExtraKind
  104323. * - VertexBuffer.MatricesWeightsKind
  104324. * - VertexBuffer.MatricesWeightsExtraKind
  104325. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  104326. */
  104327. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104328. /**
  104329. * Tests if a specific vertex buffer is associated with this mesh
  104330. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104331. * - VertexBuffer.PositionKind
  104332. * - VertexBuffer.NormalKind
  104333. * - VertexBuffer.UVKind
  104334. * - VertexBuffer.UV2Kind
  104335. * - VertexBuffer.UV3Kind
  104336. * - VertexBuffer.UV4Kind
  104337. * - VertexBuffer.UV5Kind
  104338. * - VertexBuffer.UV6Kind
  104339. * - VertexBuffer.ColorKind
  104340. * - VertexBuffer.MatricesIndicesKind
  104341. * - VertexBuffer.MatricesIndicesExtraKind
  104342. * - VertexBuffer.MatricesWeightsKind
  104343. * - VertexBuffer.MatricesWeightsExtraKind
  104344. * @returns a boolean
  104345. */
  104346. isVerticesDataPresent(kind: string): boolean;
  104347. /**
  104348. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  104349. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104350. * - VertexBuffer.PositionKind
  104351. * - VertexBuffer.UVKind
  104352. * - VertexBuffer.UV2Kind
  104353. * - VertexBuffer.UV3Kind
  104354. * - VertexBuffer.UV4Kind
  104355. * - VertexBuffer.UV5Kind
  104356. * - VertexBuffer.UV6Kind
  104357. * - VertexBuffer.ColorKind
  104358. * - VertexBuffer.MatricesIndicesKind
  104359. * - VertexBuffer.MatricesIndicesExtraKind
  104360. * - VertexBuffer.MatricesWeightsKind
  104361. * - VertexBuffer.MatricesWeightsExtraKind
  104362. * @returns a boolean
  104363. */
  104364. isVertexBufferUpdatable(kind: string): boolean;
  104365. /**
  104366. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  104367. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104368. * - VertexBuffer.PositionKind
  104369. * - VertexBuffer.NormalKind
  104370. * - VertexBuffer.UVKind
  104371. * - VertexBuffer.UV2Kind
  104372. * - VertexBuffer.UV3Kind
  104373. * - VertexBuffer.UV4Kind
  104374. * - VertexBuffer.UV5Kind
  104375. * - VertexBuffer.UV6Kind
  104376. * - VertexBuffer.ColorKind
  104377. * - VertexBuffer.MatricesIndicesKind
  104378. * - VertexBuffer.MatricesIndicesExtraKind
  104379. * - VertexBuffer.MatricesWeightsKind
  104380. * - VertexBuffer.MatricesWeightsExtraKind
  104381. * @returns an array of strings
  104382. */
  104383. getVerticesDataKinds(): string[];
  104384. /**
  104385. * Returns a positive integer : the total number of indices in this mesh geometry.
  104386. * @returns the numner of indices or zero if the mesh has no geometry.
  104387. */
  104388. getTotalIndices(): number;
  104389. /**
  104390. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104391. * @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.
  104392. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104393. * @returns the indices array or an empty array if the mesh has no geometry
  104394. */
  104395. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104396. get isBlocked(): boolean;
  104397. /**
  104398. * Determine if the current mesh is ready to be rendered
  104399. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104400. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  104401. * @returns true if all associated assets are ready (material, textures, shaders)
  104402. */
  104403. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  104404. /**
  104405. * 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.
  104406. */
  104407. get areNormalsFrozen(): boolean;
  104408. /**
  104409. * 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.
  104410. * @returns the current mesh
  104411. */
  104412. freezeNormals(): Mesh;
  104413. /**
  104414. * 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
  104415. * @returns the current mesh
  104416. */
  104417. unfreezeNormals(): Mesh;
  104418. /**
  104419. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  104420. */
  104421. set overridenInstanceCount(count: number);
  104422. /** @hidden */
  104423. _preActivate(): Mesh;
  104424. /** @hidden */
  104425. _preActivateForIntermediateRendering(renderId: number): Mesh;
  104426. /** @hidden */
  104427. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  104428. /**
  104429. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104430. * This means the mesh underlying bounding box and sphere are recomputed.
  104431. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104432. * @returns the current mesh
  104433. */
  104434. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  104435. /** @hidden */
  104436. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  104437. /**
  104438. * This function will subdivide the mesh into multiple submeshes
  104439. * @param count defines the expected number of submeshes
  104440. */
  104441. subdivide(count: number): void;
  104442. /**
  104443. * Copy a FloatArray into a specific associated vertex buffer
  104444. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104445. * - VertexBuffer.PositionKind
  104446. * - VertexBuffer.UVKind
  104447. * - VertexBuffer.UV2Kind
  104448. * - VertexBuffer.UV3Kind
  104449. * - VertexBuffer.UV4Kind
  104450. * - VertexBuffer.UV5Kind
  104451. * - VertexBuffer.UV6Kind
  104452. * - VertexBuffer.ColorKind
  104453. * - VertexBuffer.MatricesIndicesKind
  104454. * - VertexBuffer.MatricesIndicesExtraKind
  104455. * - VertexBuffer.MatricesWeightsKind
  104456. * - VertexBuffer.MatricesWeightsExtraKind
  104457. * @param data defines the data source
  104458. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104459. * @param stride defines the data stride size (can be null)
  104460. * @returns the current mesh
  104461. */
  104462. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104463. /**
  104464. * Delete a vertex buffer associated with this mesh
  104465. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  104466. * - VertexBuffer.PositionKind
  104467. * - VertexBuffer.UVKind
  104468. * - VertexBuffer.UV2Kind
  104469. * - VertexBuffer.UV3Kind
  104470. * - VertexBuffer.UV4Kind
  104471. * - VertexBuffer.UV5Kind
  104472. * - VertexBuffer.UV6Kind
  104473. * - VertexBuffer.ColorKind
  104474. * - VertexBuffer.MatricesIndicesKind
  104475. * - VertexBuffer.MatricesIndicesExtraKind
  104476. * - VertexBuffer.MatricesWeightsKind
  104477. * - VertexBuffer.MatricesWeightsExtraKind
  104478. */
  104479. removeVerticesData(kind: string): void;
  104480. /**
  104481. * Flags an associated vertex buffer as updatable
  104482. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  104483. * - VertexBuffer.PositionKind
  104484. * - VertexBuffer.UVKind
  104485. * - VertexBuffer.UV2Kind
  104486. * - VertexBuffer.UV3Kind
  104487. * - VertexBuffer.UV4Kind
  104488. * - VertexBuffer.UV5Kind
  104489. * - VertexBuffer.UV6Kind
  104490. * - VertexBuffer.ColorKind
  104491. * - VertexBuffer.MatricesIndicesKind
  104492. * - VertexBuffer.MatricesIndicesExtraKind
  104493. * - VertexBuffer.MatricesWeightsKind
  104494. * - VertexBuffer.MatricesWeightsExtraKind
  104495. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104496. */
  104497. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  104498. /**
  104499. * Sets the mesh global Vertex Buffer
  104500. * @param buffer defines the buffer to use
  104501. * @returns the current mesh
  104502. */
  104503. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  104504. /**
  104505. * Update a specific associated vertex buffer
  104506. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104507. * - VertexBuffer.PositionKind
  104508. * - VertexBuffer.UVKind
  104509. * - VertexBuffer.UV2Kind
  104510. * - VertexBuffer.UV3Kind
  104511. * - VertexBuffer.UV4Kind
  104512. * - VertexBuffer.UV5Kind
  104513. * - VertexBuffer.UV6Kind
  104514. * - VertexBuffer.ColorKind
  104515. * - VertexBuffer.MatricesIndicesKind
  104516. * - VertexBuffer.MatricesIndicesExtraKind
  104517. * - VertexBuffer.MatricesWeightsKind
  104518. * - VertexBuffer.MatricesWeightsExtraKind
  104519. * @param data defines the data source
  104520. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104521. * @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)
  104522. * @returns the current mesh
  104523. */
  104524. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104525. /**
  104526. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  104527. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  104528. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  104529. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  104530. * @returns the current mesh
  104531. */
  104532. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  104533. /**
  104534. * Creates a un-shared specific occurence of the geometry for the mesh.
  104535. * @returns the current mesh
  104536. */
  104537. makeGeometryUnique(): Mesh;
  104538. /**
  104539. * Set the index buffer of this mesh
  104540. * @param indices defines the source data
  104541. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  104542. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  104543. * @returns the current mesh
  104544. */
  104545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  104546. /**
  104547. * Update the current index buffer
  104548. * @param indices defines the source data
  104549. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104550. * @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)
  104551. * @returns the current mesh
  104552. */
  104553. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104554. /**
  104555. * Invert the geometry to move from a right handed system to a left handed one.
  104556. * @returns the current mesh
  104557. */
  104558. toLeftHanded(): Mesh;
  104559. /** @hidden */
  104560. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  104561. /** @hidden */
  104562. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  104563. /**
  104564. * Registers for this mesh a javascript function called just before the rendering process
  104565. * @param func defines the function to call before rendering this mesh
  104566. * @returns the current mesh
  104567. */
  104568. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104569. /**
  104570. * Disposes a previously registered javascript function called before the rendering
  104571. * @param func defines the function to remove
  104572. * @returns the current mesh
  104573. */
  104574. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104575. /**
  104576. * Registers for this mesh a javascript function called just after the rendering is complete
  104577. * @param func defines the function to call after rendering this mesh
  104578. * @returns the current mesh
  104579. */
  104580. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104581. /**
  104582. * Disposes a previously registered javascript function called after the rendering.
  104583. * @param func defines the function to remove
  104584. * @returns the current mesh
  104585. */
  104586. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104587. /** @hidden */
  104588. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  104589. /** @hidden */
  104590. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  104591. /** @hidden */
  104592. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  104593. /** @hidden */
  104594. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  104595. /** @hidden */
  104596. _rebuild(): void;
  104597. /** @hidden */
  104598. _freeze(): void;
  104599. /** @hidden */
  104600. _unFreeze(): void;
  104601. /**
  104602. * 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
  104603. * @param subMesh defines the subMesh to render
  104604. * @param enableAlphaMode defines if alpha mode can be changed
  104605. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  104606. * @returns the current mesh
  104607. */
  104608. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  104609. private _onBeforeDraw;
  104610. /**
  104611. * Renormalize the mesh and patch it up if there are no weights
  104612. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  104613. * However in the case of zero weights then we set just a single influence to 1.
  104614. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  104615. */
  104616. cleanMatrixWeights(): void;
  104617. private normalizeSkinFourWeights;
  104618. private normalizeSkinWeightsAndExtra;
  104619. /**
  104620. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  104621. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  104622. * the user know there was an issue with importing the mesh
  104623. * @returns a validation object with skinned, valid and report string
  104624. */
  104625. validateSkinning(): {
  104626. skinned: boolean;
  104627. valid: boolean;
  104628. report: string;
  104629. };
  104630. /** @hidden */
  104631. _checkDelayState(): Mesh;
  104632. private _queueLoad;
  104633. /**
  104634. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104635. * A mesh is in the frustum if its bounding box intersects the frustum
  104636. * @param frustumPlanes defines the frustum to test
  104637. * @returns true if the mesh is in the frustum planes
  104638. */
  104639. isInFrustum(frustumPlanes: Plane[]): boolean;
  104640. /**
  104641. * Sets the mesh material by the material or multiMaterial `id` property
  104642. * @param id is a string identifying the material or the multiMaterial
  104643. * @returns the current mesh
  104644. */
  104645. setMaterialByID(id: string): Mesh;
  104646. /**
  104647. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  104648. * @returns an array of IAnimatable
  104649. */
  104650. getAnimatables(): IAnimatable[];
  104651. /**
  104652. * Modifies the mesh geometry according to the passed transformation matrix.
  104653. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  104654. * The mesh normals are modified using the same transformation.
  104655. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104656. * @param transform defines the transform matrix to use
  104657. * @see http://doc.babylonjs.com/resources/baking_transformations
  104658. * @returns the current mesh
  104659. */
  104660. bakeTransformIntoVertices(transform: Matrix): Mesh;
  104661. /**
  104662. * Modifies the mesh geometry according to its own current World Matrix.
  104663. * The mesh World Matrix is then reset.
  104664. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  104665. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104666. * @see http://doc.babylonjs.com/resources/baking_transformations
  104667. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  104668. * @returns the current mesh
  104669. */
  104670. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  104671. /** @hidden */
  104672. get _positions(): Nullable<Vector3[]>;
  104673. /** @hidden */
  104674. _resetPointsArrayCache(): Mesh;
  104675. /** @hidden */
  104676. _generatePointsArray(): boolean;
  104677. /**
  104678. * Returns a new Mesh object generated from the current mesh properties.
  104679. * This method must not get confused with createInstance()
  104680. * @param name is a string, the name given to the new mesh
  104681. * @param newParent can be any Node object (default `null`)
  104682. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  104683. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  104684. * @returns a new mesh
  104685. */
  104686. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  104687. /**
  104688. * Releases resources associated with this mesh.
  104689. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104690. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104691. */
  104692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104693. /** @hidden */
  104694. _disposeInstanceSpecificData(): void;
  104695. /**
  104696. * Modifies the mesh geometry according to a displacement map.
  104697. * 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.
  104698. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  104699. * @param url is a string, the URL from the image file is to be downloaded.
  104700. * @param minHeight is the lower limit of the displacement.
  104701. * @param maxHeight is the upper limit of the displacement.
  104702. * @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.
  104703. * @param uvOffset is an optional vector2 used to offset UV.
  104704. * @param uvScale is an optional vector2 used to scale UV.
  104705. * @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.
  104706. * @returns the Mesh.
  104707. */
  104708. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  104709. /**
  104710. * Modifies the mesh geometry according to a displacementMap buffer.
  104711. * 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.
  104712. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  104713. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  104714. * @param heightMapWidth is the width of the buffer image.
  104715. * @param heightMapHeight is the height of the buffer image.
  104716. * @param minHeight is the lower limit of the displacement.
  104717. * @param maxHeight is the upper limit of the displacement.
  104718. * @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.
  104719. * @param uvOffset is an optional vector2 used to offset UV.
  104720. * @param uvScale is an optional vector2 used to scale UV.
  104721. * @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.
  104722. * @returns the Mesh.
  104723. */
  104724. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  104725. /**
  104726. * Modify the mesh to get a flat shading rendering.
  104727. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  104728. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  104729. * @returns current mesh
  104730. */
  104731. convertToFlatShadedMesh(): Mesh;
  104732. /**
  104733. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  104734. * In other words, more vertices, no more indices and a single bigger VBO.
  104735. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  104736. * @returns current mesh
  104737. */
  104738. convertToUnIndexedMesh(): Mesh;
  104739. /**
  104740. * Inverses facet orientations.
  104741. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  104742. * @param flipNormals will also inverts the normals
  104743. * @returns current mesh
  104744. */
  104745. flipFaces(flipNormals?: boolean): Mesh;
  104746. /**
  104747. * Increase the number of facets and hence vertices in a mesh
  104748. * Vertex normals are interpolated from existing vertex normals
  104749. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  104750. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  104751. */
  104752. increaseVertices(numberPerEdge: number): void;
  104753. /**
  104754. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  104755. * This will undo any application of covertToFlatShadedMesh
  104756. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  104757. */
  104758. forceSharedVertices(): void;
  104759. /** @hidden */
  104760. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  104761. /** @hidden */
  104762. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  104763. /**
  104764. * Creates a new InstancedMesh object from the mesh model.
  104765. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104766. * @param name defines the name of the new instance
  104767. * @returns a new InstancedMesh
  104768. */
  104769. createInstance(name: string): InstancedMesh;
  104770. /**
  104771. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  104772. * After this call, all the mesh instances have the same submeshes than the current mesh.
  104773. * @returns the current mesh
  104774. */
  104775. synchronizeInstances(): Mesh;
  104776. /**
  104777. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  104778. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  104779. * This should be used together with the simplification to avoid disappearing triangles.
  104780. * @param successCallback an optional success callback to be called after the optimization finished.
  104781. * @returns the current mesh
  104782. */
  104783. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  104784. /**
  104785. * Serialize current mesh
  104786. * @param serializationObject defines the object which will receive the serialization data
  104787. */
  104788. serialize(serializationObject: any): void;
  104789. /** @hidden */
  104790. _syncGeometryWithMorphTargetManager(): void;
  104791. /** @hidden */
  104792. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  104793. /**
  104794. * Returns a new Mesh object parsed from the source provided.
  104795. * @param parsedMesh is the source
  104796. * @param scene defines the hosting scene
  104797. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  104798. * @returns a new Mesh
  104799. */
  104800. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  104801. /**
  104802. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  104803. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  104804. * @param name defines the name of the mesh to create
  104805. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  104806. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  104807. * @param closePath creates a seam between the first and the last points of each path of the path array
  104808. * @param offset is taken in account only if the `pathArray` is containing a single path
  104809. * @param scene defines the hosting scene
  104810. * @param updatable defines if the mesh must be flagged as updatable
  104811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104812. * @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)
  104813. * @returns a new Mesh
  104814. */
  104815. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  104816. /**
  104817. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  104818. * @param name defines the name of the mesh to create
  104819. * @param radius sets the radius size (float) of the polygon (default 0.5)
  104820. * @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
  104821. * @param scene defines the hosting scene
  104822. * @param updatable defines if the mesh must be flagged as updatable
  104823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104824. * @returns a new Mesh
  104825. */
  104826. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  104827. /**
  104828. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  104829. * @param name defines the name of the mesh to create
  104830. * @param size sets the size (float) of each box side (default 1)
  104831. * @param scene defines the hosting scene
  104832. * @param updatable defines if the mesh must be flagged as updatable
  104833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104834. * @returns a new Mesh
  104835. */
  104836. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  104837. /**
  104838. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  104839. * @param name defines the name of the mesh to create
  104840. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  104841. * @param diameter sets the diameter size (float) of the sphere (default 1)
  104842. * @param scene defines the hosting scene
  104843. * @param updatable defines if the mesh must be flagged as updatable
  104844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104845. * @returns a new Mesh
  104846. */
  104847. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  104848. /**
  104849. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  104850. * @param name defines the name of the mesh to create
  104851. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  104852. * @param diameter sets the diameter size (float) of the sphere (default 1)
  104853. * @param scene defines the hosting scene
  104854. * @returns a new Mesh
  104855. */
  104856. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  104857. /**
  104858. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  104859. * @param name defines the name of the mesh to create
  104860. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  104861. * @param diameterTop set the top cap diameter (floats, default 1)
  104862. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  104863. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  104864. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  104865. * @param scene defines the hosting scene
  104866. * @param updatable defines if the mesh must be flagged as updatable
  104867. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104868. * @returns a new Mesh
  104869. */
  104870. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  104871. /**
  104872. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  104873. * @param name defines the name of the mesh to create
  104874. * @param diameter sets the diameter size (float) of the torus (default 1)
  104875. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  104876. * @param tessellation sets the number of torus sides (postive integer, default 16)
  104877. * @param scene defines the hosting scene
  104878. * @param updatable defines if the mesh must be flagged as updatable
  104879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104880. * @returns a new Mesh
  104881. */
  104882. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  104883. /**
  104884. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  104885. * @param name defines the name of the mesh to create
  104886. * @param radius sets the global radius size (float) of the torus knot (default 2)
  104887. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  104888. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  104889. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  104890. * @param p the number of windings on X axis (positive integers, default 2)
  104891. * @param q the number of windings on Y axis (positive integers, default 3)
  104892. * @param scene defines the hosting scene
  104893. * @param updatable defines if the mesh must be flagged as updatable
  104894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104895. * @returns a new Mesh
  104896. */
  104897. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  104898. /**
  104899. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  104900. * @param name defines the name of the mesh to create
  104901. * @param points is an array successive Vector3
  104902. * @param scene defines the hosting scene
  104903. * @param updatable defines if the mesh must be flagged as updatable
  104904. * @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).
  104905. * @returns a new Mesh
  104906. */
  104907. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  104908. /**
  104909. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  104910. * @param name defines the name of the mesh to create
  104911. * @param points is an array successive Vector3
  104912. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  104913. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104914. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  104915. * @param scene defines the hosting scene
  104916. * @param updatable defines if the mesh must be flagged as updatable
  104917. * @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)
  104918. * @returns a new Mesh
  104919. */
  104920. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  104921. /**
  104922. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  104923. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  104924. * 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.
  104925. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104926. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104927. * Remember you can only change the shape positions, not their number when updating a polygon.
  104928. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  104929. * @param name defines the name of the mesh to create
  104930. * @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
  104931. * @param scene defines the hosting scene
  104932. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  104933. * @param updatable defines if the mesh must be flagged as updatable
  104934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104935. * @param earcutInjection can be used to inject your own earcut reference
  104936. * @returns a new Mesh
  104937. */
  104938. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  104939. /**
  104940. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  104941. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  104942. * @param name defines the name of the mesh to create
  104943. * @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
  104944. * @param depth defines the height of extrusion
  104945. * @param scene defines the hosting scene
  104946. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  104947. * @param updatable defines if the mesh must be flagged as updatable
  104948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104949. * @param earcutInjection can be used to inject your own earcut reference
  104950. * @returns a new Mesh
  104951. */
  104952. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  104953. /**
  104954. * Creates an extruded shape mesh.
  104955. * 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
  104956. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  104957. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104958. * @param name defines the name of the mesh to create
  104959. * @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
  104960. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  104961. * @param scale is the value to scale the shape
  104962. * @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
  104963. * @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
  104964. * @param scene defines the hosting scene
  104965. * @param updatable defines if the mesh must be flagged as updatable
  104966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104967. * @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)
  104968. * @returns a new Mesh
  104969. */
  104970. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  104971. /**
  104972. * Creates an custom extruded shape mesh.
  104973. * The custom extrusion is a parametric shape.
  104974. * It has no predefined shape. Its final shape will depend on the input parameters.
  104975. * Please consider using the same method from the MeshBuilder class instead
  104976. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104977. * @param name defines the name of the mesh to create
  104978. * @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
  104979. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  104980. * @param scaleFunction is a custom Javascript function called on each path point
  104981. * @param rotationFunction is a custom Javascript function called on each path point
  104982. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104983. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  104984. * @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
  104985. * @param scene defines the hosting scene
  104986. * @param updatable defines if the mesh must be flagged as updatable
  104987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104988. * @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)
  104989. * @returns a new Mesh
  104990. */
  104991. 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;
  104992. /**
  104993. * Creates lathe mesh.
  104994. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  104995. * Please consider using the same method from the MeshBuilder class instead
  104996. * @param name defines the name of the mesh to create
  104997. * @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
  104998. * @param radius is the radius value of the lathe
  104999. * @param tessellation is the side number of the lathe.
  105000. * @param scene defines the hosting scene
  105001. * @param updatable defines if the mesh must be flagged as updatable
  105002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105003. * @returns a new Mesh
  105004. */
  105005. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105006. /**
  105007. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105008. * @param name defines the name of the mesh to create
  105009. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105010. * @param scene defines the hosting scene
  105011. * @param updatable defines if the mesh must be flagged as updatable
  105012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105013. * @returns a new Mesh
  105014. */
  105015. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105016. /**
  105017. * Creates a ground mesh.
  105018. * Please consider using the same method from the MeshBuilder class instead
  105019. * @param name defines the name of the mesh to create
  105020. * @param width set the width of the ground
  105021. * @param height set the height of the ground
  105022. * @param subdivisions sets the number of subdivisions per side
  105023. * @param scene defines the hosting scene
  105024. * @param updatable defines if the mesh must be flagged as updatable
  105025. * @returns a new Mesh
  105026. */
  105027. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105028. /**
  105029. * Creates a tiled ground mesh.
  105030. * Please consider using the same method from the MeshBuilder class instead
  105031. * @param name defines the name of the mesh to create
  105032. * @param xmin set the ground minimum X coordinate
  105033. * @param zmin set the ground minimum Y coordinate
  105034. * @param xmax set the ground maximum X coordinate
  105035. * @param zmax set the ground maximum Z coordinate
  105036. * @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
  105037. * @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
  105038. * @param scene defines the hosting scene
  105039. * @param updatable defines if the mesh must be flagged as updatable
  105040. * @returns a new Mesh
  105041. */
  105042. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105043. w: number;
  105044. h: number;
  105045. }, precision: {
  105046. w: number;
  105047. h: number;
  105048. }, scene: Scene, updatable?: boolean): Mesh;
  105049. /**
  105050. * Creates a ground mesh from a height map.
  105051. * Please consider using the same method from the MeshBuilder class instead
  105052. * @see http://doc.babylonjs.com/babylon101/height_map
  105053. * @param name defines the name of the mesh to create
  105054. * @param url sets the URL of the height map image resource
  105055. * @param width set the ground width size
  105056. * @param height set the ground height size
  105057. * @param subdivisions sets the number of subdivision per side
  105058. * @param minHeight is the minimum altitude on the ground
  105059. * @param maxHeight is the maximum altitude on the ground
  105060. * @param scene defines the hosting scene
  105061. * @param updatable defines if the mesh must be flagged as updatable
  105062. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105063. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105064. * @returns a new Mesh
  105065. */
  105066. 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;
  105067. /**
  105068. * Creates a tube mesh.
  105069. * The tube is a parametric shape.
  105070. * It has no predefined shape. Its final shape will depend on the input parameters.
  105071. * Please consider using the same method from the MeshBuilder class instead
  105072. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105073. * @param name defines the name of the mesh to create
  105074. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105075. * @param radius sets the tube radius size
  105076. * @param tessellation is the number of sides on the tubular surface
  105077. * @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
  105078. * @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
  105079. * @param scene defines the hosting scene
  105080. * @param updatable defines if the mesh must be flagged as updatable
  105081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105082. * @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)
  105083. * @returns a new Mesh
  105084. */
  105085. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105086. (i: number, distance: number): number;
  105087. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105088. /**
  105089. * Creates a polyhedron mesh.
  105090. * Please consider using the same method from the MeshBuilder class instead.
  105091. * * 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
  105092. * * The parameter `size` (positive float, default 1) sets the polygon size
  105093. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105094. * * 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`
  105095. * * 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
  105096. * * 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)`)
  105097. * * 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
  105098. * * 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
  105099. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105100. * * If you create a double-sided mesh, you can choose what parts of 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
  105101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105102. * @param name defines the name of the mesh to create
  105103. * @param options defines the options used to create the mesh
  105104. * @param scene defines the hosting scene
  105105. * @returns a new Mesh
  105106. */
  105107. static CreatePolyhedron(name: string, options: {
  105108. type?: number;
  105109. size?: number;
  105110. sizeX?: number;
  105111. sizeY?: number;
  105112. sizeZ?: number;
  105113. custom?: any;
  105114. faceUV?: Vector4[];
  105115. faceColors?: Color4[];
  105116. updatable?: boolean;
  105117. sideOrientation?: number;
  105118. }, scene: Scene): Mesh;
  105119. /**
  105120. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105121. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105122. * * 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`)
  105123. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105124. * * 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
  105125. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105126. * * If you create a double-sided mesh, you can choose what parts of 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
  105127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105128. * @param name defines the name of the mesh
  105129. * @param options defines the options used to create the mesh
  105130. * @param scene defines the hosting scene
  105131. * @returns a new Mesh
  105132. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105133. */
  105134. static CreateIcoSphere(name: string, options: {
  105135. radius?: number;
  105136. flat?: boolean;
  105137. subdivisions?: number;
  105138. sideOrientation?: number;
  105139. updatable?: boolean;
  105140. }, scene: Scene): Mesh;
  105141. /**
  105142. * Creates a decal mesh.
  105143. * Please consider using the same method from the MeshBuilder class instead.
  105144. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105145. * @param name defines the name of the mesh
  105146. * @param sourceMesh defines the mesh receiving the decal
  105147. * @param position sets the position of the decal in world coordinates
  105148. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105149. * @param size sets the decal scaling
  105150. * @param angle sets the angle to rotate the decal
  105151. * @returns a new Mesh
  105152. */
  105153. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105154. /**
  105155. * Prepare internal position array for software CPU skinning
  105156. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105157. */
  105158. setPositionsForCPUSkinning(): Float32Array;
  105159. /**
  105160. * Prepare internal normal array for software CPU skinning
  105161. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105162. */
  105163. setNormalsForCPUSkinning(): Float32Array;
  105164. /**
  105165. * Updates the vertex buffer by applying transformation from the bones
  105166. * @param skeleton defines the skeleton to apply to current mesh
  105167. * @returns the current mesh
  105168. */
  105169. applySkeleton(skeleton: Skeleton): Mesh;
  105170. /**
  105171. * 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
  105172. * @param meshes defines the list of meshes to scan
  105173. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105174. */
  105175. static MinMax(meshes: AbstractMesh[]): {
  105176. min: Vector3;
  105177. max: Vector3;
  105178. };
  105179. /**
  105180. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105181. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105182. * @returns a vector3
  105183. */
  105184. static Center(meshesOrMinMaxVector: {
  105185. min: Vector3;
  105186. max: Vector3;
  105187. } | AbstractMesh[]): Vector3;
  105188. /**
  105189. * Merge the array of meshes into a single mesh for performance reasons.
  105190. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105191. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105192. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105193. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105194. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105195. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105196. * @returns a new mesh
  105197. */
  105198. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105199. /** @hidden */
  105200. addInstance(instance: InstancedMesh): void;
  105201. /** @hidden */
  105202. removeInstance(instance: InstancedMesh): void;
  105203. }
  105204. }
  105205. declare module BABYLON {
  105206. /**
  105207. * This is the base class of all the camera used in the application.
  105208. * @see http://doc.babylonjs.com/features/cameras
  105209. */
  105210. export class Camera extends Node {
  105211. /** @hidden */
  105212. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105213. /**
  105214. * This is the default projection mode used by the cameras.
  105215. * It helps recreating a feeling of perspective and better appreciate depth.
  105216. * This is the best way to simulate real life cameras.
  105217. */
  105218. static readonly PERSPECTIVE_CAMERA: number;
  105219. /**
  105220. * This helps creating camera with an orthographic mode.
  105221. * 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.
  105222. */
  105223. static readonly ORTHOGRAPHIC_CAMERA: number;
  105224. /**
  105225. * This is the default FOV mode for perspective cameras.
  105226. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105227. */
  105228. static readonly FOVMODE_VERTICAL_FIXED: number;
  105229. /**
  105230. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105231. */
  105232. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105233. /**
  105234. * This specifies ther is no need for a camera rig.
  105235. * Basically only one eye is rendered corresponding to the camera.
  105236. */
  105237. static readonly RIG_MODE_NONE: number;
  105238. /**
  105239. * Simulates a camera Rig with one blue eye and one red eye.
  105240. * This can be use with 3d blue and red glasses.
  105241. */
  105242. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105243. /**
  105244. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105245. */
  105246. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105247. /**
  105248. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105249. */
  105250. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105251. /**
  105252. * Defines that both eyes of the camera will be rendered over under each other.
  105253. */
  105254. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105255. /**
  105256. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105257. */
  105258. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  105259. /**
  105260. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  105261. */
  105262. static readonly RIG_MODE_VR: number;
  105263. /**
  105264. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  105265. */
  105266. static readonly RIG_MODE_WEBVR: number;
  105267. /**
  105268. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  105269. */
  105270. static readonly RIG_MODE_CUSTOM: number;
  105271. /**
  105272. * Defines if by default attaching controls should prevent the default javascript event to continue.
  105273. */
  105274. static ForceAttachControlToAlwaysPreventDefault: boolean;
  105275. /**
  105276. * Define the input manager associated with the camera.
  105277. */
  105278. inputs: CameraInputsManager<Camera>;
  105279. /** @hidden */
  105280. _position: Vector3;
  105281. /**
  105282. * Define the current local position of the camera in the scene
  105283. */
  105284. get position(): Vector3;
  105285. set position(newPosition: Vector3);
  105286. /**
  105287. * The vector the camera should consider as up.
  105288. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  105289. */
  105290. upVector: Vector3;
  105291. /**
  105292. * Define the current limit on the left side for an orthographic camera
  105293. * In scene unit
  105294. */
  105295. orthoLeft: Nullable<number>;
  105296. /**
  105297. * Define the current limit on the right side for an orthographic camera
  105298. * In scene unit
  105299. */
  105300. orthoRight: Nullable<number>;
  105301. /**
  105302. * Define the current limit on the bottom side for an orthographic camera
  105303. * In scene unit
  105304. */
  105305. orthoBottom: Nullable<number>;
  105306. /**
  105307. * Define the current limit on the top side for an orthographic camera
  105308. * In scene unit
  105309. */
  105310. orthoTop: Nullable<number>;
  105311. /**
  105312. * Field Of View is set in Radians. (default is 0.8)
  105313. */
  105314. fov: number;
  105315. /**
  105316. * Define the minimum distance the camera can see from.
  105317. * This is important to note that the depth buffer are not infinite and the closer it starts
  105318. * the more your scene might encounter depth fighting issue.
  105319. */
  105320. minZ: number;
  105321. /**
  105322. * Define the maximum distance the camera can see to.
  105323. * This is important to note that the depth buffer are not infinite and the further it end
  105324. * the more your scene might encounter depth fighting issue.
  105325. */
  105326. maxZ: number;
  105327. /**
  105328. * Define the default inertia of the camera.
  105329. * This helps giving a smooth feeling to the camera movement.
  105330. */
  105331. inertia: number;
  105332. /**
  105333. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  105334. */
  105335. mode: number;
  105336. /**
  105337. * Define whether the camera is intermediate.
  105338. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  105339. */
  105340. isIntermediate: boolean;
  105341. /**
  105342. * Define the viewport of the camera.
  105343. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  105344. */
  105345. viewport: Viewport;
  105346. /**
  105347. * Restricts the camera to viewing objects with the same layerMask.
  105348. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  105349. */
  105350. layerMask: number;
  105351. /**
  105352. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  105353. */
  105354. fovMode: number;
  105355. /**
  105356. * Rig mode of the camera.
  105357. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  105358. * This is normally controlled byt the camera themselves as internal use.
  105359. */
  105360. cameraRigMode: number;
  105361. /**
  105362. * Defines the distance between both "eyes" in case of a RIG
  105363. */
  105364. interaxialDistance: number;
  105365. /**
  105366. * Defines if stereoscopic rendering is done side by side or over under.
  105367. */
  105368. isStereoscopicSideBySide: boolean;
  105369. /**
  105370. * 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
  105371. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  105372. * else in the scene. (Eg. security camera)
  105373. *
  105374. * 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)
  105375. */
  105376. customRenderTargets: RenderTargetTexture[];
  105377. /**
  105378. * When set, the camera will render to this render target instead of the default canvas
  105379. *
  105380. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  105381. */
  105382. outputRenderTarget: Nullable<RenderTargetTexture>;
  105383. /**
  105384. * Observable triggered when the camera view matrix has changed.
  105385. */
  105386. onViewMatrixChangedObservable: Observable<Camera>;
  105387. /**
  105388. * Observable triggered when the camera Projection matrix has changed.
  105389. */
  105390. onProjectionMatrixChangedObservable: Observable<Camera>;
  105391. /**
  105392. * Observable triggered when the inputs have been processed.
  105393. */
  105394. onAfterCheckInputsObservable: Observable<Camera>;
  105395. /**
  105396. * Observable triggered when reset has been called and applied to the camera.
  105397. */
  105398. onRestoreStateObservable: Observable<Camera>;
  105399. /**
  105400. * Is this camera a part of a rig system?
  105401. */
  105402. isRigCamera: boolean;
  105403. /**
  105404. * If isRigCamera set to true this will be set with the parent camera.
  105405. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  105406. */
  105407. rigParent?: Camera;
  105408. /** @hidden */
  105409. _cameraRigParams: any;
  105410. /** @hidden */
  105411. _rigCameras: Camera[];
  105412. /** @hidden */
  105413. _rigPostProcess: Nullable<PostProcess>;
  105414. protected _webvrViewMatrix: Matrix;
  105415. /** @hidden */
  105416. _skipRendering: boolean;
  105417. /** @hidden */
  105418. _projectionMatrix: Matrix;
  105419. /** @hidden */
  105420. _postProcesses: Nullable<PostProcess>[];
  105421. /** @hidden */
  105422. _activeMeshes: SmartArray<AbstractMesh>;
  105423. protected _globalPosition: Vector3;
  105424. /** @hidden */
  105425. _computedViewMatrix: Matrix;
  105426. private _doNotComputeProjectionMatrix;
  105427. private _transformMatrix;
  105428. private _frustumPlanes;
  105429. private _refreshFrustumPlanes;
  105430. private _storedFov;
  105431. private _stateStored;
  105432. /**
  105433. * Instantiates a new camera object.
  105434. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  105435. * @see http://doc.babylonjs.com/features/cameras
  105436. * @param name Defines the name of the camera in the scene
  105437. * @param position Defines the position of the camera
  105438. * @param scene Defines the scene the camera belongs too
  105439. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  105440. */
  105441. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105442. /**
  105443. * Store current camera state (fov, position, etc..)
  105444. * @returns the camera
  105445. */
  105446. storeState(): Camera;
  105447. /**
  105448. * Restores the camera state values if it has been stored. You must call storeState() first
  105449. */
  105450. protected _restoreStateValues(): boolean;
  105451. /**
  105452. * Restored camera state. You must call storeState() first.
  105453. * @returns true if restored and false otherwise
  105454. */
  105455. restoreState(): boolean;
  105456. /**
  105457. * Gets the class name of the camera.
  105458. * @returns the class name
  105459. */
  105460. getClassName(): string;
  105461. /** @hidden */
  105462. readonly _isCamera: boolean;
  105463. /**
  105464. * Gets a string representation of the camera useful for debug purpose.
  105465. * @param fullDetails Defines that a more verboe level of logging is required
  105466. * @returns the string representation
  105467. */
  105468. toString(fullDetails?: boolean): string;
  105469. /**
  105470. * Gets the current world space position of the camera.
  105471. */
  105472. get globalPosition(): Vector3;
  105473. /**
  105474. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  105475. * @returns the active meshe list
  105476. */
  105477. getActiveMeshes(): SmartArray<AbstractMesh>;
  105478. /**
  105479. * Check whether a mesh is part of the current active mesh list of the camera
  105480. * @param mesh Defines the mesh to check
  105481. * @returns true if active, false otherwise
  105482. */
  105483. isActiveMesh(mesh: Mesh): boolean;
  105484. /**
  105485. * Is this camera ready to be used/rendered
  105486. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  105487. * @return true if the camera is ready
  105488. */
  105489. isReady(completeCheck?: boolean): boolean;
  105490. /** @hidden */
  105491. _initCache(): void;
  105492. /** @hidden */
  105493. _updateCache(ignoreParentClass?: boolean): void;
  105494. /** @hidden */
  105495. _isSynchronized(): boolean;
  105496. /** @hidden */
  105497. _isSynchronizedViewMatrix(): boolean;
  105498. /** @hidden */
  105499. _isSynchronizedProjectionMatrix(): boolean;
  105500. /**
  105501. * Attach the input controls to a specific dom element to get the input from.
  105502. * @param element Defines the element the controls should be listened from
  105503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105504. */
  105505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105506. /**
  105507. * Detach the current controls from the specified dom element.
  105508. * @param element Defines the element to stop listening the inputs from
  105509. */
  105510. detachControl(element: HTMLElement): void;
  105511. /**
  105512. * Update the camera state according to the different inputs gathered during the frame.
  105513. */
  105514. update(): void;
  105515. /** @hidden */
  105516. _checkInputs(): void;
  105517. /** @hidden */
  105518. get rigCameras(): Camera[];
  105519. /**
  105520. * Gets the post process used by the rig cameras
  105521. */
  105522. get rigPostProcess(): Nullable<PostProcess>;
  105523. /**
  105524. * Internal, gets the first post proces.
  105525. * @returns the first post process to be run on this camera.
  105526. */
  105527. _getFirstPostProcess(): Nullable<PostProcess>;
  105528. private _cascadePostProcessesToRigCams;
  105529. /**
  105530. * Attach a post process to the camera.
  105531. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105532. * @param postProcess The post process to attach to the camera
  105533. * @param insertAt The position of the post process in case several of them are in use in the scene
  105534. * @returns the position the post process has been inserted at
  105535. */
  105536. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  105537. /**
  105538. * Detach a post process to the camera.
  105539. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105540. * @param postProcess The post process to detach from the camera
  105541. */
  105542. detachPostProcess(postProcess: PostProcess): void;
  105543. /**
  105544. * Gets the current world matrix of the camera
  105545. */
  105546. getWorldMatrix(): Matrix;
  105547. /** @hidden */
  105548. _getViewMatrix(): Matrix;
  105549. /**
  105550. * Gets the current view matrix of the camera.
  105551. * @param force forces the camera to recompute the matrix without looking at the cached state
  105552. * @returns the view matrix
  105553. */
  105554. getViewMatrix(force?: boolean): Matrix;
  105555. /**
  105556. * Freeze the projection matrix.
  105557. * It will prevent the cache check of the camera projection compute and can speed up perf
  105558. * if no parameter of the camera are meant to change
  105559. * @param projection Defines manually a projection if necessary
  105560. */
  105561. freezeProjectionMatrix(projection?: Matrix): void;
  105562. /**
  105563. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  105564. */
  105565. unfreezeProjectionMatrix(): void;
  105566. /**
  105567. * Gets the current projection matrix of the camera.
  105568. * @param force forces the camera to recompute the matrix without looking at the cached state
  105569. * @returns the projection matrix
  105570. */
  105571. getProjectionMatrix(force?: boolean): Matrix;
  105572. /**
  105573. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  105574. * @returns a Matrix
  105575. */
  105576. getTransformationMatrix(): Matrix;
  105577. private _updateFrustumPlanes;
  105578. /**
  105579. * Checks if a cullable object (mesh...) is in the camera frustum
  105580. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  105581. * @param target The object to check
  105582. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  105583. * @returns true if the object is in frustum otherwise false
  105584. */
  105585. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  105586. /**
  105587. * Checks if a cullable object (mesh...) is in the camera frustum
  105588. * Unlike isInFrustum this cheks the full bounding box
  105589. * @param target The object to check
  105590. * @returns true if the object is in frustum otherwise false
  105591. */
  105592. isCompletelyInFrustum(target: ICullable): boolean;
  105593. /**
  105594. * Gets a ray in the forward direction from the camera.
  105595. * @param length Defines the length of the ray to create
  105596. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  105597. * @param origin Defines the start point of the ray which defaults to the camera position
  105598. * @returns the forward ray
  105599. */
  105600. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  105601. /**
  105602. * Releases resources associated with this node.
  105603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105605. */
  105606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105607. /** @hidden */
  105608. _isLeftCamera: boolean;
  105609. /**
  105610. * Gets the left camera of a rig setup in case of Rigged Camera
  105611. */
  105612. get isLeftCamera(): boolean;
  105613. /** @hidden */
  105614. _isRightCamera: boolean;
  105615. /**
  105616. * Gets the right camera of a rig setup in case of Rigged Camera
  105617. */
  105618. get isRightCamera(): boolean;
  105619. /**
  105620. * Gets the left camera of a rig setup in case of Rigged Camera
  105621. */
  105622. get leftCamera(): Nullable<FreeCamera>;
  105623. /**
  105624. * Gets the right camera of a rig setup in case of Rigged Camera
  105625. */
  105626. get rightCamera(): Nullable<FreeCamera>;
  105627. /**
  105628. * Gets the left camera target of a rig setup in case of Rigged Camera
  105629. * @returns the target position
  105630. */
  105631. getLeftTarget(): Nullable<Vector3>;
  105632. /**
  105633. * Gets the right camera target of a rig setup in case of Rigged Camera
  105634. * @returns the target position
  105635. */
  105636. getRightTarget(): Nullable<Vector3>;
  105637. /**
  105638. * @hidden
  105639. */
  105640. setCameraRigMode(mode: number, rigParams: any): void;
  105641. /** @hidden */
  105642. static _setStereoscopicRigMode(camera: Camera): void;
  105643. /** @hidden */
  105644. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  105645. /** @hidden */
  105646. static _setVRRigMode(camera: Camera, rigParams: any): void;
  105647. /** @hidden */
  105648. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  105649. /** @hidden */
  105650. _getVRProjectionMatrix(): Matrix;
  105651. protected _updateCameraRotationMatrix(): void;
  105652. protected _updateWebVRCameraRotationMatrix(): void;
  105653. /**
  105654. * This function MUST be overwritten by the different WebVR cameras available.
  105655. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105656. * @hidden
  105657. */
  105658. _getWebVRProjectionMatrix(): Matrix;
  105659. /**
  105660. * This function MUST be overwritten by the different WebVR cameras available.
  105661. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105662. * @hidden
  105663. */
  105664. _getWebVRViewMatrix(): Matrix;
  105665. /** @hidden */
  105666. setCameraRigParameter(name: string, value: any): void;
  105667. /**
  105668. * needs to be overridden by children so sub has required properties to be copied
  105669. * @hidden
  105670. */
  105671. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  105672. /**
  105673. * May need to be overridden by children
  105674. * @hidden
  105675. */
  105676. _updateRigCameras(): void;
  105677. /** @hidden */
  105678. _setupInputs(): void;
  105679. /**
  105680. * Serialiaze the camera setup to a json represention
  105681. * @returns the JSON representation
  105682. */
  105683. serialize(): any;
  105684. /**
  105685. * Clones the current camera.
  105686. * @param name The cloned camera name
  105687. * @returns the cloned camera
  105688. */
  105689. clone(name: string): Camera;
  105690. /**
  105691. * Gets the direction of the camera relative to a given local axis.
  105692. * @param localAxis Defines the reference axis to provide a relative direction.
  105693. * @return the direction
  105694. */
  105695. getDirection(localAxis: Vector3): Vector3;
  105696. /**
  105697. * Returns the current camera absolute rotation
  105698. */
  105699. get absoluteRotation(): Quaternion;
  105700. /**
  105701. * Gets the direction of the camera relative to a given local axis into a passed vector.
  105702. * @param localAxis Defines the reference axis to provide a relative direction.
  105703. * @param result Defines the vector to store the result in
  105704. */
  105705. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  105706. /**
  105707. * Gets a camera constructor for a given camera type
  105708. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  105709. * @param name The name of the camera the result will be able to instantiate
  105710. * @param scene The scene the result will construct the camera in
  105711. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  105712. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  105713. * @returns a factory method to construc the camera
  105714. */
  105715. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  105716. /**
  105717. * Compute the world matrix of the camera.
  105718. * @returns the camera world matrix
  105719. */
  105720. computeWorldMatrix(): Matrix;
  105721. /**
  105722. * Parse a JSON and creates the camera from the parsed information
  105723. * @param parsedCamera The JSON to parse
  105724. * @param scene The scene to instantiate the camera in
  105725. * @returns the newly constructed camera
  105726. */
  105727. static Parse(parsedCamera: any, scene: Scene): Camera;
  105728. }
  105729. }
  105730. declare module BABYLON {
  105731. /**
  105732. * Class containing static functions to help procedurally build meshes
  105733. */
  105734. export class DiscBuilder {
  105735. /**
  105736. * Creates a plane polygonal mesh. By default, this is a disc
  105737. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105738. * * 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
  105739. * * 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
  105740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105743. * @param name defines the name of the mesh
  105744. * @param options defines the options used to create the mesh
  105745. * @param scene defines the hosting scene
  105746. * @returns the plane polygonal mesh
  105747. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105748. */
  105749. static CreateDisc(name: string, options: {
  105750. radius?: number;
  105751. tessellation?: number;
  105752. arc?: number;
  105753. updatable?: boolean;
  105754. sideOrientation?: number;
  105755. frontUVs?: Vector4;
  105756. backUVs?: Vector4;
  105757. }, scene?: Nullable<Scene>): Mesh;
  105758. }
  105759. }
  105760. declare module BABYLON {
  105761. /**
  105762. * Options to be used when creating a FresnelParameters.
  105763. */
  105764. export type IFresnelParametersCreationOptions = {
  105765. /**
  105766. * Define the color used on edges (grazing angle)
  105767. */
  105768. leftColor?: Color3;
  105769. /**
  105770. * Define the color used on center
  105771. */
  105772. rightColor?: Color3;
  105773. /**
  105774. * Define bias applied to computed fresnel term
  105775. */
  105776. bias?: number;
  105777. /**
  105778. * Defined the power exponent applied to fresnel term
  105779. */
  105780. power?: number;
  105781. /**
  105782. * Define if the fresnel effect is enable or not.
  105783. */
  105784. isEnabled?: boolean;
  105785. };
  105786. /**
  105787. * Serialized format for FresnelParameters.
  105788. */
  105789. export type IFresnelParametersSerialized = {
  105790. /**
  105791. * Define the color used on edges (grazing angle) [as an array]
  105792. */
  105793. leftColor: number[];
  105794. /**
  105795. * Define the color used on center [as an array]
  105796. */
  105797. rightColor: number[];
  105798. /**
  105799. * Define bias applied to computed fresnel term
  105800. */
  105801. bias: number;
  105802. /**
  105803. * Defined the power exponent applied to fresnel term
  105804. */
  105805. power?: number;
  105806. /**
  105807. * Define if the fresnel effect is enable or not.
  105808. */
  105809. isEnabled: boolean;
  105810. };
  105811. /**
  105812. * This represents all the required information to add a fresnel effect on a material:
  105813. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105814. */
  105815. export class FresnelParameters {
  105816. private _isEnabled;
  105817. /**
  105818. * Define if the fresnel effect is enable or not.
  105819. */
  105820. get isEnabled(): boolean;
  105821. set isEnabled(value: boolean);
  105822. /**
  105823. * Define the color used on edges (grazing angle)
  105824. */
  105825. leftColor: Color3;
  105826. /**
  105827. * Define the color used on center
  105828. */
  105829. rightColor: Color3;
  105830. /**
  105831. * Define bias applied to computed fresnel term
  105832. */
  105833. bias: number;
  105834. /**
  105835. * Defined the power exponent applied to fresnel term
  105836. */
  105837. power: number;
  105838. /**
  105839. * Creates a new FresnelParameters object.
  105840. *
  105841. * @param options provide your own settings to optionally to override defaults
  105842. */
  105843. constructor(options?: IFresnelParametersCreationOptions);
  105844. /**
  105845. * Clones the current fresnel and its valuues
  105846. * @returns a clone fresnel configuration
  105847. */
  105848. clone(): FresnelParameters;
  105849. /**
  105850. * Determines equality between FresnelParameters objects
  105851. * @param otherFresnelParameters defines the second operand
  105852. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  105853. */
  105854. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  105855. /**
  105856. * Serializes the current fresnel parameters to a JSON representation.
  105857. * @return the JSON serialization
  105858. */
  105859. serialize(): IFresnelParametersSerialized;
  105860. /**
  105861. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  105862. * @param parsedFresnelParameters Define the JSON representation
  105863. * @returns the parsed parameters
  105864. */
  105865. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  105866. }
  105867. }
  105868. declare module BABYLON {
  105869. /**
  105870. * This groups all the flags used to control the materials channel.
  105871. */
  105872. export class MaterialFlags {
  105873. private static _DiffuseTextureEnabled;
  105874. /**
  105875. * Are diffuse textures enabled in the application.
  105876. */
  105877. static get DiffuseTextureEnabled(): boolean;
  105878. static set DiffuseTextureEnabled(value: boolean);
  105879. private static _AmbientTextureEnabled;
  105880. /**
  105881. * Are ambient textures enabled in the application.
  105882. */
  105883. static get AmbientTextureEnabled(): boolean;
  105884. static set AmbientTextureEnabled(value: boolean);
  105885. private static _OpacityTextureEnabled;
  105886. /**
  105887. * Are opacity textures enabled in the application.
  105888. */
  105889. static get OpacityTextureEnabled(): boolean;
  105890. static set OpacityTextureEnabled(value: boolean);
  105891. private static _ReflectionTextureEnabled;
  105892. /**
  105893. * Are reflection textures enabled in the application.
  105894. */
  105895. static get ReflectionTextureEnabled(): boolean;
  105896. static set ReflectionTextureEnabled(value: boolean);
  105897. private static _EmissiveTextureEnabled;
  105898. /**
  105899. * Are emissive textures enabled in the application.
  105900. */
  105901. static get EmissiveTextureEnabled(): boolean;
  105902. static set EmissiveTextureEnabled(value: boolean);
  105903. private static _SpecularTextureEnabled;
  105904. /**
  105905. * Are specular textures enabled in the application.
  105906. */
  105907. static get SpecularTextureEnabled(): boolean;
  105908. static set SpecularTextureEnabled(value: boolean);
  105909. private static _BumpTextureEnabled;
  105910. /**
  105911. * Are bump textures enabled in the application.
  105912. */
  105913. static get BumpTextureEnabled(): boolean;
  105914. static set BumpTextureEnabled(value: boolean);
  105915. private static _LightmapTextureEnabled;
  105916. /**
  105917. * Are lightmap textures enabled in the application.
  105918. */
  105919. static get LightmapTextureEnabled(): boolean;
  105920. static set LightmapTextureEnabled(value: boolean);
  105921. private static _RefractionTextureEnabled;
  105922. /**
  105923. * Are refraction textures enabled in the application.
  105924. */
  105925. static get RefractionTextureEnabled(): boolean;
  105926. static set RefractionTextureEnabled(value: boolean);
  105927. private static _ColorGradingTextureEnabled;
  105928. /**
  105929. * Are color grading textures enabled in the application.
  105930. */
  105931. static get ColorGradingTextureEnabled(): boolean;
  105932. static set ColorGradingTextureEnabled(value: boolean);
  105933. private static _FresnelEnabled;
  105934. /**
  105935. * Are fresnels enabled in the application.
  105936. */
  105937. static get FresnelEnabled(): boolean;
  105938. static set FresnelEnabled(value: boolean);
  105939. private static _ClearCoatTextureEnabled;
  105940. /**
  105941. * Are clear coat textures enabled in the application.
  105942. */
  105943. static get ClearCoatTextureEnabled(): boolean;
  105944. static set ClearCoatTextureEnabled(value: boolean);
  105945. private static _ClearCoatBumpTextureEnabled;
  105946. /**
  105947. * Are clear coat bump textures enabled in the application.
  105948. */
  105949. static get ClearCoatBumpTextureEnabled(): boolean;
  105950. static set ClearCoatBumpTextureEnabled(value: boolean);
  105951. private static _ClearCoatTintTextureEnabled;
  105952. /**
  105953. * Are clear coat tint textures enabled in the application.
  105954. */
  105955. static get ClearCoatTintTextureEnabled(): boolean;
  105956. static set ClearCoatTintTextureEnabled(value: boolean);
  105957. private static _SheenTextureEnabled;
  105958. /**
  105959. * Are sheen textures enabled in the application.
  105960. */
  105961. static get SheenTextureEnabled(): boolean;
  105962. static set SheenTextureEnabled(value: boolean);
  105963. private static _AnisotropicTextureEnabled;
  105964. /**
  105965. * Are anisotropic textures enabled in the application.
  105966. */
  105967. static get AnisotropicTextureEnabled(): boolean;
  105968. static set AnisotropicTextureEnabled(value: boolean);
  105969. private static _ThicknessTextureEnabled;
  105970. /**
  105971. * Are thickness textures enabled in the application.
  105972. */
  105973. static get ThicknessTextureEnabled(): boolean;
  105974. static set ThicknessTextureEnabled(value: boolean);
  105975. }
  105976. }
  105977. declare module BABYLON {
  105978. /** @hidden */
  105979. export var defaultFragmentDeclaration: {
  105980. name: string;
  105981. shader: string;
  105982. };
  105983. }
  105984. declare module BABYLON {
  105985. /** @hidden */
  105986. export var defaultUboDeclaration: {
  105987. name: string;
  105988. shader: string;
  105989. };
  105990. }
  105991. declare module BABYLON {
  105992. /** @hidden */
  105993. export var lightFragmentDeclaration: {
  105994. name: string;
  105995. shader: string;
  105996. };
  105997. }
  105998. declare module BABYLON {
  105999. /** @hidden */
  106000. export var lightUboDeclaration: {
  106001. name: string;
  106002. shader: string;
  106003. };
  106004. }
  106005. declare module BABYLON {
  106006. /** @hidden */
  106007. export var lightsFragmentFunctions: {
  106008. name: string;
  106009. shader: string;
  106010. };
  106011. }
  106012. declare module BABYLON {
  106013. /** @hidden */
  106014. export var shadowsFragmentFunctions: {
  106015. name: string;
  106016. shader: string;
  106017. };
  106018. }
  106019. declare module BABYLON {
  106020. /** @hidden */
  106021. export var fresnelFunction: {
  106022. name: string;
  106023. shader: string;
  106024. };
  106025. }
  106026. declare module BABYLON {
  106027. /** @hidden */
  106028. export var bumpFragmentMainFunctions: {
  106029. name: string;
  106030. shader: string;
  106031. };
  106032. }
  106033. declare module BABYLON {
  106034. /** @hidden */
  106035. export var bumpFragmentFunctions: {
  106036. name: string;
  106037. shader: string;
  106038. };
  106039. }
  106040. declare module BABYLON {
  106041. /** @hidden */
  106042. export var logDepthDeclaration: {
  106043. name: string;
  106044. shader: string;
  106045. };
  106046. }
  106047. declare module BABYLON {
  106048. /** @hidden */
  106049. export var bumpFragment: {
  106050. name: string;
  106051. shader: string;
  106052. };
  106053. }
  106054. declare module BABYLON {
  106055. /** @hidden */
  106056. export var depthPrePass: {
  106057. name: string;
  106058. shader: string;
  106059. };
  106060. }
  106061. declare module BABYLON {
  106062. /** @hidden */
  106063. export var lightFragment: {
  106064. name: string;
  106065. shader: string;
  106066. };
  106067. }
  106068. declare module BABYLON {
  106069. /** @hidden */
  106070. export var logDepthFragment: {
  106071. name: string;
  106072. shader: string;
  106073. };
  106074. }
  106075. declare module BABYLON {
  106076. /** @hidden */
  106077. export var defaultPixelShader: {
  106078. name: string;
  106079. shader: string;
  106080. };
  106081. }
  106082. declare module BABYLON {
  106083. /** @hidden */
  106084. export var defaultVertexDeclaration: {
  106085. name: string;
  106086. shader: string;
  106087. };
  106088. }
  106089. declare module BABYLON {
  106090. /** @hidden */
  106091. export var bumpVertexDeclaration: {
  106092. name: string;
  106093. shader: string;
  106094. };
  106095. }
  106096. declare module BABYLON {
  106097. /** @hidden */
  106098. export var bumpVertex: {
  106099. name: string;
  106100. shader: string;
  106101. };
  106102. }
  106103. declare module BABYLON {
  106104. /** @hidden */
  106105. export var fogVertex: {
  106106. name: string;
  106107. shader: string;
  106108. };
  106109. }
  106110. declare module BABYLON {
  106111. /** @hidden */
  106112. export var shadowsVertex: {
  106113. name: string;
  106114. shader: string;
  106115. };
  106116. }
  106117. declare module BABYLON {
  106118. /** @hidden */
  106119. export var pointCloudVertex: {
  106120. name: string;
  106121. shader: string;
  106122. };
  106123. }
  106124. declare module BABYLON {
  106125. /** @hidden */
  106126. export var logDepthVertex: {
  106127. name: string;
  106128. shader: string;
  106129. };
  106130. }
  106131. declare module BABYLON {
  106132. /** @hidden */
  106133. export var defaultVertexShader: {
  106134. name: string;
  106135. shader: string;
  106136. };
  106137. }
  106138. declare module BABYLON {
  106139. /** @hidden */
  106140. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106141. MAINUV1: boolean;
  106142. MAINUV2: boolean;
  106143. DIFFUSE: boolean;
  106144. DIFFUSEDIRECTUV: number;
  106145. AMBIENT: boolean;
  106146. AMBIENTDIRECTUV: number;
  106147. OPACITY: boolean;
  106148. OPACITYDIRECTUV: number;
  106149. OPACITYRGB: boolean;
  106150. REFLECTION: boolean;
  106151. EMISSIVE: boolean;
  106152. EMISSIVEDIRECTUV: number;
  106153. SPECULAR: boolean;
  106154. SPECULARDIRECTUV: number;
  106155. BUMP: boolean;
  106156. BUMPDIRECTUV: number;
  106157. PARALLAX: boolean;
  106158. PARALLAXOCCLUSION: boolean;
  106159. SPECULAROVERALPHA: boolean;
  106160. CLIPPLANE: boolean;
  106161. CLIPPLANE2: boolean;
  106162. CLIPPLANE3: boolean;
  106163. CLIPPLANE4: boolean;
  106164. CLIPPLANE5: boolean;
  106165. CLIPPLANE6: boolean;
  106166. ALPHATEST: boolean;
  106167. DEPTHPREPASS: boolean;
  106168. ALPHAFROMDIFFUSE: boolean;
  106169. POINTSIZE: boolean;
  106170. FOG: boolean;
  106171. SPECULARTERM: boolean;
  106172. DIFFUSEFRESNEL: boolean;
  106173. OPACITYFRESNEL: boolean;
  106174. REFLECTIONFRESNEL: boolean;
  106175. REFRACTIONFRESNEL: boolean;
  106176. EMISSIVEFRESNEL: boolean;
  106177. FRESNEL: boolean;
  106178. NORMAL: boolean;
  106179. UV1: boolean;
  106180. UV2: boolean;
  106181. VERTEXCOLOR: boolean;
  106182. VERTEXALPHA: boolean;
  106183. NUM_BONE_INFLUENCERS: number;
  106184. BonesPerMesh: number;
  106185. BONETEXTURE: boolean;
  106186. INSTANCES: boolean;
  106187. GLOSSINESS: boolean;
  106188. ROUGHNESS: boolean;
  106189. EMISSIVEASILLUMINATION: boolean;
  106190. LINKEMISSIVEWITHDIFFUSE: boolean;
  106191. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106192. LIGHTMAP: boolean;
  106193. LIGHTMAPDIRECTUV: number;
  106194. OBJECTSPACE_NORMALMAP: boolean;
  106195. USELIGHTMAPASSHADOWMAP: boolean;
  106196. REFLECTIONMAP_3D: boolean;
  106197. REFLECTIONMAP_SPHERICAL: boolean;
  106198. REFLECTIONMAP_PLANAR: boolean;
  106199. REFLECTIONMAP_CUBIC: boolean;
  106200. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106201. REFLECTIONMAP_PROJECTION: boolean;
  106202. REFLECTIONMAP_SKYBOX: boolean;
  106203. REFLECTIONMAP_EXPLICIT: boolean;
  106204. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106205. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106206. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106207. INVERTCUBICMAP: boolean;
  106208. LOGARITHMICDEPTH: boolean;
  106209. REFRACTION: boolean;
  106210. REFRACTIONMAP_3D: boolean;
  106211. REFLECTIONOVERALPHA: boolean;
  106212. TWOSIDEDLIGHTING: boolean;
  106213. SHADOWFLOAT: boolean;
  106214. MORPHTARGETS: boolean;
  106215. MORPHTARGETS_NORMAL: boolean;
  106216. MORPHTARGETS_TANGENT: boolean;
  106217. MORPHTARGETS_UV: boolean;
  106218. NUM_MORPH_INFLUENCERS: number;
  106219. NONUNIFORMSCALING: boolean;
  106220. PREMULTIPLYALPHA: boolean;
  106221. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106222. ALPHABLEND: boolean;
  106223. RGBDLIGHTMAP: boolean;
  106224. RGBDREFLECTION: boolean;
  106225. RGBDREFRACTION: boolean;
  106226. IMAGEPROCESSING: boolean;
  106227. VIGNETTE: boolean;
  106228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106229. VIGNETTEBLENDMODEOPAQUE: boolean;
  106230. TONEMAPPING: boolean;
  106231. TONEMAPPING_ACES: boolean;
  106232. CONTRAST: boolean;
  106233. COLORCURVES: boolean;
  106234. COLORGRADING: boolean;
  106235. COLORGRADING3D: boolean;
  106236. SAMPLER3DGREENDEPTH: boolean;
  106237. SAMPLER3DBGRMAP: boolean;
  106238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106239. MULTIVIEW: boolean;
  106240. /**
  106241. * If the reflection texture on this material is in linear color space
  106242. * @hidden
  106243. */
  106244. IS_REFLECTION_LINEAR: boolean;
  106245. /**
  106246. * If the refraction texture on this material is in linear color space
  106247. * @hidden
  106248. */
  106249. IS_REFRACTION_LINEAR: boolean;
  106250. EXPOSURE: boolean;
  106251. constructor();
  106252. setReflectionMode(modeToEnable: string): void;
  106253. }
  106254. /**
  106255. * This is the default material used in Babylon. It is the best trade off between quality
  106256. * and performances.
  106257. * @see http://doc.babylonjs.com/babylon101/materials
  106258. */
  106259. export class StandardMaterial extends PushMaterial {
  106260. private _diffuseTexture;
  106261. /**
  106262. * The basic texture of the material as viewed under a light.
  106263. */
  106264. diffuseTexture: Nullable<BaseTexture>;
  106265. private _ambientTexture;
  106266. /**
  106267. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106268. */
  106269. ambientTexture: Nullable<BaseTexture>;
  106270. private _opacityTexture;
  106271. /**
  106272. * Define the transparency of the material from a texture.
  106273. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106274. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106275. */
  106276. opacityTexture: Nullable<BaseTexture>;
  106277. private _reflectionTexture;
  106278. /**
  106279. * Define the texture used to display the reflection.
  106280. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106281. */
  106282. reflectionTexture: Nullable<BaseTexture>;
  106283. private _emissiveTexture;
  106284. /**
  106285. * Define texture of the material as if self lit.
  106286. * This will be mixed in the final result even in the absence of light.
  106287. */
  106288. emissiveTexture: Nullable<BaseTexture>;
  106289. private _specularTexture;
  106290. /**
  106291. * Define how the color and intensity of the highlight given by the light in the material.
  106292. */
  106293. specularTexture: Nullable<BaseTexture>;
  106294. private _bumpTexture;
  106295. /**
  106296. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106297. * 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.
  106298. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106299. */
  106300. bumpTexture: Nullable<BaseTexture>;
  106301. private _lightmapTexture;
  106302. /**
  106303. * Complex lighting can be computationally expensive to compute at runtime.
  106304. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106305. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106306. */
  106307. lightmapTexture: Nullable<BaseTexture>;
  106308. private _refractionTexture;
  106309. /**
  106310. * Define the texture used to display the refraction.
  106311. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106312. */
  106313. refractionTexture: Nullable<BaseTexture>;
  106314. /**
  106315. * The color of the material lit by the environmental background lighting.
  106316. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106317. */
  106318. ambientColor: Color3;
  106319. /**
  106320. * The basic color of the material as viewed under a light.
  106321. */
  106322. diffuseColor: Color3;
  106323. /**
  106324. * Define how the color and intensity of the highlight given by the light in the material.
  106325. */
  106326. specularColor: Color3;
  106327. /**
  106328. * Define the color of the material as if self lit.
  106329. * This will be mixed in the final result even in the absence of light.
  106330. */
  106331. emissiveColor: Color3;
  106332. /**
  106333. * Defines how sharp are the highlights in the material.
  106334. * The bigger the value the sharper giving a more glossy feeling to the result.
  106335. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106336. */
  106337. specularPower: number;
  106338. private _useAlphaFromDiffuseTexture;
  106339. /**
  106340. * Does the transparency come from the diffuse texture alpha channel.
  106341. */
  106342. useAlphaFromDiffuseTexture: boolean;
  106343. private _useEmissiveAsIllumination;
  106344. /**
  106345. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106346. */
  106347. useEmissiveAsIllumination: boolean;
  106348. private _linkEmissiveWithDiffuse;
  106349. /**
  106350. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106351. * the emissive level when the final color is close to one.
  106352. */
  106353. linkEmissiveWithDiffuse: boolean;
  106354. private _useSpecularOverAlpha;
  106355. /**
  106356. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106357. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106358. */
  106359. useSpecularOverAlpha: boolean;
  106360. private _useReflectionOverAlpha;
  106361. /**
  106362. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106363. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106364. */
  106365. useReflectionOverAlpha: boolean;
  106366. private _disableLighting;
  106367. /**
  106368. * Does lights from the scene impacts this material.
  106369. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106370. */
  106371. disableLighting: boolean;
  106372. private _useObjectSpaceNormalMap;
  106373. /**
  106374. * Allows using an object space normal map (instead of tangent space).
  106375. */
  106376. useObjectSpaceNormalMap: boolean;
  106377. private _useParallax;
  106378. /**
  106379. * Is parallax enabled or not.
  106380. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106381. */
  106382. useParallax: boolean;
  106383. private _useParallaxOcclusion;
  106384. /**
  106385. * Is parallax occlusion enabled or not.
  106386. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106387. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106388. */
  106389. useParallaxOcclusion: boolean;
  106390. /**
  106391. * 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.
  106392. */
  106393. parallaxScaleBias: number;
  106394. private _roughness;
  106395. /**
  106396. * Helps to define how blurry the reflections should appears in the material.
  106397. */
  106398. roughness: number;
  106399. /**
  106400. * In case of refraction, define the value of the index of refraction.
  106401. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106402. */
  106403. indexOfRefraction: number;
  106404. /**
  106405. * Invert the refraction texture alongside the y axis.
  106406. * It can be useful with procedural textures or probe for instance.
  106407. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106408. */
  106409. invertRefractionY: boolean;
  106410. /**
  106411. * Defines the alpha limits in alpha test mode.
  106412. */
  106413. alphaCutOff: number;
  106414. private _useLightmapAsShadowmap;
  106415. /**
  106416. * In case of light mapping, define whether the map contains light or shadow informations.
  106417. */
  106418. useLightmapAsShadowmap: boolean;
  106419. private _diffuseFresnelParameters;
  106420. /**
  106421. * Define the diffuse fresnel parameters of the material.
  106422. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106423. */
  106424. diffuseFresnelParameters: FresnelParameters;
  106425. private _opacityFresnelParameters;
  106426. /**
  106427. * Define the opacity fresnel parameters of the material.
  106428. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106429. */
  106430. opacityFresnelParameters: FresnelParameters;
  106431. private _reflectionFresnelParameters;
  106432. /**
  106433. * Define the reflection fresnel parameters of the material.
  106434. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106435. */
  106436. reflectionFresnelParameters: FresnelParameters;
  106437. private _refractionFresnelParameters;
  106438. /**
  106439. * Define the refraction fresnel parameters of the material.
  106440. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106441. */
  106442. refractionFresnelParameters: FresnelParameters;
  106443. private _emissiveFresnelParameters;
  106444. /**
  106445. * Define the emissive fresnel parameters of the material.
  106446. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106447. */
  106448. emissiveFresnelParameters: FresnelParameters;
  106449. private _useReflectionFresnelFromSpecular;
  106450. /**
  106451. * If true automatically deducts the fresnels values from the material specularity.
  106452. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106453. */
  106454. useReflectionFresnelFromSpecular: boolean;
  106455. private _useGlossinessFromSpecularMapAlpha;
  106456. /**
  106457. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106458. */
  106459. useGlossinessFromSpecularMapAlpha: boolean;
  106460. private _maxSimultaneousLights;
  106461. /**
  106462. * Defines the maximum number of lights that can be used in the material
  106463. */
  106464. maxSimultaneousLights: number;
  106465. private _invertNormalMapX;
  106466. /**
  106467. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106468. */
  106469. invertNormalMapX: boolean;
  106470. private _invertNormalMapY;
  106471. /**
  106472. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106473. */
  106474. invertNormalMapY: boolean;
  106475. private _twoSidedLighting;
  106476. /**
  106477. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106478. */
  106479. twoSidedLighting: boolean;
  106480. /**
  106481. * Default configuration related to image processing available in the standard Material.
  106482. */
  106483. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106484. /**
  106485. * Gets the image processing configuration used either in this material.
  106486. */
  106487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106488. /**
  106489. * Sets the Default image processing configuration used either in the this material.
  106490. *
  106491. * If sets to null, the scene one is in use.
  106492. */
  106493. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  106494. /**
  106495. * Keep track of the image processing observer to allow dispose and replace.
  106496. */
  106497. private _imageProcessingObserver;
  106498. /**
  106499. * Attaches a new image processing configuration to the Standard Material.
  106500. * @param configuration
  106501. */
  106502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106503. /**
  106504. * Gets wether the color curves effect is enabled.
  106505. */
  106506. get cameraColorCurvesEnabled(): boolean;
  106507. /**
  106508. * Sets wether the color curves effect is enabled.
  106509. */
  106510. set cameraColorCurvesEnabled(value: boolean);
  106511. /**
  106512. * Gets wether the color grading effect is enabled.
  106513. */
  106514. get cameraColorGradingEnabled(): boolean;
  106515. /**
  106516. * Gets wether the color grading effect is enabled.
  106517. */
  106518. set cameraColorGradingEnabled(value: boolean);
  106519. /**
  106520. * Gets wether tonemapping is enabled or not.
  106521. */
  106522. get cameraToneMappingEnabled(): boolean;
  106523. /**
  106524. * Sets wether tonemapping is enabled or not
  106525. */
  106526. set cameraToneMappingEnabled(value: boolean);
  106527. /**
  106528. * The camera exposure used on this material.
  106529. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106530. * This corresponds to a photographic exposure.
  106531. */
  106532. get cameraExposure(): number;
  106533. /**
  106534. * The camera exposure used on this material.
  106535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106536. * This corresponds to a photographic exposure.
  106537. */
  106538. set cameraExposure(value: number);
  106539. /**
  106540. * Gets The camera contrast used on this material.
  106541. */
  106542. get cameraContrast(): number;
  106543. /**
  106544. * Sets The camera contrast used on this material.
  106545. */
  106546. set cameraContrast(value: number);
  106547. /**
  106548. * Gets the Color Grading 2D Lookup Texture.
  106549. */
  106550. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  106551. /**
  106552. * Sets the Color Grading 2D Lookup Texture.
  106553. */
  106554. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  106555. /**
  106556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106558. * 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;
  106559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106560. */
  106561. get cameraColorCurves(): Nullable<ColorCurves>;
  106562. /**
  106563. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106564. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106565. * 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;
  106566. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106567. */
  106568. set cameraColorCurves(value: Nullable<ColorCurves>);
  106569. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106570. protected _worldViewProjectionMatrix: Matrix;
  106571. protected _globalAmbientColor: Color3;
  106572. protected _useLogarithmicDepth: boolean;
  106573. protected _rebuildInParallel: boolean;
  106574. /**
  106575. * Instantiates a new standard material.
  106576. * This is the default material used in Babylon. It is the best trade off between quality
  106577. * and performances.
  106578. * @see http://doc.babylonjs.com/babylon101/materials
  106579. * @param name Define the name of the material in the scene
  106580. * @param scene Define the scene the material belong to
  106581. */
  106582. constructor(name: string, scene: Scene);
  106583. /**
  106584. * Gets a boolean indicating that current material needs to register RTT
  106585. */
  106586. get hasRenderTargetTextures(): boolean;
  106587. /**
  106588. * Gets the current class name of the material e.g. "StandardMaterial"
  106589. * Mainly use in serialization.
  106590. * @returns the class name
  106591. */
  106592. getClassName(): string;
  106593. /**
  106594. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106595. * You can try switching to logarithmic depth.
  106596. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106597. */
  106598. get useLogarithmicDepth(): boolean;
  106599. set useLogarithmicDepth(value: boolean);
  106600. /**
  106601. * Specifies if the material will require alpha blending
  106602. * @returns a boolean specifying if alpha blending is needed
  106603. */
  106604. needAlphaBlending(): boolean;
  106605. /**
  106606. * Specifies if this material should be rendered in alpha test mode
  106607. * @returns a boolean specifying if an alpha test is needed.
  106608. */
  106609. needAlphaTesting(): boolean;
  106610. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106611. /**
  106612. * Get the texture used for alpha test purpose.
  106613. * @returns the diffuse texture in case of the standard material.
  106614. */
  106615. getAlphaTestTexture(): Nullable<BaseTexture>;
  106616. /**
  106617. * Get if the submesh is ready to be used and all its information available.
  106618. * Child classes can use it to update shaders
  106619. * @param mesh defines the mesh to check
  106620. * @param subMesh defines which submesh to check
  106621. * @param useInstances specifies that instances should be used
  106622. * @returns a boolean indicating that the submesh is ready or not
  106623. */
  106624. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106625. /**
  106626. * Builds the material UBO layouts.
  106627. * Used internally during the effect preparation.
  106628. */
  106629. buildUniformLayout(): void;
  106630. /**
  106631. * Unbinds the material from the mesh
  106632. */
  106633. unbind(): void;
  106634. /**
  106635. * Binds the submesh to this material by preparing the effect and shader to draw
  106636. * @param world defines the world transformation matrix
  106637. * @param mesh defines the mesh containing the submesh
  106638. * @param subMesh defines the submesh to bind the material to
  106639. */
  106640. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106641. /**
  106642. * Get the list of animatables in the material.
  106643. * @returns the list of animatables object used in the material
  106644. */
  106645. getAnimatables(): IAnimatable[];
  106646. /**
  106647. * Gets the active textures from the material
  106648. * @returns an array of textures
  106649. */
  106650. getActiveTextures(): BaseTexture[];
  106651. /**
  106652. * Specifies if the material uses a texture
  106653. * @param texture defines the texture to check against the material
  106654. * @returns a boolean specifying if the material uses the texture
  106655. */
  106656. hasTexture(texture: BaseTexture): boolean;
  106657. /**
  106658. * Disposes the material
  106659. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106660. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106661. */
  106662. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106663. /**
  106664. * Makes a duplicate of the material, and gives it a new name
  106665. * @param name defines the new name for the duplicated material
  106666. * @returns the cloned material
  106667. */
  106668. clone(name: string): StandardMaterial;
  106669. /**
  106670. * Serializes this material in a JSON representation
  106671. * @returns the serialized material object
  106672. */
  106673. serialize(): any;
  106674. /**
  106675. * Creates a standard material from parsed material data
  106676. * @param source defines the JSON representation of the material
  106677. * @param scene defines the hosting scene
  106678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106679. * @returns a new standard material
  106680. */
  106681. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106682. /**
  106683. * Are diffuse textures enabled in the application.
  106684. */
  106685. static get DiffuseTextureEnabled(): boolean;
  106686. static set DiffuseTextureEnabled(value: boolean);
  106687. /**
  106688. * Are ambient textures enabled in the application.
  106689. */
  106690. static get AmbientTextureEnabled(): boolean;
  106691. static set AmbientTextureEnabled(value: boolean);
  106692. /**
  106693. * Are opacity textures enabled in the application.
  106694. */
  106695. static get OpacityTextureEnabled(): boolean;
  106696. static set OpacityTextureEnabled(value: boolean);
  106697. /**
  106698. * Are reflection textures enabled in the application.
  106699. */
  106700. static get ReflectionTextureEnabled(): boolean;
  106701. static set ReflectionTextureEnabled(value: boolean);
  106702. /**
  106703. * Are emissive textures enabled in the application.
  106704. */
  106705. static get EmissiveTextureEnabled(): boolean;
  106706. static set EmissiveTextureEnabled(value: boolean);
  106707. /**
  106708. * Are specular textures enabled in the application.
  106709. */
  106710. static get SpecularTextureEnabled(): boolean;
  106711. static set SpecularTextureEnabled(value: boolean);
  106712. /**
  106713. * Are bump textures enabled in the application.
  106714. */
  106715. static get BumpTextureEnabled(): boolean;
  106716. static set BumpTextureEnabled(value: boolean);
  106717. /**
  106718. * Are lightmap textures enabled in the application.
  106719. */
  106720. static get LightmapTextureEnabled(): boolean;
  106721. static set LightmapTextureEnabled(value: boolean);
  106722. /**
  106723. * Are refraction textures enabled in the application.
  106724. */
  106725. static get RefractionTextureEnabled(): boolean;
  106726. static set RefractionTextureEnabled(value: boolean);
  106727. /**
  106728. * Are color grading textures enabled in the application.
  106729. */
  106730. static get ColorGradingTextureEnabled(): boolean;
  106731. static set ColorGradingTextureEnabled(value: boolean);
  106732. /**
  106733. * Are fresnels enabled in the application.
  106734. */
  106735. static get FresnelEnabled(): boolean;
  106736. static set FresnelEnabled(value: boolean);
  106737. }
  106738. }
  106739. declare module BABYLON {
  106740. /**
  106741. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  106742. *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.
  106743. * The SPS is also a particle system. It provides some methods to manage the particles.
  106744. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  106745. *
  106746. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  106747. */
  106748. export class SolidParticleSystem implements IDisposable {
  106749. /**
  106750. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  106751. * Example : var p = SPS.particles[i];
  106752. */
  106753. particles: SolidParticle[];
  106754. /**
  106755. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  106756. */
  106757. nbParticles: number;
  106758. /**
  106759. * If the particles must ever face the camera (default false). Useful for planar particles.
  106760. */
  106761. billboard: boolean;
  106762. /**
  106763. * Recompute normals when adding a shape
  106764. */
  106765. recomputeNormals: boolean;
  106766. /**
  106767. * This a counter ofr your own usage. It's not set by any SPS functions.
  106768. */
  106769. counter: number;
  106770. /**
  106771. * The SPS name. This name is also given to the underlying mesh.
  106772. */
  106773. name: string;
  106774. /**
  106775. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  106776. */
  106777. mesh: Mesh;
  106778. /**
  106779. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  106780. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  106781. */
  106782. vars: any;
  106783. /**
  106784. * This array is populated when the SPS is set as 'pickable'.
  106785. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  106786. * Each element of this array is an object `{idx: int, faceId: int}`.
  106787. * `idx` is the picked particle index in the `SPS.particles` array
  106788. * `faceId` is the picked face index counted within this particle.
  106789. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  106790. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  106791. * Use the method SPS.pickedParticle(pickingInfo) instead.
  106792. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  106793. */
  106794. pickedParticles: {
  106795. idx: number;
  106796. faceId: number;
  106797. }[];
  106798. /**
  106799. * This array is populated when the SPS is set as 'pickable'
  106800. * Each key of this array is a submesh index.
  106801. * Each element of this array is a second array defined like this :
  106802. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  106803. * Each element of this second array is an object `{idx: int, faceId: int}`.
  106804. * `idx` is the picked particle index in the `SPS.particles` array
  106805. * `faceId` is the picked face index counted within this particle.
  106806. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  106807. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  106808. */
  106809. pickedBySubMesh: {
  106810. idx: number;
  106811. faceId: number;
  106812. }[][];
  106813. /**
  106814. * This array is populated when `enableDepthSort` is set to true.
  106815. * Each element of this array is an instance of the class DepthSortedParticle.
  106816. */
  106817. depthSortedParticles: DepthSortedParticle[];
  106818. /**
  106819. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  106820. * @hidden
  106821. */
  106822. _bSphereOnly: boolean;
  106823. /**
  106824. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  106825. * @hidden
  106826. */
  106827. _bSphereRadiusFactor: number;
  106828. private _scene;
  106829. private _positions;
  106830. private _indices;
  106831. private _normals;
  106832. private _colors;
  106833. private _uvs;
  106834. private _indices32;
  106835. private _positions32;
  106836. private _normals32;
  106837. private _fixedNormal32;
  106838. private _colors32;
  106839. private _uvs32;
  106840. private _index;
  106841. private _updatable;
  106842. private _pickable;
  106843. private _isVisibilityBoxLocked;
  106844. private _alwaysVisible;
  106845. private _depthSort;
  106846. private _expandable;
  106847. private _shapeCounter;
  106848. private _copy;
  106849. private _color;
  106850. private _computeParticleColor;
  106851. private _computeParticleTexture;
  106852. private _computeParticleRotation;
  106853. private _computeParticleVertex;
  106854. private _computeBoundingBox;
  106855. private _depthSortParticles;
  106856. private _camera;
  106857. private _mustUnrotateFixedNormals;
  106858. private _particlesIntersect;
  106859. private _needs32Bits;
  106860. private _isNotBuilt;
  106861. private _lastParticleId;
  106862. private _idxOfId;
  106863. private _multimaterialEnabled;
  106864. private _useModelMaterial;
  106865. private _indicesByMaterial;
  106866. private _materialIndexes;
  106867. private _depthSortFunction;
  106868. private _materialSortFunction;
  106869. private _materials;
  106870. private _multimaterial;
  106871. private _materialIndexesById;
  106872. private _defaultMaterial;
  106873. private _autoUpdateSubMeshes;
  106874. private _tmpVertex;
  106875. /**
  106876. * Creates a SPS (Solid Particle System) object.
  106877. * @param name (String) is the SPS name, this will be the underlying mesh name.
  106878. * @param scene (Scene) is the scene in which the SPS is added.
  106879. * @param options defines the options of the sps e.g.
  106880. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  106881. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  106882. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  106883. * * 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.
  106884. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  106885. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  106886. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  106887. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  106888. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  106889. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  106890. */
  106891. constructor(name: string, scene: Scene, options?: {
  106892. updatable?: boolean;
  106893. isPickable?: boolean;
  106894. enableDepthSort?: boolean;
  106895. particleIntersection?: boolean;
  106896. boundingSphereOnly?: boolean;
  106897. bSphereRadiusFactor?: number;
  106898. expandable?: boolean;
  106899. useModelMaterial?: boolean;
  106900. enableMultiMaterial?: boolean;
  106901. });
  106902. /**
  106903. * Builds the SPS underlying mesh. Returns a standard Mesh.
  106904. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  106905. * @returns the created mesh
  106906. */
  106907. buildMesh(): Mesh;
  106908. /**
  106909. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  106910. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  106911. * Thus the particles generated from `digest()` have their property `position` set yet.
  106912. * @param mesh ( Mesh ) is the mesh to be digested
  106913. * @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
  106914. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  106915. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  106916. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  106917. * @returns the current SPS
  106918. */
  106919. digest(mesh: Mesh, options?: {
  106920. facetNb?: number;
  106921. number?: number;
  106922. delta?: number;
  106923. storage?: [];
  106924. }): SolidParticleSystem;
  106925. /**
  106926. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  106927. * @hidden
  106928. */
  106929. private _unrotateFixedNormals;
  106930. /**
  106931. * Resets the temporary working copy particle
  106932. * @hidden
  106933. */
  106934. private _resetCopy;
  106935. /**
  106936. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  106937. * @param p the current index in the positions array to be updated
  106938. * @param ind the current index in the indices array
  106939. * @param shape a Vector3 array, the shape geometry
  106940. * @param positions the positions array to be updated
  106941. * @param meshInd the shape indices array
  106942. * @param indices the indices array to be updated
  106943. * @param meshUV the shape uv array
  106944. * @param uvs the uv array to be updated
  106945. * @param meshCol the shape color array
  106946. * @param colors the color array to be updated
  106947. * @param meshNor the shape normals array
  106948. * @param normals the normals array to be updated
  106949. * @param idx the particle index
  106950. * @param idxInShape the particle index in its shape
  106951. * @param options the addShape() method passed options
  106952. * @model the particle model
  106953. * @hidden
  106954. */
  106955. private _meshBuilder;
  106956. /**
  106957. * Returns a shape Vector3 array from positions float array
  106958. * @param positions float array
  106959. * @returns a vector3 array
  106960. * @hidden
  106961. */
  106962. private _posToShape;
  106963. /**
  106964. * Returns a shapeUV array from a float uvs (array deep copy)
  106965. * @param uvs as a float array
  106966. * @returns a shapeUV array
  106967. * @hidden
  106968. */
  106969. private _uvsToShapeUV;
  106970. /**
  106971. * Adds a new particle object in the particles array
  106972. * @param idx particle index in particles array
  106973. * @param id particle id
  106974. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  106975. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  106976. * @param model particle ModelShape object
  106977. * @param shapeId model shape identifier
  106978. * @param idxInShape index of the particle in the current model
  106979. * @param bInfo model bounding info object
  106980. * @param storage target storage array, if any
  106981. * @hidden
  106982. */
  106983. private _addParticle;
  106984. /**
  106985. * Adds some particles to the SPS from the model shape. Returns the shape id.
  106986. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  106987. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  106988. * @param nb (positive integer) the number of particles to be created from this model
  106989. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  106990. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  106991. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  106992. * @returns the number of shapes in the system
  106993. */
  106994. addShape(mesh: Mesh, nb: number, options?: {
  106995. positionFunction?: any;
  106996. vertexFunction?: any;
  106997. storage?: [];
  106998. }): number;
  106999. /**
  107000. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107001. * @hidden
  107002. */
  107003. private _rebuildParticle;
  107004. /**
  107005. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107006. * @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.
  107007. * @returns the SPS.
  107008. */
  107009. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107010. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107011. * Returns an array with the removed particles.
  107012. * 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.
  107013. * The SPS can't be empty so at least one particle needs to remain in place.
  107014. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107015. * @param start index of the first particle to remove
  107016. * @param end index of the last particle to remove (included)
  107017. * @returns an array populated with the removed particles
  107018. */
  107019. removeParticles(start: number, end: number): SolidParticle[];
  107020. /**
  107021. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107022. * @param solidParticleArray an array populated with Solid Particles objects
  107023. * @returns the SPS
  107024. */
  107025. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107026. /**
  107027. * Creates a new particle and modifies the SPS mesh geometry :
  107028. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107029. * - calls _addParticle() to populate the particle array
  107030. * factorized code from addShape() and insertParticlesFromArray()
  107031. * @param idx particle index in the particles array
  107032. * @param i particle index in its shape
  107033. * @param modelShape particle ModelShape object
  107034. * @param shape shape vertex array
  107035. * @param meshInd shape indices array
  107036. * @param meshUV shape uv array
  107037. * @param meshCol shape color array
  107038. * @param meshNor shape normals array
  107039. * @param bbInfo shape bounding info
  107040. * @param storage target particle storage
  107041. * @options addShape() passed options
  107042. * @hidden
  107043. */
  107044. private _insertNewParticle;
  107045. /**
  107046. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107047. * This method calls `updateParticle()` for each particle of the SPS.
  107048. * For an animated SPS, it is usually called within the render loop.
  107049. * 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.
  107050. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107051. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107052. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107053. * @returns the SPS.
  107054. */
  107055. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107056. /**
  107057. * Disposes the SPS.
  107058. */
  107059. dispose(): void;
  107060. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107061. * idx is the particle index in the SPS
  107062. * faceId is the picked face index counted within this particle.
  107063. * Returns null if the pickInfo can't identify a picked particle.
  107064. * @param pickingInfo (PickingInfo object)
  107065. * @returns {idx: number, faceId: number} or null
  107066. */
  107067. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107068. idx: number;
  107069. faceId: number;
  107070. }>;
  107071. /**
  107072. * Returns a SolidParticle object from its identifier : particle.id
  107073. * @param id (integer) the particle Id
  107074. * @returns the searched particle or null if not found in the SPS.
  107075. */
  107076. getParticleById(id: number): Nullable<SolidParticle>;
  107077. /**
  107078. * Returns a new array populated with the particles having the passed shapeId.
  107079. * @param shapeId (integer) the shape identifier
  107080. * @returns a new solid particle array
  107081. */
  107082. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107083. /**
  107084. * Populates the passed array "ref" with the particles having the passed shapeId.
  107085. * @param shapeId the shape identifier
  107086. * @returns the SPS
  107087. * @param ref
  107088. */
  107089. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107090. /**
  107091. * Computes the required SubMeshes according the materials assigned to the particles.
  107092. * @returns the solid particle system.
  107093. * Does nothing if called before the SPS mesh is built.
  107094. */
  107095. computeSubMeshes(): SolidParticleSystem;
  107096. /**
  107097. * Sorts the solid particles by material when MultiMaterial is enabled.
  107098. * Updates the indices32 array.
  107099. * Updates the indicesByMaterial array.
  107100. * Updates the mesh indices array.
  107101. * @returns the SPS
  107102. * @hidden
  107103. */
  107104. private _sortParticlesByMaterial;
  107105. /**
  107106. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107107. * @hidden
  107108. */
  107109. private _setMaterialIndexesById;
  107110. /**
  107111. * Returns an array with unique values of Materials from the passed array
  107112. * @param array the material array to be checked and filtered
  107113. * @hidden
  107114. */
  107115. private _filterUniqueMaterialId;
  107116. /**
  107117. * Sets a new Standard Material as _defaultMaterial if not already set.
  107118. * @hidden
  107119. */
  107120. private _setDefaultMaterial;
  107121. /**
  107122. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107123. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107124. * @returns the SPS.
  107125. */
  107126. refreshVisibleSize(): SolidParticleSystem;
  107127. /**
  107128. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107129. * @param size the size (float) of the visibility box
  107130. * note : this doesn't lock the SPS mesh bounding box.
  107131. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107132. */
  107133. setVisibilityBox(size: number): void;
  107134. /**
  107135. * Gets whether the SPS as always visible or not
  107136. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107137. */
  107138. get isAlwaysVisible(): boolean;
  107139. /**
  107140. * Sets the SPS as always visible or not
  107141. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107142. */
  107143. set isAlwaysVisible(val: boolean);
  107144. /**
  107145. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107147. */
  107148. set isVisibilityBoxLocked(val: boolean);
  107149. /**
  107150. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107152. */
  107153. get isVisibilityBoxLocked(): boolean;
  107154. /**
  107155. * Tells to `setParticles()` to compute the particle rotations or not.
  107156. * Default value : true. The SPS is faster when it's set to false.
  107157. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107158. */
  107159. set computeParticleRotation(val: boolean);
  107160. /**
  107161. * Tells to `setParticles()` to compute the particle colors or not.
  107162. * Default value : true. The SPS is faster when it's set to false.
  107163. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107164. */
  107165. set computeParticleColor(val: boolean);
  107166. set computeParticleTexture(val: boolean);
  107167. /**
  107168. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107169. * Default value : false. The SPS is faster when it's set to false.
  107170. * Note : the particle custom vertex positions aren't stored values.
  107171. */
  107172. set computeParticleVertex(val: boolean);
  107173. /**
  107174. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107175. */
  107176. set computeBoundingBox(val: boolean);
  107177. /**
  107178. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107179. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107180. * Default : `true`
  107181. */
  107182. set depthSortParticles(val: boolean);
  107183. /**
  107184. * Gets if `setParticles()` computes the particle rotations or not.
  107185. * Default value : true. The SPS is faster when it's set to false.
  107186. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107187. */
  107188. get computeParticleRotation(): boolean;
  107189. /**
  107190. * Gets if `setParticles()` computes the particle colors or not.
  107191. * Default value : true. The SPS is faster when it's set to false.
  107192. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107193. */
  107194. get computeParticleColor(): boolean;
  107195. /**
  107196. * Gets if `setParticles()` computes the particle textures or not.
  107197. * Default value : true. The SPS is faster when it's set to false.
  107198. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107199. */
  107200. get computeParticleTexture(): boolean;
  107201. /**
  107202. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107203. * Default value : false. The SPS is faster when it's set to false.
  107204. * Note : the particle custom vertex positions aren't stored values.
  107205. */
  107206. get computeParticleVertex(): boolean;
  107207. /**
  107208. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107209. */
  107210. get computeBoundingBox(): boolean;
  107211. /**
  107212. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107213. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107214. * Default : `true`
  107215. */
  107216. get depthSortParticles(): boolean;
  107217. /**
  107218. * Gets if the SPS is created as expandable at construction time.
  107219. * Default : `false`
  107220. */
  107221. get expandable(): boolean;
  107222. /**
  107223. * Gets if the SPS supports the Multi Materials
  107224. */
  107225. get multimaterialEnabled(): boolean;
  107226. /**
  107227. * Gets if the SPS uses the model materials for its own multimaterial.
  107228. */
  107229. get useModelMaterial(): boolean;
  107230. /**
  107231. * The SPS used material array.
  107232. */
  107233. get materials(): Material[];
  107234. /**
  107235. * Sets the SPS MultiMaterial from the passed materials.
  107236. * Note : the passed array is internally copied and not used then by reference.
  107237. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107238. */
  107239. setMultiMaterial(materials: Material[]): void;
  107240. /**
  107241. * The SPS computed multimaterial object
  107242. */
  107243. get multimaterial(): MultiMaterial;
  107244. set multimaterial(mm: MultiMaterial);
  107245. /**
  107246. * If the subMeshes must be updated on the next call to setParticles()
  107247. */
  107248. get autoUpdateSubMeshes(): boolean;
  107249. set autoUpdateSubMeshes(val: boolean);
  107250. /**
  107251. * This function does nothing. It may be overwritten to set all the particle first values.
  107252. * The SPS doesn't call this function, you may have to call it by your own.
  107253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107254. */
  107255. initParticles(): void;
  107256. /**
  107257. * This function does nothing. It may be overwritten to recycle a particle.
  107258. * The SPS doesn't call this function, you may have to call it by your own.
  107259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107260. * @param particle The particle to recycle
  107261. * @returns the recycled particle
  107262. */
  107263. recycleParticle(particle: SolidParticle): SolidParticle;
  107264. /**
  107265. * Updates a particle : this function should be overwritten by the user.
  107266. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107267. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107268. * @example : just set a particle position or velocity and recycle conditions
  107269. * @param particle The particle to update
  107270. * @returns the updated particle
  107271. */
  107272. updateParticle(particle: SolidParticle): SolidParticle;
  107273. /**
  107274. * Updates a vertex of a particle : it can be overwritten by the user.
  107275. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107276. * @param particle the current particle
  107277. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  107278. * @param pt the index of the current vertex in the particle shape
  107279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  107280. * @example : just set a vertex particle position or color
  107281. * @returns the sps
  107282. */
  107283. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  107284. /**
  107285. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107286. * This does nothing and may be overwritten by the user.
  107287. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107288. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107289. * @param update the boolean update value actually passed to setParticles()
  107290. */
  107291. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107292. /**
  107293. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107294. * This will be passed three parameters.
  107295. * This does nothing and may be overwritten by the user.
  107296. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107298. * @param update the boolean update value actually passed to setParticles()
  107299. */
  107300. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107301. }
  107302. }
  107303. declare module BABYLON {
  107304. /**
  107305. * Represents one particle of a solid particle system.
  107306. */
  107307. export class SolidParticle {
  107308. /**
  107309. * particle global index
  107310. */
  107311. idx: number;
  107312. /**
  107313. * particle identifier
  107314. */
  107315. id: number;
  107316. /**
  107317. * The color of the particle
  107318. */
  107319. color: Nullable<Color4>;
  107320. /**
  107321. * The world space position of the particle.
  107322. */
  107323. position: Vector3;
  107324. /**
  107325. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107326. */
  107327. rotation: Vector3;
  107328. /**
  107329. * The world space rotation quaternion of the particle.
  107330. */
  107331. rotationQuaternion: Nullable<Quaternion>;
  107332. /**
  107333. * The scaling of the particle.
  107334. */
  107335. scaling: Vector3;
  107336. /**
  107337. * The uvs of the particle.
  107338. */
  107339. uvs: Vector4;
  107340. /**
  107341. * The current speed of the particle.
  107342. */
  107343. velocity: Vector3;
  107344. /**
  107345. * The pivot point in the particle local space.
  107346. */
  107347. pivot: Vector3;
  107348. /**
  107349. * Must the particle be translated from its pivot point in its local space ?
  107350. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107351. * Default : false
  107352. */
  107353. translateFromPivot: boolean;
  107354. /**
  107355. * Is the particle active or not ?
  107356. */
  107357. alive: boolean;
  107358. /**
  107359. * Is the particle visible or not ?
  107360. */
  107361. isVisible: boolean;
  107362. /**
  107363. * Index of this particle in the global "positions" array (Internal use)
  107364. * @hidden
  107365. */
  107366. _pos: number;
  107367. /**
  107368. * @hidden Index of this particle in the global "indices" array (Internal use)
  107369. */
  107370. _ind: number;
  107371. /**
  107372. * @hidden ModelShape of this particle (Internal use)
  107373. */
  107374. _model: ModelShape;
  107375. /**
  107376. * ModelShape id of this particle
  107377. */
  107378. shapeId: number;
  107379. /**
  107380. * Index of the particle in its shape id
  107381. */
  107382. idxInShape: number;
  107383. /**
  107384. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  107385. */
  107386. _modelBoundingInfo: BoundingInfo;
  107387. /**
  107388. * @hidden Particle BoundingInfo object (Internal use)
  107389. */
  107390. _boundingInfo: BoundingInfo;
  107391. /**
  107392. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  107393. */
  107394. _sps: SolidParticleSystem;
  107395. /**
  107396. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107397. */
  107398. _stillInvisible: boolean;
  107399. /**
  107400. * @hidden Last computed particle rotation matrix
  107401. */
  107402. _rotationMatrix: number[];
  107403. /**
  107404. * Parent particle Id, if any.
  107405. * Default null.
  107406. */
  107407. parentId: Nullable<number>;
  107408. /**
  107409. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  107410. */
  107411. materialIndex: Nullable<number>;
  107412. /**
  107413. * Custom object or properties.
  107414. */
  107415. props: Nullable<any>;
  107416. /**
  107417. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107418. * The possible values are :
  107419. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107420. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107421. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107422. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107423. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107424. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107425. * */
  107426. cullingStrategy: number;
  107427. /**
  107428. * @hidden Internal global position in the SPS.
  107429. */
  107430. _globalPosition: Vector3;
  107431. /**
  107432. * Creates a Solid Particle object.
  107433. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107434. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  107435. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  107436. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107437. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107438. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107439. * @param shapeId (integer) is the model shape identifier in the SPS.
  107440. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107441. * @param sps defines the sps it is associated to
  107442. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107443. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  107444. */
  107445. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  107446. /**
  107447. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  107448. * @param target the particle target
  107449. * @returns the current particle
  107450. */
  107451. copyToRef(target: SolidParticle): SolidParticle;
  107452. /**
  107453. * Legacy support, changed scale to scaling
  107454. */
  107455. get scale(): Vector3;
  107456. /**
  107457. * Legacy support, changed scale to scaling
  107458. */
  107459. set scale(scale: Vector3);
  107460. /**
  107461. * Legacy support, changed quaternion to rotationQuaternion
  107462. */
  107463. get quaternion(): Nullable<Quaternion>;
  107464. /**
  107465. * Legacy support, changed quaternion to rotationQuaternion
  107466. */
  107467. set quaternion(q: Nullable<Quaternion>);
  107468. /**
  107469. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107470. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107471. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107472. * @returns true if it intersects
  107473. */
  107474. intersectsMesh(target: Mesh | SolidParticle): boolean;
  107475. /**
  107476. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107477. * A particle is in the frustum if its bounding box intersects the frustum
  107478. * @param frustumPlanes defines the frustum to test
  107479. * @returns true if the particle is in the frustum planes
  107480. */
  107481. isInFrustum(frustumPlanes: Plane[]): boolean;
  107482. /**
  107483. * get the rotation matrix of the particle
  107484. * @hidden
  107485. */
  107486. getRotationMatrix(m: Matrix): void;
  107487. }
  107488. /**
  107489. * Represents the shape of the model used by one particle of a solid particle system.
  107490. * SPS internal tool, don't use it manually.
  107491. */
  107492. export class ModelShape {
  107493. /**
  107494. * The shape id
  107495. * @hidden
  107496. */
  107497. shapeID: number;
  107498. /**
  107499. * flat array of model positions (internal use)
  107500. * @hidden
  107501. */
  107502. _shape: Vector3[];
  107503. /**
  107504. * flat array of model UVs (internal use)
  107505. * @hidden
  107506. */
  107507. _shapeUV: number[];
  107508. /**
  107509. * color array of the model
  107510. * @hidden
  107511. */
  107512. _shapeColors: number[];
  107513. /**
  107514. * indices array of the model
  107515. * @hidden
  107516. */
  107517. _indices: number[];
  107518. /**
  107519. * normals array of the model
  107520. * @hidden
  107521. */
  107522. _normals: number[];
  107523. /**
  107524. * length of the shape in the model indices array (internal use)
  107525. * @hidden
  107526. */
  107527. _indicesLength: number;
  107528. /**
  107529. * Custom position function (internal use)
  107530. * @hidden
  107531. */
  107532. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  107533. /**
  107534. * Custom vertex function (internal use)
  107535. * @hidden
  107536. */
  107537. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  107538. /**
  107539. * Model material (internal use)
  107540. * @hidden
  107541. */
  107542. _material: Nullable<Material>;
  107543. /**
  107544. * 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.
  107545. * SPS internal tool, don't use it manually.
  107546. * @hidden
  107547. */
  107548. 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>);
  107549. }
  107550. /**
  107551. * Represents a Depth Sorted Particle in the solid particle system.
  107552. * @hidden
  107553. */
  107554. export class DepthSortedParticle {
  107555. /**
  107556. * Particle index
  107557. */
  107558. idx: number;
  107559. /**
  107560. * Index of the particle in the "indices" array
  107561. */
  107562. ind: number;
  107563. /**
  107564. * Length of the particle shape in the "indices" array
  107565. */
  107566. indicesLength: number;
  107567. /**
  107568. * Squared distance from the particle to the camera
  107569. */
  107570. sqDistance: number;
  107571. /**
  107572. * Material index when used with MultiMaterials
  107573. */
  107574. materialIndex: number;
  107575. /**
  107576. * Creates a new sorted particle
  107577. * @param materialIndex
  107578. */
  107579. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  107580. }
  107581. /**
  107582. * Represents a solid particle vertex
  107583. */
  107584. export class SolidParticleVertex {
  107585. /**
  107586. * Vertex position
  107587. */
  107588. position: Vector3;
  107589. /**
  107590. * Vertex color
  107591. */
  107592. color: Color4;
  107593. /**
  107594. * Vertex UV
  107595. */
  107596. uv: Vector2;
  107597. /**
  107598. * Creates a new solid particle vertex
  107599. */
  107600. constructor();
  107601. /** Vertex x coordinate */
  107602. get x(): number;
  107603. set x(val: number);
  107604. /** Vertex y coordinate */
  107605. get y(): number;
  107606. set y(val: number);
  107607. /** Vertex z coordinate */
  107608. get z(): number;
  107609. set z(val: number);
  107610. }
  107611. }
  107612. declare module BABYLON {
  107613. /**
  107614. * @hidden
  107615. */
  107616. export class _MeshCollisionData {
  107617. _checkCollisions: boolean;
  107618. _collisionMask: number;
  107619. _collisionGroup: number;
  107620. _surroundingMeshes: Nullable<AbstractMesh[]>;
  107621. _collider: Nullable<Collider>;
  107622. _oldPositionForCollisions: Vector3;
  107623. _diffPositionForCollisions: Vector3;
  107624. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  107625. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  107626. }
  107627. }
  107628. declare module BABYLON {
  107629. /** @hidden */
  107630. class _FacetDataStorage {
  107631. facetPositions: Vector3[];
  107632. facetNormals: Vector3[];
  107633. facetPartitioning: number[][];
  107634. facetNb: number;
  107635. partitioningSubdivisions: number;
  107636. partitioningBBoxRatio: number;
  107637. facetDataEnabled: boolean;
  107638. facetParameters: any;
  107639. bbSize: Vector3;
  107640. subDiv: {
  107641. max: number;
  107642. X: number;
  107643. Y: number;
  107644. Z: number;
  107645. };
  107646. facetDepthSort: boolean;
  107647. facetDepthSortEnabled: boolean;
  107648. depthSortedIndices: IndicesArray;
  107649. depthSortedFacets: {
  107650. ind: number;
  107651. sqDistance: number;
  107652. }[];
  107653. facetDepthSortFunction: (f1: {
  107654. ind: number;
  107655. sqDistance: number;
  107656. }, f2: {
  107657. ind: number;
  107658. sqDistance: number;
  107659. }) => number;
  107660. facetDepthSortFrom: Vector3;
  107661. facetDepthSortOrigin: Vector3;
  107662. invertedMatrix: Matrix;
  107663. }
  107664. /**
  107665. * @hidden
  107666. **/
  107667. class _InternalAbstractMeshDataInfo {
  107668. _hasVertexAlpha: boolean;
  107669. _useVertexColors: boolean;
  107670. _numBoneInfluencers: number;
  107671. _applyFog: boolean;
  107672. _receiveShadows: boolean;
  107673. _facetData: _FacetDataStorage;
  107674. _visibility: number;
  107675. _skeleton: Nullable<Skeleton>;
  107676. _layerMask: number;
  107677. _computeBonesUsingShaders: boolean;
  107678. _isActive: boolean;
  107679. _onlyForInstances: boolean;
  107680. _isActiveIntermediate: boolean;
  107681. _onlyForInstancesIntermediate: boolean;
  107682. _actAsRegularMesh: boolean;
  107683. }
  107684. /**
  107685. * Class used to store all common mesh properties
  107686. */
  107687. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  107688. /** No occlusion */
  107689. static OCCLUSION_TYPE_NONE: number;
  107690. /** Occlusion set to optimisitic */
  107691. static OCCLUSION_TYPE_OPTIMISTIC: number;
  107692. /** Occlusion set to strict */
  107693. static OCCLUSION_TYPE_STRICT: number;
  107694. /** Use an accurante occlusion algorithm */
  107695. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  107696. /** Use a conservative occlusion algorithm */
  107697. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  107698. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  107699. * Test order :
  107700. * Is the bounding sphere outside the frustum ?
  107701. * If not, are the bounding box vertices outside the frustum ?
  107702. * It not, then the cullable object is in the frustum.
  107703. */
  107704. static readonly CULLINGSTRATEGY_STANDARD: number;
  107705. /** Culling strategy : Bounding Sphere Only.
  107706. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  107707. * It's also less accurate than the standard because some not visible objects can still be selected.
  107708. * Test : is the bounding sphere outside the frustum ?
  107709. * If not, then the cullable object is in the frustum.
  107710. */
  107711. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  107712. /** Culling strategy : Optimistic Inclusion.
  107713. * This in an inclusion test first, then the standard exclusion test.
  107714. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  107715. * 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.
  107716. * Anyway, it's as accurate as the standard strategy.
  107717. * Test :
  107718. * Is the cullable object bounding sphere center in the frustum ?
  107719. * If not, apply the default culling strategy.
  107720. */
  107721. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  107722. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  107723. * This in an inclusion test first, then the bounding sphere only exclusion test.
  107724. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  107725. * 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.
  107726. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  107727. * Test :
  107728. * Is the cullable object bounding sphere center in the frustum ?
  107729. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  107730. */
  107731. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  107732. /**
  107733. * No billboard
  107734. */
  107735. static get BILLBOARDMODE_NONE(): number;
  107736. /** Billboard on X axis */
  107737. static get BILLBOARDMODE_X(): number;
  107738. /** Billboard on Y axis */
  107739. static get BILLBOARDMODE_Y(): number;
  107740. /** Billboard on Z axis */
  107741. static get BILLBOARDMODE_Z(): number;
  107742. /** Billboard on all axes */
  107743. static get BILLBOARDMODE_ALL(): number;
  107744. /** Billboard on using position instead of orientation */
  107745. static get BILLBOARDMODE_USE_POSITION(): number;
  107746. /** @hidden */
  107747. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  107748. /**
  107749. * The culling strategy to use to check whether the mesh must be rendered or not.
  107750. * This value can be changed at any time and will be used on the next render mesh selection.
  107751. * The possible values are :
  107752. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107753. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107754. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107755. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107756. * Please read each static variable documentation to get details about the culling process.
  107757. * */
  107758. cullingStrategy: number;
  107759. /**
  107760. * Gets the number of facets in the mesh
  107761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  107762. */
  107763. get facetNb(): number;
  107764. /**
  107765. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  107766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  107767. */
  107768. get partitioningSubdivisions(): number;
  107769. set partitioningSubdivisions(nb: number);
  107770. /**
  107771. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  107772. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  107773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  107774. */
  107775. get partitioningBBoxRatio(): number;
  107776. set partitioningBBoxRatio(ratio: number);
  107777. /**
  107778. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  107779. * Works only for updatable meshes.
  107780. * Doesn't work with multi-materials
  107781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  107782. */
  107783. get mustDepthSortFacets(): boolean;
  107784. set mustDepthSortFacets(sort: boolean);
  107785. /**
  107786. * The location (Vector3) where the facet depth sort must be computed from.
  107787. * By default, the active camera position.
  107788. * Used only when facet depth sort is enabled
  107789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  107790. */
  107791. get facetDepthSortFrom(): Vector3;
  107792. set facetDepthSortFrom(location: Vector3);
  107793. /**
  107794. * gets a boolean indicating if facetData is enabled
  107795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  107796. */
  107797. get isFacetDataEnabled(): boolean;
  107798. /** @hidden */
  107799. _updateNonUniformScalingState(value: boolean): boolean;
  107800. /**
  107801. * An event triggered when this mesh collides with another one
  107802. */
  107803. onCollideObservable: Observable<AbstractMesh>;
  107804. /** Set a function to call when this mesh collides with another one */
  107805. set onCollide(callback: () => void);
  107806. /**
  107807. * An event triggered when the collision's position changes
  107808. */
  107809. onCollisionPositionChangeObservable: Observable<Vector3>;
  107810. /** Set a function to call when the collision's position changes */
  107811. set onCollisionPositionChange(callback: () => void);
  107812. /**
  107813. * An event triggered when material is changed
  107814. */
  107815. onMaterialChangedObservable: Observable<AbstractMesh>;
  107816. /**
  107817. * Gets or sets the orientation for POV movement & rotation
  107818. */
  107819. definedFacingForward: boolean;
  107820. /** @hidden */
  107821. _occlusionQuery: Nullable<WebGLQuery>;
  107822. /** @hidden */
  107823. _renderingGroup: Nullable<RenderingGroup>;
  107824. /**
  107825. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  107826. */
  107827. get visibility(): number;
  107828. /**
  107829. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  107830. */
  107831. set visibility(value: number);
  107832. /** Gets or sets the alpha index used to sort transparent meshes
  107833. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  107834. */
  107835. alphaIndex: number;
  107836. /**
  107837. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  107838. */
  107839. isVisible: boolean;
  107840. /**
  107841. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  107842. */
  107843. isPickable: boolean;
  107844. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  107845. showSubMeshesBoundingBox: boolean;
  107846. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  107847. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107848. */
  107849. isBlocker: boolean;
  107850. /**
  107851. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  107852. */
  107853. enablePointerMoveEvents: boolean;
  107854. /**
  107855. * Specifies the rendering group id for this mesh (0 by default)
  107856. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  107857. */
  107858. renderingGroupId: number;
  107859. private _material;
  107860. /** Gets or sets current material */
  107861. get material(): Nullable<Material>;
  107862. set material(value: Nullable<Material>);
  107863. /**
  107864. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  107865. * @see http://doc.babylonjs.com/babylon101/shadows
  107866. */
  107867. get receiveShadows(): boolean;
  107868. set receiveShadows(value: boolean);
  107869. /** Defines color to use when rendering outline */
  107870. outlineColor: Color3;
  107871. /** Define width to use when rendering outline */
  107872. outlineWidth: number;
  107873. /** Defines color to use when rendering overlay */
  107874. overlayColor: Color3;
  107875. /** Defines alpha to use when rendering overlay */
  107876. overlayAlpha: number;
  107877. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  107878. get hasVertexAlpha(): boolean;
  107879. set hasVertexAlpha(value: boolean);
  107880. /** 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) */
  107881. get useVertexColors(): boolean;
  107882. set useVertexColors(value: boolean);
  107883. /**
  107884. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  107885. */
  107886. get computeBonesUsingShaders(): boolean;
  107887. set computeBonesUsingShaders(value: boolean);
  107888. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  107889. get numBoneInfluencers(): number;
  107890. set numBoneInfluencers(value: number);
  107891. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  107892. get applyFog(): boolean;
  107893. set applyFog(value: boolean);
  107894. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  107895. useOctreeForRenderingSelection: boolean;
  107896. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  107897. useOctreeForPicking: boolean;
  107898. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  107899. useOctreeForCollisions: boolean;
  107900. /**
  107901. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  107902. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  107903. */
  107904. get layerMask(): number;
  107905. set layerMask(value: number);
  107906. /**
  107907. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  107908. */
  107909. alwaysSelectAsActiveMesh: boolean;
  107910. /**
  107911. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  107912. */
  107913. doNotSyncBoundingInfo: boolean;
  107914. /**
  107915. * Gets or sets the current action manager
  107916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107917. */
  107918. actionManager: Nullable<AbstractActionManager>;
  107919. private _meshCollisionData;
  107920. /**
  107921. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  107922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  107923. */
  107924. ellipsoid: Vector3;
  107925. /**
  107926. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  107927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  107928. */
  107929. ellipsoidOffset: Vector3;
  107930. /**
  107931. * Gets or sets a collision mask used to mask collisions (default is -1).
  107932. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  107933. */
  107934. get collisionMask(): number;
  107935. set collisionMask(mask: number);
  107936. /**
  107937. * Gets or sets the current collision group mask (-1 by default).
  107938. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  107939. */
  107940. get collisionGroup(): number;
  107941. set collisionGroup(mask: number);
  107942. /**
  107943. * Gets or sets current surrounding meshes (null by default).
  107944. *
  107945. * By default collision detection is tested against every mesh in the scene.
  107946. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  107947. * meshes will be tested for the collision.
  107948. *
  107949. * Note: if set to an empty array no collision will happen when this mesh is moved.
  107950. */
  107951. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  107952. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  107953. /**
  107954. * Defines edge width used when edgesRenderer is enabled
  107955. * @see https://www.babylonjs-playground.com/#10OJSG#13
  107956. */
  107957. edgesWidth: number;
  107958. /**
  107959. * Defines edge color used when edgesRenderer is enabled
  107960. * @see https://www.babylonjs-playground.com/#10OJSG#13
  107961. */
  107962. edgesColor: Color4;
  107963. /** @hidden */
  107964. _edgesRenderer: Nullable<IEdgesRenderer>;
  107965. /** @hidden */
  107966. _masterMesh: Nullable<AbstractMesh>;
  107967. /** @hidden */
  107968. _boundingInfo: Nullable<BoundingInfo>;
  107969. /** @hidden */
  107970. _renderId: number;
  107971. /**
  107972. * Gets or sets the list of subMeshes
  107973. * @see http://doc.babylonjs.com/how_to/multi_materials
  107974. */
  107975. subMeshes: SubMesh[];
  107976. /** @hidden */
  107977. _intersectionsInProgress: AbstractMesh[];
  107978. /** @hidden */
  107979. _unIndexed: boolean;
  107980. /** @hidden */
  107981. _lightSources: Light[];
  107982. /** Gets the list of lights affecting that mesh */
  107983. get lightSources(): Light[];
  107984. /** @hidden */
  107985. get _positions(): Nullable<Vector3[]>;
  107986. /** @hidden */
  107987. _waitingData: {
  107988. lods: Nullable<any>;
  107989. actions: Nullable<any>;
  107990. freezeWorldMatrix: Nullable<boolean>;
  107991. };
  107992. /** @hidden */
  107993. _bonesTransformMatrices: Nullable<Float32Array>;
  107994. /** @hidden */
  107995. _transformMatrixTexture: Nullable<RawTexture>;
  107996. /**
  107997. * Gets or sets a skeleton to apply skining transformations
  107998. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107999. */
  108000. set skeleton(value: Nullable<Skeleton>);
  108001. get skeleton(): Nullable<Skeleton>;
  108002. /**
  108003. * An event triggered when the mesh is rebuilt.
  108004. */
  108005. onRebuildObservable: Observable<AbstractMesh>;
  108006. /**
  108007. * Creates a new AbstractMesh
  108008. * @param name defines the name of the mesh
  108009. * @param scene defines the hosting scene
  108010. */
  108011. constructor(name: string, scene?: Nullable<Scene>);
  108012. /**
  108013. * Returns the string "AbstractMesh"
  108014. * @returns "AbstractMesh"
  108015. */
  108016. getClassName(): string;
  108017. /**
  108018. * Gets a string representation of the current mesh
  108019. * @param fullDetails defines a boolean indicating if full details must be included
  108020. * @returns a string representation of the current mesh
  108021. */
  108022. toString(fullDetails?: boolean): string;
  108023. /**
  108024. * @hidden
  108025. */
  108026. protected _getEffectiveParent(): Nullable<Node>;
  108027. /** @hidden */
  108028. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108029. /** @hidden */
  108030. _rebuild(): void;
  108031. /** @hidden */
  108032. _resyncLightSources(): void;
  108033. /** @hidden */
  108034. _resyncLightSource(light: Light): void;
  108035. /** @hidden */
  108036. _unBindEffect(): void;
  108037. /** @hidden */
  108038. _removeLightSource(light: Light, dispose: boolean): void;
  108039. private _markSubMeshesAsDirty;
  108040. /** @hidden */
  108041. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108042. /** @hidden */
  108043. _markSubMeshesAsAttributesDirty(): void;
  108044. /** @hidden */
  108045. _markSubMeshesAsMiscDirty(): void;
  108046. /**
  108047. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108048. */
  108049. get scaling(): Vector3;
  108050. set scaling(newScaling: Vector3);
  108051. /**
  108052. * Returns true if the mesh is blocked. Implemented by child classes
  108053. */
  108054. get isBlocked(): boolean;
  108055. /**
  108056. * Returns the mesh itself by default. Implemented by child classes
  108057. * @param camera defines the camera to use to pick the right LOD level
  108058. * @returns the currentAbstractMesh
  108059. */
  108060. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108061. /**
  108062. * Returns 0 by default. Implemented by child classes
  108063. * @returns an integer
  108064. */
  108065. getTotalVertices(): number;
  108066. /**
  108067. * Returns a positive integer : the total number of indices in this mesh geometry.
  108068. * @returns the numner of indices or zero if the mesh has no geometry.
  108069. */
  108070. getTotalIndices(): number;
  108071. /**
  108072. * Returns null by default. Implemented by child classes
  108073. * @returns null
  108074. */
  108075. getIndices(): Nullable<IndicesArray>;
  108076. /**
  108077. * Returns the array of the requested vertex data kind. Implemented by child classes
  108078. * @param kind defines the vertex data kind to use
  108079. * @returns null
  108080. */
  108081. getVerticesData(kind: string): Nullable<FloatArray>;
  108082. /**
  108083. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108084. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108085. * Note that a new underlying VertexBuffer object is created each call.
  108086. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108087. * @param kind defines vertex data kind:
  108088. * * VertexBuffer.PositionKind
  108089. * * VertexBuffer.UVKind
  108090. * * VertexBuffer.UV2Kind
  108091. * * VertexBuffer.UV3Kind
  108092. * * VertexBuffer.UV4Kind
  108093. * * VertexBuffer.UV5Kind
  108094. * * VertexBuffer.UV6Kind
  108095. * * VertexBuffer.ColorKind
  108096. * * VertexBuffer.MatricesIndicesKind
  108097. * * VertexBuffer.MatricesIndicesExtraKind
  108098. * * VertexBuffer.MatricesWeightsKind
  108099. * * VertexBuffer.MatricesWeightsExtraKind
  108100. * @param data defines the data source
  108101. * @param updatable defines if the data must be flagged as updatable (or static)
  108102. * @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
  108103. * @returns the current mesh
  108104. */
  108105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108106. /**
  108107. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108108. * If the mesh has no geometry, it is simply returned as it is.
  108109. * @param kind defines vertex data kind:
  108110. * * VertexBuffer.PositionKind
  108111. * * VertexBuffer.UVKind
  108112. * * VertexBuffer.UV2Kind
  108113. * * VertexBuffer.UV3Kind
  108114. * * VertexBuffer.UV4Kind
  108115. * * VertexBuffer.UV5Kind
  108116. * * VertexBuffer.UV6Kind
  108117. * * VertexBuffer.ColorKind
  108118. * * VertexBuffer.MatricesIndicesKind
  108119. * * VertexBuffer.MatricesIndicesExtraKind
  108120. * * VertexBuffer.MatricesWeightsKind
  108121. * * VertexBuffer.MatricesWeightsExtraKind
  108122. * @param data defines the data source
  108123. * @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
  108124. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108125. * @returns the current mesh
  108126. */
  108127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108128. /**
  108129. * Sets the mesh indices,
  108130. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108131. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108132. * @param totalVertices Defines the total number of vertices
  108133. * @returns the current mesh
  108134. */
  108135. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108136. /**
  108137. * Gets a boolean indicating if specific vertex data is present
  108138. * @param kind defines the vertex data kind to use
  108139. * @returns true is data kind is present
  108140. */
  108141. isVerticesDataPresent(kind: string): boolean;
  108142. /**
  108143. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108144. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108145. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108146. * @returns a BoundingInfo
  108147. */
  108148. getBoundingInfo(): BoundingInfo;
  108149. /**
  108150. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108151. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108152. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108153. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108154. * @returns the current mesh
  108155. */
  108156. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108157. /**
  108158. * Overwrite the current bounding info
  108159. * @param boundingInfo defines the new bounding info
  108160. * @returns the current mesh
  108161. */
  108162. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108163. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108164. get useBones(): boolean;
  108165. /** @hidden */
  108166. _preActivate(): void;
  108167. /** @hidden */
  108168. _preActivateForIntermediateRendering(renderId: number): void;
  108169. /** @hidden */
  108170. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108171. /** @hidden */
  108172. _postActivate(): void;
  108173. /** @hidden */
  108174. _freeze(): void;
  108175. /** @hidden */
  108176. _unFreeze(): void;
  108177. /**
  108178. * Gets the current world matrix
  108179. * @returns a Matrix
  108180. */
  108181. getWorldMatrix(): Matrix;
  108182. /** @hidden */
  108183. _getWorldMatrixDeterminant(): number;
  108184. /**
  108185. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108186. */
  108187. get isAnInstance(): boolean;
  108188. /**
  108189. * Gets a boolean indicating if this mesh has instances
  108190. */
  108191. get hasInstances(): boolean;
  108192. /**
  108193. * Perform relative position change from the point of view of behind the front of the mesh.
  108194. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108195. * Supports definition of mesh facing forward or backward
  108196. * @param amountRight defines the distance on the right axis
  108197. * @param amountUp defines the distance on the up axis
  108198. * @param amountForward defines the distance on the forward axis
  108199. * @returns the current mesh
  108200. */
  108201. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108202. /**
  108203. * Calculate relative position change from the point of view of behind the front of the mesh.
  108204. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108205. * Supports definition of mesh facing forward or backward
  108206. * @param amountRight defines the distance on the right axis
  108207. * @param amountUp defines the distance on the up axis
  108208. * @param amountForward defines the distance on the forward axis
  108209. * @returns the new displacement vector
  108210. */
  108211. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108212. /**
  108213. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108214. * Supports definition of mesh facing forward or backward
  108215. * @param flipBack defines the flip
  108216. * @param twirlClockwise defines the twirl
  108217. * @param tiltRight defines the tilt
  108218. * @returns the current mesh
  108219. */
  108220. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108221. /**
  108222. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108223. * Supports definition of mesh facing forward or backward.
  108224. * @param flipBack defines the flip
  108225. * @param twirlClockwise defines the twirl
  108226. * @param tiltRight defines the tilt
  108227. * @returns the new rotation vector
  108228. */
  108229. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108230. /**
  108231. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108232. * This means the mesh underlying bounding box and sphere are recomputed.
  108233. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108234. * @returns the current mesh
  108235. */
  108236. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108237. /** @hidden */
  108238. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108239. /** @hidden */
  108240. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108241. /** @hidden */
  108242. _updateBoundingInfo(): AbstractMesh;
  108243. /** @hidden */
  108244. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108245. /** @hidden */
  108246. protected _afterComputeWorldMatrix(): void;
  108247. /** @hidden */
  108248. get _effectiveMesh(): AbstractMesh;
  108249. /**
  108250. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108251. * A mesh is in the frustum if its bounding box intersects the frustum
  108252. * @param frustumPlanes defines the frustum to test
  108253. * @returns true if the mesh is in the frustum planes
  108254. */
  108255. isInFrustum(frustumPlanes: Plane[]): boolean;
  108256. /**
  108257. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  108258. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  108259. * @param frustumPlanes defines the frustum to test
  108260. * @returns true if the mesh is completely in the frustum planes
  108261. */
  108262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  108263. /**
  108264. * True if the mesh intersects another mesh or a SolidParticle object
  108265. * @param mesh defines a target mesh or SolidParticle to test
  108266. * @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)
  108267. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  108268. * @returns true if there is an intersection
  108269. */
  108270. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  108271. /**
  108272. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  108273. * @param point defines the point to test
  108274. * @returns true if there is an intersection
  108275. */
  108276. intersectsPoint(point: Vector3): boolean;
  108277. /**
  108278. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  108279. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108280. */
  108281. get checkCollisions(): boolean;
  108282. set checkCollisions(collisionEnabled: boolean);
  108283. /**
  108284. * Gets Collider object used to compute collisions (not physics)
  108285. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108286. */
  108287. get collider(): Nullable<Collider>;
  108288. /**
  108289. * Move the mesh using collision engine
  108290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108291. * @param displacement defines the requested displacement vector
  108292. * @returns the current mesh
  108293. */
  108294. moveWithCollisions(displacement: Vector3): AbstractMesh;
  108295. private _onCollisionPositionChange;
  108296. /** @hidden */
  108297. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  108298. /** @hidden */
  108299. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  108300. /** @hidden */
  108301. _checkCollision(collider: Collider): AbstractMesh;
  108302. /** @hidden */
  108303. _generatePointsArray(): boolean;
  108304. /**
  108305. * Checks if the passed Ray intersects with the mesh
  108306. * @param ray defines the ray to use
  108307. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  108308. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108309. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  108310. * @returns the picking info
  108311. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  108312. */
  108313. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  108314. /**
  108315. * Clones the current mesh
  108316. * @param name defines the mesh name
  108317. * @param newParent defines the new mesh parent
  108318. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  108319. * @returns the new mesh
  108320. */
  108321. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  108322. /**
  108323. * Disposes all the submeshes of the current meshnp
  108324. * @returns the current mesh
  108325. */
  108326. releaseSubMeshes(): AbstractMesh;
  108327. /**
  108328. * Releases resources associated with this abstract mesh.
  108329. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108330. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108331. */
  108332. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108333. /**
  108334. * Adds the passed mesh as a child to the current mesh
  108335. * @param mesh defines the child mesh
  108336. * @returns the current mesh
  108337. */
  108338. addChild(mesh: AbstractMesh): AbstractMesh;
  108339. /**
  108340. * Removes the passed mesh from the current mesh children list
  108341. * @param mesh defines the child mesh
  108342. * @returns the current mesh
  108343. */
  108344. removeChild(mesh: AbstractMesh): AbstractMesh;
  108345. /** @hidden */
  108346. private _initFacetData;
  108347. /**
  108348. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  108349. * This method can be called within the render loop.
  108350. * 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
  108351. * @returns the current mesh
  108352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108353. */
  108354. updateFacetData(): AbstractMesh;
  108355. /**
  108356. * Returns the facetLocalNormals array.
  108357. * The normals are expressed in the mesh local spac
  108358. * @returns an array of Vector3
  108359. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108360. */
  108361. getFacetLocalNormals(): Vector3[];
  108362. /**
  108363. * Returns the facetLocalPositions array.
  108364. * The facet positions are expressed in the mesh local space
  108365. * @returns an array of Vector3
  108366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108367. */
  108368. getFacetLocalPositions(): Vector3[];
  108369. /**
  108370. * Returns the facetLocalPartioning array
  108371. * @returns an array of array of numbers
  108372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108373. */
  108374. getFacetLocalPartitioning(): number[][];
  108375. /**
  108376. * Returns the i-th facet position in the world system.
  108377. * This method allocates a new Vector3 per call
  108378. * @param i defines the facet index
  108379. * @returns a new Vector3
  108380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108381. */
  108382. getFacetPosition(i: number): Vector3;
  108383. /**
  108384. * Sets the reference Vector3 with the i-th facet position in the world system
  108385. * @param i defines the facet index
  108386. * @param ref defines the target vector
  108387. * @returns the current mesh
  108388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108389. */
  108390. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  108391. /**
  108392. * Returns the i-th facet normal in the world system.
  108393. * This method allocates a new Vector3 per call
  108394. * @param i defines the facet index
  108395. * @returns a new Vector3
  108396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108397. */
  108398. getFacetNormal(i: number): Vector3;
  108399. /**
  108400. * Sets the reference Vector3 with the i-th facet normal in the world system
  108401. * @param i defines the facet index
  108402. * @param ref defines the target vector
  108403. * @returns the current mesh
  108404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108405. */
  108406. getFacetNormalToRef(i: number, ref: Vector3): this;
  108407. /**
  108408. * 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)
  108409. * @param x defines x coordinate
  108410. * @param y defines y coordinate
  108411. * @param z defines z coordinate
  108412. * @returns the array of facet indexes
  108413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108414. */
  108415. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  108416. /**
  108417. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  108418. * @param projected sets as the (x,y,z) world projection on the facet
  108419. * @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
  108420. * @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
  108421. * @param x defines x coordinate
  108422. * @param y defines y coordinate
  108423. * @param z defines z coordinate
  108424. * @returns the face index if found (or null instead)
  108425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108426. */
  108427. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108428. /**
  108429. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  108430. * @param projected sets as the (x,y,z) local projection on the facet
  108431. * @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
  108432. * @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
  108433. * @param x defines x coordinate
  108434. * @param y defines y coordinate
  108435. * @param z defines z coordinate
  108436. * @returns the face index if found (or null instead)
  108437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108438. */
  108439. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108440. /**
  108441. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  108442. * @returns the parameters
  108443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108444. */
  108445. getFacetDataParameters(): any;
  108446. /**
  108447. * Disables the feature FacetData and frees the related memory
  108448. * @returns the current mesh
  108449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108450. */
  108451. disableFacetData(): AbstractMesh;
  108452. /**
  108453. * Updates the AbstractMesh indices array
  108454. * @param indices defines the data source
  108455. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108456. * @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)
  108457. * @returns the current mesh
  108458. */
  108459. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108460. /**
  108461. * Creates new normals data for the mesh
  108462. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  108463. * @returns the current mesh
  108464. */
  108465. createNormals(updatable: boolean): AbstractMesh;
  108466. /**
  108467. * Align the mesh with a normal
  108468. * @param normal defines the normal to use
  108469. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  108470. * @returns the current mesh
  108471. */
  108472. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  108473. /** @hidden */
  108474. _checkOcclusionQuery(): boolean;
  108475. /**
  108476. * Disables the mesh edge rendering mode
  108477. * @returns the currentAbstractMesh
  108478. */
  108479. disableEdgesRendering(): AbstractMesh;
  108480. /**
  108481. * Enables the edge rendering mode on the mesh.
  108482. * This mode makes the mesh edges visible
  108483. * @param epsilon defines the maximal distance between two angles to detect a face
  108484. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  108485. * @returns the currentAbstractMesh
  108486. * @see https://www.babylonjs-playground.com/#19O9TU#0
  108487. */
  108488. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  108489. }
  108490. }
  108491. declare module BABYLON {
  108492. /**
  108493. * Interface used to define ActionEvent
  108494. */
  108495. export interface IActionEvent {
  108496. /** The mesh or sprite that triggered the action */
  108497. source: any;
  108498. /** The X mouse cursor position at the time of the event */
  108499. pointerX: number;
  108500. /** The Y mouse cursor position at the time of the event */
  108501. pointerY: number;
  108502. /** The mesh that is currently pointed at (can be null) */
  108503. meshUnderPointer: Nullable<AbstractMesh>;
  108504. /** the original (browser) event that triggered the ActionEvent */
  108505. sourceEvent?: any;
  108506. /** additional data for the event */
  108507. additionalData?: any;
  108508. }
  108509. /**
  108510. * ActionEvent is the event being sent when an action is triggered.
  108511. */
  108512. export class ActionEvent implements IActionEvent {
  108513. /** The mesh or sprite that triggered the action */
  108514. source: any;
  108515. /** The X mouse cursor position at the time of the event */
  108516. pointerX: number;
  108517. /** The Y mouse cursor position at the time of the event */
  108518. pointerY: number;
  108519. /** The mesh that is currently pointed at (can be null) */
  108520. meshUnderPointer: Nullable<AbstractMesh>;
  108521. /** the original (browser) event that triggered the ActionEvent */
  108522. sourceEvent?: any;
  108523. /** additional data for the event */
  108524. additionalData?: any;
  108525. /**
  108526. * Creates a new ActionEvent
  108527. * @param source The mesh or sprite that triggered the action
  108528. * @param pointerX The X mouse cursor position at the time of the event
  108529. * @param pointerY The Y mouse cursor position at the time of the event
  108530. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  108531. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  108532. * @param additionalData additional data for the event
  108533. */
  108534. constructor(
  108535. /** The mesh or sprite that triggered the action */
  108536. source: any,
  108537. /** The X mouse cursor position at the time of the event */
  108538. pointerX: number,
  108539. /** The Y mouse cursor position at the time of the event */
  108540. pointerY: number,
  108541. /** The mesh that is currently pointed at (can be null) */
  108542. meshUnderPointer: Nullable<AbstractMesh>,
  108543. /** the original (browser) event that triggered the ActionEvent */
  108544. sourceEvent?: any,
  108545. /** additional data for the event */
  108546. additionalData?: any);
  108547. /**
  108548. * Helper function to auto-create an ActionEvent from a source mesh.
  108549. * @param source The source mesh that triggered the event
  108550. * @param evt The original (browser) event
  108551. * @param additionalData additional data for the event
  108552. * @returns the new ActionEvent
  108553. */
  108554. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  108555. /**
  108556. * Helper function to auto-create an ActionEvent from a source sprite
  108557. * @param source The source sprite that triggered the event
  108558. * @param scene Scene associated with the sprite
  108559. * @param evt The original (browser) event
  108560. * @param additionalData additional data for the event
  108561. * @returns the new ActionEvent
  108562. */
  108563. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  108564. /**
  108565. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  108566. * @param scene the scene where the event occurred
  108567. * @param evt The original (browser) event
  108568. * @returns the new ActionEvent
  108569. */
  108570. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  108571. /**
  108572. * Helper function to auto-create an ActionEvent from a primitive
  108573. * @param prim defines the target primitive
  108574. * @param pointerPos defines the pointer position
  108575. * @param evt The original (browser) event
  108576. * @param additionalData additional data for the event
  108577. * @returns the new ActionEvent
  108578. */
  108579. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  108580. }
  108581. }
  108582. declare module BABYLON {
  108583. /**
  108584. * Abstract class used to decouple action Manager from scene and meshes.
  108585. * Do not instantiate.
  108586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108587. */
  108588. export abstract class AbstractActionManager implements IDisposable {
  108589. /** Gets the list of active triggers */
  108590. static Triggers: {
  108591. [key: string]: number;
  108592. };
  108593. /** Gets the cursor to use when hovering items */
  108594. hoverCursor: string;
  108595. /** Gets the list of actions */
  108596. actions: IAction[];
  108597. /**
  108598. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  108599. */
  108600. isRecursive: boolean;
  108601. /**
  108602. * Releases all associated resources
  108603. */
  108604. abstract dispose(): void;
  108605. /**
  108606. * Does this action manager has pointer triggers
  108607. */
  108608. abstract get hasPointerTriggers(): boolean;
  108609. /**
  108610. * Does this action manager has pick triggers
  108611. */
  108612. abstract get hasPickTriggers(): boolean;
  108613. /**
  108614. * Process a specific trigger
  108615. * @param trigger defines the trigger to process
  108616. * @param evt defines the event details to be processed
  108617. */
  108618. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  108619. /**
  108620. * Does this action manager handles actions of any of the given triggers
  108621. * @param triggers defines the triggers to be tested
  108622. * @return a boolean indicating whether one (or more) of the triggers is handled
  108623. */
  108624. abstract hasSpecificTriggers(triggers: number[]): boolean;
  108625. /**
  108626. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  108627. * speed.
  108628. * @param triggerA defines the trigger to be tested
  108629. * @param triggerB defines the trigger to be tested
  108630. * @return a boolean indicating whether one (or more) of the triggers is handled
  108631. */
  108632. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  108633. /**
  108634. * Does this action manager handles actions of a given trigger
  108635. * @param trigger defines the trigger to be tested
  108636. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  108637. * @return whether the trigger is handled
  108638. */
  108639. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  108640. /**
  108641. * Serialize this manager to a JSON object
  108642. * @param name defines the property name to store this manager
  108643. * @returns a JSON representation of this manager
  108644. */
  108645. abstract serialize(name: string): any;
  108646. /**
  108647. * Registers an action to this action manager
  108648. * @param action defines the action to be registered
  108649. * @return the action amended (prepared) after registration
  108650. */
  108651. abstract registerAction(action: IAction): Nullable<IAction>;
  108652. /**
  108653. * Unregisters an action to this action manager
  108654. * @param action defines the action to be unregistered
  108655. * @return a boolean indicating whether the action has been unregistered
  108656. */
  108657. abstract unregisterAction(action: IAction): Boolean;
  108658. /**
  108659. * Does exist one action manager with at least one trigger
  108660. **/
  108661. static get HasTriggers(): boolean;
  108662. /**
  108663. * Does exist one action manager with at least one pick trigger
  108664. **/
  108665. static get HasPickTriggers(): boolean;
  108666. /**
  108667. * Does exist one action manager that handles actions of a given trigger
  108668. * @param trigger defines the trigger to be tested
  108669. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  108670. **/
  108671. static HasSpecificTrigger(trigger: number): boolean;
  108672. }
  108673. }
  108674. declare module BABYLON {
  108675. /**
  108676. * Defines how a node can be built from a string name.
  108677. */
  108678. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  108679. /**
  108680. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  108681. */
  108682. export class Node implements IBehaviorAware<Node> {
  108683. /** @hidden */
  108684. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  108685. private static _NodeConstructors;
  108686. /**
  108687. * Add a new node constructor
  108688. * @param type defines the type name of the node to construct
  108689. * @param constructorFunc defines the constructor function
  108690. */
  108691. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  108692. /**
  108693. * Returns a node constructor based on type name
  108694. * @param type defines the type name
  108695. * @param name defines the new node name
  108696. * @param scene defines the hosting scene
  108697. * @param options defines optional options to transmit to constructors
  108698. * @returns the new constructor or null
  108699. */
  108700. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  108701. /**
  108702. * Gets or sets the name of the node
  108703. */
  108704. name: string;
  108705. /**
  108706. * Gets or sets the id of the node
  108707. */
  108708. id: string;
  108709. /**
  108710. * Gets or sets the unique id of the node
  108711. */
  108712. uniqueId: number;
  108713. /**
  108714. * Gets or sets a string used to store user defined state for the node
  108715. */
  108716. state: string;
  108717. /**
  108718. * Gets or sets an object used to store user defined information for the node
  108719. */
  108720. metadata: any;
  108721. /**
  108722. * For internal use only. Please do not use.
  108723. */
  108724. reservedDataStore: any;
  108725. /**
  108726. * List of inspectable custom properties (used by the Inspector)
  108727. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108728. */
  108729. inspectableCustomProperties: IInspectable[];
  108730. private _doNotSerialize;
  108731. /**
  108732. * Gets or sets a boolean used to define if the node must be serialized
  108733. */
  108734. get doNotSerialize(): boolean;
  108735. set doNotSerialize(value: boolean);
  108736. /** @hidden */
  108737. _isDisposed: boolean;
  108738. /**
  108739. * Gets a list of Animations associated with the node
  108740. */
  108741. animations: Animation[];
  108742. protected _ranges: {
  108743. [name: string]: Nullable<AnimationRange>;
  108744. };
  108745. /**
  108746. * Callback raised when the node is ready to be used
  108747. */
  108748. onReady: Nullable<(node: Node) => void>;
  108749. private _isEnabled;
  108750. private _isParentEnabled;
  108751. private _isReady;
  108752. /** @hidden */
  108753. _currentRenderId: number;
  108754. private _parentUpdateId;
  108755. /** @hidden */
  108756. _childUpdateId: number;
  108757. /** @hidden */
  108758. _waitingParentId: Nullable<string>;
  108759. /** @hidden */
  108760. _scene: Scene;
  108761. /** @hidden */
  108762. _cache: any;
  108763. private _parentNode;
  108764. private _children;
  108765. /** @hidden */
  108766. _worldMatrix: Matrix;
  108767. /** @hidden */
  108768. _worldMatrixDeterminant: number;
  108769. /** @hidden */
  108770. _worldMatrixDeterminantIsDirty: boolean;
  108771. /** @hidden */
  108772. private _sceneRootNodesIndex;
  108773. /**
  108774. * Gets a boolean indicating if the node has been disposed
  108775. * @returns true if the node was disposed
  108776. */
  108777. isDisposed(): boolean;
  108778. /**
  108779. * Gets or sets the parent of the node (without keeping the current position in the scene)
  108780. * @see https://doc.babylonjs.com/how_to/parenting
  108781. */
  108782. set parent(parent: Nullable<Node>);
  108783. get parent(): Nullable<Node>;
  108784. /** @hidden */
  108785. _addToSceneRootNodes(): void;
  108786. /** @hidden */
  108787. _removeFromSceneRootNodes(): void;
  108788. private _animationPropertiesOverride;
  108789. /**
  108790. * Gets or sets the animation properties override
  108791. */
  108792. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108793. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108794. /**
  108795. * Gets a string idenfifying the name of the class
  108796. * @returns "Node" string
  108797. */
  108798. getClassName(): string;
  108799. /** @hidden */
  108800. readonly _isNode: boolean;
  108801. /**
  108802. * An event triggered when the mesh is disposed
  108803. */
  108804. onDisposeObservable: Observable<Node>;
  108805. private _onDisposeObserver;
  108806. /**
  108807. * Sets a callback that will be raised when the node will be disposed
  108808. */
  108809. set onDispose(callback: () => void);
  108810. /**
  108811. * Creates a new Node
  108812. * @param name the name and id to be given to this node
  108813. * @param scene the scene this node will be added to
  108814. */
  108815. constructor(name: string, scene?: Nullable<Scene>);
  108816. /**
  108817. * Gets the scene of the node
  108818. * @returns a scene
  108819. */
  108820. getScene(): Scene;
  108821. /**
  108822. * Gets the engine of the node
  108823. * @returns a Engine
  108824. */
  108825. getEngine(): Engine;
  108826. private _behaviors;
  108827. /**
  108828. * Attach a behavior to the node
  108829. * @see http://doc.babylonjs.com/features/behaviour
  108830. * @param behavior defines the behavior to attach
  108831. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  108832. * @returns the current Node
  108833. */
  108834. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  108835. /**
  108836. * Remove an attached behavior
  108837. * @see http://doc.babylonjs.com/features/behaviour
  108838. * @param behavior defines the behavior to attach
  108839. * @returns the current Node
  108840. */
  108841. removeBehavior(behavior: Behavior<Node>): Node;
  108842. /**
  108843. * Gets the list of attached behaviors
  108844. * @see http://doc.babylonjs.com/features/behaviour
  108845. */
  108846. get behaviors(): Behavior<Node>[];
  108847. /**
  108848. * Gets an attached behavior by name
  108849. * @param name defines the name of the behavior to look for
  108850. * @see http://doc.babylonjs.com/features/behaviour
  108851. * @returns null if behavior was not found else the requested behavior
  108852. */
  108853. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  108854. /**
  108855. * Returns the latest update of the World matrix
  108856. * @returns a Matrix
  108857. */
  108858. getWorldMatrix(): Matrix;
  108859. /** @hidden */
  108860. _getWorldMatrixDeterminant(): number;
  108861. /**
  108862. * Returns directly the latest state of the mesh World matrix.
  108863. * A Matrix is returned.
  108864. */
  108865. get worldMatrixFromCache(): Matrix;
  108866. /** @hidden */
  108867. _initCache(): void;
  108868. /** @hidden */
  108869. updateCache(force?: boolean): void;
  108870. /** @hidden */
  108871. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108872. /** @hidden */
  108873. _updateCache(ignoreParentClass?: boolean): void;
  108874. /** @hidden */
  108875. _isSynchronized(): boolean;
  108876. /** @hidden */
  108877. _markSyncedWithParent(): void;
  108878. /** @hidden */
  108879. isSynchronizedWithParent(): boolean;
  108880. /** @hidden */
  108881. isSynchronized(): boolean;
  108882. /**
  108883. * Is this node ready to be used/rendered
  108884. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108885. * @return true if the node is ready
  108886. */
  108887. isReady(completeCheck?: boolean): boolean;
  108888. /**
  108889. * Is this node enabled?
  108890. * 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
  108891. * @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
  108892. * @return whether this node (and its parent) is enabled
  108893. */
  108894. isEnabled(checkAncestors?: boolean): boolean;
  108895. /** @hidden */
  108896. protected _syncParentEnabledState(): void;
  108897. /**
  108898. * Set the enabled state of this node
  108899. * @param value defines the new enabled state
  108900. */
  108901. setEnabled(value: boolean): void;
  108902. /**
  108903. * Is this node a descendant of the given node?
  108904. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  108905. * @param ancestor defines the parent node to inspect
  108906. * @returns a boolean indicating if this node is a descendant of the given node
  108907. */
  108908. isDescendantOf(ancestor: Node): boolean;
  108909. /** @hidden */
  108910. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  108911. /**
  108912. * Will return all nodes that have this node as ascendant
  108913. * @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
  108914. * @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
  108915. * @return all children nodes of all types
  108916. */
  108917. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  108918. /**
  108919. * Get all child-meshes of this node
  108920. * @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)
  108921. * @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
  108922. * @returns an array of AbstractMesh
  108923. */
  108924. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  108925. /**
  108926. * Get all direct children of this node
  108927. * @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
  108928. * @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)
  108929. * @returns an array of Node
  108930. */
  108931. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  108932. /** @hidden */
  108933. _setReady(state: boolean): void;
  108934. /**
  108935. * Get an animation by name
  108936. * @param name defines the name of the animation to look for
  108937. * @returns null if not found else the requested animation
  108938. */
  108939. getAnimationByName(name: string): Nullable<Animation>;
  108940. /**
  108941. * Creates an animation range for this node
  108942. * @param name defines the name of the range
  108943. * @param from defines the starting key
  108944. * @param to defines the end key
  108945. */
  108946. createAnimationRange(name: string, from: number, to: number): void;
  108947. /**
  108948. * Delete a specific animation range
  108949. * @param name defines the name of the range to delete
  108950. * @param deleteFrames defines if animation frames from the range must be deleted as well
  108951. */
  108952. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  108953. /**
  108954. * Get an animation range by name
  108955. * @param name defines the name of the animation range to look for
  108956. * @returns null if not found else the requested animation range
  108957. */
  108958. getAnimationRange(name: string): Nullable<AnimationRange>;
  108959. /**
  108960. * Gets the list of all animation ranges defined on this node
  108961. * @returns an array
  108962. */
  108963. getAnimationRanges(): Nullable<AnimationRange>[];
  108964. /**
  108965. * Will start the animation sequence
  108966. * @param name defines the range frames for animation sequence
  108967. * @param loop defines if the animation should loop (false by default)
  108968. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  108969. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  108970. * @returns the object created for this animation. If range does not exist, it will return null
  108971. */
  108972. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  108973. /**
  108974. * Serialize animation ranges into a JSON compatible object
  108975. * @returns serialization object
  108976. */
  108977. serializeAnimationRanges(): any;
  108978. /**
  108979. * Computes the world matrix of the node
  108980. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  108981. * @returns the world matrix
  108982. */
  108983. computeWorldMatrix(force?: boolean): Matrix;
  108984. /**
  108985. * Releases resources associated with this node.
  108986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108988. */
  108989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108990. /**
  108991. * Parse animation range data from a serialization object and store them into a given node
  108992. * @param node defines where to store the animation ranges
  108993. * @param parsedNode defines the serialization object to read data from
  108994. * @param scene defines the hosting scene
  108995. */
  108996. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  108997. /**
  108998. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  108999. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109000. * @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
  109001. * @returns the new bounding vectors
  109002. */
  109003. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109004. min: Vector3;
  109005. max: Vector3;
  109006. };
  109007. }
  109008. }
  109009. declare module BABYLON {
  109010. /**
  109011. * @hidden
  109012. */
  109013. export class _IAnimationState {
  109014. key: number;
  109015. repeatCount: number;
  109016. workValue?: any;
  109017. loopMode?: number;
  109018. offsetValue?: any;
  109019. highLimitValue?: any;
  109020. }
  109021. /**
  109022. * Class used to store any kind of animation
  109023. */
  109024. export class Animation {
  109025. /**Name of the animation */
  109026. name: string;
  109027. /**Property to animate */
  109028. targetProperty: string;
  109029. /**The frames per second of the animation */
  109030. framePerSecond: number;
  109031. /**The data type of the animation */
  109032. dataType: number;
  109033. /**The loop mode of the animation */
  109034. loopMode?: number | undefined;
  109035. /**Specifies if blending should be enabled */
  109036. enableBlending?: boolean | undefined;
  109037. /**
  109038. * Use matrix interpolation instead of using direct key value when animating matrices
  109039. */
  109040. static AllowMatricesInterpolation: boolean;
  109041. /**
  109042. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109043. */
  109044. static AllowMatrixDecomposeForInterpolation: boolean;
  109045. /**
  109046. * Stores the key frames of the animation
  109047. */
  109048. private _keys;
  109049. /**
  109050. * Stores the easing function of the animation
  109051. */
  109052. private _easingFunction;
  109053. /**
  109054. * @hidden Internal use only
  109055. */
  109056. _runtimeAnimations: RuntimeAnimation[];
  109057. /**
  109058. * The set of event that will be linked to this animation
  109059. */
  109060. private _events;
  109061. /**
  109062. * Stores an array of target property paths
  109063. */
  109064. targetPropertyPath: string[];
  109065. /**
  109066. * Stores the blending speed of the animation
  109067. */
  109068. blendingSpeed: number;
  109069. /**
  109070. * Stores the animation ranges for the animation
  109071. */
  109072. private _ranges;
  109073. /**
  109074. * @hidden Internal use
  109075. */
  109076. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109077. /**
  109078. * Sets up an animation
  109079. * @param property The property to animate
  109080. * @param animationType The animation type to apply
  109081. * @param framePerSecond The frames per second of the animation
  109082. * @param easingFunction The easing function used in the animation
  109083. * @returns The created animation
  109084. */
  109085. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109086. /**
  109087. * Create and start an animation on a node
  109088. * @param name defines the name of the global animation that will be run on all nodes
  109089. * @param node defines the root node where the animation will take place
  109090. * @param targetProperty defines property to animate
  109091. * @param framePerSecond defines the number of frame per second yo use
  109092. * @param totalFrame defines the number of frames in total
  109093. * @param from defines the initial value
  109094. * @param to defines the final value
  109095. * @param loopMode defines which loop mode you want to use (off by default)
  109096. * @param easingFunction defines the easing function to use (linear by default)
  109097. * @param onAnimationEnd defines the callback to call when animation end
  109098. * @returns the animatable created for this animation
  109099. */
  109100. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109101. /**
  109102. * Create and start an animation on a node and its descendants
  109103. * @param name defines the name of the global animation that will be run on all nodes
  109104. * @param node defines the root node where the animation will take place
  109105. * @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
  109106. * @param targetProperty defines property to animate
  109107. * @param framePerSecond defines the number of frame per second to use
  109108. * @param totalFrame defines the number of frames in total
  109109. * @param from defines the initial value
  109110. * @param to defines the final value
  109111. * @param loopMode defines which loop mode you want to use (off by default)
  109112. * @param easingFunction defines the easing function to use (linear by default)
  109113. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109114. * @returns the list of animatables created for all nodes
  109115. * @example https://www.babylonjs-playground.com/#MH0VLI
  109116. */
  109117. 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[]>;
  109118. /**
  109119. * Creates a new animation, merges it with the existing animations and starts it
  109120. * @param name Name of the animation
  109121. * @param node Node which contains the scene that begins the animations
  109122. * @param targetProperty Specifies which property to animate
  109123. * @param framePerSecond The frames per second of the animation
  109124. * @param totalFrame The total number of frames
  109125. * @param from The frame at the beginning of the animation
  109126. * @param to The frame at the end of the animation
  109127. * @param loopMode Specifies the loop mode of the animation
  109128. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109129. * @param onAnimationEnd Callback to run once the animation is complete
  109130. * @returns Nullable animation
  109131. */
  109132. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109133. /**
  109134. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109135. * @param sourceAnimation defines the Animation containing keyframes to convert
  109136. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109137. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109138. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109139. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109140. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109141. */
  109142. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109143. /**
  109144. * Transition property of an host to the target Value
  109145. * @param property The property to transition
  109146. * @param targetValue The target Value of the property
  109147. * @param host The object where the property to animate belongs
  109148. * @param scene Scene used to run the animation
  109149. * @param frameRate Framerate (in frame/s) to use
  109150. * @param transition The transition type we want to use
  109151. * @param duration The duration of the animation, in milliseconds
  109152. * @param onAnimationEnd Callback trigger at the end of the animation
  109153. * @returns Nullable animation
  109154. */
  109155. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109156. /**
  109157. * Return the array of runtime animations currently using this animation
  109158. */
  109159. get runtimeAnimations(): RuntimeAnimation[];
  109160. /**
  109161. * Specifies if any of the runtime animations are currently running
  109162. */
  109163. get hasRunningRuntimeAnimations(): boolean;
  109164. /**
  109165. * Initializes the animation
  109166. * @param name Name of the animation
  109167. * @param targetProperty Property to animate
  109168. * @param framePerSecond The frames per second of the animation
  109169. * @param dataType The data type of the animation
  109170. * @param loopMode The loop mode of the animation
  109171. * @param enableBlending Specifies if blending should be enabled
  109172. */
  109173. constructor(
  109174. /**Name of the animation */
  109175. name: string,
  109176. /**Property to animate */
  109177. targetProperty: string,
  109178. /**The frames per second of the animation */
  109179. framePerSecond: number,
  109180. /**The data type of the animation */
  109181. dataType: number,
  109182. /**The loop mode of the animation */
  109183. loopMode?: number | undefined,
  109184. /**Specifies if blending should be enabled */
  109185. enableBlending?: boolean | undefined);
  109186. /**
  109187. * Converts the animation to a string
  109188. * @param fullDetails support for multiple levels of logging within scene loading
  109189. * @returns String form of the animation
  109190. */
  109191. toString(fullDetails?: boolean): string;
  109192. /**
  109193. * Add an event to this animation
  109194. * @param event Event to add
  109195. */
  109196. addEvent(event: AnimationEvent): void;
  109197. /**
  109198. * Remove all events found at the given frame
  109199. * @param frame The frame to remove events from
  109200. */
  109201. removeEvents(frame: number): void;
  109202. /**
  109203. * Retrieves all the events from the animation
  109204. * @returns Events from the animation
  109205. */
  109206. getEvents(): AnimationEvent[];
  109207. /**
  109208. * Creates an animation range
  109209. * @param name Name of the animation range
  109210. * @param from Starting frame of the animation range
  109211. * @param to Ending frame of the animation
  109212. */
  109213. createRange(name: string, from: number, to: number): void;
  109214. /**
  109215. * Deletes an animation range by name
  109216. * @param name Name of the animation range to delete
  109217. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109218. */
  109219. deleteRange(name: string, deleteFrames?: boolean): void;
  109220. /**
  109221. * Gets the animation range by name, or null if not defined
  109222. * @param name Name of the animation range
  109223. * @returns Nullable animation range
  109224. */
  109225. getRange(name: string): Nullable<AnimationRange>;
  109226. /**
  109227. * Gets the key frames from the animation
  109228. * @returns The key frames of the animation
  109229. */
  109230. getKeys(): Array<IAnimationKey>;
  109231. /**
  109232. * Gets the highest frame rate of the animation
  109233. * @returns Highest frame rate of the animation
  109234. */
  109235. getHighestFrame(): number;
  109236. /**
  109237. * Gets the easing function of the animation
  109238. * @returns Easing function of the animation
  109239. */
  109240. getEasingFunction(): IEasingFunction;
  109241. /**
  109242. * Sets the easing function of the animation
  109243. * @param easingFunction A custom mathematical formula for animation
  109244. */
  109245. setEasingFunction(easingFunction: EasingFunction): void;
  109246. /**
  109247. * Interpolates a scalar linearly
  109248. * @param startValue Start value of the animation curve
  109249. * @param endValue End value of the animation curve
  109250. * @param gradient Scalar amount to interpolate
  109251. * @returns Interpolated scalar value
  109252. */
  109253. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  109254. /**
  109255. * Interpolates a scalar cubically
  109256. * @param startValue Start value of the animation curve
  109257. * @param outTangent End tangent of the animation
  109258. * @param endValue End value of the animation curve
  109259. * @param inTangent Start tangent of the animation curve
  109260. * @param gradient Scalar amount to interpolate
  109261. * @returns Interpolated scalar value
  109262. */
  109263. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  109264. /**
  109265. * Interpolates a quaternion using a spherical linear interpolation
  109266. * @param startValue Start value of the animation curve
  109267. * @param endValue End value of the animation curve
  109268. * @param gradient Scalar amount to interpolate
  109269. * @returns Interpolated quaternion value
  109270. */
  109271. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  109272. /**
  109273. * Interpolates a quaternion cubically
  109274. * @param startValue Start value of the animation curve
  109275. * @param outTangent End tangent of the animation curve
  109276. * @param endValue End value of the animation curve
  109277. * @param inTangent Start tangent of the animation curve
  109278. * @param gradient Scalar amount to interpolate
  109279. * @returns Interpolated quaternion value
  109280. */
  109281. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  109282. /**
  109283. * Interpolates a Vector3 linearl
  109284. * @param startValue Start value of the animation curve
  109285. * @param endValue End value of the animation curve
  109286. * @param gradient Scalar amount to interpolate
  109287. * @returns Interpolated scalar value
  109288. */
  109289. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  109290. /**
  109291. * Interpolates a Vector3 cubically
  109292. * @param startValue Start value of the animation curve
  109293. * @param outTangent End tangent of the animation
  109294. * @param endValue End value of the animation curve
  109295. * @param inTangent Start tangent of the animation curve
  109296. * @param gradient Scalar amount to interpolate
  109297. * @returns InterpolatedVector3 value
  109298. */
  109299. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  109300. /**
  109301. * Interpolates a Vector2 linearly
  109302. * @param startValue Start value of the animation curve
  109303. * @param endValue End value of the animation curve
  109304. * @param gradient Scalar amount to interpolate
  109305. * @returns Interpolated Vector2 value
  109306. */
  109307. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  109308. /**
  109309. * Interpolates a Vector2 cubically
  109310. * @param startValue Start value of the animation curve
  109311. * @param outTangent End tangent of the animation
  109312. * @param endValue End value of the animation curve
  109313. * @param inTangent Start tangent of the animation curve
  109314. * @param gradient Scalar amount to interpolate
  109315. * @returns Interpolated Vector2 value
  109316. */
  109317. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  109318. /**
  109319. * Interpolates a size linearly
  109320. * @param startValue Start value of the animation curve
  109321. * @param endValue End value of the animation curve
  109322. * @param gradient Scalar amount to interpolate
  109323. * @returns Interpolated Size value
  109324. */
  109325. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  109326. /**
  109327. * Interpolates a Color3 linearly
  109328. * @param startValue Start value of the animation curve
  109329. * @param endValue End value of the animation curve
  109330. * @param gradient Scalar amount to interpolate
  109331. * @returns Interpolated Color3 value
  109332. */
  109333. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  109334. /**
  109335. * Interpolates a Color4 linearly
  109336. * @param startValue Start value of the animation curve
  109337. * @param endValue End value of the animation curve
  109338. * @param gradient Scalar amount to interpolate
  109339. * @returns Interpolated Color3 value
  109340. */
  109341. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  109342. /**
  109343. * @hidden Internal use only
  109344. */
  109345. _getKeyValue(value: any): any;
  109346. /**
  109347. * @hidden Internal use only
  109348. */
  109349. _interpolate(currentFrame: number, state: _IAnimationState): any;
  109350. /**
  109351. * Defines the function to use to interpolate matrices
  109352. * @param startValue defines the start matrix
  109353. * @param endValue defines the end matrix
  109354. * @param gradient defines the gradient between both matrices
  109355. * @param result defines an optional target matrix where to store the interpolation
  109356. * @returns the interpolated matrix
  109357. */
  109358. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  109359. /**
  109360. * Makes a copy of the animation
  109361. * @returns Cloned animation
  109362. */
  109363. clone(): Animation;
  109364. /**
  109365. * Sets the key frames of the animation
  109366. * @param values The animation key frames to set
  109367. */
  109368. setKeys(values: Array<IAnimationKey>): void;
  109369. /**
  109370. * Serializes the animation to an object
  109371. * @returns Serialized object
  109372. */
  109373. serialize(): any;
  109374. /**
  109375. * Float animation type
  109376. */
  109377. static readonly ANIMATIONTYPE_FLOAT: number;
  109378. /**
  109379. * Vector3 animation type
  109380. */
  109381. static readonly ANIMATIONTYPE_VECTOR3: number;
  109382. /**
  109383. * Quaternion animation type
  109384. */
  109385. static readonly ANIMATIONTYPE_QUATERNION: number;
  109386. /**
  109387. * Matrix animation type
  109388. */
  109389. static readonly ANIMATIONTYPE_MATRIX: number;
  109390. /**
  109391. * Color3 animation type
  109392. */
  109393. static readonly ANIMATIONTYPE_COLOR3: number;
  109394. /**
  109395. * Color3 animation type
  109396. */
  109397. static readonly ANIMATIONTYPE_COLOR4: number;
  109398. /**
  109399. * Vector2 animation type
  109400. */
  109401. static readonly ANIMATIONTYPE_VECTOR2: number;
  109402. /**
  109403. * Size animation type
  109404. */
  109405. static readonly ANIMATIONTYPE_SIZE: number;
  109406. /**
  109407. * Relative Loop Mode
  109408. */
  109409. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  109410. /**
  109411. * Cycle Loop Mode
  109412. */
  109413. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  109414. /**
  109415. * Constant Loop Mode
  109416. */
  109417. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  109418. /** @hidden */
  109419. static _UniversalLerp(left: any, right: any, amount: number): any;
  109420. /**
  109421. * Parses an animation object and creates an animation
  109422. * @param parsedAnimation Parsed animation object
  109423. * @returns Animation object
  109424. */
  109425. static Parse(parsedAnimation: any): Animation;
  109426. /**
  109427. * Appends the serialized animations from the source animations
  109428. * @param source Source containing the animations
  109429. * @param destination Target to store the animations
  109430. */
  109431. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109432. }
  109433. }
  109434. declare module BABYLON {
  109435. /**
  109436. * Interface containing an array of animations
  109437. */
  109438. export interface IAnimatable {
  109439. /**
  109440. * Array of animations
  109441. */
  109442. animations: Nullable<Array<Animation>>;
  109443. }
  109444. }
  109445. declare module BABYLON {
  109446. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  109447. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109448. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109449. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109450. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109451. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109452. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109453. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109454. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109455. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109456. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109457. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109458. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109459. /**
  109460. * Decorator used to define property that can be serialized as reference to a camera
  109461. * @param sourceName defines the name of the property to decorate
  109462. */
  109463. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109464. /**
  109465. * Class used to help serialization objects
  109466. */
  109467. export class SerializationHelper {
  109468. /** @hidden */
  109469. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  109470. /** @hidden */
  109471. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  109472. /** @hidden */
  109473. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  109474. /** @hidden */
  109475. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  109476. /**
  109477. * Appends the serialized animations from the source animations
  109478. * @param source Source containing the animations
  109479. * @param destination Target to store the animations
  109480. */
  109481. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109482. /**
  109483. * Static function used to serialized a specific entity
  109484. * @param entity defines the entity to serialize
  109485. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109486. * @returns a JSON compatible object representing the serialization of the entity
  109487. */
  109488. static Serialize<T>(entity: T, serializationObject?: any): any;
  109489. /**
  109490. * Creates a new entity from a serialization data object
  109491. * @param creationFunction defines a function used to instanciated the new entity
  109492. * @param source defines the source serialization data
  109493. * @param scene defines the hosting scene
  109494. * @param rootUrl defines the root url for resources
  109495. * @returns a new entity
  109496. */
  109497. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  109498. /**
  109499. * Clones an object
  109500. * @param creationFunction defines the function used to instanciate the new object
  109501. * @param source defines the source object
  109502. * @returns the cloned object
  109503. */
  109504. static Clone<T>(creationFunction: () => T, source: T): T;
  109505. /**
  109506. * Instanciates a new object based on a source one (some data will be shared between both object)
  109507. * @param creationFunction defines the function used to instanciate the new object
  109508. * @param source defines the source object
  109509. * @returns the new object
  109510. */
  109511. static Instanciate<T>(creationFunction: () => T, source: T): T;
  109512. }
  109513. }
  109514. declare module BABYLON {
  109515. /**
  109516. * Base class of all the textures in babylon.
  109517. * It groups all the common properties the materials, post process, lights... might need
  109518. * in order to make a correct use of the texture.
  109519. */
  109520. export class BaseTexture implements IAnimatable {
  109521. /**
  109522. * Default anisotropic filtering level for the application.
  109523. * It is set to 4 as a good tradeoff between perf and quality.
  109524. */
  109525. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  109526. /**
  109527. * Gets or sets the unique id of the texture
  109528. */
  109529. uniqueId: number;
  109530. /**
  109531. * Define the name of the texture.
  109532. */
  109533. name: string;
  109534. /**
  109535. * Gets or sets an object used to store user defined information.
  109536. */
  109537. metadata: any;
  109538. /**
  109539. * For internal use only. Please do not use.
  109540. */
  109541. reservedDataStore: any;
  109542. private _hasAlpha;
  109543. /**
  109544. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  109545. */
  109546. set hasAlpha(value: boolean);
  109547. get hasAlpha(): boolean;
  109548. /**
  109549. * Defines if the alpha value should be determined via the rgb values.
  109550. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  109551. */
  109552. getAlphaFromRGB: boolean;
  109553. /**
  109554. * Intensity or strength of the texture.
  109555. * It is commonly used by materials to fine tune the intensity of the texture
  109556. */
  109557. level: number;
  109558. /**
  109559. * Define the UV chanel to use starting from 0 and defaulting to 0.
  109560. * This is part of the texture as textures usually maps to one uv set.
  109561. */
  109562. coordinatesIndex: number;
  109563. private _coordinatesMode;
  109564. /**
  109565. * How a texture is mapped.
  109566. *
  109567. * | Value | Type | Description |
  109568. * | ----- | ----------------------------------- | ----------- |
  109569. * | 0 | EXPLICIT_MODE | |
  109570. * | 1 | SPHERICAL_MODE | |
  109571. * | 2 | PLANAR_MODE | |
  109572. * | 3 | CUBIC_MODE | |
  109573. * | 4 | PROJECTION_MODE | |
  109574. * | 5 | SKYBOX_MODE | |
  109575. * | 6 | INVCUBIC_MODE | |
  109576. * | 7 | EQUIRECTANGULAR_MODE | |
  109577. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  109578. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  109579. */
  109580. set coordinatesMode(value: number);
  109581. get coordinatesMode(): number;
  109582. /**
  109583. * | Value | Type | Description |
  109584. * | ----- | ------------------ | ----------- |
  109585. * | 0 | CLAMP_ADDRESSMODE | |
  109586. * | 1 | WRAP_ADDRESSMODE | |
  109587. * | 2 | MIRROR_ADDRESSMODE | |
  109588. */
  109589. wrapU: number;
  109590. /**
  109591. * | Value | Type | Description |
  109592. * | ----- | ------------------ | ----------- |
  109593. * | 0 | CLAMP_ADDRESSMODE | |
  109594. * | 1 | WRAP_ADDRESSMODE | |
  109595. * | 2 | MIRROR_ADDRESSMODE | |
  109596. */
  109597. wrapV: number;
  109598. /**
  109599. * | Value | Type | Description |
  109600. * | ----- | ------------------ | ----------- |
  109601. * | 0 | CLAMP_ADDRESSMODE | |
  109602. * | 1 | WRAP_ADDRESSMODE | |
  109603. * | 2 | MIRROR_ADDRESSMODE | |
  109604. */
  109605. wrapR: number;
  109606. /**
  109607. * With compliant hardware and browser (supporting anisotropic filtering)
  109608. * this defines the level of anisotropic filtering in the texture.
  109609. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  109610. */
  109611. anisotropicFilteringLevel: number;
  109612. /**
  109613. * Define if the texture is a cube texture or if false a 2d texture.
  109614. */
  109615. get isCube(): boolean;
  109616. set isCube(value: boolean);
  109617. /**
  109618. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  109619. */
  109620. get is3D(): boolean;
  109621. set is3D(value: boolean);
  109622. /**
  109623. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  109624. */
  109625. get is2DArray(): boolean;
  109626. set is2DArray(value: boolean);
  109627. /**
  109628. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  109629. * HDR texture are usually stored in linear space.
  109630. * This only impacts the PBR and Background materials
  109631. */
  109632. gammaSpace: boolean;
  109633. /**
  109634. * Gets or sets whether or not the texture contains RGBD data.
  109635. */
  109636. get isRGBD(): boolean;
  109637. set isRGBD(value: boolean);
  109638. /**
  109639. * Is Z inverted in the texture (useful in a cube texture).
  109640. */
  109641. invertZ: boolean;
  109642. /**
  109643. * Are mip maps generated for this texture or not.
  109644. */
  109645. get noMipmap(): boolean;
  109646. /**
  109647. * @hidden
  109648. */
  109649. lodLevelInAlpha: boolean;
  109650. /**
  109651. * With prefiltered texture, defined the offset used during the prefiltering steps.
  109652. */
  109653. get lodGenerationOffset(): number;
  109654. set lodGenerationOffset(value: number);
  109655. /**
  109656. * With prefiltered texture, defined the scale used during the prefiltering steps.
  109657. */
  109658. get lodGenerationScale(): number;
  109659. set lodGenerationScale(value: number);
  109660. /**
  109661. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  109662. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  109663. * average roughness values.
  109664. */
  109665. get linearSpecularLOD(): boolean;
  109666. set linearSpecularLOD(value: boolean);
  109667. /**
  109668. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  109669. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  109670. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  109671. */
  109672. get irradianceTexture(): Nullable<BaseTexture>;
  109673. set irradianceTexture(value: Nullable<BaseTexture>);
  109674. /**
  109675. * Define if the texture is a render target.
  109676. */
  109677. isRenderTarget: boolean;
  109678. /**
  109679. * Define the unique id of the texture in the scene.
  109680. */
  109681. get uid(): string;
  109682. /**
  109683. * Return a string representation of the texture.
  109684. * @returns the texture as a string
  109685. */
  109686. toString(): string;
  109687. /**
  109688. * Get the class name of the texture.
  109689. * @returns "BaseTexture"
  109690. */
  109691. getClassName(): string;
  109692. private _realTimeFiltering;
  109693. /**
  109694. * Enables realtime filtering on the texture.
  109695. */
  109696. get realTimeFiltering(): boolean;
  109697. set realTimeFiltering(b: boolean);
  109698. private _realTimeFilteringQuality;
  109699. /**
  109700. * Quality switch for realtime filtering
  109701. */
  109702. get realTimeFilteringQuality(): number;
  109703. set realTimeFilteringQuality(n: number);
  109704. /**
  109705. * Define the list of animation attached to the texture.
  109706. */
  109707. animations: Animation[];
  109708. /**
  109709. * An event triggered when the texture is disposed.
  109710. */
  109711. onDisposeObservable: Observable<BaseTexture>;
  109712. private _onDisposeObserver;
  109713. /**
  109714. * Callback triggered when the texture has been disposed.
  109715. * Kept for back compatibility, you can use the onDisposeObservable instead.
  109716. */
  109717. set onDispose(callback: () => void);
  109718. /**
  109719. * Define the current state of the loading sequence when in delayed load mode.
  109720. */
  109721. delayLoadState: number;
  109722. private _scene;
  109723. private _engine;
  109724. /** @hidden */
  109725. _texture: Nullable<InternalTexture>;
  109726. private _uid;
  109727. /**
  109728. * Define if the texture is preventinga material to render or not.
  109729. * If not and the texture is not ready, the engine will use a default black texture instead.
  109730. */
  109731. get isBlocking(): boolean;
  109732. /**
  109733. * Instantiates a new BaseTexture.
  109734. * Base class of all the textures in babylon.
  109735. * It groups all the common properties the materials, post process, lights... might need
  109736. * in order to make a correct use of the texture.
  109737. * @param sceneOrEngine Define the scene or engine the texture blongs to
  109738. */
  109739. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  109740. /**
  109741. * Get the scene the texture belongs to.
  109742. * @returns the scene or null if undefined
  109743. */
  109744. getScene(): Nullable<Scene>;
  109745. /** @hidden */
  109746. protected _getEngine(): Nullable<ThinEngine>;
  109747. /**
  109748. * Get the texture transform matrix used to offset tile the texture for istance.
  109749. * @returns the transformation matrix
  109750. */
  109751. getTextureMatrix(): Matrix;
  109752. /**
  109753. * Get the texture reflection matrix used to rotate/transform the reflection.
  109754. * @returns the reflection matrix
  109755. */
  109756. getReflectionTextureMatrix(): Matrix;
  109757. /**
  109758. * Get the underlying lower level texture from Babylon.
  109759. * @returns the insternal texture
  109760. */
  109761. getInternalTexture(): Nullable<InternalTexture>;
  109762. /**
  109763. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  109764. * @returns true if ready or not blocking
  109765. */
  109766. isReadyOrNotBlocking(): boolean;
  109767. /**
  109768. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  109769. * @returns true if fully ready
  109770. */
  109771. isReady(): boolean;
  109772. private _cachedSize;
  109773. /**
  109774. * Get the size of the texture.
  109775. * @returns the texture size.
  109776. */
  109777. getSize(): ISize;
  109778. /**
  109779. * Get the base size of the texture.
  109780. * It can be different from the size if the texture has been resized for POT for instance
  109781. * @returns the base size
  109782. */
  109783. getBaseSize(): ISize;
  109784. /**
  109785. * Update the sampling mode of the texture.
  109786. * Default is Trilinear mode.
  109787. *
  109788. * | Value | Type | Description |
  109789. * | ----- | ------------------ | ----------- |
  109790. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  109791. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  109792. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  109793. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  109794. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  109795. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  109796. * | 7 | NEAREST_LINEAR | |
  109797. * | 8 | NEAREST_NEAREST | |
  109798. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  109799. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  109800. * | 11 | LINEAR_LINEAR | |
  109801. * | 12 | LINEAR_NEAREST | |
  109802. *
  109803. * > _mag_: magnification filter (close to the viewer)
  109804. * > _min_: minification filter (far from the viewer)
  109805. * > _mip_: filter used between mip map levels
  109806. *@param samplingMode Define the new sampling mode of the texture
  109807. */
  109808. updateSamplingMode(samplingMode: number): void;
  109809. /**
  109810. * Scales the texture if is `canRescale()`
  109811. * @param ratio the resize factor we want to use to rescale
  109812. */
  109813. scale(ratio: number): void;
  109814. /**
  109815. * Get if the texture can rescale.
  109816. */
  109817. get canRescale(): boolean;
  109818. /** @hidden */
  109819. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  109820. /** @hidden */
  109821. _rebuild(): void;
  109822. /**
  109823. * Triggers the load sequence in delayed load mode.
  109824. */
  109825. delayLoad(): void;
  109826. /**
  109827. * Clones the texture.
  109828. * @returns the cloned texture
  109829. */
  109830. clone(): Nullable<BaseTexture>;
  109831. /**
  109832. * Get the texture underlying type (INT, FLOAT...)
  109833. */
  109834. get textureType(): number;
  109835. /**
  109836. * Get the texture underlying format (RGB, RGBA...)
  109837. */
  109838. get textureFormat(): number;
  109839. /**
  109840. * Indicates that textures need to be re-calculated for all materials
  109841. */
  109842. protected _markAllSubMeshesAsTexturesDirty(): void;
  109843. /**
  109844. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  109845. * This will returns an RGBA array buffer containing either in values (0-255) or
  109846. * float values (0-1) depending of the underlying buffer type.
  109847. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  109848. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  109849. * @param buffer defines a user defined buffer to fill with data (can be null)
  109850. * @returns The Array buffer containing the pixels data.
  109851. */
  109852. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  109853. /**
  109854. * Release and destroy the underlying lower level texture aka internalTexture.
  109855. */
  109856. releaseInternalTexture(): void;
  109857. /** @hidden */
  109858. get _lodTextureHigh(): Nullable<BaseTexture>;
  109859. /** @hidden */
  109860. get _lodTextureMid(): Nullable<BaseTexture>;
  109861. /** @hidden */
  109862. get _lodTextureLow(): Nullable<BaseTexture>;
  109863. /**
  109864. * Dispose the texture and release its associated resources.
  109865. */
  109866. dispose(): void;
  109867. /**
  109868. * Serialize the texture into a JSON representation that can be parsed later on.
  109869. * @returns the JSON representation of the texture
  109870. */
  109871. serialize(): any;
  109872. /**
  109873. * Helper function to be called back once a list of texture contains only ready textures.
  109874. * @param textures Define the list of textures to wait for
  109875. * @param callback Define the callback triggered once the entire list will be ready
  109876. */
  109877. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  109878. private static _isScene;
  109879. }
  109880. }
  109881. declare module BABYLON {
  109882. /**
  109883. * Options to be used when creating an effect.
  109884. */
  109885. export interface IEffectCreationOptions {
  109886. /**
  109887. * Atrributes that will be used in the shader.
  109888. */
  109889. attributes: string[];
  109890. /**
  109891. * Uniform varible names that will be set in the shader.
  109892. */
  109893. uniformsNames: string[];
  109894. /**
  109895. * Uniform buffer variable names that will be set in the shader.
  109896. */
  109897. uniformBuffersNames: string[];
  109898. /**
  109899. * Sampler texture variable names that will be set in the shader.
  109900. */
  109901. samplers: string[];
  109902. /**
  109903. * Define statements that will be set in the shader.
  109904. */
  109905. defines: any;
  109906. /**
  109907. * Possible fallbacks for this effect to improve performance when needed.
  109908. */
  109909. fallbacks: Nullable<IEffectFallbacks>;
  109910. /**
  109911. * Callback that will be called when the shader is compiled.
  109912. */
  109913. onCompiled: Nullable<(effect: Effect) => void>;
  109914. /**
  109915. * Callback that will be called if an error occurs during shader compilation.
  109916. */
  109917. onError: Nullable<(effect: Effect, errors: string) => void>;
  109918. /**
  109919. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  109920. */
  109921. indexParameters?: any;
  109922. /**
  109923. * Max number of lights that can be used in the shader.
  109924. */
  109925. maxSimultaneousLights?: number;
  109926. /**
  109927. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  109928. */
  109929. transformFeedbackVaryings?: Nullable<string[]>;
  109930. }
  109931. /**
  109932. * Effect containing vertex and fragment shader that can be executed on an object.
  109933. */
  109934. export class Effect implements IDisposable {
  109935. /**
  109936. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  109937. */
  109938. static ShadersRepository: string;
  109939. /**
  109940. * Enable logging of the shader code when a compilation error occurs
  109941. */
  109942. static LogShaderCodeOnCompilationError: boolean;
  109943. /**
  109944. * Name of the effect.
  109945. */
  109946. name: any;
  109947. /**
  109948. * String container all the define statements that should be set on the shader.
  109949. */
  109950. defines: string;
  109951. /**
  109952. * Callback that will be called when the shader is compiled.
  109953. */
  109954. onCompiled: Nullable<(effect: Effect) => void>;
  109955. /**
  109956. * Callback that will be called if an error occurs during shader compilation.
  109957. */
  109958. onError: Nullable<(effect: Effect, errors: string) => void>;
  109959. /**
  109960. * Callback that will be called when effect is bound.
  109961. */
  109962. onBind: Nullable<(effect: Effect) => void>;
  109963. /**
  109964. * Unique ID of the effect.
  109965. */
  109966. uniqueId: number;
  109967. /**
  109968. * Observable that will be called when the shader is compiled.
  109969. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  109970. */
  109971. onCompileObservable: Observable<Effect>;
  109972. /**
  109973. * Observable that will be called if an error occurs during shader compilation.
  109974. */
  109975. onErrorObservable: Observable<Effect>;
  109976. /** @hidden */
  109977. _onBindObservable: Nullable<Observable<Effect>>;
  109978. /**
  109979. * @hidden
  109980. * Specifies if the effect was previously ready
  109981. */
  109982. _wasPreviouslyReady: boolean;
  109983. /**
  109984. * Observable that will be called when effect is bound.
  109985. */
  109986. get onBindObservable(): Observable<Effect>;
  109987. /** @hidden */
  109988. _bonesComputationForcedToCPU: boolean;
  109989. private static _uniqueIdSeed;
  109990. private _engine;
  109991. private _uniformBuffersNames;
  109992. private _uniformBuffersNamesList;
  109993. private _uniformsNames;
  109994. private _samplerList;
  109995. private _samplers;
  109996. private _isReady;
  109997. private _compilationError;
  109998. private _allFallbacksProcessed;
  109999. private _attributesNames;
  110000. private _attributes;
  110001. private _attributeLocationByName;
  110002. private _uniforms;
  110003. /**
  110004. * Key for the effect.
  110005. * @hidden
  110006. */
  110007. _key: string;
  110008. private _indexParameters;
  110009. private _fallbacks;
  110010. private _vertexSourceCode;
  110011. private _fragmentSourceCode;
  110012. private _vertexSourceCodeOverride;
  110013. private _fragmentSourceCodeOverride;
  110014. private _transformFeedbackVaryings;
  110015. /**
  110016. * Compiled shader to webGL program.
  110017. * @hidden
  110018. */
  110019. _pipelineContext: Nullable<IPipelineContext>;
  110020. private _valueCache;
  110021. private static _baseCache;
  110022. /**
  110023. * Instantiates an effect.
  110024. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110025. * @param baseName Name of the effect.
  110026. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110027. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110028. * @param samplers List of sampler variables that will be passed to the shader.
  110029. * @param engine Engine to be used to render the effect
  110030. * @param defines Define statements to be added to the shader.
  110031. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110032. * @param onCompiled Callback that will be called when the shader is compiled.
  110033. * @param onError Callback that will be called if an error occurs during shader compilation.
  110034. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110035. */
  110036. 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);
  110037. private _useFinalCode;
  110038. /**
  110039. * Unique key for this effect
  110040. */
  110041. get key(): string;
  110042. /**
  110043. * If the effect has been compiled and prepared.
  110044. * @returns if the effect is compiled and prepared.
  110045. */
  110046. isReady(): boolean;
  110047. private _isReadyInternal;
  110048. /**
  110049. * The engine the effect was initialized with.
  110050. * @returns the engine.
  110051. */
  110052. getEngine(): Engine;
  110053. /**
  110054. * The pipeline context for this effect
  110055. * @returns the associated pipeline context
  110056. */
  110057. getPipelineContext(): Nullable<IPipelineContext>;
  110058. /**
  110059. * The set of names of attribute variables for the shader.
  110060. * @returns An array of attribute names.
  110061. */
  110062. getAttributesNames(): string[];
  110063. /**
  110064. * Returns the attribute at the given index.
  110065. * @param index The index of the attribute.
  110066. * @returns The location of the attribute.
  110067. */
  110068. getAttributeLocation(index: number): number;
  110069. /**
  110070. * Returns the attribute based on the name of the variable.
  110071. * @param name of the attribute to look up.
  110072. * @returns the attribute location.
  110073. */
  110074. getAttributeLocationByName(name: string): number;
  110075. /**
  110076. * The number of attributes.
  110077. * @returns the numnber of attributes.
  110078. */
  110079. getAttributesCount(): number;
  110080. /**
  110081. * Gets the index of a uniform variable.
  110082. * @param uniformName of the uniform to look up.
  110083. * @returns the index.
  110084. */
  110085. getUniformIndex(uniformName: string): number;
  110086. /**
  110087. * Returns the attribute based on the name of the variable.
  110088. * @param uniformName of the uniform to look up.
  110089. * @returns the location of the uniform.
  110090. */
  110091. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110092. /**
  110093. * Returns an array of sampler variable names
  110094. * @returns The array of sampler variable names.
  110095. */
  110096. getSamplers(): string[];
  110097. /**
  110098. * Returns an array of uniform variable names
  110099. * @returns The array of uniform variable names.
  110100. */
  110101. getUniformNames(): string[];
  110102. /**
  110103. * Returns an array of uniform buffer variable names
  110104. * @returns The array of uniform buffer variable names.
  110105. */
  110106. getUniformBuffersNames(): string[];
  110107. /**
  110108. * Returns the index parameters used to create the effect
  110109. * @returns The index parameters object
  110110. */
  110111. getIndexParameters(): any;
  110112. /**
  110113. * The error from the last compilation.
  110114. * @returns the error string.
  110115. */
  110116. getCompilationError(): string;
  110117. /**
  110118. * Gets a boolean indicating that all fallbacks were used during compilation
  110119. * @returns true if all fallbacks were used
  110120. */
  110121. allFallbacksProcessed(): boolean;
  110122. /**
  110123. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110124. * @param func The callback to be used.
  110125. */
  110126. executeWhenCompiled(func: (effect: Effect) => void): void;
  110127. private _checkIsReady;
  110128. private _loadShader;
  110129. /**
  110130. * Gets the vertex shader source code of this effect
  110131. */
  110132. get vertexSourceCode(): string;
  110133. /**
  110134. * Gets the fragment shader source code of this effect
  110135. */
  110136. get fragmentSourceCode(): string;
  110137. /**
  110138. * Recompiles the webGL program
  110139. * @param vertexSourceCode The source code for the vertex shader.
  110140. * @param fragmentSourceCode The source code for the fragment shader.
  110141. * @param onCompiled Callback called when completed.
  110142. * @param onError Callback called on error.
  110143. * @hidden
  110144. */
  110145. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110146. /**
  110147. * Prepares the effect
  110148. * @hidden
  110149. */
  110150. _prepareEffect(): void;
  110151. private _getShaderCodeAndErrorLine;
  110152. private _processCompilationErrors;
  110153. /**
  110154. * Checks if the effect is supported. (Must be called after compilation)
  110155. */
  110156. get isSupported(): boolean;
  110157. /**
  110158. * Binds a texture to the engine to be used as output of the shader.
  110159. * @param channel Name of the output variable.
  110160. * @param texture Texture to bind.
  110161. * @hidden
  110162. */
  110163. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110164. /**
  110165. * Sets a texture on the engine to be used in the shader.
  110166. * @param channel Name of the sampler variable.
  110167. * @param texture Texture to set.
  110168. */
  110169. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110170. /**
  110171. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110172. * @param channel Name of the sampler variable.
  110173. * @param texture Texture to set.
  110174. */
  110175. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110176. /**
  110177. * Sets an array of textures on the engine to be used in the shader.
  110178. * @param channel Name of the variable.
  110179. * @param textures Textures to set.
  110180. */
  110181. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110182. /**
  110183. * 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)
  110184. * @param channel Name of the sampler variable.
  110185. * @param postProcess Post process to get the input texture from.
  110186. */
  110187. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110188. /**
  110189. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110190. * 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)
  110191. * @param channel Name of the sampler variable.
  110192. * @param postProcess Post process to get the output texture from.
  110193. */
  110194. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110195. /** @hidden */
  110196. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110197. /** @hidden */
  110198. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110199. /** @hidden */
  110200. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110201. /** @hidden */
  110202. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110203. /**
  110204. * Binds a buffer to a uniform.
  110205. * @param buffer Buffer to bind.
  110206. * @param name Name of the uniform variable to bind to.
  110207. */
  110208. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110209. /**
  110210. * Binds block to a uniform.
  110211. * @param blockName Name of the block to bind.
  110212. * @param index Index to bind.
  110213. */
  110214. bindUniformBlock(blockName: string, index: number): void;
  110215. /**
  110216. * Sets an interger value on a uniform variable.
  110217. * @param uniformName Name of the variable.
  110218. * @param value Value to be set.
  110219. * @returns this effect.
  110220. */
  110221. setInt(uniformName: string, value: number): Effect;
  110222. /**
  110223. * Sets an int array on a uniform variable.
  110224. * @param uniformName Name of the variable.
  110225. * @param array array to be set.
  110226. * @returns this effect.
  110227. */
  110228. setIntArray(uniformName: string, array: Int32Array): Effect;
  110229. /**
  110230. * 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)
  110231. * @param uniformName Name of the variable.
  110232. * @param array array to be set.
  110233. * @returns this effect.
  110234. */
  110235. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110236. /**
  110237. * 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)
  110238. * @param uniformName Name of the variable.
  110239. * @param array array to be set.
  110240. * @returns this effect.
  110241. */
  110242. setIntArray3(uniformName: string, array: Int32Array): Effect;
  110243. /**
  110244. * 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)
  110245. * @param uniformName Name of the variable.
  110246. * @param array array to be set.
  110247. * @returns this effect.
  110248. */
  110249. setIntArray4(uniformName: string, array: Int32Array): Effect;
  110250. /**
  110251. * Sets an float array on a uniform variable.
  110252. * @param uniformName Name of the variable.
  110253. * @param array array to be set.
  110254. * @returns this effect.
  110255. */
  110256. setFloatArray(uniformName: string, array: Float32Array): Effect;
  110257. /**
  110258. * 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)
  110259. * @param uniformName Name of the variable.
  110260. * @param array array to be set.
  110261. * @returns this effect.
  110262. */
  110263. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  110264. /**
  110265. * 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)
  110266. * @param uniformName Name of the variable.
  110267. * @param array array to be set.
  110268. * @returns this effect.
  110269. */
  110270. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  110271. /**
  110272. * 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)
  110273. * @param uniformName Name of the variable.
  110274. * @param array array to be set.
  110275. * @returns this effect.
  110276. */
  110277. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  110278. /**
  110279. * Sets an array on a uniform variable.
  110280. * @param uniformName Name of the variable.
  110281. * @param array array to be set.
  110282. * @returns this effect.
  110283. */
  110284. setArray(uniformName: string, array: number[]): Effect;
  110285. /**
  110286. * 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)
  110287. * @param uniformName Name of the variable.
  110288. * @param array array to be set.
  110289. * @returns this effect.
  110290. */
  110291. setArray2(uniformName: string, array: number[]): Effect;
  110292. /**
  110293. * 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)
  110294. * @param uniformName Name of the variable.
  110295. * @param array array to be set.
  110296. * @returns this effect.
  110297. */
  110298. setArray3(uniformName: string, array: number[]): Effect;
  110299. /**
  110300. * 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)
  110301. * @param uniformName Name of the variable.
  110302. * @param array array to be set.
  110303. * @returns this effect.
  110304. */
  110305. setArray4(uniformName: string, array: number[]): Effect;
  110306. /**
  110307. * Sets matrices on a uniform variable.
  110308. * @param uniformName Name of the variable.
  110309. * @param matrices matrices to be set.
  110310. * @returns this effect.
  110311. */
  110312. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  110313. /**
  110314. * Sets matrix on a uniform variable.
  110315. * @param uniformName Name of the variable.
  110316. * @param matrix matrix to be set.
  110317. * @returns this effect.
  110318. */
  110319. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  110320. /**
  110321. * 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)
  110322. * @param uniformName Name of the variable.
  110323. * @param matrix matrix to be set.
  110324. * @returns this effect.
  110325. */
  110326. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  110327. /**
  110328. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  110329. * @param uniformName Name of the variable.
  110330. * @param matrix matrix to be set.
  110331. * @returns this effect.
  110332. */
  110333. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  110334. /**
  110335. * Sets a float on a uniform variable.
  110336. * @param uniformName Name of the variable.
  110337. * @param value value to be set.
  110338. * @returns this effect.
  110339. */
  110340. setFloat(uniformName: string, value: number): Effect;
  110341. /**
  110342. * Sets a boolean on a uniform variable.
  110343. * @param uniformName Name of the variable.
  110344. * @param bool value to be set.
  110345. * @returns this effect.
  110346. */
  110347. setBool(uniformName: string, bool: boolean): Effect;
  110348. /**
  110349. * Sets a Vector2 on a uniform variable.
  110350. * @param uniformName Name of the variable.
  110351. * @param vector2 vector2 to be set.
  110352. * @returns this effect.
  110353. */
  110354. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  110355. /**
  110356. * Sets a float2 on a uniform variable.
  110357. * @param uniformName Name of the variable.
  110358. * @param x First float in float2.
  110359. * @param y Second float in float2.
  110360. * @returns this effect.
  110361. */
  110362. setFloat2(uniformName: string, x: number, y: number): Effect;
  110363. /**
  110364. * Sets a Vector3 on a uniform variable.
  110365. * @param uniformName Name of the variable.
  110366. * @param vector3 Value to be set.
  110367. * @returns this effect.
  110368. */
  110369. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  110370. /**
  110371. * Sets a float3 on a uniform variable.
  110372. * @param uniformName Name of the variable.
  110373. * @param x First float in float3.
  110374. * @param y Second float in float3.
  110375. * @param z Third float in float3.
  110376. * @returns this effect.
  110377. */
  110378. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  110379. /**
  110380. * Sets a Vector4 on a uniform variable.
  110381. * @param uniformName Name of the variable.
  110382. * @param vector4 Value to be set.
  110383. * @returns this effect.
  110384. */
  110385. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  110386. /**
  110387. * Sets a float4 on a uniform variable.
  110388. * @param uniformName Name of the variable.
  110389. * @param x First float in float4.
  110390. * @param y Second float in float4.
  110391. * @param z Third float in float4.
  110392. * @param w Fourth float in float4.
  110393. * @returns this effect.
  110394. */
  110395. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  110396. /**
  110397. * Sets a Color3 on a uniform variable.
  110398. * @param uniformName Name of the variable.
  110399. * @param color3 Value to be set.
  110400. * @returns this effect.
  110401. */
  110402. setColor3(uniformName: string, color3: IColor3Like): Effect;
  110403. /**
  110404. * Sets a Color4 on a uniform variable.
  110405. * @param uniformName Name of the variable.
  110406. * @param color3 Value to be set.
  110407. * @param alpha Alpha value to be set.
  110408. * @returns this effect.
  110409. */
  110410. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  110411. /**
  110412. * Sets a Color4 on a uniform variable
  110413. * @param uniformName defines the name of the variable
  110414. * @param color4 defines the value to be set
  110415. * @returns this effect.
  110416. */
  110417. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  110418. /** Release all associated resources */
  110419. dispose(): void;
  110420. /**
  110421. * This function will add a new shader to the shader store
  110422. * @param name the name of the shader
  110423. * @param pixelShader optional pixel shader content
  110424. * @param vertexShader optional vertex shader content
  110425. */
  110426. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  110427. /**
  110428. * Store of each shader (The can be looked up using effect.key)
  110429. */
  110430. static ShadersStore: {
  110431. [key: string]: string;
  110432. };
  110433. /**
  110434. * Store of each included file for a shader (The can be looked up using effect.key)
  110435. */
  110436. static IncludesShadersStore: {
  110437. [key: string]: string;
  110438. };
  110439. /**
  110440. * Resets the cache of effects.
  110441. */
  110442. static ResetCache(): void;
  110443. }
  110444. }
  110445. declare module BABYLON {
  110446. /**
  110447. * Interface used to describe the capabilities of the engine relatively to the current browser
  110448. */
  110449. export interface EngineCapabilities {
  110450. /** Maximum textures units per fragment shader */
  110451. maxTexturesImageUnits: number;
  110452. /** Maximum texture units per vertex shader */
  110453. maxVertexTextureImageUnits: number;
  110454. /** Maximum textures units in the entire pipeline */
  110455. maxCombinedTexturesImageUnits: number;
  110456. /** Maximum texture size */
  110457. maxTextureSize: number;
  110458. /** Maximum texture samples */
  110459. maxSamples?: number;
  110460. /** Maximum cube texture size */
  110461. maxCubemapTextureSize: number;
  110462. /** Maximum render texture size */
  110463. maxRenderTextureSize: number;
  110464. /** Maximum number of vertex attributes */
  110465. maxVertexAttribs: number;
  110466. /** Maximum number of varyings */
  110467. maxVaryingVectors: number;
  110468. /** Maximum number of uniforms per vertex shader */
  110469. maxVertexUniformVectors: number;
  110470. /** Maximum number of uniforms per fragment shader */
  110471. maxFragmentUniformVectors: number;
  110472. /** Defines if standard derivates (dx/dy) are supported */
  110473. standardDerivatives: boolean;
  110474. /** Defines if s3tc texture compression is supported */
  110475. s3tc?: WEBGL_compressed_texture_s3tc;
  110476. /** Defines if pvrtc texture compression is supported */
  110477. pvrtc: any;
  110478. /** Defines if etc1 texture compression is supported */
  110479. etc1: any;
  110480. /** Defines if etc2 texture compression is supported */
  110481. etc2: any;
  110482. /** Defines if astc texture compression is supported */
  110483. astc: any;
  110484. /** Defines if float textures are supported */
  110485. textureFloat: boolean;
  110486. /** Defines if vertex array objects are supported */
  110487. vertexArrayObject: boolean;
  110488. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  110489. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  110490. /** Gets the maximum level of anisotropy supported */
  110491. maxAnisotropy: number;
  110492. /** Defines if instancing is supported */
  110493. instancedArrays: boolean;
  110494. /** Defines if 32 bits indices are supported */
  110495. uintIndices: boolean;
  110496. /** Defines if high precision shaders are supported */
  110497. highPrecisionShaderSupported: boolean;
  110498. /** Defines if depth reading in the fragment shader is supported */
  110499. fragmentDepthSupported: boolean;
  110500. /** Defines if float texture linear filtering is supported*/
  110501. textureFloatLinearFiltering: boolean;
  110502. /** Defines if rendering to float textures is supported */
  110503. textureFloatRender: boolean;
  110504. /** Defines if half float textures are supported*/
  110505. textureHalfFloat: boolean;
  110506. /** Defines if half float texture linear filtering is supported*/
  110507. textureHalfFloatLinearFiltering: boolean;
  110508. /** Defines if rendering to half float textures is supported */
  110509. textureHalfFloatRender: boolean;
  110510. /** Defines if textureLOD shader command is supported */
  110511. textureLOD: boolean;
  110512. /** Defines if draw buffers extension is supported */
  110513. drawBuffersExtension: boolean;
  110514. /** Defines if depth textures are supported */
  110515. depthTextureExtension: boolean;
  110516. /** Defines if float color buffer are supported */
  110517. colorBufferFloat: boolean;
  110518. /** Gets disjoint timer query extension (null if not supported) */
  110519. timerQuery?: EXT_disjoint_timer_query;
  110520. /** Defines if timestamp can be used with timer query */
  110521. canUseTimestampForTimerQuery: boolean;
  110522. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  110523. multiview?: any;
  110524. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  110525. oculusMultiview?: any;
  110526. /** Function used to let the system compiles shaders in background */
  110527. parallelShaderCompile?: {
  110528. COMPLETION_STATUS_KHR: number;
  110529. };
  110530. /** Max number of texture samples for MSAA */
  110531. maxMSAASamples: number;
  110532. /** Defines if the blend min max extension is supported */
  110533. blendMinMax: boolean;
  110534. }
  110535. }
  110536. declare module BABYLON {
  110537. /**
  110538. * @hidden
  110539. **/
  110540. export class DepthCullingState {
  110541. private _isDepthTestDirty;
  110542. private _isDepthMaskDirty;
  110543. private _isDepthFuncDirty;
  110544. private _isCullFaceDirty;
  110545. private _isCullDirty;
  110546. private _isZOffsetDirty;
  110547. private _isFrontFaceDirty;
  110548. private _depthTest;
  110549. private _depthMask;
  110550. private _depthFunc;
  110551. private _cull;
  110552. private _cullFace;
  110553. private _zOffset;
  110554. private _frontFace;
  110555. /**
  110556. * Initializes the state.
  110557. */
  110558. constructor();
  110559. get isDirty(): boolean;
  110560. get zOffset(): number;
  110561. set zOffset(value: number);
  110562. get cullFace(): Nullable<number>;
  110563. set cullFace(value: Nullable<number>);
  110564. get cull(): Nullable<boolean>;
  110565. set cull(value: Nullable<boolean>);
  110566. get depthFunc(): Nullable<number>;
  110567. set depthFunc(value: Nullable<number>);
  110568. get depthMask(): boolean;
  110569. set depthMask(value: boolean);
  110570. get depthTest(): boolean;
  110571. set depthTest(value: boolean);
  110572. get frontFace(): Nullable<number>;
  110573. set frontFace(value: Nullable<number>);
  110574. reset(): void;
  110575. apply(gl: WebGLRenderingContext): void;
  110576. }
  110577. }
  110578. declare module BABYLON {
  110579. /**
  110580. * @hidden
  110581. **/
  110582. export class StencilState {
  110583. /** 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 */
  110584. static readonly ALWAYS: number;
  110585. /** Passed to stencilOperation to specify that stencil value must be kept */
  110586. static readonly KEEP: number;
  110587. /** Passed to stencilOperation to specify that stencil value must be replaced */
  110588. static readonly REPLACE: number;
  110589. private _isStencilTestDirty;
  110590. private _isStencilMaskDirty;
  110591. private _isStencilFuncDirty;
  110592. private _isStencilOpDirty;
  110593. private _stencilTest;
  110594. private _stencilMask;
  110595. private _stencilFunc;
  110596. private _stencilFuncRef;
  110597. private _stencilFuncMask;
  110598. private _stencilOpStencilFail;
  110599. private _stencilOpDepthFail;
  110600. private _stencilOpStencilDepthPass;
  110601. get isDirty(): boolean;
  110602. get stencilFunc(): number;
  110603. set stencilFunc(value: number);
  110604. get stencilFuncRef(): number;
  110605. set stencilFuncRef(value: number);
  110606. get stencilFuncMask(): number;
  110607. set stencilFuncMask(value: number);
  110608. get stencilOpStencilFail(): number;
  110609. set stencilOpStencilFail(value: number);
  110610. get stencilOpDepthFail(): number;
  110611. set stencilOpDepthFail(value: number);
  110612. get stencilOpStencilDepthPass(): number;
  110613. set stencilOpStencilDepthPass(value: number);
  110614. get stencilMask(): number;
  110615. set stencilMask(value: number);
  110616. get stencilTest(): boolean;
  110617. set stencilTest(value: boolean);
  110618. constructor();
  110619. reset(): void;
  110620. apply(gl: WebGLRenderingContext): void;
  110621. }
  110622. }
  110623. declare module BABYLON {
  110624. /**
  110625. * @hidden
  110626. **/
  110627. export class AlphaState {
  110628. private _isAlphaBlendDirty;
  110629. private _isBlendFunctionParametersDirty;
  110630. private _isBlendEquationParametersDirty;
  110631. private _isBlendConstantsDirty;
  110632. private _alphaBlend;
  110633. private _blendFunctionParameters;
  110634. private _blendEquationParameters;
  110635. private _blendConstants;
  110636. /**
  110637. * Initializes the state.
  110638. */
  110639. constructor();
  110640. get isDirty(): boolean;
  110641. get alphaBlend(): boolean;
  110642. set alphaBlend(value: boolean);
  110643. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  110644. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  110645. setAlphaEquationParameters(rgb: number, alpha: number): void;
  110646. reset(): void;
  110647. apply(gl: WebGLRenderingContext): void;
  110648. }
  110649. }
  110650. declare module BABYLON {
  110651. /** @hidden */
  110652. export class WebGL2ShaderProcessor implements IShaderProcessor {
  110653. attributeProcessor(attribute: string): string;
  110654. varyingProcessor(varying: string, isFragment: boolean): string;
  110655. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110656. }
  110657. }
  110658. declare module BABYLON {
  110659. /**
  110660. * Interface for attribute information associated with buffer instanciation
  110661. */
  110662. export interface InstancingAttributeInfo {
  110663. /**
  110664. * Name of the GLSL attribute
  110665. * if attribute index is not specified, this is used to retrieve the index from the effect
  110666. */
  110667. attributeName: string;
  110668. /**
  110669. * Index/offset of the attribute in the vertex shader
  110670. * if not specified, this will be computes from the name.
  110671. */
  110672. index?: number;
  110673. /**
  110674. * size of the attribute, 1, 2, 3 or 4
  110675. */
  110676. attributeSize: number;
  110677. /**
  110678. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  110679. */
  110680. offset: number;
  110681. /**
  110682. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  110683. * default to 1
  110684. */
  110685. divisor?: number;
  110686. /**
  110687. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  110688. * default is FLOAT
  110689. */
  110690. attributeType?: number;
  110691. /**
  110692. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  110693. */
  110694. normalized?: boolean;
  110695. }
  110696. }
  110697. declare module BABYLON {
  110698. interface ThinEngine {
  110699. /**
  110700. * Update a video texture
  110701. * @param texture defines the texture to update
  110702. * @param video defines the video element to use
  110703. * @param invertY defines if data must be stored with Y axis inverted
  110704. */
  110705. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  110706. }
  110707. }
  110708. declare module BABYLON {
  110709. /**
  110710. * Settings for finer control over video usage
  110711. */
  110712. export interface VideoTextureSettings {
  110713. /**
  110714. * Applies `autoplay` to video, if specified
  110715. */
  110716. autoPlay?: boolean;
  110717. /**
  110718. * Applies `loop` to video, if specified
  110719. */
  110720. loop?: boolean;
  110721. /**
  110722. * Automatically updates internal texture from video at every frame in the render loop
  110723. */
  110724. autoUpdateTexture: boolean;
  110725. /**
  110726. * Image src displayed during the video loading or until the user interacts with the video.
  110727. */
  110728. poster?: string;
  110729. }
  110730. /**
  110731. * If you want to display a video in your scene, this is the special texture for that.
  110732. * This special texture works similar to other textures, with the exception of a few parameters.
  110733. * @see https://doc.babylonjs.com/how_to/video_texture
  110734. */
  110735. export class VideoTexture extends Texture {
  110736. /**
  110737. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  110738. */
  110739. readonly autoUpdateTexture: boolean;
  110740. /**
  110741. * The video instance used by the texture internally
  110742. */
  110743. readonly video: HTMLVideoElement;
  110744. private _onUserActionRequestedObservable;
  110745. /**
  110746. * Event triggerd when a dom action is required by the user to play the video.
  110747. * This happens due to recent changes in browser policies preventing video to auto start.
  110748. */
  110749. get onUserActionRequestedObservable(): Observable<Texture>;
  110750. private _generateMipMaps;
  110751. private _stillImageCaptured;
  110752. private _displayingPosterTexture;
  110753. private _settings;
  110754. private _createInternalTextureOnEvent;
  110755. private _frameId;
  110756. private _currentSrc;
  110757. /**
  110758. * Creates a video texture.
  110759. * If you want to display a video in your scene, this is the special texture for that.
  110760. * This special texture works similar to other textures, with the exception of a few parameters.
  110761. * @see https://doc.babylonjs.com/how_to/video_texture
  110762. * @param name optional name, will detect from video source, if not defined
  110763. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  110764. * @param scene is obviously the current scene.
  110765. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  110766. * @param invertY is false by default but can be used to invert video on Y axis
  110767. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  110768. * @param settings allows finer control over video usage
  110769. */
  110770. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  110771. private _getName;
  110772. private _getVideo;
  110773. private _createInternalTexture;
  110774. private reset;
  110775. /**
  110776. * @hidden Internal method to initiate `update`.
  110777. */
  110778. _rebuild(): void;
  110779. /**
  110780. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  110781. */
  110782. update(): void;
  110783. /**
  110784. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  110785. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  110786. */
  110787. updateTexture(isVisible: boolean): void;
  110788. protected _updateInternalTexture: () => void;
  110789. /**
  110790. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  110791. * @param url New url.
  110792. */
  110793. updateURL(url: string): void;
  110794. /**
  110795. * Clones the texture.
  110796. * @returns the cloned texture
  110797. */
  110798. clone(): VideoTexture;
  110799. /**
  110800. * Dispose the texture and release its associated resources.
  110801. */
  110802. dispose(): void;
  110803. /**
  110804. * Creates a video texture straight from a stream.
  110805. * @param scene Define the scene the texture should be created in
  110806. * @param stream Define the stream the texture should be created from
  110807. * @returns The created video texture as a promise
  110808. */
  110809. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  110810. /**
  110811. * Creates a video texture straight from your WebCam video feed.
  110812. * @param scene Define the scene the texture should be created in
  110813. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  110814. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  110815. * @returns The created video texture as a promise
  110816. */
  110817. static CreateFromWebCamAsync(scene: Scene, constraints: {
  110818. minWidth: number;
  110819. maxWidth: number;
  110820. minHeight: number;
  110821. maxHeight: number;
  110822. deviceId: string;
  110823. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  110824. /**
  110825. * Creates a video texture straight from your WebCam video feed.
  110826. * @param scene Define the scene the texture should be created in
  110827. * @param onReady Define a callback to triggered once the texture will be ready
  110828. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  110829. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  110830. */
  110831. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  110832. minWidth: number;
  110833. maxWidth: number;
  110834. minHeight: number;
  110835. maxHeight: number;
  110836. deviceId: string;
  110837. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  110838. }
  110839. }
  110840. declare module BABYLON {
  110841. /**
  110842. * Defines the interface used by objects working like Scene
  110843. * @hidden
  110844. */
  110845. export interface ISceneLike {
  110846. _addPendingData(data: any): void;
  110847. _removePendingData(data: any): void;
  110848. offlineProvider: IOfflineProvider;
  110849. }
  110850. /** Interface defining initialization parameters for Engine class */
  110851. export interface EngineOptions extends WebGLContextAttributes {
  110852. /**
  110853. * Defines if the engine should no exceed a specified device ratio
  110854. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  110855. */
  110856. limitDeviceRatio?: number;
  110857. /**
  110858. * Defines if webvr should be enabled automatically
  110859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110860. */
  110861. autoEnableWebVR?: boolean;
  110862. /**
  110863. * Defines if webgl2 should be turned off even if supported
  110864. * @see http://doc.babylonjs.com/features/webgl2
  110865. */
  110866. disableWebGL2Support?: boolean;
  110867. /**
  110868. * Defines if webaudio should be initialized as well
  110869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110870. */
  110871. audioEngine?: boolean;
  110872. /**
  110873. * Defines if animations should run using a deterministic lock step
  110874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110875. */
  110876. deterministicLockstep?: boolean;
  110877. /** Defines the maximum steps to use with deterministic lock step mode */
  110878. lockstepMaxSteps?: number;
  110879. /** Defines the seconds between each deterministic lock step */
  110880. timeStep?: number;
  110881. /**
  110882. * Defines that engine should ignore context lost events
  110883. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  110884. */
  110885. doNotHandleContextLost?: boolean;
  110886. /**
  110887. * Defines that engine should ignore modifying touch action attribute and style
  110888. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  110889. */
  110890. doNotHandleTouchAction?: boolean;
  110891. /**
  110892. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  110893. */
  110894. useHighPrecisionFloats?: boolean;
  110895. }
  110896. /**
  110897. * The base engine class (root of all engines)
  110898. */
  110899. export class ThinEngine {
  110900. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  110901. static ExceptionList: ({
  110902. key: string;
  110903. capture: string;
  110904. captureConstraint: number;
  110905. targets: string[];
  110906. } | {
  110907. key: string;
  110908. capture: null;
  110909. captureConstraint: null;
  110910. targets: string[];
  110911. })[];
  110912. /** @hidden */
  110913. static _TextureLoaders: IInternalTextureLoader[];
  110914. /**
  110915. * Returns the current npm package of the sdk
  110916. */
  110917. static get NpmPackage(): string;
  110918. /**
  110919. * Returns the current version of the framework
  110920. */
  110921. static get Version(): string;
  110922. /**
  110923. * Returns a string describing the current engine
  110924. */
  110925. get description(): string;
  110926. /**
  110927. * Gets or sets the epsilon value used by collision engine
  110928. */
  110929. static CollisionsEpsilon: number;
  110930. /**
  110931. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110932. */
  110933. static get ShadersRepository(): string;
  110934. static set ShadersRepository(value: string);
  110935. /** @hidden */
  110936. _shaderProcessor: IShaderProcessor;
  110937. /**
  110938. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  110939. */
  110940. forcePOTTextures: boolean;
  110941. /**
  110942. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  110943. */
  110944. isFullscreen: boolean;
  110945. /**
  110946. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  110947. */
  110948. cullBackFaces: boolean;
  110949. /**
  110950. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  110951. */
  110952. renderEvenInBackground: boolean;
  110953. /**
  110954. * Gets or sets a boolean indicating that cache can be kept between frames
  110955. */
  110956. preventCacheWipeBetweenFrames: boolean;
  110957. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  110958. validateShaderPrograms: boolean;
  110959. /**
  110960. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  110961. * This can provide greater z depth for distant objects.
  110962. */
  110963. useReverseDepthBuffer: boolean;
  110964. /**
  110965. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  110966. */
  110967. disableUniformBuffers: boolean;
  110968. /** @hidden */
  110969. _uniformBuffers: UniformBuffer[];
  110970. /**
  110971. * Gets a boolean indicating that the engine supports uniform buffers
  110972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  110973. */
  110974. get supportsUniformBuffers(): boolean;
  110975. /** @hidden */
  110976. _gl: WebGLRenderingContext;
  110977. /** @hidden */
  110978. _webGLVersion: number;
  110979. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  110980. protected _windowIsBackground: boolean;
  110981. protected _creationOptions: EngineOptions;
  110982. protected _highPrecisionShadersAllowed: boolean;
  110983. /** @hidden */
  110984. get _shouldUseHighPrecisionShader(): boolean;
  110985. /**
  110986. * Gets a boolean indicating that only power of 2 textures are supported
  110987. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  110988. */
  110989. get needPOTTextures(): boolean;
  110990. /** @hidden */
  110991. _badOS: boolean;
  110992. /** @hidden */
  110993. _badDesktopOS: boolean;
  110994. private _hardwareScalingLevel;
  110995. /** @hidden */
  110996. _caps: EngineCapabilities;
  110997. private _isStencilEnable;
  110998. private _glVersion;
  110999. private _glRenderer;
  111000. private _glVendor;
  111001. /** @hidden */
  111002. _videoTextureSupported: boolean;
  111003. protected _renderingQueueLaunched: boolean;
  111004. protected _activeRenderLoops: (() => void)[];
  111005. /**
  111006. * Observable signaled when a context lost event is raised
  111007. */
  111008. onContextLostObservable: Observable<ThinEngine>;
  111009. /**
  111010. * Observable signaled when a context restored event is raised
  111011. */
  111012. onContextRestoredObservable: Observable<ThinEngine>;
  111013. private _onContextLost;
  111014. private _onContextRestored;
  111015. protected _contextWasLost: boolean;
  111016. /** @hidden */
  111017. _doNotHandleContextLost: boolean;
  111018. /**
  111019. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111021. */
  111022. get doNotHandleContextLost(): boolean;
  111023. set doNotHandleContextLost(value: boolean);
  111024. /**
  111025. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111026. */
  111027. disableVertexArrayObjects: boolean;
  111028. /** @hidden */
  111029. protected _colorWrite: boolean;
  111030. /** @hidden */
  111031. protected _colorWriteChanged: boolean;
  111032. /** @hidden */
  111033. protected _depthCullingState: DepthCullingState;
  111034. /** @hidden */
  111035. protected _stencilState: StencilState;
  111036. /** @hidden */
  111037. _alphaState: AlphaState;
  111038. /** @hidden */
  111039. _alphaMode: number;
  111040. /** @hidden */
  111041. _alphaEquation: number;
  111042. /** @hidden */
  111043. _internalTexturesCache: InternalTexture[];
  111044. /** @hidden */
  111045. protected _activeChannel: number;
  111046. private _currentTextureChannel;
  111047. /** @hidden */
  111048. protected _boundTexturesCache: {
  111049. [key: string]: Nullable<InternalTexture>;
  111050. };
  111051. /** @hidden */
  111052. protected _currentEffect: Nullable<Effect>;
  111053. /** @hidden */
  111054. protected _currentProgram: Nullable<WebGLProgram>;
  111055. private _compiledEffects;
  111056. private _vertexAttribArraysEnabled;
  111057. /** @hidden */
  111058. protected _cachedViewport: Nullable<IViewportLike>;
  111059. private _cachedVertexArrayObject;
  111060. /** @hidden */
  111061. protected _cachedVertexBuffers: any;
  111062. /** @hidden */
  111063. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111064. /** @hidden */
  111065. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111066. /** @hidden */
  111067. _currentRenderTarget: Nullable<InternalTexture>;
  111068. private _uintIndicesCurrentlySet;
  111069. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111070. /** @hidden */
  111071. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111072. /** @hidden */
  111073. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111074. private _currentBufferPointers;
  111075. private _currentInstanceLocations;
  111076. private _currentInstanceBuffers;
  111077. private _textureUnits;
  111078. /** @hidden */
  111079. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111080. /** @hidden */
  111081. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111082. /** @hidden */
  111083. _boundRenderFunction: any;
  111084. private _vaoRecordInProgress;
  111085. private _mustWipeVertexAttributes;
  111086. private _emptyTexture;
  111087. private _emptyCubeTexture;
  111088. private _emptyTexture3D;
  111089. private _emptyTexture2DArray;
  111090. /** @hidden */
  111091. _frameHandler: number;
  111092. private _nextFreeTextureSlots;
  111093. private _maxSimultaneousTextures;
  111094. private _activeRequests;
  111095. /** @hidden */
  111096. _transformTextureUrl: Nullable<(url: string) => string>;
  111097. protected get _supportsHardwareTextureRescaling(): boolean;
  111098. private _framebufferDimensionsObject;
  111099. /**
  111100. * sets the object from which width and height will be taken from when getting render width and height
  111101. * Will fallback to the gl object
  111102. * @param dimensions the framebuffer width and height that will be used.
  111103. */
  111104. set framebufferDimensionsObject(dimensions: Nullable<{
  111105. framebufferWidth: number;
  111106. framebufferHeight: number;
  111107. }>);
  111108. /**
  111109. * Gets the current viewport
  111110. */
  111111. get currentViewport(): Nullable<IViewportLike>;
  111112. /**
  111113. * Gets the default empty texture
  111114. */
  111115. get emptyTexture(): InternalTexture;
  111116. /**
  111117. * Gets the default empty 3D texture
  111118. */
  111119. get emptyTexture3D(): InternalTexture;
  111120. /**
  111121. * Gets the default empty 2D array texture
  111122. */
  111123. get emptyTexture2DArray(): InternalTexture;
  111124. /**
  111125. * Gets the default empty cube texture
  111126. */
  111127. get emptyCubeTexture(): InternalTexture;
  111128. /**
  111129. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111130. */
  111131. readonly premultipliedAlpha: boolean;
  111132. /**
  111133. * Observable event triggered before each texture is initialized
  111134. */
  111135. onBeforeTextureInitObservable: Observable<Texture>;
  111136. /**
  111137. * Creates a new engine
  111138. * @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
  111139. * @param antialias defines enable antialiasing (default: false)
  111140. * @param options defines further options to be sent to the getContext() function
  111141. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111142. */
  111143. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111144. private _rebuildInternalTextures;
  111145. private _rebuildEffects;
  111146. /**
  111147. * Gets a boolean indicating if all created effects are ready
  111148. * @returns true if all effects are ready
  111149. */
  111150. areAllEffectsReady(): boolean;
  111151. protected _rebuildBuffers(): void;
  111152. protected _initGLContext(): void;
  111153. /**
  111154. * Gets version of the current webGL context
  111155. */
  111156. get webGLVersion(): number;
  111157. /**
  111158. * Gets a string idenfifying the name of the class
  111159. * @returns "Engine" string
  111160. */
  111161. getClassName(): string;
  111162. /**
  111163. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111164. */
  111165. get isStencilEnable(): boolean;
  111166. /** @hidden */
  111167. _prepareWorkingCanvas(): void;
  111168. /**
  111169. * Reset the texture cache to empty state
  111170. */
  111171. resetTextureCache(): void;
  111172. /**
  111173. * Gets an object containing information about the current webGL context
  111174. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111175. */
  111176. getGlInfo(): {
  111177. vendor: string;
  111178. renderer: string;
  111179. version: string;
  111180. };
  111181. /**
  111182. * Defines the hardware scaling level.
  111183. * By default the hardware scaling level is computed from the window device ratio.
  111184. * 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.
  111185. * @param level defines the level to use
  111186. */
  111187. setHardwareScalingLevel(level: number): void;
  111188. /**
  111189. * Gets the current hardware scaling level.
  111190. * By default the hardware scaling level is computed from the window device ratio.
  111191. * 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.
  111192. * @returns a number indicating the current hardware scaling level
  111193. */
  111194. getHardwareScalingLevel(): number;
  111195. /**
  111196. * Gets the list of loaded textures
  111197. * @returns an array containing all loaded textures
  111198. */
  111199. getLoadedTexturesCache(): InternalTexture[];
  111200. /**
  111201. * Gets the object containing all engine capabilities
  111202. * @returns the EngineCapabilities object
  111203. */
  111204. getCaps(): EngineCapabilities;
  111205. /**
  111206. * stop executing a render loop function and remove it from the execution array
  111207. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111208. */
  111209. stopRenderLoop(renderFunction?: () => void): void;
  111210. /** @hidden */
  111211. _renderLoop(): void;
  111212. /**
  111213. * Gets the HTML canvas attached with the current webGL context
  111214. * @returns a HTML canvas
  111215. */
  111216. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111217. /**
  111218. * Gets host window
  111219. * @returns the host window object
  111220. */
  111221. getHostWindow(): Nullable<Window>;
  111222. /**
  111223. * Gets the current render width
  111224. * @param useScreen defines if screen size must be used (or the current render target if any)
  111225. * @returns a number defining the current render width
  111226. */
  111227. getRenderWidth(useScreen?: boolean): number;
  111228. /**
  111229. * Gets the current render height
  111230. * @param useScreen defines if screen size must be used (or the current render target if any)
  111231. * @returns a number defining the current render height
  111232. */
  111233. getRenderHeight(useScreen?: boolean): number;
  111234. /**
  111235. * Can be used to override the current requestAnimationFrame requester.
  111236. * @hidden
  111237. */
  111238. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  111239. /**
  111240. * Register and execute a render loop. The engine can have more than one render function
  111241. * @param renderFunction defines the function to continuously execute
  111242. */
  111243. runRenderLoop(renderFunction: () => void): void;
  111244. /**
  111245. * Clear the current render buffer or the current render target (if any is set up)
  111246. * @param color defines the color to use
  111247. * @param backBuffer defines if the back buffer must be cleared
  111248. * @param depth defines if the depth buffer must be cleared
  111249. * @param stencil defines if the stencil buffer must be cleared
  111250. */
  111251. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111252. private _viewportCached;
  111253. /** @hidden */
  111254. _viewport(x: number, y: number, width: number, height: number): void;
  111255. /**
  111256. * Set the WebGL's viewport
  111257. * @param viewport defines the viewport element to be used
  111258. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111259. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111260. */
  111261. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111262. /**
  111263. * Begin a new frame
  111264. */
  111265. beginFrame(): void;
  111266. /**
  111267. * Enf the current frame
  111268. */
  111269. endFrame(): void;
  111270. /**
  111271. * Resize the view according to the canvas' size
  111272. */
  111273. resize(): void;
  111274. /**
  111275. * Force a specific size of the canvas
  111276. * @param width defines the new canvas' width
  111277. * @param height defines the new canvas' height
  111278. */
  111279. setSize(width: number, height: number): void;
  111280. /**
  111281. * Binds the frame buffer to the specified texture.
  111282. * @param texture The texture to render to or null for the default canvas
  111283. * @param faceIndex The face of the texture to render to in case of cube texture
  111284. * @param requiredWidth The width of the target to render to
  111285. * @param requiredHeight The height of the target to render to
  111286. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111287. * @param lodLevel defines the lod level to bind to the frame buffer
  111288. * @param layer defines the 2d array index to bind to frame buffer to
  111289. */
  111290. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  111291. /** @hidden */
  111292. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  111293. /**
  111294. * Unbind the current render target texture from the webGL context
  111295. * @param texture defines the render target texture to unbind
  111296. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111297. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111298. */
  111299. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111300. /**
  111301. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  111302. */
  111303. flushFramebuffer(): void;
  111304. /**
  111305. * Unbind the current render target and bind the default framebuffer
  111306. */
  111307. restoreDefaultFramebuffer(): void;
  111308. /** @hidden */
  111309. protected _resetVertexBufferBinding(): void;
  111310. /**
  111311. * Creates a vertex buffer
  111312. * @param data the data for the vertex buffer
  111313. * @returns the new WebGL static buffer
  111314. */
  111315. createVertexBuffer(data: DataArray): DataBuffer;
  111316. private _createVertexBuffer;
  111317. /**
  111318. * Creates a dynamic vertex buffer
  111319. * @param data the data for the dynamic vertex buffer
  111320. * @returns the new WebGL dynamic buffer
  111321. */
  111322. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111323. protected _resetIndexBufferBinding(): void;
  111324. /**
  111325. * Creates a new index buffer
  111326. * @param indices defines the content of the index buffer
  111327. * @param updatable defines if the index buffer must be updatable
  111328. * @returns a new webGL buffer
  111329. */
  111330. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  111331. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  111332. /**
  111333. * Bind a webGL buffer to the webGL context
  111334. * @param buffer defines the buffer to bind
  111335. */
  111336. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  111337. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  111338. private bindBuffer;
  111339. /**
  111340. * update the bound buffer with the given data
  111341. * @param data defines the data to update
  111342. */
  111343. updateArrayBuffer(data: Float32Array): void;
  111344. private _vertexAttribPointer;
  111345. /** @hidden */
  111346. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  111347. private _bindVertexBuffersAttributes;
  111348. /**
  111349. * Records a vertex array object
  111350. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111351. * @param vertexBuffers defines the list of vertex buffers to store
  111352. * @param indexBuffer defines the index buffer to store
  111353. * @param effect defines the effect to store
  111354. * @returns the new vertex array object
  111355. */
  111356. recordVertexArrayObject(vertexBuffers: {
  111357. [key: string]: VertexBuffer;
  111358. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111359. /**
  111360. * Bind a specific vertex array object
  111361. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111362. * @param vertexArrayObject defines the vertex array object to bind
  111363. * @param indexBuffer defines the index buffer to bind
  111364. */
  111365. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  111366. /**
  111367. * Bind webGl buffers directly to the webGL context
  111368. * @param vertexBuffer defines the vertex buffer to bind
  111369. * @param indexBuffer defines the index buffer to bind
  111370. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111371. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111372. * @param effect defines the effect associated with the vertex buffer
  111373. */
  111374. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  111375. private _unbindVertexArrayObject;
  111376. /**
  111377. * Bind a list of vertex buffers to the webGL context
  111378. * @param vertexBuffers defines the list of vertex buffers to bind
  111379. * @param indexBuffer defines the index buffer to bind
  111380. * @param effect defines the effect associated with the vertex buffers
  111381. */
  111382. bindBuffers(vertexBuffers: {
  111383. [key: string]: Nullable<VertexBuffer>;
  111384. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  111385. /**
  111386. * Unbind all instance attributes
  111387. */
  111388. unbindInstanceAttributes(): void;
  111389. /**
  111390. * Release and free the memory of a vertex array object
  111391. * @param vao defines the vertex array object to delete
  111392. */
  111393. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  111394. /** @hidden */
  111395. _releaseBuffer(buffer: DataBuffer): boolean;
  111396. protected _deleteBuffer(buffer: DataBuffer): void;
  111397. /**
  111398. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  111399. * @param instancesBuffer defines the webGL buffer to update and bind
  111400. * @param data defines the data to store in the buffer
  111401. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  111402. */
  111403. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  111404. /**
  111405. * Bind the content of a webGL buffer used with instantiation
  111406. * @param instancesBuffer defines the webGL buffer to bind
  111407. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  111408. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  111409. */
  111410. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  111411. /**
  111412. * Disable the instance attribute corresponding to the name in parameter
  111413. * @param name defines the name of the attribute to disable
  111414. */
  111415. disableInstanceAttributeByName(name: string): void;
  111416. /**
  111417. * Disable the instance attribute corresponding to the location in parameter
  111418. * @param attributeLocation defines the attribute location of the attribute to disable
  111419. */
  111420. disableInstanceAttribute(attributeLocation: number): void;
  111421. /**
  111422. * Disable the attribute corresponding to the location in parameter
  111423. * @param attributeLocation defines the attribute location of the attribute to disable
  111424. */
  111425. disableAttributeByIndex(attributeLocation: number): void;
  111426. /**
  111427. * Send a draw order
  111428. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111429. * @param indexStart defines the starting index
  111430. * @param indexCount defines the number of index to draw
  111431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111432. */
  111433. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111434. /**
  111435. * Draw a list of points
  111436. * @param verticesStart defines the index of first vertex to draw
  111437. * @param verticesCount defines the count of vertices to draw
  111438. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111439. */
  111440. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111441. /**
  111442. * Draw a list of unindexed primitives
  111443. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111444. * @param verticesStart defines the index of first vertex to draw
  111445. * @param verticesCount defines the count of vertices to draw
  111446. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111447. */
  111448. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111449. /**
  111450. * Draw a list of indexed primitives
  111451. * @param fillMode defines the primitive to use
  111452. * @param indexStart defines the starting index
  111453. * @param indexCount defines the number of index to draw
  111454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111455. */
  111456. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111457. /**
  111458. * Draw a list of unindexed primitives
  111459. * @param fillMode defines the primitive to use
  111460. * @param verticesStart defines the index of first vertex to draw
  111461. * @param verticesCount defines the count of vertices to draw
  111462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111463. */
  111464. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111465. private _drawMode;
  111466. /** @hidden */
  111467. protected _reportDrawCall(): void;
  111468. /** @hidden */
  111469. _releaseEffect(effect: Effect): void;
  111470. /** @hidden */
  111471. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111472. /**
  111473. * Create a new effect (used to store vertex/fragment shaders)
  111474. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  111475. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  111476. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  111477. * @param samplers defines an array of string used to represent textures
  111478. * @param defines defines the string containing the defines to use to compile the shaders
  111479. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111480. * @param onCompiled defines a function to call when the effect creation is successful
  111481. * @param onError defines a function to call when the effect creation has failed
  111482. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  111483. * @returns the new Effect
  111484. */
  111485. 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;
  111486. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  111487. private _compileShader;
  111488. private _compileRawShader;
  111489. /** @hidden */
  111490. _getShaderSource(shader: WebGLShader): Nullable<string>;
  111491. /**
  111492. * Directly creates a webGL program
  111493. * @param pipelineContext defines the pipeline context to attach to
  111494. * @param vertexCode defines the vertex shader code to use
  111495. * @param fragmentCode defines the fragment shader code to use
  111496. * @param context defines the webGL context to use (if not set, the current one will be used)
  111497. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111498. * @returns the new webGL program
  111499. */
  111500. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111501. /**
  111502. * Creates a webGL program
  111503. * @param pipelineContext defines the pipeline context to attach to
  111504. * @param vertexCode defines the vertex shader code to use
  111505. * @param fragmentCode defines the fragment shader code to use
  111506. * @param defines defines the string containing the defines to use to compile the shaders
  111507. * @param context defines the webGL context to use (if not set, the current one will be used)
  111508. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111509. * @returns the new webGL program
  111510. */
  111511. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111512. /**
  111513. * Creates a new pipeline context
  111514. * @returns the new pipeline
  111515. */
  111516. createPipelineContext(): IPipelineContext;
  111517. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111518. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  111519. /** @hidden */
  111520. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111521. /** @hidden */
  111522. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111523. /** @hidden */
  111524. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111525. /**
  111526. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111527. * @param pipelineContext defines the pipeline context to use
  111528. * @param uniformsNames defines the list of uniform names
  111529. * @returns an array of webGL uniform locations
  111530. */
  111531. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111532. /**
  111533. * Gets the lsit of active attributes for a given webGL program
  111534. * @param pipelineContext defines the pipeline context to use
  111535. * @param attributesNames defines the list of attribute names to get
  111536. * @returns an array of indices indicating the offset of each attribute
  111537. */
  111538. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111539. /**
  111540. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111541. * @param effect defines the effect to activate
  111542. */
  111543. enableEffect(effect: Nullable<Effect>): void;
  111544. /**
  111545. * Set the value of an uniform to a number (int)
  111546. * @param uniform defines the webGL uniform location where to store the value
  111547. * @param value defines the int number to store
  111548. */
  111549. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111550. /**
  111551. * Set the value of an uniform to an array of int32
  111552. * @param uniform defines the webGL uniform location where to store the value
  111553. * @param array defines the array of int32 to store
  111554. */
  111555. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111556. /**
  111557. * Set the value of an uniform to an array of int32 (stored as vec2)
  111558. * @param uniform defines the webGL uniform location where to store the value
  111559. * @param array defines the array of int32 to store
  111560. */
  111561. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111562. /**
  111563. * Set the value of an uniform to an array of int32 (stored as vec3)
  111564. * @param uniform defines the webGL uniform location where to store the value
  111565. * @param array defines the array of int32 to store
  111566. */
  111567. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111568. /**
  111569. * Set the value of an uniform to an array of int32 (stored as vec4)
  111570. * @param uniform defines the webGL uniform location where to store the value
  111571. * @param array defines the array of int32 to store
  111572. */
  111573. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111574. /**
  111575. * Set the value of an uniform to an array of number
  111576. * @param uniform defines the webGL uniform location where to store the value
  111577. * @param array defines the array of number to store
  111578. */
  111579. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111580. /**
  111581. * Set the value of an uniform to an array of number (stored as vec2)
  111582. * @param uniform defines the webGL uniform location where to store the value
  111583. * @param array defines the array of number to store
  111584. */
  111585. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111586. /**
  111587. * Set the value of an uniform to an array of number (stored as vec3)
  111588. * @param uniform defines the webGL uniform location where to store the value
  111589. * @param array defines the array of number to store
  111590. */
  111591. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111592. /**
  111593. * Set the value of an uniform to an array of number (stored as vec4)
  111594. * @param uniform defines the webGL uniform location where to store the value
  111595. * @param array defines the array of number to store
  111596. */
  111597. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111598. /**
  111599. * Set the value of an uniform to an array of float32 (stored as matrices)
  111600. * @param uniform defines the webGL uniform location where to store the value
  111601. * @param matrices defines the array of float32 to store
  111602. */
  111603. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  111604. /**
  111605. * Set the value of an uniform to a matrix (3x3)
  111606. * @param uniform defines the webGL uniform location where to store the value
  111607. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111608. */
  111609. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111610. /**
  111611. * Set the value of an uniform to a matrix (2x2)
  111612. * @param uniform defines the webGL uniform location where to store the value
  111613. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111614. */
  111615. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111616. /**
  111617. * Set the value of an uniform to a number (float)
  111618. * @param uniform defines the webGL uniform location where to store the value
  111619. * @param value defines the float number to store
  111620. */
  111621. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111622. /**
  111623. * Set the value of an uniform to a vec2
  111624. * @param uniform defines the webGL uniform location where to store the value
  111625. * @param x defines the 1st component of the value
  111626. * @param y defines the 2nd component of the value
  111627. */
  111628. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  111629. /**
  111630. * Set the value of an uniform to a vec3
  111631. * @param uniform defines the webGL uniform location where to store the value
  111632. * @param x defines the 1st component of the value
  111633. * @param y defines the 2nd component of the value
  111634. * @param z defines the 3rd component of the value
  111635. */
  111636. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  111637. /**
  111638. * Set the value of an uniform to a vec4
  111639. * @param uniform defines the webGL uniform location where to store the value
  111640. * @param x defines the 1st component of the value
  111641. * @param y defines the 2nd component of the value
  111642. * @param z defines the 3rd component of the value
  111643. * @param w defines the 4th component of the value
  111644. */
  111645. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  111646. /**
  111647. * Apply all cached states (depth, culling, stencil and alpha)
  111648. */
  111649. applyStates(): void;
  111650. /**
  111651. * Enable or disable color writing
  111652. * @param enable defines the state to set
  111653. */
  111654. setColorWrite(enable: boolean): void;
  111655. /**
  111656. * Gets a boolean indicating if color writing is enabled
  111657. * @returns the current color writing state
  111658. */
  111659. getColorWrite(): boolean;
  111660. /**
  111661. * Gets the depth culling state manager
  111662. */
  111663. get depthCullingState(): DepthCullingState;
  111664. /**
  111665. * Gets the alpha state manager
  111666. */
  111667. get alphaState(): AlphaState;
  111668. /**
  111669. * Gets the stencil state manager
  111670. */
  111671. get stencilState(): StencilState;
  111672. /**
  111673. * Clears the list of texture accessible through engine.
  111674. * This can help preventing texture load conflict due to name collision.
  111675. */
  111676. clearInternalTexturesCache(): void;
  111677. /**
  111678. * Force the entire cache to be cleared
  111679. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111680. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111681. */
  111682. wipeCaches(bruteForce?: boolean): void;
  111683. /** @hidden */
  111684. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  111685. min: number;
  111686. mag: number;
  111687. };
  111688. /** @hidden */
  111689. _createTexture(): WebGLTexture;
  111690. /**
  111691. * Usually called from Texture.ts.
  111692. * Passed information to create a WebGLTexture
  111693. * @param url defines a value which contains one of the following:
  111694. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111695. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111696. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111698. * @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)
  111699. * @param scene needed for loading to the correct scene
  111700. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111701. * @param onLoad optional callback to be called upon successful completion
  111702. * @param onError optional callback to be called upon failure
  111703. * @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
  111704. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111705. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111706. * @param forcedExtension defines the extension to use to pick the right loader
  111707. * @param mimeType defines an optional mime type
  111708. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111709. */
  111710. 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;
  111711. /**
  111712. * Loads an image as an HTMLImageElement.
  111713. * @param input url string, ArrayBuffer, or Blob to load
  111714. * @param onLoad callback called when the image successfully loads
  111715. * @param onError callback called when the image fails to load
  111716. * @param offlineProvider offline provider for caching
  111717. * @param mimeType optional mime type
  111718. * @returns the HTMLImageElement of the loaded image
  111719. * @hidden
  111720. */
  111721. 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>;
  111722. /**
  111723. * @hidden
  111724. */
  111725. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  111726. private _unpackFlipYCached;
  111727. /**
  111728. * In case you are sharing the context with other applications, it might
  111729. * be interested to not cache the unpack flip y state to ensure a consistent
  111730. * value would be set.
  111731. */
  111732. enableUnpackFlipYCached: boolean;
  111733. /** @hidden */
  111734. _unpackFlipY(value: boolean): void;
  111735. /** @hidden */
  111736. _getUnpackAlignement(): number;
  111737. private _getTextureTarget;
  111738. /**
  111739. * Update the sampling mode of a given texture
  111740. * @param samplingMode defines the required sampling mode
  111741. * @param texture defines the texture to update
  111742. * @param generateMipMaps defines whether to generate mipmaps for the texture
  111743. */
  111744. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  111745. /**
  111746. * Update the sampling mode of a given texture
  111747. * @param texture defines the texture to update
  111748. * @param wrapU defines the texture wrap mode of the u coordinates
  111749. * @param wrapV defines the texture wrap mode of the v coordinates
  111750. * @param wrapR defines the texture wrap mode of the r coordinates
  111751. */
  111752. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  111753. /** @hidden */
  111754. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  111755. width: number;
  111756. height: number;
  111757. layers?: number;
  111758. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  111759. /** @hidden */
  111760. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111761. /** @hidden */
  111762. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  111763. /**
  111764. * Update a portion of an internal texture
  111765. * @param texture defines the texture to update
  111766. * @param imageData defines the data to store into the texture
  111767. * @param xOffset defines the x coordinates of the update rectangle
  111768. * @param yOffset defines the y coordinates of the update rectangle
  111769. * @param width defines the width of the update rectangle
  111770. * @param height defines the height of the update rectangle
  111771. * @param faceIndex defines the face index if texture is a cube (0 by default)
  111772. * @param lod defines the lod level to update (0 by default)
  111773. */
  111774. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  111775. /** @hidden */
  111776. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111777. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  111778. private _prepareWebGLTexture;
  111779. /** @hidden */
  111780. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  111781. private _getDepthStencilBuffer;
  111782. /** @hidden */
  111783. _releaseFramebufferObjects(texture: InternalTexture): void;
  111784. /** @hidden */
  111785. _releaseTexture(texture: InternalTexture): void;
  111786. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111787. protected _setProgram(program: WebGLProgram): void;
  111788. protected _boundUniforms: {
  111789. [key: number]: WebGLUniformLocation;
  111790. };
  111791. /**
  111792. * Binds an effect to the webGL context
  111793. * @param effect defines the effect to bind
  111794. */
  111795. bindSamplers(effect: Effect): void;
  111796. private _activateCurrentTexture;
  111797. /** @hidden */
  111798. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  111799. /** @hidden */
  111800. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  111801. /**
  111802. * Unbind all textures from the webGL context
  111803. */
  111804. unbindAllTextures(): void;
  111805. /**
  111806. * Sets a texture to the according uniform.
  111807. * @param channel The texture channel
  111808. * @param uniform The uniform to set
  111809. * @param texture The texture to apply
  111810. */
  111811. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  111812. private _bindSamplerUniformToChannel;
  111813. private _getTextureWrapMode;
  111814. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111815. /**
  111816. * Sets an array of texture to the webGL context
  111817. * @param channel defines the channel where the texture array must be set
  111818. * @param uniform defines the associated uniform location
  111819. * @param textures defines the array of textures to bind
  111820. */
  111821. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  111822. /** @hidden */
  111823. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  111824. private _setTextureParameterFloat;
  111825. private _setTextureParameterInteger;
  111826. /**
  111827. * Unbind all vertex attributes from the webGL context
  111828. */
  111829. unbindAllAttributes(): void;
  111830. /**
  111831. * 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
  111832. */
  111833. releaseEffects(): void;
  111834. /**
  111835. * Dispose and release all associated resources
  111836. */
  111837. dispose(): void;
  111838. /**
  111839. * Attach a new callback raised when context lost event is fired
  111840. * @param callback defines the callback to call
  111841. */
  111842. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  111843. /**
  111844. * Attach a new callback raised when context restored event is fired
  111845. * @param callback defines the callback to call
  111846. */
  111847. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  111848. /**
  111849. * Get the current error code of the webGL context
  111850. * @returns the error code
  111851. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111852. */
  111853. getError(): number;
  111854. private _canRenderToFloatFramebuffer;
  111855. private _canRenderToHalfFloatFramebuffer;
  111856. private _canRenderToFramebuffer;
  111857. /** @hidden */
  111858. _getWebGLTextureType(type: number): number;
  111859. /** @hidden */
  111860. _getInternalFormat(format: number): number;
  111861. /** @hidden */
  111862. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  111863. /** @hidden */
  111864. _getRGBAMultiSampleBufferFormat(type: number): number;
  111865. /** @hidden */
  111866. _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;
  111867. /**
  111868. * Loads a file from a url
  111869. * @param url url to load
  111870. * @param onSuccess callback called when the file successfully loads
  111871. * @param onProgress callback called while file is loading (if the server supports this mode)
  111872. * @param offlineProvider defines the offline provider for caching
  111873. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111874. * @param onError callback called when the file fails to load
  111875. * @returns a file request object
  111876. * @hidden
  111877. */
  111878. 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;
  111879. /**
  111880. * Reads pixels from the current frame buffer. Please note that this function can be slow
  111881. * @param x defines the x coordinate of the rectangle where pixels must be read
  111882. * @param y defines the y coordinate of the rectangle where pixels must be read
  111883. * @param width defines the width of the rectangle where pixels must be read
  111884. * @param height defines the height of the rectangle where pixels must be read
  111885. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  111886. * @returns a Uint8Array containing RGBA colors
  111887. */
  111888. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  111889. private static _isSupported;
  111890. /**
  111891. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  111892. * @returns true if the engine can be created
  111893. * @ignorenaming
  111894. */
  111895. static isSupported(): boolean;
  111896. /**
  111897. * Find the next highest power of two.
  111898. * @param x Number to start search from.
  111899. * @return Next highest power of two.
  111900. */
  111901. static CeilingPOT(x: number): number;
  111902. /**
  111903. * Find the next lowest power of two.
  111904. * @param x Number to start search from.
  111905. * @return Next lowest power of two.
  111906. */
  111907. static FloorPOT(x: number): number;
  111908. /**
  111909. * Find the nearest power of two.
  111910. * @param x Number to start search from.
  111911. * @return Next nearest power of two.
  111912. */
  111913. static NearestPOT(x: number): number;
  111914. /**
  111915. * Get the closest exponent of two
  111916. * @param value defines the value to approximate
  111917. * @param max defines the maximum value to return
  111918. * @param mode defines how to define the closest value
  111919. * @returns closest exponent of two of the given value
  111920. */
  111921. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  111922. /**
  111923. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  111924. * @param func - the function to be called
  111925. * @param requester - the object that will request the next frame. Falls back to window.
  111926. * @returns frame number
  111927. */
  111928. static QueueNewFrame(func: () => void, requester?: any): number;
  111929. /**
  111930. * Gets host document
  111931. * @returns the host document object
  111932. */
  111933. getHostDocument(): Nullable<Document>;
  111934. }
  111935. }
  111936. declare module BABYLON {
  111937. /**
  111938. * Class representing spherical harmonics coefficients to the 3rd degree
  111939. */
  111940. export class SphericalHarmonics {
  111941. /**
  111942. * Defines whether or not the harmonics have been prescaled for rendering.
  111943. */
  111944. preScaled: boolean;
  111945. /**
  111946. * The l0,0 coefficients of the spherical harmonics
  111947. */
  111948. l00: Vector3;
  111949. /**
  111950. * The l1,-1 coefficients of the spherical harmonics
  111951. */
  111952. l1_1: Vector3;
  111953. /**
  111954. * The l1,0 coefficients of the spherical harmonics
  111955. */
  111956. l10: Vector3;
  111957. /**
  111958. * The l1,1 coefficients of the spherical harmonics
  111959. */
  111960. l11: Vector3;
  111961. /**
  111962. * The l2,-2 coefficients of the spherical harmonics
  111963. */
  111964. l2_2: Vector3;
  111965. /**
  111966. * The l2,-1 coefficients of the spherical harmonics
  111967. */
  111968. l2_1: Vector3;
  111969. /**
  111970. * The l2,0 coefficients of the spherical harmonics
  111971. */
  111972. l20: Vector3;
  111973. /**
  111974. * The l2,1 coefficients of the spherical harmonics
  111975. */
  111976. l21: Vector3;
  111977. /**
  111978. * The l2,2 coefficients of the spherical harmonics
  111979. */
  111980. l22: Vector3;
  111981. /**
  111982. * Adds a light to the spherical harmonics
  111983. * @param direction the direction of the light
  111984. * @param color the color of the light
  111985. * @param deltaSolidAngle the delta solid angle of the light
  111986. */
  111987. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  111988. /**
  111989. * Scales the spherical harmonics by the given amount
  111990. * @param scale the amount to scale
  111991. */
  111992. scaleInPlace(scale: number): void;
  111993. /**
  111994. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  111995. *
  111996. * ```
  111997. * E_lm = A_l * L_lm
  111998. * ```
  111999. *
  112000. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112001. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112002. * the scaling factors are given in equation 9.
  112003. */
  112004. convertIncidentRadianceToIrradiance(): void;
  112005. /**
  112006. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112007. *
  112008. * ```
  112009. * L = (1/pi) * E * rho
  112010. * ```
  112011. *
  112012. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112013. */
  112014. convertIrradianceToLambertianRadiance(): void;
  112015. /**
  112016. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112017. * required operations at run time.
  112018. *
  112019. * This is simply done by scaling back the SH with Ylm constants parameter.
  112020. * The trigonometric part being applied by the shader at run time.
  112021. */
  112022. preScaleForRendering(): void;
  112023. /**
  112024. * Constructs a spherical harmonics from an array.
  112025. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112026. * @returns the spherical harmonics
  112027. */
  112028. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112029. /**
  112030. * Gets the spherical harmonics from polynomial
  112031. * @param polynomial the spherical polynomial
  112032. * @returns the spherical harmonics
  112033. */
  112034. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112035. }
  112036. /**
  112037. * Class representing spherical polynomial coefficients to the 3rd degree
  112038. */
  112039. export class SphericalPolynomial {
  112040. private _harmonics;
  112041. /**
  112042. * The spherical harmonics used to create the polynomials.
  112043. */
  112044. get preScaledHarmonics(): SphericalHarmonics;
  112045. /**
  112046. * The x coefficients of the spherical polynomial
  112047. */
  112048. x: Vector3;
  112049. /**
  112050. * The y coefficients of the spherical polynomial
  112051. */
  112052. y: Vector3;
  112053. /**
  112054. * The z coefficients of the spherical polynomial
  112055. */
  112056. z: Vector3;
  112057. /**
  112058. * The xx coefficients of the spherical polynomial
  112059. */
  112060. xx: Vector3;
  112061. /**
  112062. * The yy coefficients of the spherical polynomial
  112063. */
  112064. yy: Vector3;
  112065. /**
  112066. * The zz coefficients of the spherical polynomial
  112067. */
  112068. zz: Vector3;
  112069. /**
  112070. * The xy coefficients of the spherical polynomial
  112071. */
  112072. xy: Vector3;
  112073. /**
  112074. * The yz coefficients of the spherical polynomial
  112075. */
  112076. yz: Vector3;
  112077. /**
  112078. * The zx coefficients of the spherical polynomial
  112079. */
  112080. zx: Vector3;
  112081. /**
  112082. * Adds an ambient color to the spherical polynomial
  112083. * @param color the color to add
  112084. */
  112085. addAmbient(color: Color3): void;
  112086. /**
  112087. * Scales the spherical polynomial by the given amount
  112088. * @param scale the amount to scale
  112089. */
  112090. scaleInPlace(scale: number): void;
  112091. /**
  112092. * Gets the spherical polynomial from harmonics
  112093. * @param harmonics the spherical harmonics
  112094. * @returns the spherical polynomial
  112095. */
  112096. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112097. /**
  112098. * Constructs a spherical polynomial from an array.
  112099. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112100. * @returns the spherical polynomial
  112101. */
  112102. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112103. }
  112104. }
  112105. declare module BABYLON {
  112106. /**
  112107. * Defines the source of the internal texture
  112108. */
  112109. export enum InternalTextureSource {
  112110. /**
  112111. * The source of the texture data is unknown
  112112. */
  112113. Unknown = 0,
  112114. /**
  112115. * Texture data comes from an URL
  112116. */
  112117. Url = 1,
  112118. /**
  112119. * Texture data is only used for temporary storage
  112120. */
  112121. Temp = 2,
  112122. /**
  112123. * Texture data comes from raw data (ArrayBuffer)
  112124. */
  112125. Raw = 3,
  112126. /**
  112127. * Texture content is dynamic (video or dynamic texture)
  112128. */
  112129. Dynamic = 4,
  112130. /**
  112131. * Texture content is generated by rendering to it
  112132. */
  112133. RenderTarget = 5,
  112134. /**
  112135. * Texture content is part of a multi render target process
  112136. */
  112137. MultiRenderTarget = 6,
  112138. /**
  112139. * Texture data comes from a cube data file
  112140. */
  112141. Cube = 7,
  112142. /**
  112143. * Texture data comes from a raw cube data
  112144. */
  112145. CubeRaw = 8,
  112146. /**
  112147. * Texture data come from a prefiltered cube data file
  112148. */
  112149. CubePrefiltered = 9,
  112150. /**
  112151. * Texture content is raw 3D data
  112152. */
  112153. Raw3D = 10,
  112154. /**
  112155. * Texture content is raw 2D array data
  112156. */
  112157. Raw2DArray = 11,
  112158. /**
  112159. * Texture content is a depth texture
  112160. */
  112161. Depth = 12,
  112162. /**
  112163. * Texture data comes from a raw cube data encoded with RGBD
  112164. */
  112165. CubeRawRGBD = 13
  112166. }
  112167. /**
  112168. * Class used to store data associated with WebGL texture data for the engine
  112169. * This class should not be used directly
  112170. */
  112171. export class InternalTexture {
  112172. /** @hidden */
  112173. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112174. /**
  112175. * Defines if the texture is ready
  112176. */
  112177. isReady: boolean;
  112178. /**
  112179. * Defines if the texture is a cube texture
  112180. */
  112181. isCube: boolean;
  112182. /**
  112183. * Defines if the texture contains 3D data
  112184. */
  112185. is3D: boolean;
  112186. /**
  112187. * Defines if the texture contains 2D array data
  112188. */
  112189. is2DArray: boolean;
  112190. /**
  112191. * Defines if the texture contains multiview data
  112192. */
  112193. isMultiview: boolean;
  112194. /**
  112195. * Gets the URL used to load this texture
  112196. */
  112197. url: string;
  112198. /**
  112199. * Gets the sampling mode of the texture
  112200. */
  112201. samplingMode: number;
  112202. /**
  112203. * Gets a boolean indicating if the texture needs mipmaps generation
  112204. */
  112205. generateMipMaps: boolean;
  112206. /**
  112207. * Gets the number of samples used by the texture (WebGL2+ only)
  112208. */
  112209. samples: number;
  112210. /**
  112211. * Gets the type of the texture (int, float...)
  112212. */
  112213. type: number;
  112214. /**
  112215. * Gets the format of the texture (RGB, RGBA...)
  112216. */
  112217. format: number;
  112218. /**
  112219. * Observable called when the texture is loaded
  112220. */
  112221. onLoadedObservable: Observable<InternalTexture>;
  112222. /**
  112223. * Gets the width of the texture
  112224. */
  112225. width: number;
  112226. /**
  112227. * Gets the height of the texture
  112228. */
  112229. height: number;
  112230. /**
  112231. * Gets the depth of the texture
  112232. */
  112233. depth: number;
  112234. /**
  112235. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112236. */
  112237. baseWidth: number;
  112238. /**
  112239. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  112240. */
  112241. baseHeight: number;
  112242. /**
  112243. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  112244. */
  112245. baseDepth: number;
  112246. /**
  112247. * Gets a boolean indicating if the texture is inverted on Y axis
  112248. */
  112249. invertY: boolean;
  112250. /** @hidden */
  112251. _invertVScale: boolean;
  112252. /** @hidden */
  112253. _associatedChannel: number;
  112254. /** @hidden */
  112255. _source: InternalTextureSource;
  112256. /** @hidden */
  112257. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  112258. /** @hidden */
  112259. _bufferView: Nullable<ArrayBufferView>;
  112260. /** @hidden */
  112261. _bufferViewArray: Nullable<ArrayBufferView[]>;
  112262. /** @hidden */
  112263. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  112264. /** @hidden */
  112265. _size: number;
  112266. /** @hidden */
  112267. _extension: string;
  112268. /** @hidden */
  112269. _files: Nullable<string[]>;
  112270. /** @hidden */
  112271. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112272. /** @hidden */
  112273. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112274. /** @hidden */
  112275. _framebuffer: Nullable<WebGLFramebuffer>;
  112276. /** @hidden */
  112277. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  112278. /** @hidden */
  112279. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  112280. /** @hidden */
  112281. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  112282. /** @hidden */
  112283. _attachments: Nullable<number[]>;
  112284. /** @hidden */
  112285. _cachedCoordinatesMode: Nullable<number>;
  112286. /** @hidden */
  112287. _cachedWrapU: Nullable<number>;
  112288. /** @hidden */
  112289. _cachedWrapV: Nullable<number>;
  112290. /** @hidden */
  112291. _cachedWrapR: Nullable<number>;
  112292. /** @hidden */
  112293. _cachedAnisotropicFilteringLevel: Nullable<number>;
  112294. /** @hidden */
  112295. _isDisabled: boolean;
  112296. /** @hidden */
  112297. _compression: Nullable<string>;
  112298. /** @hidden */
  112299. _generateStencilBuffer: boolean;
  112300. /** @hidden */
  112301. _generateDepthBuffer: boolean;
  112302. /** @hidden */
  112303. _comparisonFunction: number;
  112304. /** @hidden */
  112305. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  112306. /** @hidden */
  112307. _lodGenerationScale: number;
  112308. /** @hidden */
  112309. _lodGenerationOffset: number;
  112310. /** @hidden */
  112311. _depthStencilTexture: Nullable<InternalTexture>;
  112312. /** @hidden */
  112313. _colorTextureArray: Nullable<WebGLTexture>;
  112314. /** @hidden */
  112315. _depthStencilTextureArray: Nullable<WebGLTexture>;
  112316. /** @hidden */
  112317. _lodTextureHigh: Nullable<BaseTexture>;
  112318. /** @hidden */
  112319. _lodTextureMid: Nullable<BaseTexture>;
  112320. /** @hidden */
  112321. _lodTextureLow: Nullable<BaseTexture>;
  112322. /** @hidden */
  112323. _isRGBD: boolean;
  112324. /** @hidden */
  112325. _linearSpecularLOD: boolean;
  112326. /** @hidden */
  112327. _irradianceTexture: Nullable<BaseTexture>;
  112328. /** @hidden */
  112329. _webGLTexture: Nullable<WebGLTexture>;
  112330. /** @hidden */
  112331. _references: number;
  112332. private _engine;
  112333. /**
  112334. * Gets the Engine the texture belongs to.
  112335. * @returns The babylon engine
  112336. */
  112337. getEngine(): ThinEngine;
  112338. /**
  112339. * Gets the data source type of the texture
  112340. */
  112341. get source(): InternalTextureSource;
  112342. /**
  112343. * Creates a new InternalTexture
  112344. * @param engine defines the engine to use
  112345. * @param source defines the type of data that will be used
  112346. * @param delayAllocation if the texture allocation should be delayed (default: false)
  112347. */
  112348. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  112349. /**
  112350. * Increments the number of references (ie. the number of Texture that point to it)
  112351. */
  112352. incrementReferences(): void;
  112353. /**
  112354. * Change the size of the texture (not the size of the content)
  112355. * @param width defines the new width
  112356. * @param height defines the new height
  112357. * @param depth defines the new depth (1 by default)
  112358. */
  112359. updateSize(width: int, height: int, depth?: int): void;
  112360. /** @hidden */
  112361. _rebuild(): void;
  112362. /** @hidden */
  112363. _swapAndDie(target: InternalTexture): void;
  112364. /**
  112365. * Dispose the current allocated resources
  112366. */
  112367. dispose(): void;
  112368. }
  112369. }
  112370. declare module BABYLON {
  112371. /**
  112372. * Class used to work with sound analyzer using fast fourier transform (FFT)
  112373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112374. */
  112375. export class Analyser {
  112376. /**
  112377. * Gets or sets the smoothing
  112378. * @ignorenaming
  112379. */
  112380. SMOOTHING: number;
  112381. /**
  112382. * Gets or sets the FFT table size
  112383. * @ignorenaming
  112384. */
  112385. FFT_SIZE: number;
  112386. /**
  112387. * Gets or sets the bar graph amplitude
  112388. * @ignorenaming
  112389. */
  112390. BARGRAPHAMPLITUDE: number;
  112391. /**
  112392. * Gets or sets the position of the debug canvas
  112393. * @ignorenaming
  112394. */
  112395. DEBUGCANVASPOS: {
  112396. x: number;
  112397. y: number;
  112398. };
  112399. /**
  112400. * Gets or sets the debug canvas size
  112401. * @ignorenaming
  112402. */
  112403. DEBUGCANVASSIZE: {
  112404. width: number;
  112405. height: number;
  112406. };
  112407. private _byteFreqs;
  112408. private _byteTime;
  112409. private _floatFreqs;
  112410. private _webAudioAnalyser;
  112411. private _debugCanvas;
  112412. private _debugCanvasContext;
  112413. private _scene;
  112414. private _registerFunc;
  112415. private _audioEngine;
  112416. /**
  112417. * Creates a new analyser
  112418. * @param scene defines hosting scene
  112419. */
  112420. constructor(scene: Scene);
  112421. /**
  112422. * Get the number of data values you will have to play with for the visualization
  112423. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  112424. * @returns a number
  112425. */
  112426. getFrequencyBinCount(): number;
  112427. /**
  112428. * Gets the current frequency data as a byte array
  112429. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112430. * @returns a Uint8Array
  112431. */
  112432. getByteFrequencyData(): Uint8Array;
  112433. /**
  112434. * Gets the current waveform as a byte array
  112435. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  112436. * @returns a Uint8Array
  112437. */
  112438. getByteTimeDomainData(): Uint8Array;
  112439. /**
  112440. * Gets the current frequency data as a float array
  112441. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112442. * @returns a Float32Array
  112443. */
  112444. getFloatFrequencyData(): Float32Array;
  112445. /**
  112446. * Renders the debug canvas
  112447. */
  112448. drawDebugCanvas(): void;
  112449. /**
  112450. * Stops rendering the debug canvas and removes it
  112451. */
  112452. stopDebugCanvas(): void;
  112453. /**
  112454. * Connects two audio nodes
  112455. * @param inputAudioNode defines first node to connect
  112456. * @param outputAudioNode defines second node to connect
  112457. */
  112458. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  112459. /**
  112460. * Releases all associated resources
  112461. */
  112462. dispose(): void;
  112463. }
  112464. }
  112465. declare module BABYLON {
  112466. /**
  112467. * This represents an audio engine and it is responsible
  112468. * to play, synchronize and analyse sounds throughout the application.
  112469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112470. */
  112471. export interface IAudioEngine extends IDisposable {
  112472. /**
  112473. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112474. */
  112475. readonly canUseWebAudio: boolean;
  112476. /**
  112477. * Gets the current AudioContext if available.
  112478. */
  112479. readonly audioContext: Nullable<AudioContext>;
  112480. /**
  112481. * The master gain node defines the global audio volume of your audio engine.
  112482. */
  112483. readonly masterGain: GainNode;
  112484. /**
  112485. * Gets whether or not mp3 are supported by your browser.
  112486. */
  112487. readonly isMP3supported: boolean;
  112488. /**
  112489. * Gets whether or not ogg are supported by your browser.
  112490. */
  112491. readonly isOGGsupported: boolean;
  112492. /**
  112493. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112494. * @ignoreNaming
  112495. */
  112496. WarnedWebAudioUnsupported: boolean;
  112497. /**
  112498. * Defines if the audio engine relies on a custom unlocked button.
  112499. * In this case, the embedded button will not be displayed.
  112500. */
  112501. useCustomUnlockedButton: boolean;
  112502. /**
  112503. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  112504. */
  112505. readonly unlocked: boolean;
  112506. /**
  112507. * Event raised when audio has been unlocked on the browser.
  112508. */
  112509. onAudioUnlockedObservable: Observable<AudioEngine>;
  112510. /**
  112511. * Event raised when audio has been locked on the browser.
  112512. */
  112513. onAudioLockedObservable: Observable<AudioEngine>;
  112514. /**
  112515. * Flags the audio engine in Locked state.
  112516. * This happens due to new browser policies preventing audio to autoplay.
  112517. */
  112518. lock(): void;
  112519. /**
  112520. * Unlocks the audio engine once a user action has been done on the dom.
  112521. * This is helpful to resume play once browser policies have been satisfied.
  112522. */
  112523. unlock(): void;
  112524. /**
  112525. * Gets the global volume sets on the master gain.
  112526. * @returns the global volume if set or -1 otherwise
  112527. */
  112528. getGlobalVolume(): number;
  112529. /**
  112530. * Sets the global volume of your experience (sets on the master gain).
  112531. * @param newVolume Defines the new global volume of the application
  112532. */
  112533. setGlobalVolume(newVolume: number): void;
  112534. /**
  112535. * Connect the audio engine to an audio analyser allowing some amazing
  112536. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112538. * @param analyser The analyser to connect to the engine
  112539. */
  112540. connectToAnalyser(analyser: Analyser): void;
  112541. }
  112542. /**
  112543. * This represents the default audio engine used in babylon.
  112544. * It is responsible to play, synchronize and analyse sounds throughout the application.
  112545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112546. */
  112547. export class AudioEngine implements IAudioEngine {
  112548. private _audioContext;
  112549. private _audioContextInitialized;
  112550. private _muteButton;
  112551. private _hostElement;
  112552. /**
  112553. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112554. */
  112555. canUseWebAudio: boolean;
  112556. /**
  112557. * The master gain node defines the global audio volume of your audio engine.
  112558. */
  112559. masterGain: GainNode;
  112560. /**
  112561. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112562. * @ignoreNaming
  112563. */
  112564. WarnedWebAudioUnsupported: boolean;
  112565. /**
  112566. * Gets whether or not mp3 are supported by your browser.
  112567. */
  112568. isMP3supported: boolean;
  112569. /**
  112570. * Gets whether or not ogg are supported by your browser.
  112571. */
  112572. isOGGsupported: boolean;
  112573. /**
  112574. * Gets whether audio has been unlocked on the device.
  112575. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  112576. * a user interaction has happened.
  112577. */
  112578. unlocked: boolean;
  112579. /**
  112580. * Defines if the audio engine relies on a custom unlocked button.
  112581. * In this case, the embedded button will not be displayed.
  112582. */
  112583. useCustomUnlockedButton: boolean;
  112584. /**
  112585. * Event raised when audio has been unlocked on the browser.
  112586. */
  112587. onAudioUnlockedObservable: Observable<AudioEngine>;
  112588. /**
  112589. * Event raised when audio has been locked on the browser.
  112590. */
  112591. onAudioLockedObservable: Observable<AudioEngine>;
  112592. /**
  112593. * Gets the current AudioContext if available.
  112594. */
  112595. get audioContext(): Nullable<AudioContext>;
  112596. private _connectedAnalyser;
  112597. /**
  112598. * Instantiates a new audio engine.
  112599. *
  112600. * There should be only one per page as some browsers restrict the number
  112601. * of audio contexts you can create.
  112602. * @param hostElement defines the host element where to display the mute icon if necessary
  112603. */
  112604. constructor(hostElement?: Nullable<HTMLElement>);
  112605. /**
  112606. * Flags the audio engine in Locked state.
  112607. * This happens due to new browser policies preventing audio to autoplay.
  112608. */
  112609. lock(): void;
  112610. /**
  112611. * Unlocks the audio engine once a user action has been done on the dom.
  112612. * This is helpful to resume play once browser policies have been satisfied.
  112613. */
  112614. unlock(): void;
  112615. private _resumeAudioContext;
  112616. private _initializeAudioContext;
  112617. private _tryToRun;
  112618. private _triggerRunningState;
  112619. private _triggerSuspendedState;
  112620. private _displayMuteButton;
  112621. private _moveButtonToTopLeft;
  112622. private _onResize;
  112623. private _hideMuteButton;
  112624. /**
  112625. * Destroy and release the resources associated with the audio ccontext.
  112626. */
  112627. dispose(): void;
  112628. /**
  112629. * Gets the global volume sets on the master gain.
  112630. * @returns the global volume if set or -1 otherwise
  112631. */
  112632. getGlobalVolume(): number;
  112633. /**
  112634. * Sets the global volume of your experience (sets on the master gain).
  112635. * @param newVolume Defines the new global volume of the application
  112636. */
  112637. setGlobalVolume(newVolume: number): void;
  112638. /**
  112639. * Connect the audio engine to an audio analyser allowing some amazing
  112640. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112642. * @param analyser The analyser to connect to the engine
  112643. */
  112644. connectToAnalyser(analyser: Analyser): void;
  112645. }
  112646. }
  112647. declare module BABYLON {
  112648. /**
  112649. * Interface used to present a loading screen while loading a scene
  112650. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112651. */
  112652. export interface ILoadingScreen {
  112653. /**
  112654. * Function called to display the loading screen
  112655. */
  112656. displayLoadingUI: () => void;
  112657. /**
  112658. * Function called to hide the loading screen
  112659. */
  112660. hideLoadingUI: () => void;
  112661. /**
  112662. * Gets or sets the color to use for the background
  112663. */
  112664. loadingUIBackgroundColor: string;
  112665. /**
  112666. * Gets or sets the text to display while loading
  112667. */
  112668. loadingUIText: string;
  112669. }
  112670. /**
  112671. * Class used for the default loading screen
  112672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112673. */
  112674. export class DefaultLoadingScreen implements ILoadingScreen {
  112675. private _renderingCanvas;
  112676. private _loadingText;
  112677. private _loadingDivBackgroundColor;
  112678. private _loadingDiv;
  112679. private _loadingTextDiv;
  112680. /** Gets or sets the logo url to use for the default loading screen */
  112681. static DefaultLogoUrl: string;
  112682. /** Gets or sets the spinner url to use for the default loading screen */
  112683. static DefaultSpinnerUrl: string;
  112684. /**
  112685. * Creates a new default loading screen
  112686. * @param _renderingCanvas defines the canvas used to render the scene
  112687. * @param _loadingText defines the default text to display
  112688. * @param _loadingDivBackgroundColor defines the default background color
  112689. */
  112690. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  112691. /**
  112692. * Function called to display the loading screen
  112693. */
  112694. displayLoadingUI(): void;
  112695. /**
  112696. * Function called to hide the loading screen
  112697. */
  112698. hideLoadingUI(): void;
  112699. /**
  112700. * Gets or sets the text to display while loading
  112701. */
  112702. set loadingUIText(text: string);
  112703. get loadingUIText(): string;
  112704. /**
  112705. * Gets or sets the color to use for the background
  112706. */
  112707. get loadingUIBackgroundColor(): string;
  112708. set loadingUIBackgroundColor(color: string);
  112709. private _resizeLoadingUI;
  112710. }
  112711. }
  112712. declare module BABYLON {
  112713. /**
  112714. * Interface for any object that can request an animation frame
  112715. */
  112716. export interface ICustomAnimationFrameRequester {
  112717. /**
  112718. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  112719. */
  112720. renderFunction?: Function;
  112721. /**
  112722. * Called to request the next frame to render to
  112723. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  112724. */
  112725. requestAnimationFrame: Function;
  112726. /**
  112727. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  112728. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  112729. */
  112730. requestID?: number;
  112731. }
  112732. }
  112733. declare module BABYLON {
  112734. /**
  112735. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  112736. */
  112737. export class PerformanceMonitor {
  112738. private _enabled;
  112739. private _rollingFrameTime;
  112740. private _lastFrameTimeMs;
  112741. /**
  112742. * constructor
  112743. * @param frameSampleSize The number of samples required to saturate the sliding window
  112744. */
  112745. constructor(frameSampleSize?: number);
  112746. /**
  112747. * Samples current frame
  112748. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  112749. */
  112750. sampleFrame(timeMs?: number): void;
  112751. /**
  112752. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  112753. */
  112754. get averageFrameTime(): number;
  112755. /**
  112756. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  112757. */
  112758. get averageFrameTimeVariance(): number;
  112759. /**
  112760. * Returns the frame time of the most recent frame
  112761. */
  112762. get instantaneousFrameTime(): number;
  112763. /**
  112764. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  112765. */
  112766. get averageFPS(): number;
  112767. /**
  112768. * Returns the average framerate in frames per second using the most recent frame time
  112769. */
  112770. get instantaneousFPS(): number;
  112771. /**
  112772. * Returns true if enough samples have been taken to completely fill the sliding window
  112773. */
  112774. get isSaturated(): boolean;
  112775. /**
  112776. * Enables contributions to the sliding window sample set
  112777. */
  112778. enable(): void;
  112779. /**
  112780. * Disables contributions to the sliding window sample set
  112781. * Samples will not be interpolated over the disabled period
  112782. */
  112783. disable(): void;
  112784. /**
  112785. * Returns true if sampling is enabled
  112786. */
  112787. get isEnabled(): boolean;
  112788. /**
  112789. * Resets performance monitor
  112790. */
  112791. reset(): void;
  112792. }
  112793. /**
  112794. * RollingAverage
  112795. *
  112796. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  112797. */
  112798. export class RollingAverage {
  112799. /**
  112800. * Current average
  112801. */
  112802. average: number;
  112803. /**
  112804. * Current variance
  112805. */
  112806. variance: number;
  112807. protected _samples: Array<number>;
  112808. protected _sampleCount: number;
  112809. protected _pos: number;
  112810. protected _m2: number;
  112811. /**
  112812. * constructor
  112813. * @param length The number of samples required to saturate the sliding window
  112814. */
  112815. constructor(length: number);
  112816. /**
  112817. * Adds a sample to the sample set
  112818. * @param v The sample value
  112819. */
  112820. add(v: number): void;
  112821. /**
  112822. * Returns previously added values or null if outside of history or outside the sliding window domain
  112823. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  112824. * @return Value previously recorded with add() or null if outside of range
  112825. */
  112826. history(i: number): number;
  112827. /**
  112828. * Returns true if enough samples have been taken to completely fill the sliding window
  112829. * @return true if sample-set saturated
  112830. */
  112831. isSaturated(): boolean;
  112832. /**
  112833. * Resets the rolling average (equivalent to 0 samples taken so far)
  112834. */
  112835. reset(): void;
  112836. /**
  112837. * Wraps a value around the sample range boundaries
  112838. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  112839. * @return Wrapped position in sample range
  112840. */
  112841. protected _wrapPosition(i: number): number;
  112842. }
  112843. }
  112844. declare module BABYLON {
  112845. /**
  112846. * This class is used to track a performance counter which is number based.
  112847. * The user has access to many properties which give statistics of different nature.
  112848. *
  112849. * The implementer can track two kinds of Performance Counter: time and count.
  112850. * 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.
  112851. * 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.
  112852. */
  112853. export class PerfCounter {
  112854. /**
  112855. * Gets or sets a global boolean to turn on and off all the counters
  112856. */
  112857. static Enabled: boolean;
  112858. /**
  112859. * Returns the smallest value ever
  112860. */
  112861. get min(): number;
  112862. /**
  112863. * Returns the biggest value ever
  112864. */
  112865. get max(): number;
  112866. /**
  112867. * Returns the average value since the performance counter is running
  112868. */
  112869. get average(): number;
  112870. /**
  112871. * Returns the average value of the last second the counter was monitored
  112872. */
  112873. get lastSecAverage(): number;
  112874. /**
  112875. * Returns the current value
  112876. */
  112877. get current(): number;
  112878. /**
  112879. * Gets the accumulated total
  112880. */
  112881. get total(): number;
  112882. /**
  112883. * Gets the total value count
  112884. */
  112885. get count(): number;
  112886. /**
  112887. * Creates a new counter
  112888. */
  112889. constructor();
  112890. /**
  112891. * Call this method to start monitoring a new frame.
  112892. * 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.
  112893. */
  112894. fetchNewFrame(): void;
  112895. /**
  112896. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  112897. * @param newCount the count value to add to the monitored count
  112898. * @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.
  112899. */
  112900. addCount(newCount: number, fetchResult: boolean): void;
  112901. /**
  112902. * Start monitoring this performance counter
  112903. */
  112904. beginMonitoring(): void;
  112905. /**
  112906. * Compute the time lapsed since the previous beginMonitoring() call.
  112907. * @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
  112908. */
  112909. endMonitoring(newFrame?: boolean): void;
  112910. private _fetchResult;
  112911. private _startMonitoringTime;
  112912. private _min;
  112913. private _max;
  112914. private _average;
  112915. private _current;
  112916. private _totalValueCount;
  112917. private _totalAccumulated;
  112918. private _lastSecAverage;
  112919. private _lastSecAccumulated;
  112920. private _lastSecTime;
  112921. private _lastSecValueCount;
  112922. }
  112923. }
  112924. declare module BABYLON {
  112925. interface ThinEngine {
  112926. /**
  112927. * Sets alpha constants used by some alpha blending modes
  112928. * @param r defines the red component
  112929. * @param g defines the green component
  112930. * @param b defines the blue component
  112931. * @param a defines the alpha component
  112932. */
  112933. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112934. /**
  112935. * Sets the current alpha mode
  112936. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112937. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112938. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112939. */
  112940. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112941. /**
  112942. * Gets the current alpha mode
  112943. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112944. * @returns the current alpha mode
  112945. */
  112946. getAlphaMode(): number;
  112947. /**
  112948. * Sets the current alpha equation
  112949. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  112950. */
  112951. setAlphaEquation(equation: number): void;
  112952. /**
  112953. * Gets the current alpha equation.
  112954. * @returns the current alpha equation
  112955. */
  112956. getAlphaEquation(): number;
  112957. }
  112958. }
  112959. declare module BABYLON {
  112960. interface ThinEngine {
  112961. /** @hidden */
  112962. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  112963. }
  112964. }
  112965. declare module BABYLON {
  112966. /**
  112967. * Defines the interface used by display changed events
  112968. */
  112969. export interface IDisplayChangedEventArgs {
  112970. /** Gets the vrDisplay object (if any) */
  112971. vrDisplay: Nullable<any>;
  112972. /** Gets a boolean indicating if webVR is supported */
  112973. vrSupported: boolean;
  112974. }
  112975. /**
  112976. * Defines the interface used by objects containing a viewport (like a camera)
  112977. */
  112978. interface IViewportOwnerLike {
  112979. /**
  112980. * Gets or sets the viewport
  112981. */
  112982. viewport: IViewportLike;
  112983. }
  112984. /**
  112985. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  112986. */
  112987. export class Engine extends ThinEngine {
  112988. /** Defines that alpha blending is disabled */
  112989. static readonly ALPHA_DISABLE: number;
  112990. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  112991. static readonly ALPHA_ADD: number;
  112992. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  112993. static readonly ALPHA_COMBINE: number;
  112994. /** Defines that alpha blending to DEST - SRC * DEST */
  112995. static readonly ALPHA_SUBTRACT: number;
  112996. /** Defines that alpha blending to SRC * DEST */
  112997. static readonly ALPHA_MULTIPLY: number;
  112998. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  112999. static readonly ALPHA_MAXIMIZED: number;
  113000. /** Defines that alpha blending to SRC + DEST */
  113001. static readonly ALPHA_ONEONE: number;
  113002. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113003. static readonly ALPHA_PREMULTIPLIED: number;
  113004. /**
  113005. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113006. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113007. */
  113008. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113009. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113010. static readonly ALPHA_INTERPOLATE: number;
  113011. /**
  113012. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113013. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113014. */
  113015. static readonly ALPHA_SCREENMODE: number;
  113016. /** Defines that the ressource is not delayed*/
  113017. static readonly DELAYLOADSTATE_NONE: number;
  113018. /** Defines that the ressource was successfully delay loaded */
  113019. static readonly DELAYLOADSTATE_LOADED: number;
  113020. /** Defines that the ressource is currently delay loading */
  113021. static readonly DELAYLOADSTATE_LOADING: number;
  113022. /** Defines that the ressource is delayed and has not started loading */
  113023. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113025. static readonly NEVER: number;
  113026. /** 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 */
  113027. static readonly ALWAYS: number;
  113028. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113029. static readonly LESS: number;
  113030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113031. static readonly EQUAL: number;
  113032. /** 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 */
  113033. static readonly LEQUAL: number;
  113034. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113035. static readonly GREATER: number;
  113036. /** 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 */
  113037. static readonly GEQUAL: number;
  113038. /** 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 */
  113039. static readonly NOTEQUAL: number;
  113040. /** Passed to stencilOperation to specify that stencil value must be kept */
  113041. static readonly KEEP: number;
  113042. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113043. static readonly REPLACE: number;
  113044. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113045. static readonly INCR: number;
  113046. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113047. static readonly DECR: number;
  113048. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113049. static readonly INVERT: number;
  113050. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113051. static readonly INCR_WRAP: number;
  113052. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113053. static readonly DECR_WRAP: number;
  113054. /** Texture is not repeating outside of 0..1 UVs */
  113055. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113056. /** Texture is repeating outside of 0..1 UVs */
  113057. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113058. /** Texture is repeating and mirrored */
  113059. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113060. /** ALPHA */
  113061. static readonly TEXTUREFORMAT_ALPHA: number;
  113062. /** LUMINANCE */
  113063. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113064. /** LUMINANCE_ALPHA */
  113065. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113066. /** RGB */
  113067. static readonly TEXTUREFORMAT_RGB: number;
  113068. /** RGBA */
  113069. static readonly TEXTUREFORMAT_RGBA: number;
  113070. /** RED */
  113071. static readonly TEXTUREFORMAT_RED: number;
  113072. /** RED (2nd reference) */
  113073. static readonly TEXTUREFORMAT_R: number;
  113074. /** RG */
  113075. static readonly TEXTUREFORMAT_RG: number;
  113076. /** RED_INTEGER */
  113077. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113078. /** RED_INTEGER (2nd reference) */
  113079. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113080. /** RG_INTEGER */
  113081. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113082. /** RGB_INTEGER */
  113083. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113084. /** RGBA_INTEGER */
  113085. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113086. /** UNSIGNED_BYTE */
  113087. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113088. /** UNSIGNED_BYTE (2nd reference) */
  113089. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113090. /** FLOAT */
  113091. static readonly TEXTURETYPE_FLOAT: number;
  113092. /** HALF_FLOAT */
  113093. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113094. /** BYTE */
  113095. static readonly TEXTURETYPE_BYTE: number;
  113096. /** SHORT */
  113097. static readonly TEXTURETYPE_SHORT: number;
  113098. /** UNSIGNED_SHORT */
  113099. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113100. /** INT */
  113101. static readonly TEXTURETYPE_INT: number;
  113102. /** UNSIGNED_INT */
  113103. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113104. /** UNSIGNED_SHORT_4_4_4_4 */
  113105. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113106. /** UNSIGNED_SHORT_5_5_5_1 */
  113107. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113108. /** UNSIGNED_SHORT_5_6_5 */
  113109. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113110. /** UNSIGNED_INT_2_10_10_10_REV */
  113111. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113112. /** UNSIGNED_INT_24_8 */
  113113. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113114. /** UNSIGNED_INT_10F_11F_11F_REV */
  113115. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113116. /** UNSIGNED_INT_5_9_9_9_REV */
  113117. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113118. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113119. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113120. /** nearest is mag = nearest and min = nearest and mip = linear */
  113121. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113123. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113124. /** Trilinear is mag = linear and min = linear and mip = linear */
  113125. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113126. /** nearest is mag = nearest and min = nearest and mip = linear */
  113127. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113128. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113129. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113130. /** Trilinear is mag = linear and min = linear and mip = linear */
  113131. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113132. /** mag = nearest and min = nearest and mip = nearest */
  113133. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113134. /** mag = nearest and min = linear and mip = nearest */
  113135. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113136. /** mag = nearest and min = linear and mip = linear */
  113137. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113138. /** mag = nearest and min = linear and mip = none */
  113139. static readonly TEXTURE_NEAREST_LINEAR: number;
  113140. /** mag = nearest and min = nearest and mip = none */
  113141. static readonly TEXTURE_NEAREST_NEAREST: number;
  113142. /** mag = linear and min = nearest and mip = nearest */
  113143. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113144. /** mag = linear and min = nearest and mip = linear */
  113145. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113146. /** mag = linear and min = linear and mip = none */
  113147. static readonly TEXTURE_LINEAR_LINEAR: number;
  113148. /** mag = linear and min = nearest and mip = none */
  113149. static readonly TEXTURE_LINEAR_NEAREST: number;
  113150. /** Explicit coordinates mode */
  113151. static readonly TEXTURE_EXPLICIT_MODE: number;
  113152. /** Spherical coordinates mode */
  113153. static readonly TEXTURE_SPHERICAL_MODE: number;
  113154. /** Planar coordinates mode */
  113155. static readonly TEXTURE_PLANAR_MODE: number;
  113156. /** Cubic coordinates mode */
  113157. static readonly TEXTURE_CUBIC_MODE: number;
  113158. /** Projection coordinates mode */
  113159. static readonly TEXTURE_PROJECTION_MODE: number;
  113160. /** Skybox coordinates mode */
  113161. static readonly TEXTURE_SKYBOX_MODE: number;
  113162. /** Inverse Cubic coordinates mode */
  113163. static readonly TEXTURE_INVCUBIC_MODE: number;
  113164. /** Equirectangular coordinates mode */
  113165. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113166. /** Equirectangular Fixed coordinates mode */
  113167. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113168. /** Equirectangular Fixed Mirrored coordinates mode */
  113169. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113170. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113171. static readonly SCALEMODE_FLOOR: number;
  113172. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113173. static readonly SCALEMODE_NEAREST: number;
  113174. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113175. static readonly SCALEMODE_CEILING: number;
  113176. /**
  113177. * Returns the current npm package of the sdk
  113178. */
  113179. static get NpmPackage(): string;
  113180. /**
  113181. * Returns the current version of the framework
  113182. */
  113183. static get Version(): string;
  113184. /** Gets the list of created engines */
  113185. static get Instances(): Engine[];
  113186. /**
  113187. * Gets the latest created engine
  113188. */
  113189. static get LastCreatedEngine(): Nullable<Engine>;
  113190. /**
  113191. * Gets the latest created scene
  113192. */
  113193. static get LastCreatedScene(): Nullable<Scene>;
  113194. /**
  113195. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113196. * @param flag defines which part of the materials must be marked as dirty
  113197. * @param predicate defines a predicate used to filter which materials should be affected
  113198. */
  113199. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113200. /**
  113201. * Method called to create the default loading screen.
  113202. * This can be overriden in your own app.
  113203. * @param canvas The rendering canvas element
  113204. * @returns The loading screen
  113205. */
  113206. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113207. /**
  113208. * Method called to create the default rescale post process on each engine.
  113209. */
  113210. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113211. /**
  113212. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113213. **/
  113214. enableOfflineSupport: boolean;
  113215. /**
  113216. * 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)
  113217. **/
  113218. disableManifestCheck: boolean;
  113219. /**
  113220. * Gets the list of created scenes
  113221. */
  113222. scenes: Scene[];
  113223. /**
  113224. * Event raised when a new scene is created
  113225. */
  113226. onNewSceneAddedObservable: Observable<Scene>;
  113227. /**
  113228. * Gets the list of created postprocesses
  113229. */
  113230. postProcesses: PostProcess[];
  113231. /**
  113232. * Gets a boolean indicating if the pointer is currently locked
  113233. */
  113234. isPointerLock: boolean;
  113235. /**
  113236. * Observable event triggered each time the rendering canvas is resized
  113237. */
  113238. onResizeObservable: Observable<Engine>;
  113239. /**
  113240. * Observable event triggered each time the canvas loses focus
  113241. */
  113242. onCanvasBlurObservable: Observable<Engine>;
  113243. /**
  113244. * Observable event triggered each time the canvas gains focus
  113245. */
  113246. onCanvasFocusObservable: Observable<Engine>;
  113247. /**
  113248. * Observable event triggered each time the canvas receives pointerout event
  113249. */
  113250. onCanvasPointerOutObservable: Observable<PointerEvent>;
  113251. /**
  113252. * Observable raised when the engine begins a new frame
  113253. */
  113254. onBeginFrameObservable: Observable<Engine>;
  113255. /**
  113256. * If set, will be used to request the next animation frame for the render loop
  113257. */
  113258. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  113259. /**
  113260. * Observable raised when the engine ends the current frame
  113261. */
  113262. onEndFrameObservable: Observable<Engine>;
  113263. /**
  113264. * Observable raised when the engine is about to compile a shader
  113265. */
  113266. onBeforeShaderCompilationObservable: Observable<Engine>;
  113267. /**
  113268. * Observable raised when the engine has jsut compiled a shader
  113269. */
  113270. onAfterShaderCompilationObservable: Observable<Engine>;
  113271. /**
  113272. * Gets the audio engine
  113273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113274. * @ignorenaming
  113275. */
  113276. static audioEngine: IAudioEngine;
  113277. /**
  113278. * Default AudioEngine factory responsible of creating the Audio Engine.
  113279. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  113280. */
  113281. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  113282. /**
  113283. * Default offline support factory responsible of creating a tool used to store data locally.
  113284. * By default, this will create a Database object if the workload has been embedded.
  113285. */
  113286. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  113287. private _loadingScreen;
  113288. private _pointerLockRequested;
  113289. private _rescalePostProcess;
  113290. private _deterministicLockstep;
  113291. private _lockstepMaxSteps;
  113292. private _timeStep;
  113293. protected get _supportsHardwareTextureRescaling(): boolean;
  113294. private _fps;
  113295. private _deltaTime;
  113296. /** @hidden */
  113297. _drawCalls: PerfCounter;
  113298. /** 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 */
  113299. canvasTabIndex: number;
  113300. /**
  113301. * Turn this value on if you want to pause FPS computation when in background
  113302. */
  113303. disablePerformanceMonitorInBackground: boolean;
  113304. private _performanceMonitor;
  113305. /**
  113306. * Gets the performance monitor attached to this engine
  113307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113308. */
  113309. get performanceMonitor(): PerformanceMonitor;
  113310. private _onFocus;
  113311. private _onBlur;
  113312. private _onCanvasPointerOut;
  113313. private _onCanvasBlur;
  113314. private _onCanvasFocus;
  113315. private _onFullscreenChange;
  113316. private _onPointerLockChange;
  113317. /**
  113318. * Gets the HTML element used to attach event listeners
  113319. * @returns a HTML element
  113320. */
  113321. getInputElement(): Nullable<HTMLElement>;
  113322. /**
  113323. * Creates a new engine
  113324. * @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
  113325. * @param antialias defines enable antialiasing (default: false)
  113326. * @param options defines further options to be sent to the getContext() function
  113327. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113328. */
  113329. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113330. /**
  113331. * Gets current aspect ratio
  113332. * @param viewportOwner defines the camera to use to get the aspect ratio
  113333. * @param useScreen defines if screen size must be used (or the current render target if any)
  113334. * @returns a number defining the aspect ratio
  113335. */
  113336. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  113337. /**
  113338. * Gets current screen aspect ratio
  113339. * @returns a number defining the aspect ratio
  113340. */
  113341. getScreenAspectRatio(): number;
  113342. /**
  113343. * Gets the client rect of the HTML canvas attached with the current webGL context
  113344. * @returns a client rectanglee
  113345. */
  113346. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  113347. /**
  113348. * Gets the client rect of the HTML element used for events
  113349. * @returns a client rectanglee
  113350. */
  113351. getInputElementClientRect(): Nullable<ClientRect>;
  113352. /**
  113353. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113355. * @returns true if engine is in deterministic lock step mode
  113356. */
  113357. isDeterministicLockStep(): boolean;
  113358. /**
  113359. * Gets the max steps when engine is running in deterministic lock step
  113360. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113361. * @returns the max steps
  113362. */
  113363. getLockstepMaxSteps(): number;
  113364. /**
  113365. * Returns the time in ms between steps when using deterministic lock step.
  113366. * @returns time step in (ms)
  113367. */
  113368. getTimeStep(): number;
  113369. /**
  113370. * Force the mipmap generation for the given render target texture
  113371. * @param texture defines the render target texture to use
  113372. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  113373. */
  113374. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  113375. /** States */
  113376. /**
  113377. * Set various states to the webGL context
  113378. * @param culling defines backface culling state
  113379. * @param zOffset defines the value to apply to zOffset (0 by default)
  113380. * @param force defines if states must be applied even if cache is up to date
  113381. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113382. */
  113383. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113384. /**
  113385. * Set the z offset to apply to current rendering
  113386. * @param value defines the offset to apply
  113387. */
  113388. setZOffset(value: number): void;
  113389. /**
  113390. * Gets the current value of the zOffset
  113391. * @returns the current zOffset state
  113392. */
  113393. getZOffset(): number;
  113394. /**
  113395. * Enable or disable depth buffering
  113396. * @param enable defines the state to set
  113397. */
  113398. setDepthBuffer(enable: boolean): void;
  113399. /**
  113400. * Gets a boolean indicating if depth writing is enabled
  113401. * @returns the current depth writing state
  113402. */
  113403. getDepthWrite(): boolean;
  113404. /**
  113405. * Enable or disable depth writing
  113406. * @param enable defines the state to set
  113407. */
  113408. setDepthWrite(enable: boolean): void;
  113409. /**
  113410. * Gets a boolean indicating if stencil buffer is enabled
  113411. * @returns the current stencil buffer state
  113412. */
  113413. getStencilBuffer(): boolean;
  113414. /**
  113415. * Enable or disable the stencil buffer
  113416. * @param enable defines if the stencil buffer must be enabled or disabled
  113417. */
  113418. setStencilBuffer(enable: boolean): void;
  113419. /**
  113420. * Gets the current stencil mask
  113421. * @returns a number defining the new stencil mask to use
  113422. */
  113423. getStencilMask(): number;
  113424. /**
  113425. * Sets the current stencil mask
  113426. * @param mask defines the new stencil mask to use
  113427. */
  113428. setStencilMask(mask: number): void;
  113429. /**
  113430. * Gets the current stencil function
  113431. * @returns a number defining the stencil function to use
  113432. */
  113433. getStencilFunction(): number;
  113434. /**
  113435. * Gets the current stencil reference value
  113436. * @returns a number defining the stencil reference value to use
  113437. */
  113438. getStencilFunctionReference(): number;
  113439. /**
  113440. * Gets the current stencil mask
  113441. * @returns a number defining the stencil mask to use
  113442. */
  113443. getStencilFunctionMask(): number;
  113444. /**
  113445. * Sets the current stencil function
  113446. * @param stencilFunc defines the new stencil function to use
  113447. */
  113448. setStencilFunction(stencilFunc: number): void;
  113449. /**
  113450. * Sets the current stencil reference
  113451. * @param reference defines the new stencil reference to use
  113452. */
  113453. setStencilFunctionReference(reference: number): void;
  113454. /**
  113455. * Sets the current stencil mask
  113456. * @param mask defines the new stencil mask to use
  113457. */
  113458. setStencilFunctionMask(mask: number): void;
  113459. /**
  113460. * Gets the current stencil operation when stencil fails
  113461. * @returns a number defining stencil operation to use when stencil fails
  113462. */
  113463. getStencilOperationFail(): number;
  113464. /**
  113465. * Gets the current stencil operation when depth fails
  113466. * @returns a number defining stencil operation to use when depth fails
  113467. */
  113468. getStencilOperationDepthFail(): number;
  113469. /**
  113470. * Gets the current stencil operation when stencil passes
  113471. * @returns a number defining stencil operation to use when stencil passes
  113472. */
  113473. getStencilOperationPass(): number;
  113474. /**
  113475. * Sets the stencil operation to use when stencil fails
  113476. * @param operation defines the stencil operation to use when stencil fails
  113477. */
  113478. setStencilOperationFail(operation: number): void;
  113479. /**
  113480. * Sets the stencil operation to use when depth fails
  113481. * @param operation defines the stencil operation to use when depth fails
  113482. */
  113483. setStencilOperationDepthFail(operation: number): void;
  113484. /**
  113485. * Sets the stencil operation to use when stencil passes
  113486. * @param operation defines the stencil operation to use when stencil passes
  113487. */
  113488. setStencilOperationPass(operation: number): void;
  113489. /**
  113490. * Sets a boolean indicating if the dithering state is enabled or disabled
  113491. * @param value defines the dithering state
  113492. */
  113493. setDitheringState(value: boolean): void;
  113494. /**
  113495. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  113496. * @param value defines the rasterizer state
  113497. */
  113498. setRasterizerState(value: boolean): void;
  113499. /**
  113500. * Gets the current depth function
  113501. * @returns a number defining the depth function
  113502. */
  113503. getDepthFunction(): Nullable<number>;
  113504. /**
  113505. * Sets the current depth function
  113506. * @param depthFunc defines the function to use
  113507. */
  113508. setDepthFunction(depthFunc: number): void;
  113509. /**
  113510. * Sets the current depth function to GREATER
  113511. */
  113512. setDepthFunctionToGreater(): void;
  113513. /**
  113514. * Sets the current depth function to GEQUAL
  113515. */
  113516. setDepthFunctionToGreaterOrEqual(): void;
  113517. /**
  113518. * Sets the current depth function to LESS
  113519. */
  113520. setDepthFunctionToLess(): void;
  113521. /**
  113522. * Sets the current depth function to LEQUAL
  113523. */
  113524. setDepthFunctionToLessOrEqual(): void;
  113525. private _cachedStencilBuffer;
  113526. private _cachedStencilFunction;
  113527. private _cachedStencilMask;
  113528. private _cachedStencilOperationPass;
  113529. private _cachedStencilOperationFail;
  113530. private _cachedStencilOperationDepthFail;
  113531. private _cachedStencilReference;
  113532. /**
  113533. * Caches the the state of the stencil buffer
  113534. */
  113535. cacheStencilState(): void;
  113536. /**
  113537. * Restores the state of the stencil buffer
  113538. */
  113539. restoreStencilState(): void;
  113540. /**
  113541. * Directly set the WebGL Viewport
  113542. * @param x defines the x coordinate of the viewport (in screen space)
  113543. * @param y defines the y coordinate of the viewport (in screen space)
  113544. * @param width defines the width of the viewport (in screen space)
  113545. * @param height defines the height of the viewport (in screen space)
  113546. * @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
  113547. */
  113548. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  113549. /**
  113550. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  113551. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113552. * @param y defines the y-coordinate of the corner of the clear rectangle
  113553. * @param width defines the width of the clear rectangle
  113554. * @param height defines the height of the clear rectangle
  113555. * @param clearColor defines the clear color
  113556. */
  113557. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  113558. /**
  113559. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  113560. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113561. * @param y defines the y-coordinate of the corner of the clear rectangle
  113562. * @param width defines the width of the clear rectangle
  113563. * @param height defines the height of the clear rectangle
  113564. */
  113565. enableScissor(x: number, y: number, width: number, height: number): void;
  113566. /**
  113567. * Disable previously set scissor test rectangle
  113568. */
  113569. disableScissor(): void;
  113570. protected _reportDrawCall(): void;
  113571. /**
  113572. * Initializes a webVR display and starts listening to display change events
  113573. * The onVRDisplayChangedObservable will be notified upon these changes
  113574. * @returns The onVRDisplayChangedObservable
  113575. */
  113576. initWebVR(): Observable<IDisplayChangedEventArgs>;
  113577. /** @hidden */
  113578. _prepareVRComponent(): void;
  113579. /** @hidden */
  113580. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  113581. /** @hidden */
  113582. _submitVRFrame(): void;
  113583. /**
  113584. * Call this function to leave webVR mode
  113585. * Will do nothing if webVR is not supported or if there is no webVR device
  113586. * @see http://doc.babylonjs.com/how_to/webvr_camera
  113587. */
  113588. disableVR(): void;
  113589. /**
  113590. * Gets a boolean indicating that the system is in VR mode and is presenting
  113591. * @returns true if VR mode is engaged
  113592. */
  113593. isVRPresenting(): boolean;
  113594. /** @hidden */
  113595. _requestVRFrame(): void;
  113596. /** @hidden */
  113597. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113598. /**
  113599. * Gets the source code of the vertex shader associated with a specific webGL program
  113600. * @param program defines the program to use
  113601. * @returns a string containing the source code of the vertex shader associated with the program
  113602. */
  113603. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  113604. /**
  113605. * Gets the source code of the fragment shader associated with a specific webGL program
  113606. * @param program defines the program to use
  113607. * @returns a string containing the source code of the fragment shader associated with the program
  113608. */
  113609. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  113610. /**
  113611. * Sets a depth stencil texture from a render target to the according uniform.
  113612. * @param channel The texture channel
  113613. * @param uniform The uniform to set
  113614. * @param texture The render target texture containing the depth stencil texture to apply
  113615. */
  113616. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  113617. /**
  113618. * Sets a texture to the webGL context from a postprocess
  113619. * @param channel defines the channel to use
  113620. * @param postProcess defines the source postprocess
  113621. */
  113622. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  113623. /**
  113624. * Binds the output of the passed in post process to the texture channel specified
  113625. * @param channel The channel the texture should be bound to
  113626. * @param postProcess The post process which's output should be bound
  113627. */
  113628. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  113629. protected _rebuildBuffers(): void;
  113630. /** @hidden */
  113631. _renderFrame(): void;
  113632. _renderLoop(): void;
  113633. /** @hidden */
  113634. _renderViews(): boolean;
  113635. /**
  113636. * Toggle full screen mode
  113637. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113638. */
  113639. switchFullscreen(requestPointerLock: boolean): void;
  113640. /**
  113641. * Enters full screen mode
  113642. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113643. */
  113644. enterFullscreen(requestPointerLock: boolean): void;
  113645. /**
  113646. * Exits full screen mode
  113647. */
  113648. exitFullscreen(): void;
  113649. /**
  113650. * Enters Pointerlock mode
  113651. */
  113652. enterPointerlock(): void;
  113653. /**
  113654. * Exits Pointerlock mode
  113655. */
  113656. exitPointerlock(): void;
  113657. /**
  113658. * Begin a new frame
  113659. */
  113660. beginFrame(): void;
  113661. /**
  113662. * Enf the current frame
  113663. */
  113664. endFrame(): void;
  113665. resize(): void;
  113666. /**
  113667. * Force a specific size of the canvas
  113668. * @param width defines the new canvas' width
  113669. * @param height defines the new canvas' height
  113670. */
  113671. setSize(width: number, height: number): void;
  113672. /**
  113673. * Updates a dynamic vertex buffer.
  113674. * @param vertexBuffer the vertex buffer to update
  113675. * @param data the data used to update the vertex buffer
  113676. * @param byteOffset the byte offset of the data
  113677. * @param byteLength the byte length of the data
  113678. */
  113679. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113680. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113681. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113682. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113683. _releaseTexture(texture: InternalTexture): void;
  113684. /**
  113685. * @hidden
  113686. * Rescales a texture
  113687. * @param source input texutre
  113688. * @param destination destination texture
  113689. * @param scene scene to use to render the resize
  113690. * @param internalFormat format to use when resizing
  113691. * @param onComplete callback to be called when resize has completed
  113692. */
  113693. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113694. /**
  113695. * Gets the current framerate
  113696. * @returns a number representing the framerate
  113697. */
  113698. getFps(): number;
  113699. /**
  113700. * Gets the time spent between current and previous frame
  113701. * @returns a number representing the delta time in ms
  113702. */
  113703. getDeltaTime(): number;
  113704. private _measureFps;
  113705. /** @hidden */
  113706. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  113707. /**
  113708. * Update a dynamic index buffer
  113709. * @param indexBuffer defines the target index buffer
  113710. * @param indices defines the data to update
  113711. * @param offset defines the offset in the target index buffer where update should start
  113712. */
  113713. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113714. /**
  113715. * Updates the sample count of a render target texture
  113716. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113717. * @param texture defines the texture to update
  113718. * @param samples defines the sample count to set
  113719. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113720. */
  113721. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  113722. /**
  113723. * Updates a depth texture Comparison Mode and Function.
  113724. * If the comparison Function is equal to 0, the mode will be set to none.
  113725. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  113726. * @param texture The texture to set the comparison function for
  113727. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  113728. */
  113729. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  113730. /**
  113731. * Creates a webGL buffer to use with instanciation
  113732. * @param capacity defines the size of the buffer
  113733. * @returns the webGL buffer
  113734. */
  113735. createInstancesBuffer(capacity: number): DataBuffer;
  113736. /**
  113737. * Delete a webGL buffer used with instanciation
  113738. * @param buffer defines the webGL buffer to delete
  113739. */
  113740. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  113741. private _clientWaitAsync;
  113742. /** @hidden */
  113743. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  113744. dispose(): void;
  113745. private _disableTouchAction;
  113746. /**
  113747. * Display the loading screen
  113748. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113749. */
  113750. displayLoadingUI(): void;
  113751. /**
  113752. * Hide the loading screen
  113753. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113754. */
  113755. hideLoadingUI(): void;
  113756. /**
  113757. * Gets the current loading screen object
  113758. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113759. */
  113760. get loadingScreen(): ILoadingScreen;
  113761. /**
  113762. * Sets the current loading screen object
  113763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113764. */
  113765. set loadingScreen(loadingScreen: ILoadingScreen);
  113766. /**
  113767. * Sets the current loading screen text
  113768. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113769. */
  113770. set loadingUIText(text: string);
  113771. /**
  113772. * Sets the current loading screen background color
  113773. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113774. */
  113775. set loadingUIBackgroundColor(color: string);
  113776. /** Pointerlock and fullscreen */
  113777. /**
  113778. * Ask the browser to promote the current element to pointerlock mode
  113779. * @param element defines the DOM element to promote
  113780. */
  113781. static _RequestPointerlock(element: HTMLElement): void;
  113782. /**
  113783. * Asks the browser to exit pointerlock mode
  113784. */
  113785. static _ExitPointerlock(): void;
  113786. /**
  113787. * Ask the browser to promote the current element to fullscreen rendering mode
  113788. * @param element defines the DOM element to promote
  113789. */
  113790. static _RequestFullscreen(element: HTMLElement): void;
  113791. /**
  113792. * Asks the browser to exit fullscreen mode
  113793. */
  113794. static _ExitFullscreen(): void;
  113795. }
  113796. }
  113797. declare module BABYLON {
  113798. /**
  113799. * The engine store class is responsible to hold all the instances of Engine and Scene created
  113800. * during the life time of the application.
  113801. */
  113802. export class EngineStore {
  113803. /** Gets the list of created engines */
  113804. static Instances: Engine[];
  113805. /** @hidden */
  113806. static _LastCreatedScene: Nullable<Scene>;
  113807. /**
  113808. * Gets the latest created engine
  113809. */
  113810. static get LastCreatedEngine(): Nullable<Engine>;
  113811. /**
  113812. * Gets the latest created scene
  113813. */
  113814. static get LastCreatedScene(): Nullable<Scene>;
  113815. /**
  113816. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  113817. * @ignorenaming
  113818. */
  113819. static UseFallbackTexture: boolean;
  113820. /**
  113821. * Texture content used if a texture cannot loaded
  113822. * @ignorenaming
  113823. */
  113824. static FallbackTexture: string;
  113825. }
  113826. }
  113827. declare module BABYLON {
  113828. /**
  113829. * Helper class that provides a small promise polyfill
  113830. */
  113831. export class PromisePolyfill {
  113832. /**
  113833. * Static function used to check if the polyfill is required
  113834. * If this is the case then the function will inject the polyfill to window.Promise
  113835. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  113836. */
  113837. static Apply(force?: boolean): void;
  113838. }
  113839. }
  113840. declare module BABYLON {
  113841. /**
  113842. * Interface for screenshot methods with describe argument called `size` as object with options
  113843. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  113844. */
  113845. export interface IScreenshotSize {
  113846. /**
  113847. * number in pixels for canvas height
  113848. */
  113849. height?: number;
  113850. /**
  113851. * multiplier allowing render at a higher or lower resolution
  113852. * If value is defined then height and width will be ignored and taken from camera
  113853. */
  113854. precision?: number;
  113855. /**
  113856. * number in pixels for canvas width
  113857. */
  113858. width?: number;
  113859. }
  113860. }
  113861. declare module BABYLON {
  113862. interface IColor4Like {
  113863. r: float;
  113864. g: float;
  113865. b: float;
  113866. a: float;
  113867. }
  113868. /**
  113869. * Class containing a set of static utilities functions
  113870. */
  113871. export class Tools {
  113872. /**
  113873. * Gets or sets the base URL to use to load assets
  113874. */
  113875. static get BaseUrl(): string;
  113876. static set BaseUrl(value: string);
  113877. /**
  113878. * Enable/Disable Custom HTTP Request Headers globally.
  113879. * default = false
  113880. * @see CustomRequestHeaders
  113881. */
  113882. static UseCustomRequestHeaders: boolean;
  113883. /**
  113884. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  113885. * i.e. when loading files, where the server/service expects an Authorization header
  113886. */
  113887. static CustomRequestHeaders: {
  113888. [key: string]: string;
  113889. };
  113890. /**
  113891. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  113892. */
  113893. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  113894. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  113895. /**
  113896. * Default behaviour for cors in the application.
  113897. * It can be a string if the expected behavior is identical in the entire app.
  113898. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  113899. */
  113900. static get CorsBehavior(): string | ((url: string | string[]) => string);
  113901. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  113902. /**
  113903. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  113904. * @ignorenaming
  113905. */
  113906. static get UseFallbackTexture(): boolean;
  113907. static set UseFallbackTexture(value: boolean);
  113908. /**
  113909. * Use this object to register external classes like custom textures or material
  113910. * to allow the laoders to instantiate them
  113911. */
  113912. static get RegisteredExternalClasses(): {
  113913. [key: string]: Object;
  113914. };
  113915. static set RegisteredExternalClasses(classes: {
  113916. [key: string]: Object;
  113917. });
  113918. /**
  113919. * Texture content used if a texture cannot loaded
  113920. * @ignorenaming
  113921. */
  113922. static get fallbackTexture(): string;
  113923. static set fallbackTexture(value: string);
  113924. /**
  113925. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  113926. * @param u defines the coordinate on X axis
  113927. * @param v defines the coordinate on Y axis
  113928. * @param width defines the width of the source data
  113929. * @param height defines the height of the source data
  113930. * @param pixels defines the source byte array
  113931. * @param color defines the output color
  113932. */
  113933. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  113934. /**
  113935. * Interpolates between a and b via alpha
  113936. * @param a The lower value (returned when alpha = 0)
  113937. * @param b The upper value (returned when alpha = 1)
  113938. * @param alpha The interpolation-factor
  113939. * @return The mixed value
  113940. */
  113941. static Mix(a: number, b: number, alpha: number): number;
  113942. /**
  113943. * Tries to instantiate a new object from a given class name
  113944. * @param className defines the class name to instantiate
  113945. * @returns the new object or null if the system was not able to do the instantiation
  113946. */
  113947. static Instantiate(className: string): any;
  113948. /**
  113949. * Provides a slice function that will work even on IE
  113950. * @param data defines the array to slice
  113951. * @param start defines the start of the data (optional)
  113952. * @param end defines the end of the data (optional)
  113953. * @returns the new sliced array
  113954. */
  113955. static Slice<T>(data: T, start?: number, end?: number): T;
  113956. /**
  113957. * Polyfill for setImmediate
  113958. * @param action defines the action to execute after the current execution block
  113959. */
  113960. static SetImmediate(action: () => void): void;
  113961. /**
  113962. * Function indicating if a number is an exponent of 2
  113963. * @param value defines the value to test
  113964. * @returns true if the value is an exponent of 2
  113965. */
  113966. static IsExponentOfTwo(value: number): boolean;
  113967. private static _tmpFloatArray;
  113968. /**
  113969. * Returns the nearest 32-bit single precision float representation of a Number
  113970. * @param value A Number. If the parameter is of a different type, it will get converted
  113971. * to a number or to NaN if it cannot be converted
  113972. * @returns number
  113973. */
  113974. static FloatRound(value: number): number;
  113975. /**
  113976. * Extracts the filename from a path
  113977. * @param path defines the path to use
  113978. * @returns the filename
  113979. */
  113980. static GetFilename(path: string): string;
  113981. /**
  113982. * Extracts the "folder" part of a path (everything before the filename).
  113983. * @param uri The URI to extract the info from
  113984. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  113985. * @returns The "folder" part of the path
  113986. */
  113987. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  113988. /**
  113989. * Extracts text content from a DOM element hierarchy
  113990. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  113991. */
  113992. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  113993. /**
  113994. * Convert an angle in radians to degrees
  113995. * @param angle defines the angle to convert
  113996. * @returns the angle in degrees
  113997. */
  113998. static ToDegrees(angle: number): number;
  113999. /**
  114000. * Convert an angle in degrees to radians
  114001. * @param angle defines the angle to convert
  114002. * @returns the angle in radians
  114003. */
  114004. static ToRadians(angle: number): number;
  114005. /**
  114006. * Returns an array if obj is not an array
  114007. * @param obj defines the object to evaluate as an array
  114008. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114009. * @returns either obj directly if obj is an array or a new array containing obj
  114010. */
  114011. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114012. /**
  114013. * Gets the pointer prefix to use
  114014. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114015. */
  114016. static GetPointerPrefix(): string;
  114017. /**
  114018. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114019. * @param url define the url we are trying
  114020. * @param element define the dom element where to configure the cors policy
  114021. */
  114022. static SetCorsBehavior(url: string | string[], element: {
  114023. crossOrigin: string | null;
  114024. }): void;
  114025. /**
  114026. * Removes unwanted characters from an url
  114027. * @param url defines the url to clean
  114028. * @returns the cleaned url
  114029. */
  114030. static CleanUrl(url: string): string;
  114031. /**
  114032. * Gets or sets a function used to pre-process url before using them to load assets
  114033. */
  114034. static get PreprocessUrl(): (url: string) => string;
  114035. static set PreprocessUrl(processor: (url: string) => string);
  114036. /**
  114037. * Loads an image as an HTMLImageElement.
  114038. * @param input url string, ArrayBuffer, or Blob to load
  114039. * @param onLoad callback called when the image successfully loads
  114040. * @param onError callback called when the image fails to load
  114041. * @param offlineProvider offline provider for caching
  114042. * @param mimeType optional mime type
  114043. * @returns the HTMLImageElement of the loaded image
  114044. */
  114045. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114046. /**
  114047. * Loads a file from a url
  114048. * @param url url string, ArrayBuffer, or Blob to load
  114049. * @param onSuccess callback called when the file successfully loads
  114050. * @param onProgress callback called while file is loading (if the server supports this mode)
  114051. * @param offlineProvider defines the offline provider for caching
  114052. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114053. * @param onError callback called when the file fails to load
  114054. * @returns a file request object
  114055. */
  114056. 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;
  114057. /**
  114058. * Loads a file from a url
  114059. * @param url the file url to load
  114060. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114061. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114062. */
  114063. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114064. /**
  114065. * Load a script (identified by an url). When the url returns, the
  114066. * content of this file is added into a new script element, attached to the DOM (body element)
  114067. * @param scriptUrl defines the url of the script to laod
  114068. * @param onSuccess defines the callback called when the script is loaded
  114069. * @param onError defines the callback to call if an error occurs
  114070. * @param scriptId defines the id of the script element
  114071. */
  114072. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114073. /**
  114074. * Load an asynchronous script (identified by an url). When the url returns, the
  114075. * content of this file is added into a new script element, attached to the DOM (body element)
  114076. * @param scriptUrl defines the url of the script to laod
  114077. * @param scriptId defines the id of the script element
  114078. * @returns a promise request object
  114079. */
  114080. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114081. /**
  114082. * Loads a file from a blob
  114083. * @param fileToLoad defines the blob to use
  114084. * @param callback defines the callback to call when data is loaded
  114085. * @param progressCallback defines the callback to call during loading process
  114086. * @returns a file request object
  114087. */
  114088. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114089. /**
  114090. * Reads a file from a File object
  114091. * @param file defines the file to load
  114092. * @param onSuccess defines the callback to call when data is loaded
  114093. * @param onProgress defines the callback to call during loading process
  114094. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114095. * @param onError defines the callback to call when an error occurs
  114096. * @returns a file request object
  114097. */
  114098. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114099. /**
  114100. * Creates a data url from a given string content
  114101. * @param content defines the content to convert
  114102. * @returns the new data url link
  114103. */
  114104. static FileAsURL(content: string): string;
  114105. /**
  114106. * Format the given number to a specific decimal format
  114107. * @param value defines the number to format
  114108. * @param decimals defines the number of decimals to use
  114109. * @returns the formatted string
  114110. */
  114111. static Format(value: number, decimals?: number): string;
  114112. /**
  114113. * Tries to copy an object by duplicating every property
  114114. * @param source defines the source object
  114115. * @param destination defines the target object
  114116. * @param doNotCopyList defines a list of properties to avoid
  114117. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114118. */
  114119. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114120. /**
  114121. * Gets a boolean indicating if the given object has no own property
  114122. * @param obj defines the object to test
  114123. * @returns true if object has no own property
  114124. */
  114125. static IsEmpty(obj: any): boolean;
  114126. /**
  114127. * Function used to register events at window level
  114128. * @param windowElement defines the Window object to use
  114129. * @param events defines the events to register
  114130. */
  114131. static RegisterTopRootEvents(windowElement: Window, events: {
  114132. name: string;
  114133. handler: Nullable<(e: FocusEvent) => any>;
  114134. }[]): void;
  114135. /**
  114136. * Function used to unregister events from window level
  114137. * @param windowElement defines the Window object to use
  114138. * @param events defines the events to unregister
  114139. */
  114140. static UnregisterTopRootEvents(windowElement: Window, events: {
  114141. name: string;
  114142. handler: Nullable<(e: FocusEvent) => any>;
  114143. }[]): void;
  114144. /**
  114145. * @ignore
  114146. */
  114147. static _ScreenshotCanvas: HTMLCanvasElement;
  114148. /**
  114149. * Dumps the current bound framebuffer
  114150. * @param width defines the rendering width
  114151. * @param height defines the rendering height
  114152. * @param engine defines the hosting engine
  114153. * @param successCallback defines the callback triggered once the data are available
  114154. * @param mimeType defines the mime type of the result
  114155. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114156. */
  114157. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114158. /**
  114159. * Converts the canvas data to blob.
  114160. * This acts as a polyfill for browsers not supporting the to blob function.
  114161. * @param canvas Defines the canvas to extract the data from
  114162. * @param successCallback Defines the callback triggered once the data are available
  114163. * @param mimeType Defines the mime type of the result
  114164. */
  114165. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114166. /**
  114167. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114168. * @param successCallback defines the callback triggered once the data are available
  114169. * @param mimeType defines the mime type of the result
  114170. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114171. */
  114172. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114173. /**
  114174. * Downloads a blob in the browser
  114175. * @param blob defines the blob to download
  114176. * @param fileName defines the name of the downloaded file
  114177. */
  114178. static Download(blob: Blob, fileName: string): void;
  114179. /**
  114180. * Captures a screenshot of the current rendering
  114181. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114182. * @param engine defines the rendering engine
  114183. * @param camera defines the source camera
  114184. * @param size This parameter can be set to a single number or to an object with the
  114185. * following (optional) properties: precision, width, height. If a single number is passed,
  114186. * it will be used for both width and height. If an object is passed, the screenshot size
  114187. * will be derived from the parameters. The precision property is a multiplier allowing
  114188. * rendering at a higher or lower resolution
  114189. * @param successCallback defines the callback receives a single parameter which contains the
  114190. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114191. * src parameter of an <img> to display it
  114192. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114193. * Check your browser for supported MIME types
  114194. */
  114195. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114196. /**
  114197. * Captures a screenshot of the current rendering
  114198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114199. * @param engine defines the rendering engine
  114200. * @param camera defines the source camera
  114201. * @param size This parameter can be set to a single number or to an object with the
  114202. * following (optional) properties: precision, width, height. If a single number is passed,
  114203. * it will be used for both width and height. If an object is passed, the screenshot size
  114204. * will be derived from the parameters. The precision property is a multiplier allowing
  114205. * rendering at a higher or lower resolution
  114206. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114207. * Check your browser for supported MIME types
  114208. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114209. * to the src parameter of an <img> to display it
  114210. */
  114211. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114212. /**
  114213. * Generates an image screenshot from the specified camera.
  114214. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114215. * @param engine The engine to use for rendering
  114216. * @param camera The camera to use for rendering
  114217. * @param size This parameter can be set to a single number or to an object with the
  114218. * following (optional) properties: precision, width, height. If a single number is passed,
  114219. * it will be used for both width and height. If an object is passed, the screenshot size
  114220. * will be derived from the parameters. The precision property is a multiplier allowing
  114221. * rendering at a higher or lower resolution
  114222. * @param successCallback The callback receives a single parameter which contains the
  114223. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114224. * src parameter of an <img> to display it
  114225. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114226. * Check your browser for supported MIME types
  114227. * @param samples Texture samples (default: 1)
  114228. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114229. * @param fileName A name for for the downloaded file.
  114230. */
  114231. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114232. /**
  114233. * Generates an image screenshot from the specified camera.
  114234. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114235. * @param engine The engine to use for rendering
  114236. * @param camera The camera to use for rendering
  114237. * @param size This parameter can be set to a single number or to an object with the
  114238. * following (optional) properties: precision, width, height. If a single number is passed,
  114239. * it will be used for both width and height. If an object is passed, the screenshot size
  114240. * will be derived from the parameters. The precision property is a multiplier allowing
  114241. * rendering at a higher or lower resolution
  114242. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114243. * Check your browser for supported MIME types
  114244. * @param samples Texture samples (default: 1)
  114245. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114246. * @param fileName A name for for the downloaded file.
  114247. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114248. * to the src parameter of an <img> to display it
  114249. */
  114250. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  114251. /**
  114252. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  114253. * Be aware Math.random() could cause collisions, but:
  114254. * "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"
  114255. * @returns a pseudo random id
  114256. */
  114257. static RandomId(): string;
  114258. /**
  114259. * Test if the given uri is a base64 string
  114260. * @param uri The uri to test
  114261. * @return True if the uri is a base64 string or false otherwise
  114262. */
  114263. static IsBase64(uri: string): boolean;
  114264. /**
  114265. * Decode the given base64 uri.
  114266. * @param uri The uri to decode
  114267. * @return The decoded base64 data.
  114268. */
  114269. static DecodeBase64(uri: string): ArrayBuffer;
  114270. /**
  114271. * Gets the absolute url.
  114272. * @param url the input url
  114273. * @return the absolute url
  114274. */
  114275. static GetAbsoluteUrl(url: string): string;
  114276. /**
  114277. * No log
  114278. */
  114279. static readonly NoneLogLevel: number;
  114280. /**
  114281. * Only message logs
  114282. */
  114283. static readonly MessageLogLevel: number;
  114284. /**
  114285. * Only warning logs
  114286. */
  114287. static readonly WarningLogLevel: number;
  114288. /**
  114289. * Only error logs
  114290. */
  114291. static readonly ErrorLogLevel: number;
  114292. /**
  114293. * All logs
  114294. */
  114295. static readonly AllLogLevel: number;
  114296. /**
  114297. * Gets a value indicating the number of loading errors
  114298. * @ignorenaming
  114299. */
  114300. static get errorsCount(): number;
  114301. /**
  114302. * Callback called when a new log is added
  114303. */
  114304. static OnNewCacheEntry: (entry: string) => void;
  114305. /**
  114306. * Log a message to the console
  114307. * @param message defines the message to log
  114308. */
  114309. static Log(message: string): void;
  114310. /**
  114311. * Write a warning message to the console
  114312. * @param message defines the message to log
  114313. */
  114314. static Warn(message: string): void;
  114315. /**
  114316. * Write an error message to the console
  114317. * @param message defines the message to log
  114318. */
  114319. static Error(message: string): void;
  114320. /**
  114321. * Gets current log cache (list of logs)
  114322. */
  114323. static get LogCache(): string;
  114324. /**
  114325. * Clears the log cache
  114326. */
  114327. static ClearLogCache(): void;
  114328. /**
  114329. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  114330. */
  114331. static set LogLevels(level: number);
  114332. /**
  114333. * Checks if the window object exists
  114334. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  114335. */
  114336. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  114337. /**
  114338. * No performance log
  114339. */
  114340. static readonly PerformanceNoneLogLevel: number;
  114341. /**
  114342. * Use user marks to log performance
  114343. */
  114344. static readonly PerformanceUserMarkLogLevel: number;
  114345. /**
  114346. * Log performance to the console
  114347. */
  114348. static readonly PerformanceConsoleLogLevel: number;
  114349. private static _performance;
  114350. /**
  114351. * Sets the current performance log level
  114352. */
  114353. static set PerformanceLogLevel(level: number);
  114354. private static _StartPerformanceCounterDisabled;
  114355. private static _EndPerformanceCounterDisabled;
  114356. private static _StartUserMark;
  114357. private static _EndUserMark;
  114358. private static _StartPerformanceConsole;
  114359. private static _EndPerformanceConsole;
  114360. /**
  114361. * Starts a performance counter
  114362. */
  114363. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114364. /**
  114365. * Ends a specific performance coutner
  114366. */
  114367. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114368. /**
  114369. * Gets either window.performance.now() if supported or Date.now() else
  114370. */
  114371. static get Now(): number;
  114372. /**
  114373. * This method will return the name of the class used to create the instance of the given object.
  114374. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  114375. * @param object the object to get the class name from
  114376. * @param isType defines if the object is actually a type
  114377. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  114378. */
  114379. static GetClassName(object: any, isType?: boolean): string;
  114380. /**
  114381. * Gets the first element of an array satisfying a given predicate
  114382. * @param array defines the array to browse
  114383. * @param predicate defines the predicate to use
  114384. * @returns null if not found or the element
  114385. */
  114386. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  114387. /**
  114388. * This method will return the name of the full name of the class, including its owning module (if any).
  114389. * 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).
  114390. * @param object the object to get the class name from
  114391. * @param isType defines if the object is actually a type
  114392. * @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.
  114393. * @ignorenaming
  114394. */
  114395. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  114396. /**
  114397. * Returns a promise that resolves after the given amount of time.
  114398. * @param delay Number of milliseconds to delay
  114399. * @returns Promise that resolves after the given amount of time
  114400. */
  114401. static DelayAsync(delay: number): Promise<void>;
  114402. /**
  114403. * Utility function to detect if the current user agent is Safari
  114404. * @returns whether or not the current user agent is safari
  114405. */
  114406. static IsSafari(): boolean;
  114407. }
  114408. /**
  114409. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  114410. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  114411. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  114412. * @param name The name of the class, case should be preserved
  114413. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  114414. */
  114415. export function className(name: string, module?: string): (target: Object) => void;
  114416. /**
  114417. * An implementation of a loop for asynchronous functions.
  114418. */
  114419. export class AsyncLoop {
  114420. /**
  114421. * Defines the number of iterations for the loop
  114422. */
  114423. iterations: number;
  114424. /**
  114425. * Defines the current index of the loop.
  114426. */
  114427. index: number;
  114428. private _done;
  114429. private _fn;
  114430. private _successCallback;
  114431. /**
  114432. * Constructor.
  114433. * @param iterations the number of iterations.
  114434. * @param func the function to run each iteration
  114435. * @param successCallback the callback that will be called upon succesful execution
  114436. * @param offset starting offset.
  114437. */
  114438. constructor(
  114439. /**
  114440. * Defines the number of iterations for the loop
  114441. */
  114442. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  114443. /**
  114444. * Execute the next iteration. Must be called after the last iteration was finished.
  114445. */
  114446. executeNext(): void;
  114447. /**
  114448. * Break the loop and run the success callback.
  114449. */
  114450. breakLoop(): void;
  114451. /**
  114452. * Create and run an async loop.
  114453. * @param iterations the number of iterations.
  114454. * @param fn the function to run each iteration
  114455. * @param successCallback the callback that will be called upon succesful execution
  114456. * @param offset starting offset.
  114457. * @returns the created async loop object
  114458. */
  114459. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  114460. /**
  114461. * A for-loop that will run a given number of iterations synchronous and the rest async.
  114462. * @param iterations total number of iterations
  114463. * @param syncedIterations number of synchronous iterations in each async iteration.
  114464. * @param fn the function to call each iteration.
  114465. * @param callback a success call back that will be called when iterating stops.
  114466. * @param breakFunction a break condition (optional)
  114467. * @param timeout timeout settings for the setTimeout function. default - 0.
  114468. * @returns the created async loop object
  114469. */
  114470. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  114471. }
  114472. }
  114473. declare module BABYLON {
  114474. /**
  114475. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114476. * The underlying implementation relies on an associative array to ensure the best performances.
  114477. * The value can be anything including 'null' but except 'undefined'
  114478. */
  114479. export class StringDictionary<T> {
  114480. /**
  114481. * This will clear this dictionary and copy the content from the 'source' one.
  114482. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114483. * @param source the dictionary to take the content from and copy to this dictionary
  114484. */
  114485. copyFrom(source: StringDictionary<T>): void;
  114486. /**
  114487. * Get a value based from its key
  114488. * @param key the given key to get the matching value from
  114489. * @return the value if found, otherwise undefined is returned
  114490. */
  114491. get(key: string): T | undefined;
  114492. /**
  114493. * Get a value from its key or add it if it doesn't exist.
  114494. * This method will ensure you that a given key/data will be present in the dictionary.
  114495. * @param key the given key to get the matching value from
  114496. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114497. * The factory will only be invoked if there's no data for the given key.
  114498. * @return the value corresponding to the key.
  114499. */
  114500. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  114501. /**
  114502. * Get a value from its key if present in the dictionary otherwise add it
  114503. * @param key the key to get the value from
  114504. * @param val if there's no such key/value pair in the dictionary add it with this value
  114505. * @return the value corresponding to the key
  114506. */
  114507. getOrAdd(key: string, val: T): T;
  114508. /**
  114509. * Check if there's a given key in the dictionary
  114510. * @param key the key to check for
  114511. * @return true if the key is present, false otherwise
  114512. */
  114513. contains(key: string): boolean;
  114514. /**
  114515. * Add a new key and its corresponding value
  114516. * @param key the key to add
  114517. * @param value the value corresponding to the key
  114518. * @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
  114519. */
  114520. add(key: string, value: T): boolean;
  114521. /**
  114522. * Update a specific value associated to a key
  114523. * @param key defines the key to use
  114524. * @param value defines the value to store
  114525. * @returns true if the value was updated (or false if the key was not found)
  114526. */
  114527. set(key: string, value: T): boolean;
  114528. /**
  114529. * Get the element of the given key and remove it from the dictionary
  114530. * @param key defines the key to search
  114531. * @returns the value associated with the key or null if not found
  114532. */
  114533. getAndRemove(key: string): Nullable<T>;
  114534. /**
  114535. * Remove a key/value from the dictionary.
  114536. * @param key the key to remove
  114537. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114538. */
  114539. remove(key: string): boolean;
  114540. /**
  114541. * Clear the whole content of the dictionary
  114542. */
  114543. clear(): void;
  114544. /**
  114545. * Gets the current count
  114546. */
  114547. get count(): number;
  114548. /**
  114549. * Execute a callback on each key/val of the dictionary.
  114550. * Note that you can remove any element in this dictionary in the callback implementation
  114551. * @param callback the callback to execute on a given key/value pair
  114552. */
  114553. forEach(callback: (key: string, val: T) => void): void;
  114554. /**
  114555. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  114556. * If the callback returns null or undefined the method will iterate to the next key/value pair
  114557. * Note that you can remove any element in this dictionary in the callback implementation
  114558. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  114559. * @returns the first item
  114560. */
  114561. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  114562. private _count;
  114563. private _data;
  114564. }
  114565. }
  114566. declare module BABYLON {
  114567. /** @hidden */
  114568. export interface ICollisionCoordinator {
  114569. createCollider(): Collider;
  114570. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114571. init(scene: Scene): void;
  114572. }
  114573. /** @hidden */
  114574. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  114575. private _scene;
  114576. private _scaledPosition;
  114577. private _scaledVelocity;
  114578. private _finalPosition;
  114579. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114580. createCollider(): Collider;
  114581. init(scene: Scene): void;
  114582. private _collideWithWorld;
  114583. }
  114584. }
  114585. declare module BABYLON {
  114586. /**
  114587. * Class used to manage all inputs for the scene.
  114588. */
  114589. export class InputManager {
  114590. /** The distance in pixel that you have to move to prevent some events */
  114591. static DragMovementThreshold: number;
  114592. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  114593. static LongPressDelay: number;
  114594. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  114595. static DoubleClickDelay: number;
  114596. /** If you need to check double click without raising a single click at first click, enable this flag */
  114597. static ExclusiveDoubleClickMode: boolean;
  114598. private _wheelEventName;
  114599. private _onPointerMove;
  114600. private _onPointerDown;
  114601. private _onPointerUp;
  114602. private _initClickEvent;
  114603. private _initActionManager;
  114604. private _delayedSimpleClick;
  114605. private _delayedSimpleClickTimeout;
  114606. private _previousDelayedSimpleClickTimeout;
  114607. private _meshPickProceed;
  114608. private _previousButtonPressed;
  114609. private _currentPickResult;
  114610. private _previousPickResult;
  114611. private _totalPointersPressed;
  114612. private _doubleClickOccured;
  114613. private _pointerOverMesh;
  114614. private _pickedDownMesh;
  114615. private _pickedUpMesh;
  114616. private _pointerX;
  114617. private _pointerY;
  114618. private _unTranslatedPointerX;
  114619. private _unTranslatedPointerY;
  114620. private _startingPointerPosition;
  114621. private _previousStartingPointerPosition;
  114622. private _startingPointerTime;
  114623. private _previousStartingPointerTime;
  114624. private _pointerCaptures;
  114625. private _onKeyDown;
  114626. private _onKeyUp;
  114627. private _onCanvasFocusObserver;
  114628. private _onCanvasBlurObserver;
  114629. private _scene;
  114630. /**
  114631. * Creates a new InputManager
  114632. * @param scene defines the hosting scene
  114633. */
  114634. constructor(scene: Scene);
  114635. /**
  114636. * Gets the mesh that is currently under the pointer
  114637. */
  114638. get meshUnderPointer(): Nullable<AbstractMesh>;
  114639. /**
  114640. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  114641. */
  114642. get unTranslatedPointer(): Vector2;
  114643. /**
  114644. * Gets or sets the current on-screen X position of the pointer
  114645. */
  114646. get pointerX(): number;
  114647. set pointerX(value: number);
  114648. /**
  114649. * Gets or sets the current on-screen Y position of the pointer
  114650. */
  114651. get pointerY(): number;
  114652. set pointerY(value: number);
  114653. private _updatePointerPosition;
  114654. private _processPointerMove;
  114655. private _setRayOnPointerInfo;
  114656. private _checkPrePointerObservable;
  114657. /**
  114658. * Use this method to simulate a pointer move on a mesh
  114659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114662. */
  114663. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114664. /**
  114665. * Use this method to simulate a pointer down on a mesh
  114666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114669. */
  114670. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114671. private _processPointerDown;
  114672. /** @hidden */
  114673. _isPointerSwiping(): boolean;
  114674. /**
  114675. * Use this method to simulate a pointer up on a mesh
  114676. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114677. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114678. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114679. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  114680. */
  114681. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  114682. private _processPointerUp;
  114683. /**
  114684. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  114685. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  114686. * @returns true if the pointer was captured
  114687. */
  114688. isPointerCaptured(pointerId?: number): boolean;
  114689. /**
  114690. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  114691. * @param attachUp defines if you want to attach events to pointerup
  114692. * @param attachDown defines if you want to attach events to pointerdown
  114693. * @param attachMove defines if you want to attach events to pointermove
  114694. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  114695. */
  114696. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  114697. /**
  114698. * Detaches all event handlers
  114699. */
  114700. detachControl(): void;
  114701. /**
  114702. * Force the value of meshUnderPointer
  114703. * @param mesh defines the mesh to use
  114704. */
  114705. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  114706. /**
  114707. * Gets the mesh under the pointer
  114708. * @returns a Mesh or null if no mesh is under the pointer
  114709. */
  114710. getPointerOverMesh(): Nullable<AbstractMesh>;
  114711. }
  114712. }
  114713. declare module BABYLON {
  114714. /**
  114715. * This class defines the direct association between an animation and a target
  114716. */
  114717. export class TargetedAnimation {
  114718. /**
  114719. * Animation to perform
  114720. */
  114721. animation: Animation;
  114722. /**
  114723. * Target to animate
  114724. */
  114725. target: any;
  114726. /**
  114727. * Serialize the object
  114728. * @returns the JSON object representing the current entity
  114729. */
  114730. serialize(): any;
  114731. }
  114732. /**
  114733. * Use this class to create coordinated animations on multiple targets
  114734. */
  114735. export class AnimationGroup implements IDisposable {
  114736. /** The name of the animation group */
  114737. name: string;
  114738. private _scene;
  114739. private _targetedAnimations;
  114740. private _animatables;
  114741. private _from;
  114742. private _to;
  114743. private _isStarted;
  114744. private _isPaused;
  114745. private _speedRatio;
  114746. private _loopAnimation;
  114747. private _isAdditive;
  114748. /**
  114749. * Gets or sets the unique id of the node
  114750. */
  114751. uniqueId: number;
  114752. /**
  114753. * This observable will notify when one animation have ended
  114754. */
  114755. onAnimationEndObservable: Observable<TargetedAnimation>;
  114756. /**
  114757. * Observer raised when one animation loops
  114758. */
  114759. onAnimationLoopObservable: Observable<TargetedAnimation>;
  114760. /**
  114761. * Observer raised when all animations have looped
  114762. */
  114763. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  114764. /**
  114765. * This observable will notify when all animations have ended.
  114766. */
  114767. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  114768. /**
  114769. * This observable will notify when all animations have paused.
  114770. */
  114771. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  114772. /**
  114773. * This observable will notify when all animations are playing.
  114774. */
  114775. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  114776. /**
  114777. * Gets the first frame
  114778. */
  114779. get from(): number;
  114780. /**
  114781. * Gets the last frame
  114782. */
  114783. get to(): number;
  114784. /**
  114785. * Define if the animations are started
  114786. */
  114787. get isStarted(): boolean;
  114788. /**
  114789. * Gets a value indicating that the current group is playing
  114790. */
  114791. get isPlaying(): boolean;
  114792. /**
  114793. * Gets or sets the speed ratio to use for all animations
  114794. */
  114795. get speedRatio(): number;
  114796. /**
  114797. * Gets or sets the speed ratio to use for all animations
  114798. */
  114799. set speedRatio(value: number);
  114800. /**
  114801. * Gets or sets if all animations should loop or not
  114802. */
  114803. get loopAnimation(): boolean;
  114804. set loopAnimation(value: boolean);
  114805. /**
  114806. * Gets or sets if all animations should be evaluated additively
  114807. */
  114808. get isAdditive(): boolean;
  114809. set isAdditive(value: boolean);
  114810. /**
  114811. * Gets the targeted animations for this animation group
  114812. */
  114813. get targetedAnimations(): Array<TargetedAnimation>;
  114814. /**
  114815. * returning the list of animatables controlled by this animation group.
  114816. */
  114817. get animatables(): Array<Animatable>;
  114818. /**
  114819. * Instantiates a new Animation Group.
  114820. * This helps managing several animations at once.
  114821. * @see http://doc.babylonjs.com/how_to/group
  114822. * @param name Defines the name of the group
  114823. * @param scene Defines the scene the group belongs to
  114824. */
  114825. constructor(
  114826. /** The name of the animation group */
  114827. name: string, scene?: Nullable<Scene>);
  114828. /**
  114829. * Add an animation (with its target) in the group
  114830. * @param animation defines the animation we want to add
  114831. * @param target defines the target of the animation
  114832. * @returns the TargetedAnimation object
  114833. */
  114834. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  114835. /**
  114836. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  114837. * It can add constant keys at begin or end
  114838. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  114839. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  114840. * @returns the animation group
  114841. */
  114842. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  114843. private _animationLoopCount;
  114844. private _animationLoopFlags;
  114845. private _processLoop;
  114846. /**
  114847. * Start all animations on given targets
  114848. * @param loop defines if animations must loop
  114849. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  114850. * @param from defines the from key (optional)
  114851. * @param to defines the to key (optional)
  114852. * @param isAdditive defines the additive state for the resulting animatables (optional)
  114853. * @returns the current animation group
  114854. */
  114855. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  114856. /**
  114857. * Pause all animations
  114858. * @returns the animation group
  114859. */
  114860. pause(): AnimationGroup;
  114861. /**
  114862. * Play all animations to initial state
  114863. * This function will start() the animations if they were not started or will restart() them if they were paused
  114864. * @param loop defines if animations must loop
  114865. * @returns the animation group
  114866. */
  114867. play(loop?: boolean): AnimationGroup;
  114868. /**
  114869. * Reset all animations to initial state
  114870. * @returns the animation group
  114871. */
  114872. reset(): AnimationGroup;
  114873. /**
  114874. * Restart animations from key 0
  114875. * @returns the animation group
  114876. */
  114877. restart(): AnimationGroup;
  114878. /**
  114879. * Stop all animations
  114880. * @returns the animation group
  114881. */
  114882. stop(): AnimationGroup;
  114883. /**
  114884. * Set animation weight for all animatables
  114885. * @param weight defines the weight to use
  114886. * @return the animationGroup
  114887. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  114888. */
  114889. setWeightForAllAnimatables(weight: number): AnimationGroup;
  114890. /**
  114891. * Synchronize and normalize all animatables with a source animatable
  114892. * @param root defines the root animatable to synchronize with
  114893. * @return the animationGroup
  114894. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  114895. */
  114896. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  114897. /**
  114898. * Goes to a specific frame in this animation group
  114899. * @param frame the frame number to go to
  114900. * @return the animationGroup
  114901. */
  114902. goToFrame(frame: number): AnimationGroup;
  114903. /**
  114904. * Dispose all associated resources
  114905. */
  114906. dispose(): void;
  114907. private _checkAnimationGroupEnded;
  114908. /**
  114909. * Clone the current animation group and returns a copy
  114910. * @param newName defines the name of the new group
  114911. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  114912. * @returns the new aniamtion group
  114913. */
  114914. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  114915. /**
  114916. * Serializes the animationGroup to an object
  114917. * @returns Serialized object
  114918. */
  114919. serialize(): any;
  114920. /**
  114921. * Returns a new AnimationGroup object parsed from the source provided.
  114922. * @param parsedAnimationGroup defines the source
  114923. * @param scene defines the scene that will receive the animationGroup
  114924. * @returns a new AnimationGroup
  114925. */
  114926. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  114927. /**
  114928. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  114929. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  114930. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  114931. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  114932. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  114933. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  114934. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  114935. */
  114936. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  114937. /**
  114938. * Returns the string "AnimationGroup"
  114939. * @returns "AnimationGroup"
  114940. */
  114941. getClassName(): string;
  114942. /**
  114943. * Creates a detailled string about the object
  114944. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  114945. * @returns a string representing the object
  114946. */
  114947. toString(fullDetails?: boolean): string;
  114948. }
  114949. }
  114950. declare module BABYLON {
  114951. /**
  114952. * Define an interface for all classes that will hold resources
  114953. */
  114954. export interface IDisposable {
  114955. /**
  114956. * Releases all held resources
  114957. */
  114958. dispose(): void;
  114959. }
  114960. /** Interface defining initialization parameters for Scene class */
  114961. export interface SceneOptions {
  114962. /**
  114963. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  114964. * It will improve performance when the number of geometries becomes important.
  114965. */
  114966. useGeometryUniqueIdsMap?: boolean;
  114967. /**
  114968. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  114969. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  114970. */
  114971. useMaterialMeshMap?: boolean;
  114972. /**
  114973. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  114974. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  114975. */
  114976. useClonedMeshMap?: boolean;
  114977. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  114978. virtual?: boolean;
  114979. }
  114980. /**
  114981. * Represents a scene to be rendered by the engine.
  114982. * @see http://doc.babylonjs.com/features/scene
  114983. */
  114984. export class Scene extends AbstractScene implements IAnimatable {
  114985. /** The fog is deactivated */
  114986. static readonly FOGMODE_NONE: number;
  114987. /** The fog density is following an exponential function */
  114988. static readonly FOGMODE_EXP: number;
  114989. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  114990. static readonly FOGMODE_EXP2: number;
  114991. /** The fog density is following a linear function. */
  114992. static readonly FOGMODE_LINEAR: number;
  114993. /**
  114994. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  114995. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114996. */
  114997. static MinDeltaTime: number;
  114998. /**
  114999. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115001. */
  115002. static MaxDeltaTime: number;
  115003. /**
  115004. * Factory used to create the default material.
  115005. * @param name The name of the material to create
  115006. * @param scene The scene to create the material for
  115007. * @returns The default material
  115008. */
  115009. static DefaultMaterialFactory(scene: Scene): Material;
  115010. /**
  115011. * Factory used to create the a collision coordinator.
  115012. * @returns The collision coordinator
  115013. */
  115014. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115015. /** @hidden */
  115016. _inputManager: InputManager;
  115017. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115018. cameraToUseForPointers: Nullable<Camera>;
  115019. /** @hidden */
  115020. readonly _isScene: boolean;
  115021. /** @hidden */
  115022. _blockEntityCollection: boolean;
  115023. /**
  115024. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115025. */
  115026. autoClear: boolean;
  115027. /**
  115028. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115029. */
  115030. autoClearDepthAndStencil: boolean;
  115031. /**
  115032. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115033. */
  115034. clearColor: Color4;
  115035. /**
  115036. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115037. */
  115038. ambientColor: Color3;
  115039. /**
  115040. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115041. * It should only be one of the following (if not the default embedded one):
  115042. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115043. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115044. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115045. * The material properties need to be setup according to the type of texture in use.
  115046. */
  115047. environmentBRDFTexture: BaseTexture;
  115048. /** @hidden */
  115049. protected _environmentTexture: Nullable<BaseTexture>;
  115050. /**
  115051. * Texture used in all pbr material as the reflection texture.
  115052. * As in the majority of the scene they are the same (exception for multi room and so on),
  115053. * this is easier to reference from here than from all the materials.
  115054. */
  115055. get environmentTexture(): Nullable<BaseTexture>;
  115056. /**
  115057. * Texture used in all pbr material as the reflection texture.
  115058. * As in the majority of the scene they are the same (exception for multi room and so on),
  115059. * this is easier to set here than in all the materials.
  115060. */
  115061. set environmentTexture(value: Nullable<BaseTexture>);
  115062. /** @hidden */
  115063. protected _environmentIntensity: number;
  115064. /**
  115065. * Intensity of the environment in all pbr material.
  115066. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115067. * As in the majority of the scene they are the same (exception for multi room and so on),
  115068. * this is easier to reference from here than from all the materials.
  115069. */
  115070. get environmentIntensity(): number;
  115071. /**
  115072. * Intensity of the environment in all pbr material.
  115073. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115074. * As in the majority of the scene they are the same (exception for multi room and so on),
  115075. * this is easier to set here than in all the materials.
  115076. */
  115077. set environmentIntensity(value: number);
  115078. /** @hidden */
  115079. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115080. /**
  115081. * Default image processing configuration used either in the rendering
  115082. * Forward main pass or through the imageProcessingPostProcess if present.
  115083. * As in the majority of the scene they are the same (exception for multi camera),
  115084. * this is easier to reference from here than from all the materials and post process.
  115085. *
  115086. * No setter as we it is a shared configuration, you can set the values instead.
  115087. */
  115088. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115089. private _forceWireframe;
  115090. /**
  115091. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115092. */
  115093. set forceWireframe(value: boolean);
  115094. get forceWireframe(): boolean;
  115095. private _skipFrustumClipping;
  115096. /**
  115097. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115098. */
  115099. set skipFrustumClipping(value: boolean);
  115100. get skipFrustumClipping(): boolean;
  115101. private _forcePointsCloud;
  115102. /**
  115103. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115104. */
  115105. set forcePointsCloud(value: boolean);
  115106. get forcePointsCloud(): boolean;
  115107. /**
  115108. * Gets or sets the active clipplane 1
  115109. */
  115110. clipPlane: Nullable<Plane>;
  115111. /**
  115112. * Gets or sets the active clipplane 2
  115113. */
  115114. clipPlane2: Nullable<Plane>;
  115115. /**
  115116. * Gets or sets the active clipplane 3
  115117. */
  115118. clipPlane3: Nullable<Plane>;
  115119. /**
  115120. * Gets or sets the active clipplane 4
  115121. */
  115122. clipPlane4: Nullable<Plane>;
  115123. /**
  115124. * Gets or sets the active clipplane 5
  115125. */
  115126. clipPlane5: Nullable<Plane>;
  115127. /**
  115128. * Gets or sets the active clipplane 6
  115129. */
  115130. clipPlane6: Nullable<Plane>;
  115131. /**
  115132. * Gets or sets a boolean indicating if animations are enabled
  115133. */
  115134. animationsEnabled: boolean;
  115135. private _animationPropertiesOverride;
  115136. /**
  115137. * Gets or sets the animation properties override
  115138. */
  115139. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115140. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115141. /**
  115142. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115143. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115144. */
  115145. useConstantAnimationDeltaTime: boolean;
  115146. /**
  115147. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115148. * Please note that it requires to run a ray cast through the scene on every frame
  115149. */
  115150. constantlyUpdateMeshUnderPointer: boolean;
  115151. /**
  115152. * Defines the HTML cursor to use when hovering over interactive elements
  115153. */
  115154. hoverCursor: string;
  115155. /**
  115156. * Defines the HTML default cursor to use (empty by default)
  115157. */
  115158. defaultCursor: string;
  115159. /**
  115160. * Defines whether cursors are handled by the scene.
  115161. */
  115162. doNotHandleCursors: boolean;
  115163. /**
  115164. * This is used to call preventDefault() on pointer down
  115165. * in order to block unwanted artifacts like system double clicks
  115166. */
  115167. preventDefaultOnPointerDown: boolean;
  115168. /**
  115169. * This is used to call preventDefault() on pointer up
  115170. * in order to block unwanted artifacts like system double clicks
  115171. */
  115172. preventDefaultOnPointerUp: boolean;
  115173. /**
  115174. * Gets or sets user defined metadata
  115175. */
  115176. metadata: any;
  115177. /**
  115178. * For internal use only. Please do not use.
  115179. */
  115180. reservedDataStore: any;
  115181. /**
  115182. * Gets the name of the plugin used to load this scene (null by default)
  115183. */
  115184. loadingPluginName: string;
  115185. /**
  115186. * Use this array to add regular expressions used to disable offline support for specific urls
  115187. */
  115188. disableOfflineSupportExceptionRules: RegExp[];
  115189. /**
  115190. * An event triggered when the scene is disposed.
  115191. */
  115192. onDisposeObservable: Observable<Scene>;
  115193. private _onDisposeObserver;
  115194. /** Sets a function to be executed when this scene is disposed. */
  115195. set onDispose(callback: () => void);
  115196. /**
  115197. * An event triggered before rendering the scene (right after animations and physics)
  115198. */
  115199. onBeforeRenderObservable: Observable<Scene>;
  115200. private _onBeforeRenderObserver;
  115201. /** Sets a function to be executed before rendering this scene */
  115202. set beforeRender(callback: Nullable<() => void>);
  115203. /**
  115204. * An event triggered after rendering the scene
  115205. */
  115206. onAfterRenderObservable: Observable<Scene>;
  115207. /**
  115208. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115209. */
  115210. onAfterRenderCameraObservable: Observable<Camera>;
  115211. private _onAfterRenderObserver;
  115212. /** Sets a function to be executed after rendering this scene */
  115213. set afterRender(callback: Nullable<() => void>);
  115214. /**
  115215. * An event triggered before animating the scene
  115216. */
  115217. onBeforeAnimationsObservable: Observable<Scene>;
  115218. /**
  115219. * An event triggered after animations processing
  115220. */
  115221. onAfterAnimationsObservable: Observable<Scene>;
  115222. /**
  115223. * An event triggered before draw calls are ready to be sent
  115224. */
  115225. onBeforeDrawPhaseObservable: Observable<Scene>;
  115226. /**
  115227. * An event triggered after draw calls have been sent
  115228. */
  115229. onAfterDrawPhaseObservable: Observable<Scene>;
  115230. /**
  115231. * An event triggered when the scene is ready
  115232. */
  115233. onReadyObservable: Observable<Scene>;
  115234. /**
  115235. * An event triggered before rendering a camera
  115236. */
  115237. onBeforeCameraRenderObservable: Observable<Camera>;
  115238. private _onBeforeCameraRenderObserver;
  115239. /** Sets a function to be executed before rendering a camera*/
  115240. set beforeCameraRender(callback: () => void);
  115241. /**
  115242. * An event triggered after rendering a camera
  115243. */
  115244. onAfterCameraRenderObservable: Observable<Camera>;
  115245. private _onAfterCameraRenderObserver;
  115246. /** Sets a function to be executed after rendering a camera*/
  115247. set afterCameraRender(callback: () => void);
  115248. /**
  115249. * An event triggered when active meshes evaluation is about to start
  115250. */
  115251. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  115252. /**
  115253. * An event triggered when active meshes evaluation is done
  115254. */
  115255. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  115256. /**
  115257. * An event triggered when particles rendering is about to start
  115258. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115259. */
  115260. onBeforeParticlesRenderingObservable: Observable<Scene>;
  115261. /**
  115262. * An event triggered when particles rendering is done
  115263. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115264. */
  115265. onAfterParticlesRenderingObservable: Observable<Scene>;
  115266. /**
  115267. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  115268. */
  115269. onDataLoadedObservable: Observable<Scene>;
  115270. /**
  115271. * An event triggered when a camera is created
  115272. */
  115273. onNewCameraAddedObservable: Observable<Camera>;
  115274. /**
  115275. * An event triggered when a camera is removed
  115276. */
  115277. onCameraRemovedObservable: Observable<Camera>;
  115278. /**
  115279. * An event triggered when a light is created
  115280. */
  115281. onNewLightAddedObservable: Observable<Light>;
  115282. /**
  115283. * An event triggered when a light is removed
  115284. */
  115285. onLightRemovedObservable: Observable<Light>;
  115286. /**
  115287. * An event triggered when a geometry is created
  115288. */
  115289. onNewGeometryAddedObservable: Observable<Geometry>;
  115290. /**
  115291. * An event triggered when a geometry is removed
  115292. */
  115293. onGeometryRemovedObservable: Observable<Geometry>;
  115294. /**
  115295. * An event triggered when a transform node is created
  115296. */
  115297. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  115298. /**
  115299. * An event triggered when a transform node is removed
  115300. */
  115301. onTransformNodeRemovedObservable: Observable<TransformNode>;
  115302. /**
  115303. * An event triggered when a mesh is created
  115304. */
  115305. onNewMeshAddedObservable: Observable<AbstractMesh>;
  115306. /**
  115307. * An event triggered when a mesh is removed
  115308. */
  115309. onMeshRemovedObservable: Observable<AbstractMesh>;
  115310. /**
  115311. * An event triggered when a skeleton is created
  115312. */
  115313. onNewSkeletonAddedObservable: Observable<Skeleton>;
  115314. /**
  115315. * An event triggered when a skeleton is removed
  115316. */
  115317. onSkeletonRemovedObservable: Observable<Skeleton>;
  115318. /**
  115319. * An event triggered when a material is created
  115320. */
  115321. onNewMaterialAddedObservable: Observable<Material>;
  115322. /**
  115323. * An event triggered when a material is removed
  115324. */
  115325. onMaterialRemovedObservable: Observable<Material>;
  115326. /**
  115327. * An event triggered when a texture is created
  115328. */
  115329. onNewTextureAddedObservable: Observable<BaseTexture>;
  115330. /**
  115331. * An event triggered when a texture is removed
  115332. */
  115333. onTextureRemovedObservable: Observable<BaseTexture>;
  115334. /**
  115335. * An event triggered when render targets are about to be rendered
  115336. * Can happen multiple times per frame.
  115337. */
  115338. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  115339. /**
  115340. * An event triggered when render targets were rendered.
  115341. * Can happen multiple times per frame.
  115342. */
  115343. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  115344. /**
  115345. * An event triggered before calculating deterministic simulation step
  115346. */
  115347. onBeforeStepObservable: Observable<Scene>;
  115348. /**
  115349. * An event triggered after calculating deterministic simulation step
  115350. */
  115351. onAfterStepObservable: Observable<Scene>;
  115352. /**
  115353. * An event triggered when the activeCamera property is updated
  115354. */
  115355. onActiveCameraChanged: Observable<Scene>;
  115356. /**
  115357. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  115358. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115359. * 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)
  115360. */
  115361. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115362. /**
  115363. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  115364. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115365. * 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)
  115366. */
  115367. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115368. /**
  115369. * This Observable will when a mesh has been imported into the scene.
  115370. */
  115371. onMeshImportedObservable: Observable<AbstractMesh>;
  115372. /**
  115373. * This Observable will when an animation file has been imported into the scene.
  115374. */
  115375. onAnimationFileImportedObservable: Observable<Scene>;
  115376. /**
  115377. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  115378. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  115379. */
  115380. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  115381. /** @hidden */
  115382. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  115383. /**
  115384. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  115385. */
  115386. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  115387. /**
  115388. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  115389. */
  115390. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  115391. /**
  115392. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  115393. */
  115394. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  115395. /** Callback called when a pointer move is detected */
  115396. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115397. /** Callback called when a pointer down is detected */
  115398. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115399. /** Callback called when a pointer up is detected */
  115400. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  115401. /** Callback called when a pointer pick is detected */
  115402. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  115403. /**
  115404. * 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).
  115405. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  115406. */
  115407. onPrePointerObservable: Observable<PointerInfoPre>;
  115408. /**
  115409. * Observable event triggered each time an input event is received from the rendering canvas
  115410. */
  115411. onPointerObservable: Observable<PointerInfo>;
  115412. /**
  115413. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  115414. */
  115415. get unTranslatedPointer(): Vector2;
  115416. /**
  115417. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  115418. */
  115419. static get DragMovementThreshold(): number;
  115420. static set DragMovementThreshold(value: number);
  115421. /**
  115422. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  115423. */
  115424. static get LongPressDelay(): number;
  115425. static set LongPressDelay(value: number);
  115426. /**
  115427. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  115428. */
  115429. static get DoubleClickDelay(): number;
  115430. static set DoubleClickDelay(value: number);
  115431. /** If you need to check double click without raising a single click at first click, enable this flag */
  115432. static get ExclusiveDoubleClickMode(): boolean;
  115433. static set ExclusiveDoubleClickMode(value: boolean);
  115434. /** @hidden */
  115435. _mirroredCameraPosition: Nullable<Vector3>;
  115436. /**
  115437. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  115438. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  115439. */
  115440. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  115441. /**
  115442. * Observable event triggered each time an keyboard event is received from the hosting window
  115443. */
  115444. onKeyboardObservable: Observable<KeyboardInfo>;
  115445. private _useRightHandedSystem;
  115446. /**
  115447. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  115448. */
  115449. set useRightHandedSystem(value: boolean);
  115450. get useRightHandedSystem(): boolean;
  115451. private _timeAccumulator;
  115452. private _currentStepId;
  115453. private _currentInternalStep;
  115454. /**
  115455. * Sets the step Id used by deterministic lock step
  115456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115457. * @param newStepId defines the step Id
  115458. */
  115459. setStepId(newStepId: number): void;
  115460. /**
  115461. * Gets the step Id used by deterministic lock step
  115462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115463. * @returns the step Id
  115464. */
  115465. getStepId(): number;
  115466. /**
  115467. * Gets the internal step used by deterministic lock step
  115468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115469. * @returns the internal step
  115470. */
  115471. getInternalStep(): number;
  115472. private _fogEnabled;
  115473. /**
  115474. * Gets or sets a boolean indicating if fog is enabled on this scene
  115475. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115476. * (Default is true)
  115477. */
  115478. set fogEnabled(value: boolean);
  115479. get fogEnabled(): boolean;
  115480. private _fogMode;
  115481. /**
  115482. * Gets or sets the fog mode to use
  115483. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115484. * | mode | value |
  115485. * | --- | --- |
  115486. * | FOGMODE_NONE | 0 |
  115487. * | FOGMODE_EXP | 1 |
  115488. * | FOGMODE_EXP2 | 2 |
  115489. * | FOGMODE_LINEAR | 3 |
  115490. */
  115491. set fogMode(value: number);
  115492. get fogMode(): number;
  115493. /**
  115494. * Gets or sets the fog color to use
  115495. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115496. * (Default is Color3(0.2, 0.2, 0.3))
  115497. */
  115498. fogColor: Color3;
  115499. /**
  115500. * Gets or sets the fog density to use
  115501. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115502. * (Default is 0.1)
  115503. */
  115504. fogDensity: number;
  115505. /**
  115506. * Gets or sets the fog start distance to use
  115507. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115508. * (Default is 0)
  115509. */
  115510. fogStart: number;
  115511. /**
  115512. * Gets or sets the fog end distance to use
  115513. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115514. * (Default is 1000)
  115515. */
  115516. fogEnd: number;
  115517. private _shadowsEnabled;
  115518. /**
  115519. * Gets or sets a boolean indicating if shadows are enabled on this scene
  115520. */
  115521. set shadowsEnabled(value: boolean);
  115522. get shadowsEnabled(): boolean;
  115523. private _lightsEnabled;
  115524. /**
  115525. * Gets or sets a boolean indicating if lights are enabled on this scene
  115526. */
  115527. set lightsEnabled(value: boolean);
  115528. get lightsEnabled(): boolean;
  115529. /** All of the active cameras added to this scene. */
  115530. activeCameras: Camera[];
  115531. /** @hidden */
  115532. _activeCamera: Nullable<Camera>;
  115533. /** Gets or sets the current active camera */
  115534. get activeCamera(): Nullable<Camera>;
  115535. set activeCamera(value: Nullable<Camera>);
  115536. private _defaultMaterial;
  115537. /** The default material used on meshes when no material is affected */
  115538. get defaultMaterial(): Material;
  115539. /** The default material used on meshes when no material is affected */
  115540. set defaultMaterial(value: Material);
  115541. private _texturesEnabled;
  115542. /**
  115543. * Gets or sets a boolean indicating if textures are enabled on this scene
  115544. */
  115545. set texturesEnabled(value: boolean);
  115546. get texturesEnabled(): boolean;
  115547. /**
  115548. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  115549. */
  115550. physicsEnabled: boolean;
  115551. /**
  115552. * Gets or sets a boolean indicating if particles are enabled on this scene
  115553. */
  115554. particlesEnabled: boolean;
  115555. /**
  115556. * Gets or sets a boolean indicating if sprites are enabled on this scene
  115557. */
  115558. spritesEnabled: boolean;
  115559. private _skeletonsEnabled;
  115560. /**
  115561. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  115562. */
  115563. set skeletonsEnabled(value: boolean);
  115564. get skeletonsEnabled(): boolean;
  115565. /**
  115566. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  115567. */
  115568. lensFlaresEnabled: boolean;
  115569. /**
  115570. * Gets or sets a boolean indicating if collisions are enabled on this scene
  115571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115572. */
  115573. collisionsEnabled: boolean;
  115574. private _collisionCoordinator;
  115575. /** @hidden */
  115576. get collisionCoordinator(): ICollisionCoordinator;
  115577. /**
  115578. * Defines the gravity applied to this scene (used only for collisions)
  115579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115580. */
  115581. gravity: Vector3;
  115582. /**
  115583. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  115584. */
  115585. postProcessesEnabled: boolean;
  115586. /**
  115587. * The list of postprocesses added to the scene
  115588. */
  115589. postProcesses: PostProcess[];
  115590. /**
  115591. * Gets the current postprocess manager
  115592. */
  115593. postProcessManager: PostProcessManager;
  115594. /**
  115595. * Gets or sets a boolean indicating if render targets are enabled on this scene
  115596. */
  115597. renderTargetsEnabled: boolean;
  115598. /**
  115599. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  115600. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  115601. */
  115602. dumpNextRenderTargets: boolean;
  115603. /**
  115604. * The list of user defined render targets added to the scene
  115605. */
  115606. customRenderTargets: RenderTargetTexture[];
  115607. /**
  115608. * Defines if texture loading must be delayed
  115609. * If true, textures will only be loaded when they need to be rendered
  115610. */
  115611. useDelayedTextureLoading: boolean;
  115612. /**
  115613. * Gets the list of meshes imported to the scene through SceneLoader
  115614. */
  115615. importedMeshesFiles: String[];
  115616. /**
  115617. * Gets or sets a boolean indicating if probes are enabled on this scene
  115618. */
  115619. probesEnabled: boolean;
  115620. /**
  115621. * Gets or sets the current offline provider to use to store scene data
  115622. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115623. */
  115624. offlineProvider: IOfflineProvider;
  115625. /**
  115626. * Gets or sets the action manager associated with the scene
  115627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  115628. */
  115629. actionManager: AbstractActionManager;
  115630. private _meshesForIntersections;
  115631. /**
  115632. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  115633. */
  115634. proceduralTexturesEnabled: boolean;
  115635. private _engine;
  115636. private _totalVertices;
  115637. /** @hidden */
  115638. _activeIndices: PerfCounter;
  115639. /** @hidden */
  115640. _activeParticles: PerfCounter;
  115641. /** @hidden */
  115642. _activeBones: PerfCounter;
  115643. private _animationRatio;
  115644. /** @hidden */
  115645. _animationTimeLast: number;
  115646. /** @hidden */
  115647. _animationTime: number;
  115648. /**
  115649. * Gets or sets a general scale for animation speed
  115650. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  115651. */
  115652. animationTimeScale: number;
  115653. /** @hidden */
  115654. _cachedMaterial: Nullable<Material>;
  115655. /** @hidden */
  115656. _cachedEffect: Nullable<Effect>;
  115657. /** @hidden */
  115658. _cachedVisibility: Nullable<number>;
  115659. private _renderId;
  115660. private _frameId;
  115661. private _executeWhenReadyTimeoutId;
  115662. private _intermediateRendering;
  115663. private _viewUpdateFlag;
  115664. private _projectionUpdateFlag;
  115665. /** @hidden */
  115666. _toBeDisposed: Nullable<IDisposable>[];
  115667. private _activeRequests;
  115668. /** @hidden */
  115669. _pendingData: any[];
  115670. private _isDisposed;
  115671. /**
  115672. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  115673. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  115674. */
  115675. dispatchAllSubMeshesOfActiveMeshes: boolean;
  115676. private _activeMeshes;
  115677. private _processedMaterials;
  115678. private _renderTargets;
  115679. /** @hidden */
  115680. _activeParticleSystems: SmartArray<IParticleSystem>;
  115681. private _activeSkeletons;
  115682. private _softwareSkinnedMeshes;
  115683. private _renderingManager;
  115684. /** @hidden */
  115685. _activeAnimatables: Animatable[];
  115686. private _transformMatrix;
  115687. private _sceneUbo;
  115688. /** @hidden */
  115689. _viewMatrix: Matrix;
  115690. private _projectionMatrix;
  115691. /** @hidden */
  115692. _forcedViewPosition: Nullable<Vector3>;
  115693. /** @hidden */
  115694. _frustumPlanes: Plane[];
  115695. /**
  115696. * Gets the list of frustum planes (built from the active camera)
  115697. */
  115698. get frustumPlanes(): Plane[];
  115699. /**
  115700. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  115701. * This is useful if there are more lights that the maximum simulteanous authorized
  115702. */
  115703. requireLightSorting: boolean;
  115704. /** @hidden */
  115705. readonly useMaterialMeshMap: boolean;
  115706. /** @hidden */
  115707. readonly useClonedMeshMap: boolean;
  115708. private _externalData;
  115709. private _uid;
  115710. /**
  115711. * @hidden
  115712. * Backing store of defined scene components.
  115713. */
  115714. _components: ISceneComponent[];
  115715. /**
  115716. * @hidden
  115717. * Backing store of defined scene components.
  115718. */
  115719. _serializableComponents: ISceneSerializableComponent[];
  115720. /**
  115721. * List of components to register on the next registration step.
  115722. */
  115723. private _transientComponents;
  115724. /**
  115725. * Registers the transient components if needed.
  115726. */
  115727. private _registerTransientComponents;
  115728. /**
  115729. * @hidden
  115730. * Add a component to the scene.
  115731. * Note that the ccomponent could be registered on th next frame if this is called after
  115732. * the register component stage.
  115733. * @param component Defines the component to add to the scene
  115734. */
  115735. _addComponent(component: ISceneComponent): void;
  115736. /**
  115737. * @hidden
  115738. * Gets a component from the scene.
  115739. * @param name defines the name of the component to retrieve
  115740. * @returns the component or null if not present
  115741. */
  115742. _getComponent(name: string): Nullable<ISceneComponent>;
  115743. /**
  115744. * @hidden
  115745. * Defines the actions happening before camera updates.
  115746. */
  115747. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  115748. /**
  115749. * @hidden
  115750. * Defines the actions happening before clear the canvas.
  115751. */
  115752. _beforeClearStage: Stage<SimpleStageAction>;
  115753. /**
  115754. * @hidden
  115755. * Defines the actions when collecting render targets for the frame.
  115756. */
  115757. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  115758. /**
  115759. * @hidden
  115760. * Defines the actions happening for one camera in the frame.
  115761. */
  115762. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  115763. /**
  115764. * @hidden
  115765. * Defines the actions happening during the per mesh ready checks.
  115766. */
  115767. _isReadyForMeshStage: Stage<MeshStageAction>;
  115768. /**
  115769. * @hidden
  115770. * Defines the actions happening before evaluate active mesh checks.
  115771. */
  115772. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  115773. /**
  115774. * @hidden
  115775. * Defines the actions happening during the evaluate sub mesh checks.
  115776. */
  115777. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  115778. /**
  115779. * @hidden
  115780. * Defines the actions happening during the active mesh stage.
  115781. */
  115782. _activeMeshStage: Stage<ActiveMeshStageAction>;
  115783. /**
  115784. * @hidden
  115785. * Defines the actions happening during the per camera render target step.
  115786. */
  115787. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  115788. /**
  115789. * @hidden
  115790. * Defines the actions happening just before the active camera is drawing.
  115791. */
  115792. _beforeCameraDrawStage: Stage<CameraStageAction>;
  115793. /**
  115794. * @hidden
  115795. * Defines the actions happening just before a render target is drawing.
  115796. */
  115797. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  115798. /**
  115799. * @hidden
  115800. * Defines the actions happening just before a rendering group is drawing.
  115801. */
  115802. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  115803. /**
  115804. * @hidden
  115805. * Defines the actions happening just before a mesh is drawing.
  115806. */
  115807. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  115808. /**
  115809. * @hidden
  115810. * Defines the actions happening just after a mesh has been drawn.
  115811. */
  115812. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  115813. /**
  115814. * @hidden
  115815. * Defines the actions happening just after a rendering group has been drawn.
  115816. */
  115817. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  115818. /**
  115819. * @hidden
  115820. * Defines the actions happening just after the active camera has been drawn.
  115821. */
  115822. _afterCameraDrawStage: Stage<CameraStageAction>;
  115823. /**
  115824. * @hidden
  115825. * Defines the actions happening just after a render target has been drawn.
  115826. */
  115827. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  115828. /**
  115829. * @hidden
  115830. * Defines the actions happening just after rendering all cameras and computing intersections.
  115831. */
  115832. _afterRenderStage: Stage<SimpleStageAction>;
  115833. /**
  115834. * @hidden
  115835. * Defines the actions happening when a pointer move event happens.
  115836. */
  115837. _pointerMoveStage: Stage<PointerMoveStageAction>;
  115838. /**
  115839. * @hidden
  115840. * Defines the actions happening when a pointer down event happens.
  115841. */
  115842. _pointerDownStage: Stage<PointerUpDownStageAction>;
  115843. /**
  115844. * @hidden
  115845. * Defines the actions happening when a pointer up event happens.
  115846. */
  115847. _pointerUpStage: Stage<PointerUpDownStageAction>;
  115848. /**
  115849. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  115850. */
  115851. private geometriesByUniqueId;
  115852. /**
  115853. * Creates a new Scene
  115854. * @param engine defines the engine to use to render this scene
  115855. * @param options defines the scene options
  115856. */
  115857. constructor(engine: Engine, options?: SceneOptions);
  115858. /**
  115859. * Gets a string idenfifying the name of the class
  115860. * @returns "Scene" string
  115861. */
  115862. getClassName(): string;
  115863. private _defaultMeshCandidates;
  115864. /**
  115865. * @hidden
  115866. */
  115867. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115868. private _defaultSubMeshCandidates;
  115869. /**
  115870. * @hidden
  115871. */
  115872. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115873. /**
  115874. * Sets the default candidate providers for the scene.
  115875. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  115876. * and getCollidingSubMeshCandidates to their default function
  115877. */
  115878. setDefaultCandidateProviders(): void;
  115879. /**
  115880. * Gets the mesh that is currently under the pointer
  115881. */
  115882. get meshUnderPointer(): Nullable<AbstractMesh>;
  115883. /**
  115884. * Gets or sets the current on-screen X position of the pointer
  115885. */
  115886. get pointerX(): number;
  115887. set pointerX(value: number);
  115888. /**
  115889. * Gets or sets the current on-screen Y position of the pointer
  115890. */
  115891. get pointerY(): number;
  115892. set pointerY(value: number);
  115893. /**
  115894. * Gets the cached material (ie. the latest rendered one)
  115895. * @returns the cached material
  115896. */
  115897. getCachedMaterial(): Nullable<Material>;
  115898. /**
  115899. * Gets the cached effect (ie. the latest rendered one)
  115900. * @returns the cached effect
  115901. */
  115902. getCachedEffect(): Nullable<Effect>;
  115903. /**
  115904. * Gets the cached visibility state (ie. the latest rendered one)
  115905. * @returns the cached visibility state
  115906. */
  115907. getCachedVisibility(): Nullable<number>;
  115908. /**
  115909. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  115910. * @param material defines the current material
  115911. * @param effect defines the current effect
  115912. * @param visibility defines the current visibility state
  115913. * @returns true if one parameter is not cached
  115914. */
  115915. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  115916. /**
  115917. * Gets the engine associated with the scene
  115918. * @returns an Engine
  115919. */
  115920. getEngine(): Engine;
  115921. /**
  115922. * Gets the total number of vertices rendered per frame
  115923. * @returns the total number of vertices rendered per frame
  115924. */
  115925. getTotalVertices(): number;
  115926. /**
  115927. * Gets the performance counter for total vertices
  115928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  115929. */
  115930. get totalVerticesPerfCounter(): PerfCounter;
  115931. /**
  115932. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  115933. * @returns the total number of active indices rendered per frame
  115934. */
  115935. getActiveIndices(): number;
  115936. /**
  115937. * Gets the performance counter for active indices
  115938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  115939. */
  115940. get totalActiveIndicesPerfCounter(): PerfCounter;
  115941. /**
  115942. * Gets the total number of active particles rendered per frame
  115943. * @returns the total number of active particles rendered per frame
  115944. */
  115945. getActiveParticles(): number;
  115946. /**
  115947. * Gets the performance counter for active particles
  115948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  115949. */
  115950. get activeParticlesPerfCounter(): PerfCounter;
  115951. /**
  115952. * Gets the total number of active bones rendered per frame
  115953. * @returns the total number of active bones rendered per frame
  115954. */
  115955. getActiveBones(): number;
  115956. /**
  115957. * Gets the performance counter for active bones
  115958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  115959. */
  115960. get activeBonesPerfCounter(): PerfCounter;
  115961. /**
  115962. * Gets the array of active meshes
  115963. * @returns an array of AbstractMesh
  115964. */
  115965. getActiveMeshes(): SmartArray<AbstractMesh>;
  115966. /**
  115967. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  115968. * @returns a number
  115969. */
  115970. getAnimationRatio(): number;
  115971. /**
  115972. * Gets an unique Id for the current render phase
  115973. * @returns a number
  115974. */
  115975. getRenderId(): number;
  115976. /**
  115977. * Gets an unique Id for the current frame
  115978. * @returns a number
  115979. */
  115980. getFrameId(): number;
  115981. /** Call this function if you want to manually increment the render Id*/
  115982. incrementRenderId(): void;
  115983. private _createUbo;
  115984. /**
  115985. * Use this method to simulate a pointer move on a mesh
  115986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115989. * @returns the current scene
  115990. */
  115991. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  115992. /**
  115993. * Use this method to simulate a pointer down on a mesh
  115994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115997. * @returns the current scene
  115998. */
  115999. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116000. /**
  116001. * Use this method to simulate a pointer up on a mesh
  116002. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116003. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116004. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116005. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116006. * @returns the current scene
  116007. */
  116008. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116009. /**
  116010. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116011. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116012. * @returns true if the pointer was captured
  116013. */
  116014. isPointerCaptured(pointerId?: number): boolean;
  116015. /**
  116016. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116017. * @param attachUp defines if you want to attach events to pointerup
  116018. * @param attachDown defines if you want to attach events to pointerdown
  116019. * @param attachMove defines if you want to attach events to pointermove
  116020. */
  116021. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116022. /** Detaches all event handlers*/
  116023. detachControl(): void;
  116024. /**
  116025. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116026. * Delay loaded resources are not taking in account
  116027. * @return true if all required resources are ready
  116028. */
  116029. isReady(): boolean;
  116030. /** Resets all cached information relative to material (including effect and visibility) */
  116031. resetCachedMaterial(): void;
  116032. /**
  116033. * Registers a function to be called before every frame render
  116034. * @param func defines the function to register
  116035. */
  116036. registerBeforeRender(func: () => void): void;
  116037. /**
  116038. * Unregisters a function called before every frame render
  116039. * @param func defines the function to unregister
  116040. */
  116041. unregisterBeforeRender(func: () => void): void;
  116042. /**
  116043. * Registers a function to be called after every frame render
  116044. * @param func defines the function to register
  116045. */
  116046. registerAfterRender(func: () => void): void;
  116047. /**
  116048. * Unregisters a function called after every frame render
  116049. * @param func defines the function to unregister
  116050. */
  116051. unregisterAfterRender(func: () => void): void;
  116052. private _executeOnceBeforeRender;
  116053. /**
  116054. * The provided function will run before render once and will be disposed afterwards.
  116055. * A timeout delay can be provided so that the function will be executed in N ms.
  116056. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116057. * @param func The function to be executed.
  116058. * @param timeout optional delay in ms
  116059. */
  116060. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116061. /** @hidden */
  116062. _addPendingData(data: any): void;
  116063. /** @hidden */
  116064. _removePendingData(data: any): void;
  116065. /**
  116066. * Returns the number of items waiting to be loaded
  116067. * @returns the number of items waiting to be loaded
  116068. */
  116069. getWaitingItemsCount(): number;
  116070. /**
  116071. * Returns a boolean indicating if the scene is still loading data
  116072. */
  116073. get isLoading(): boolean;
  116074. /**
  116075. * Registers a function to be executed when the scene is ready
  116076. * @param {Function} func - the function to be executed
  116077. */
  116078. executeWhenReady(func: () => void): void;
  116079. /**
  116080. * Returns a promise that resolves when the scene is ready
  116081. * @returns A promise that resolves when the scene is ready
  116082. */
  116083. whenReadyAsync(): Promise<void>;
  116084. /** @hidden */
  116085. _checkIsReady(): void;
  116086. /**
  116087. * Gets all animatable attached to the scene
  116088. */
  116089. get animatables(): Animatable[];
  116090. /**
  116091. * Resets the last animation time frame.
  116092. * Useful to override when animations start running when loading a scene for the first time.
  116093. */
  116094. resetLastAnimationTimeFrame(): void;
  116095. /**
  116096. * Gets the current view matrix
  116097. * @returns a Matrix
  116098. */
  116099. getViewMatrix(): Matrix;
  116100. /**
  116101. * Gets the current projection matrix
  116102. * @returns a Matrix
  116103. */
  116104. getProjectionMatrix(): Matrix;
  116105. /**
  116106. * Gets the current transform matrix
  116107. * @returns a Matrix made of View * Projection
  116108. */
  116109. getTransformMatrix(): Matrix;
  116110. /**
  116111. * Sets the current transform matrix
  116112. * @param viewL defines the View matrix to use
  116113. * @param projectionL defines the Projection matrix to use
  116114. * @param viewR defines the right View matrix to use (if provided)
  116115. * @param projectionR defines the right Projection matrix to use (if provided)
  116116. */
  116117. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116118. /**
  116119. * Gets the uniform buffer used to store scene data
  116120. * @returns a UniformBuffer
  116121. */
  116122. getSceneUniformBuffer(): UniformBuffer;
  116123. /**
  116124. * Gets an unique (relatively to the current scene) Id
  116125. * @returns an unique number for the scene
  116126. */
  116127. getUniqueId(): number;
  116128. /**
  116129. * Add a mesh to the list of scene's meshes
  116130. * @param newMesh defines the mesh to add
  116131. * @param recursive if all child meshes should also be added to the scene
  116132. */
  116133. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116134. /**
  116135. * Remove a mesh for the list of scene's meshes
  116136. * @param toRemove defines the mesh to remove
  116137. * @param recursive if all child meshes should also be removed from the scene
  116138. * @returns the index where the mesh was in the mesh list
  116139. */
  116140. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116141. /**
  116142. * Add a transform node to the list of scene's transform nodes
  116143. * @param newTransformNode defines the transform node to add
  116144. */
  116145. addTransformNode(newTransformNode: TransformNode): void;
  116146. /**
  116147. * Remove a transform node for the list of scene's transform nodes
  116148. * @param toRemove defines the transform node to remove
  116149. * @returns the index where the transform node was in the transform node list
  116150. */
  116151. removeTransformNode(toRemove: TransformNode): number;
  116152. /**
  116153. * Remove a skeleton for the list of scene's skeletons
  116154. * @param toRemove defines the skeleton to remove
  116155. * @returns the index where the skeleton was in the skeleton list
  116156. */
  116157. removeSkeleton(toRemove: Skeleton): number;
  116158. /**
  116159. * Remove a morph target for the list of scene's morph targets
  116160. * @param toRemove defines the morph target to remove
  116161. * @returns the index where the morph target was in the morph target list
  116162. */
  116163. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116164. /**
  116165. * Remove a light for the list of scene's lights
  116166. * @param toRemove defines the light to remove
  116167. * @returns the index where the light was in the light list
  116168. */
  116169. removeLight(toRemove: Light): number;
  116170. /**
  116171. * Remove a camera for the list of scene's cameras
  116172. * @param toRemove defines the camera to remove
  116173. * @returns the index where the camera was in the camera list
  116174. */
  116175. removeCamera(toRemove: Camera): number;
  116176. /**
  116177. * Remove a particle system for the list of scene's particle systems
  116178. * @param toRemove defines the particle system to remove
  116179. * @returns the index where the particle system was in the particle system list
  116180. */
  116181. removeParticleSystem(toRemove: IParticleSystem): number;
  116182. /**
  116183. * Remove a animation for the list of scene's animations
  116184. * @param toRemove defines the animation to remove
  116185. * @returns the index where the animation was in the animation list
  116186. */
  116187. removeAnimation(toRemove: Animation): number;
  116188. /**
  116189. * Will stop the animation of the given target
  116190. * @param target - the target
  116191. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116192. * @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)
  116193. */
  116194. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116195. /**
  116196. * Removes the given animation group from this scene.
  116197. * @param toRemove The animation group to remove
  116198. * @returns The index of the removed animation group
  116199. */
  116200. removeAnimationGroup(toRemove: AnimationGroup): number;
  116201. /**
  116202. * Removes the given multi-material from this scene.
  116203. * @param toRemove The multi-material to remove
  116204. * @returns The index of the removed multi-material
  116205. */
  116206. removeMultiMaterial(toRemove: MultiMaterial): number;
  116207. /**
  116208. * Removes the given material from this scene.
  116209. * @param toRemove The material to remove
  116210. * @returns The index of the removed material
  116211. */
  116212. removeMaterial(toRemove: Material): number;
  116213. /**
  116214. * Removes the given action manager from this scene.
  116215. * @param toRemove The action manager to remove
  116216. * @returns The index of the removed action manager
  116217. */
  116218. removeActionManager(toRemove: AbstractActionManager): number;
  116219. /**
  116220. * Removes the given texture from this scene.
  116221. * @param toRemove The texture to remove
  116222. * @returns The index of the removed texture
  116223. */
  116224. removeTexture(toRemove: BaseTexture): number;
  116225. /**
  116226. * Adds the given light to this scene
  116227. * @param newLight The light to add
  116228. */
  116229. addLight(newLight: Light): void;
  116230. /**
  116231. * Sorts the list list based on light priorities
  116232. */
  116233. sortLightsByPriority(): void;
  116234. /**
  116235. * Adds the given camera to this scene
  116236. * @param newCamera The camera to add
  116237. */
  116238. addCamera(newCamera: Camera): void;
  116239. /**
  116240. * Adds the given skeleton to this scene
  116241. * @param newSkeleton The skeleton to add
  116242. */
  116243. addSkeleton(newSkeleton: Skeleton): void;
  116244. /**
  116245. * Adds the given particle system to this scene
  116246. * @param newParticleSystem The particle system to add
  116247. */
  116248. addParticleSystem(newParticleSystem: IParticleSystem): void;
  116249. /**
  116250. * Adds the given animation to this scene
  116251. * @param newAnimation The animation to add
  116252. */
  116253. addAnimation(newAnimation: Animation): void;
  116254. /**
  116255. * Adds the given animation group to this scene.
  116256. * @param newAnimationGroup The animation group to add
  116257. */
  116258. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  116259. /**
  116260. * Adds the given multi-material to this scene
  116261. * @param newMultiMaterial The multi-material to add
  116262. */
  116263. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  116264. /**
  116265. * Adds the given material to this scene
  116266. * @param newMaterial The material to add
  116267. */
  116268. addMaterial(newMaterial: Material): void;
  116269. /**
  116270. * Adds the given morph target to this scene
  116271. * @param newMorphTargetManager The morph target to add
  116272. */
  116273. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  116274. /**
  116275. * Adds the given geometry to this scene
  116276. * @param newGeometry The geometry to add
  116277. */
  116278. addGeometry(newGeometry: Geometry): void;
  116279. /**
  116280. * Adds the given action manager to this scene
  116281. * @param newActionManager The action manager to add
  116282. */
  116283. addActionManager(newActionManager: AbstractActionManager): void;
  116284. /**
  116285. * Adds the given texture to this scene.
  116286. * @param newTexture The texture to add
  116287. */
  116288. addTexture(newTexture: BaseTexture): void;
  116289. /**
  116290. * Switch active camera
  116291. * @param newCamera defines the new active camera
  116292. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  116293. */
  116294. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  116295. /**
  116296. * sets the active camera of the scene using its ID
  116297. * @param id defines the camera's ID
  116298. * @return the new active camera or null if none found.
  116299. */
  116300. setActiveCameraByID(id: string): Nullable<Camera>;
  116301. /**
  116302. * sets the active camera of the scene using its name
  116303. * @param name defines the camera's name
  116304. * @returns the new active camera or null if none found.
  116305. */
  116306. setActiveCameraByName(name: string): Nullable<Camera>;
  116307. /**
  116308. * get an animation group using its name
  116309. * @param name defines the material's name
  116310. * @return the animation group or null if none found.
  116311. */
  116312. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  116313. /**
  116314. * Get a material using its unique id
  116315. * @param uniqueId defines the material's unique id
  116316. * @return the material or null if none found.
  116317. */
  116318. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  116319. /**
  116320. * get a material using its id
  116321. * @param id defines the material's ID
  116322. * @return the material or null if none found.
  116323. */
  116324. getMaterialByID(id: string): Nullable<Material>;
  116325. /**
  116326. * Gets a the last added material using a given id
  116327. * @param id defines the material's ID
  116328. * @return the last material with the given id or null if none found.
  116329. */
  116330. getLastMaterialByID(id: string): Nullable<Material>;
  116331. /**
  116332. * Gets a material using its name
  116333. * @param name defines the material's name
  116334. * @return the material or null if none found.
  116335. */
  116336. getMaterialByName(name: string): Nullable<Material>;
  116337. /**
  116338. * Get a texture using its unique id
  116339. * @param uniqueId defines the texture's unique id
  116340. * @return the texture or null if none found.
  116341. */
  116342. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  116343. /**
  116344. * Gets a camera using its id
  116345. * @param id defines the id to look for
  116346. * @returns the camera or null if not found
  116347. */
  116348. getCameraByID(id: string): Nullable<Camera>;
  116349. /**
  116350. * Gets a camera using its unique id
  116351. * @param uniqueId defines the unique id to look for
  116352. * @returns the camera or null if not found
  116353. */
  116354. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  116355. /**
  116356. * Gets a camera using its name
  116357. * @param name defines the camera's name
  116358. * @return the camera or null if none found.
  116359. */
  116360. getCameraByName(name: string): Nullable<Camera>;
  116361. /**
  116362. * Gets a bone using its id
  116363. * @param id defines the bone's id
  116364. * @return the bone or null if not found
  116365. */
  116366. getBoneByID(id: string): Nullable<Bone>;
  116367. /**
  116368. * Gets a bone using its id
  116369. * @param name defines the bone's name
  116370. * @return the bone or null if not found
  116371. */
  116372. getBoneByName(name: string): Nullable<Bone>;
  116373. /**
  116374. * Gets a light node using its name
  116375. * @param name defines the the light's name
  116376. * @return the light or null if none found.
  116377. */
  116378. getLightByName(name: string): Nullable<Light>;
  116379. /**
  116380. * Gets a light node using its id
  116381. * @param id defines the light's id
  116382. * @return the light or null if none found.
  116383. */
  116384. getLightByID(id: string): Nullable<Light>;
  116385. /**
  116386. * Gets a light node using its scene-generated unique ID
  116387. * @param uniqueId defines the light's unique id
  116388. * @return the light or null if none found.
  116389. */
  116390. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  116391. /**
  116392. * Gets a particle system by id
  116393. * @param id defines the particle system id
  116394. * @return the corresponding system or null if none found
  116395. */
  116396. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  116397. /**
  116398. * Gets a geometry using its ID
  116399. * @param id defines the geometry's id
  116400. * @return the geometry or null if none found.
  116401. */
  116402. getGeometryByID(id: string): Nullable<Geometry>;
  116403. private _getGeometryByUniqueID;
  116404. /**
  116405. * Add a new geometry to this scene
  116406. * @param geometry defines the geometry to be added to the scene.
  116407. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  116408. * @return a boolean defining if the geometry was added or not
  116409. */
  116410. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  116411. /**
  116412. * Removes an existing geometry
  116413. * @param geometry defines the geometry to be removed from the scene
  116414. * @return a boolean defining if the geometry was removed or not
  116415. */
  116416. removeGeometry(geometry: Geometry): boolean;
  116417. /**
  116418. * Gets the list of geometries attached to the scene
  116419. * @returns an array of Geometry
  116420. */
  116421. getGeometries(): Geometry[];
  116422. /**
  116423. * Gets the first added mesh found of a given ID
  116424. * @param id defines the id to search for
  116425. * @return the mesh found or null if not found at all
  116426. */
  116427. getMeshByID(id: string): Nullable<AbstractMesh>;
  116428. /**
  116429. * Gets a list of meshes using their id
  116430. * @param id defines the id to search for
  116431. * @returns a list of meshes
  116432. */
  116433. getMeshesByID(id: string): Array<AbstractMesh>;
  116434. /**
  116435. * Gets the first added transform node found of a given ID
  116436. * @param id defines the id to search for
  116437. * @return the found transform node or null if not found at all.
  116438. */
  116439. getTransformNodeByID(id: string): Nullable<TransformNode>;
  116440. /**
  116441. * Gets a transform node with its auto-generated unique id
  116442. * @param uniqueId efines the unique id to search for
  116443. * @return the found transform node or null if not found at all.
  116444. */
  116445. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  116446. /**
  116447. * Gets a list of transform nodes using their id
  116448. * @param id defines the id to search for
  116449. * @returns a list of transform nodes
  116450. */
  116451. getTransformNodesByID(id: string): Array<TransformNode>;
  116452. /**
  116453. * Gets a mesh with its auto-generated unique id
  116454. * @param uniqueId defines the unique id to search for
  116455. * @return the found mesh or null if not found at all.
  116456. */
  116457. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  116458. /**
  116459. * Gets a the last added mesh using a given id
  116460. * @param id defines the id to search for
  116461. * @return the found mesh or null if not found at all.
  116462. */
  116463. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  116464. /**
  116465. * Gets a the last added node (Mesh, Camera, Light) using a given id
  116466. * @param id defines the id to search for
  116467. * @return the found node or null if not found at all
  116468. */
  116469. getLastEntryByID(id: string): Nullable<Node>;
  116470. /**
  116471. * Gets a node (Mesh, Camera, Light) using a given id
  116472. * @param id defines the id to search for
  116473. * @return the found node or null if not found at all
  116474. */
  116475. getNodeByID(id: string): Nullable<Node>;
  116476. /**
  116477. * Gets a node (Mesh, Camera, Light) using a given name
  116478. * @param name defines the name to search for
  116479. * @return the found node or null if not found at all.
  116480. */
  116481. getNodeByName(name: string): Nullable<Node>;
  116482. /**
  116483. * Gets a mesh using a given name
  116484. * @param name defines the name to search for
  116485. * @return the found mesh or null if not found at all.
  116486. */
  116487. getMeshByName(name: string): Nullable<AbstractMesh>;
  116488. /**
  116489. * Gets a transform node using a given name
  116490. * @param name defines the name to search for
  116491. * @return the found transform node or null if not found at all.
  116492. */
  116493. getTransformNodeByName(name: string): Nullable<TransformNode>;
  116494. /**
  116495. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  116496. * @param id defines the id to search for
  116497. * @return the found skeleton or null if not found at all.
  116498. */
  116499. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  116500. /**
  116501. * Gets a skeleton using a given auto generated unique id
  116502. * @param uniqueId defines the unique id to search for
  116503. * @return the found skeleton or null if not found at all.
  116504. */
  116505. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  116506. /**
  116507. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  116508. * @param id defines the id to search for
  116509. * @return the found skeleton or null if not found at all.
  116510. */
  116511. getSkeletonById(id: string): Nullable<Skeleton>;
  116512. /**
  116513. * Gets a skeleton using a given name
  116514. * @param name defines the name to search for
  116515. * @return the found skeleton or null if not found at all.
  116516. */
  116517. getSkeletonByName(name: string): Nullable<Skeleton>;
  116518. /**
  116519. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  116520. * @param id defines the id to search for
  116521. * @return the found morph target manager or null if not found at all.
  116522. */
  116523. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  116524. /**
  116525. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  116526. * @param id defines the id to search for
  116527. * @return the found morph target or null if not found at all.
  116528. */
  116529. getMorphTargetById(id: string): Nullable<MorphTarget>;
  116530. /**
  116531. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  116532. * @param name defines the name to search for
  116533. * @return the found morph target or null if not found at all.
  116534. */
  116535. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  116536. /**
  116537. * Gets a boolean indicating if the given mesh is active
  116538. * @param mesh defines the mesh to look for
  116539. * @returns true if the mesh is in the active list
  116540. */
  116541. isActiveMesh(mesh: AbstractMesh): boolean;
  116542. /**
  116543. * Return a unique id as a string which can serve as an identifier for the scene
  116544. */
  116545. get uid(): string;
  116546. /**
  116547. * Add an externaly attached data from its key.
  116548. * This method call will fail and return false, if such key already exists.
  116549. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  116550. * @param key the unique key that identifies the data
  116551. * @param data the data object to associate to the key for this Engine instance
  116552. * @return true if no such key were already present and the data was added successfully, false otherwise
  116553. */
  116554. addExternalData<T>(key: string, data: T): boolean;
  116555. /**
  116556. * Get an externaly attached data from its key
  116557. * @param key the unique key that identifies the data
  116558. * @return the associated data, if present (can be null), or undefined if not present
  116559. */
  116560. getExternalData<T>(key: string): Nullable<T>;
  116561. /**
  116562. * Get an externaly attached data from its key, create it using a factory if it's not already present
  116563. * @param key the unique key that identifies the data
  116564. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  116565. * @return the associated data, can be null if the factory returned null.
  116566. */
  116567. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  116568. /**
  116569. * Remove an externaly attached data from the Engine instance
  116570. * @param key the unique key that identifies the data
  116571. * @return true if the data was successfully removed, false if it doesn't exist
  116572. */
  116573. removeExternalData(key: string): boolean;
  116574. private _evaluateSubMesh;
  116575. /**
  116576. * Clear the processed materials smart array preventing retention point in material dispose.
  116577. */
  116578. freeProcessedMaterials(): void;
  116579. private _preventFreeActiveMeshesAndRenderingGroups;
  116580. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  116581. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  116582. * when disposing several meshes in a row or a hierarchy of meshes.
  116583. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  116584. */
  116585. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  116586. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  116587. /**
  116588. * Clear the active meshes smart array preventing retention point in mesh dispose.
  116589. */
  116590. freeActiveMeshes(): void;
  116591. /**
  116592. * Clear the info related to rendering groups preventing retention points during dispose.
  116593. */
  116594. freeRenderingGroups(): void;
  116595. /** @hidden */
  116596. _isInIntermediateRendering(): boolean;
  116597. /**
  116598. * Lambda returning the list of potentially active meshes.
  116599. */
  116600. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  116601. /**
  116602. * Lambda returning the list of potentially active sub meshes.
  116603. */
  116604. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  116605. /**
  116606. * Lambda returning the list of potentially intersecting sub meshes.
  116607. */
  116608. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  116609. /**
  116610. * Lambda returning the list of potentially colliding sub meshes.
  116611. */
  116612. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  116613. private _activeMeshesFrozen;
  116614. private _skipEvaluateActiveMeshesCompletely;
  116615. /**
  116616. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  116617. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  116618. * @returns the current scene
  116619. */
  116620. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  116621. /**
  116622. * Use this function to restart evaluating active meshes on every frame
  116623. * @returns the current scene
  116624. */
  116625. unfreezeActiveMeshes(): Scene;
  116626. private _evaluateActiveMeshes;
  116627. private _activeMesh;
  116628. /**
  116629. * Update the transform matrix to update from the current active camera
  116630. * @param force defines a boolean used to force the update even if cache is up to date
  116631. */
  116632. updateTransformMatrix(force?: boolean): void;
  116633. private _bindFrameBuffer;
  116634. /** @hidden */
  116635. _allowPostProcessClearColor: boolean;
  116636. /** @hidden */
  116637. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  116638. private _processSubCameras;
  116639. private _checkIntersections;
  116640. /** @hidden */
  116641. _advancePhysicsEngineStep(step: number): void;
  116642. /**
  116643. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  116644. */
  116645. getDeterministicFrameTime: () => number;
  116646. /** @hidden */
  116647. _animate(): void;
  116648. /** Execute all animations (for a frame) */
  116649. animate(): void;
  116650. /**
  116651. * Render the scene
  116652. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  116653. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  116654. */
  116655. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  116656. /**
  116657. * Freeze all materials
  116658. * A frozen material will not be updatable but should be faster to render
  116659. */
  116660. freezeMaterials(): void;
  116661. /**
  116662. * Unfreeze all materials
  116663. * A frozen material will not be updatable but should be faster to render
  116664. */
  116665. unfreezeMaterials(): void;
  116666. /**
  116667. * Releases all held ressources
  116668. */
  116669. dispose(): void;
  116670. /**
  116671. * Gets if the scene is already disposed
  116672. */
  116673. get isDisposed(): boolean;
  116674. /**
  116675. * Call this function to reduce memory footprint of the scene.
  116676. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  116677. */
  116678. clearCachedVertexData(): void;
  116679. /**
  116680. * This function will remove the local cached buffer data from texture.
  116681. * It will save memory but will prevent the texture from being rebuilt
  116682. */
  116683. cleanCachedTextureBuffer(): void;
  116684. /**
  116685. * Get the world extend vectors with an optional filter
  116686. *
  116687. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  116688. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  116689. */
  116690. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  116691. min: Vector3;
  116692. max: Vector3;
  116693. };
  116694. /**
  116695. * Creates a ray that can be used to pick in the scene
  116696. * @param x defines the x coordinate of the origin (on-screen)
  116697. * @param y defines the y coordinate of the origin (on-screen)
  116698. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  116699. * @param camera defines the camera to use for the picking
  116700. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  116701. * @returns a Ray
  116702. */
  116703. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  116704. /**
  116705. * Creates a ray that can be used to pick in the scene
  116706. * @param x defines the x coordinate of the origin (on-screen)
  116707. * @param y defines the y coordinate of the origin (on-screen)
  116708. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  116709. * @param result defines the ray where to store the picking ray
  116710. * @param camera defines the camera to use for the picking
  116711. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  116712. * @returns the current scene
  116713. */
  116714. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  116715. /**
  116716. * Creates a ray that can be used to pick in the scene
  116717. * @param x defines the x coordinate of the origin (on-screen)
  116718. * @param y defines the y coordinate of the origin (on-screen)
  116719. * @param camera defines the camera to use for the picking
  116720. * @returns a Ray
  116721. */
  116722. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  116723. /**
  116724. * Creates a ray that can be used to pick in the scene
  116725. * @param x defines the x coordinate of the origin (on-screen)
  116726. * @param y defines the y coordinate of the origin (on-screen)
  116727. * @param result defines the ray where to store the picking ray
  116728. * @param camera defines the camera to use for the picking
  116729. * @returns the current scene
  116730. */
  116731. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  116732. /** Launch a ray to try to pick a mesh in the scene
  116733. * @param x position on screen
  116734. * @param y position on screen
  116735. * @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
  116736. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116737. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  116738. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116739. * @returns a PickingInfo
  116740. */
  116741. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  116742. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  116743. * @param x position on screen
  116744. * @param y position on screen
  116745. * @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
  116746. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116747. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  116748. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  116749. */
  116750. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  116751. /** Use the given ray to pick a mesh in the scene
  116752. * @param ray The ray to use to pick meshes
  116753. * @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
  116754. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116755. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116756. * @returns a PickingInfo
  116757. */
  116758. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  116759. /**
  116760. * Launch a ray to try to pick a mesh in the scene
  116761. * @param x X position on screen
  116762. * @param y Y position on screen
  116763. * @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
  116764. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  116765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116766. * @returns an array of PickingInfo
  116767. */
  116768. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  116769. /**
  116770. * Launch a ray to try to pick a mesh in the scene
  116771. * @param ray Ray to use
  116772. * @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
  116773. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116774. * @returns an array of PickingInfo
  116775. */
  116776. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  116777. /**
  116778. * Force the value of meshUnderPointer
  116779. * @param mesh defines the mesh to use
  116780. */
  116781. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116782. /**
  116783. * Gets the mesh under the pointer
  116784. * @returns a Mesh or null if no mesh is under the pointer
  116785. */
  116786. getPointerOverMesh(): Nullable<AbstractMesh>;
  116787. /** @hidden */
  116788. _rebuildGeometries(): void;
  116789. /** @hidden */
  116790. _rebuildTextures(): void;
  116791. private _getByTags;
  116792. /**
  116793. * Get a list of meshes by tags
  116794. * @param tagsQuery defines the tags query to use
  116795. * @param forEach defines a predicate used to filter results
  116796. * @returns an array of Mesh
  116797. */
  116798. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  116799. /**
  116800. * Get a list of cameras by tags
  116801. * @param tagsQuery defines the tags query to use
  116802. * @param forEach defines a predicate used to filter results
  116803. * @returns an array of Camera
  116804. */
  116805. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  116806. /**
  116807. * Get a list of lights by tags
  116808. * @param tagsQuery defines the tags query to use
  116809. * @param forEach defines a predicate used to filter results
  116810. * @returns an array of Light
  116811. */
  116812. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  116813. /**
  116814. * Get a list of materials by tags
  116815. * @param tagsQuery defines the tags query to use
  116816. * @param forEach defines a predicate used to filter results
  116817. * @returns an array of Material
  116818. */
  116819. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  116820. /**
  116821. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  116822. * This allowed control for front to back rendering or reversly depending of the special needs.
  116823. *
  116824. * @param renderingGroupId The rendering group id corresponding to its index
  116825. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  116826. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  116827. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  116828. */
  116829. 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;
  116830. /**
  116831. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  116832. *
  116833. * @param renderingGroupId The rendering group id corresponding to its index
  116834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116835. * @param depth Automatically clears depth between groups if true and autoClear is true.
  116836. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  116837. */
  116838. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  116839. /**
  116840. * Gets the current auto clear configuration for one rendering group of the rendering
  116841. * manager.
  116842. * @param index the rendering group index to get the information for
  116843. * @returns The auto clear setup for the requested rendering group
  116844. */
  116845. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  116846. private _blockMaterialDirtyMechanism;
  116847. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  116848. get blockMaterialDirtyMechanism(): boolean;
  116849. set blockMaterialDirtyMechanism(value: boolean);
  116850. /**
  116851. * Will flag all materials as dirty to trigger new shader compilation
  116852. * @param flag defines the flag used to specify which material part must be marked as dirty
  116853. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  116854. */
  116855. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116856. /** @hidden */
  116857. _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;
  116858. /** @hidden */
  116859. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116860. /** @hidden */
  116861. _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;
  116862. /** @hidden */
  116863. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  116864. /** @hidden */
  116865. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  116866. /** @hidden */
  116867. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116868. }
  116869. }
  116870. declare module BABYLON {
  116871. /**
  116872. * Set of assets to keep when moving a scene into an asset container.
  116873. */
  116874. export class KeepAssets extends AbstractScene {
  116875. }
  116876. /**
  116877. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  116878. */
  116879. export class InstantiatedEntries {
  116880. /**
  116881. * List of new root nodes (eg. nodes with no parent)
  116882. */
  116883. rootNodes: TransformNode[];
  116884. /**
  116885. * List of new skeletons
  116886. */
  116887. skeletons: Skeleton[];
  116888. /**
  116889. * List of new animation groups
  116890. */
  116891. animationGroups: AnimationGroup[];
  116892. }
  116893. /**
  116894. * Container with a set of assets that can be added or removed from a scene.
  116895. */
  116896. export class AssetContainer extends AbstractScene {
  116897. private _wasAddedToScene;
  116898. /**
  116899. * The scene the AssetContainer belongs to.
  116900. */
  116901. scene: Scene;
  116902. /**
  116903. * Instantiates an AssetContainer.
  116904. * @param scene The scene the AssetContainer belongs to.
  116905. */
  116906. constructor(scene: Scene);
  116907. /**
  116908. * Instantiate or clone all meshes and add the new ones to the scene.
  116909. * Skeletons and animation groups will all be cloned
  116910. * @param nameFunction defines an optional function used to get new names for clones
  116911. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  116912. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  116913. */
  116914. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  116915. /**
  116916. * Adds all the assets from the container to the scene.
  116917. */
  116918. addAllToScene(): void;
  116919. /**
  116920. * Removes all the assets in the container from the scene
  116921. */
  116922. removeAllFromScene(): void;
  116923. /**
  116924. * Disposes all the assets in the container
  116925. */
  116926. dispose(): void;
  116927. private _moveAssets;
  116928. /**
  116929. * Removes all the assets contained in the scene and adds them to the container.
  116930. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  116931. */
  116932. moveAllFromScene(keepAssets?: KeepAssets): void;
  116933. /**
  116934. * 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.
  116935. * @returns the root mesh
  116936. */
  116937. createRootMesh(): Mesh;
  116938. /**
  116939. * Merge animations (direct and animation groups) from this asset container into a scene
  116940. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116941. * @param animatables set of animatables to retarget to a node from the scene
  116942. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  116943. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  116944. */
  116945. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  116946. }
  116947. }
  116948. declare module BABYLON {
  116949. /**
  116950. * Defines how the parser contract is defined.
  116951. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  116952. */
  116953. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  116954. /**
  116955. * Defines how the individual parser contract is defined.
  116956. * These parser can parse an individual asset
  116957. */
  116958. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  116959. /**
  116960. * Base class of the scene acting as a container for the different elements composing a scene.
  116961. * This class is dynamically extended by the different components of the scene increasing
  116962. * flexibility and reducing coupling
  116963. */
  116964. export abstract class AbstractScene {
  116965. /**
  116966. * Stores the list of available parsers in the application.
  116967. */
  116968. private static _BabylonFileParsers;
  116969. /**
  116970. * Stores the list of available individual parsers in the application.
  116971. */
  116972. private static _IndividualBabylonFileParsers;
  116973. /**
  116974. * Adds a parser in the list of available ones
  116975. * @param name Defines the name of the parser
  116976. * @param parser Defines the parser to add
  116977. */
  116978. static AddParser(name: string, parser: BabylonFileParser): void;
  116979. /**
  116980. * Gets a general parser from the list of avaialble ones
  116981. * @param name Defines the name of the parser
  116982. * @returns the requested parser or null
  116983. */
  116984. static GetParser(name: string): Nullable<BabylonFileParser>;
  116985. /**
  116986. * Adds n individual parser in the list of available ones
  116987. * @param name Defines the name of the parser
  116988. * @param parser Defines the parser to add
  116989. */
  116990. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  116991. /**
  116992. * Gets an individual parser from the list of avaialble ones
  116993. * @param name Defines the name of the parser
  116994. * @returns the requested parser or null
  116995. */
  116996. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  116997. /**
  116998. * Parser json data and populate both a scene and its associated container object
  116999. * @param jsonData Defines the data to parse
  117000. * @param scene Defines the scene to parse the data for
  117001. * @param container Defines the container attached to the parsing sequence
  117002. * @param rootUrl Defines the root url of the data
  117003. */
  117004. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117005. /**
  117006. * Gets the list of root nodes (ie. nodes with no parent)
  117007. */
  117008. rootNodes: Node[];
  117009. /** All of the cameras added to this scene
  117010. * @see http://doc.babylonjs.com/babylon101/cameras
  117011. */
  117012. cameras: Camera[];
  117013. /**
  117014. * All of the lights added to this scene
  117015. * @see http://doc.babylonjs.com/babylon101/lights
  117016. */
  117017. lights: Light[];
  117018. /**
  117019. * All of the (abstract) meshes added to this scene
  117020. */
  117021. meshes: AbstractMesh[];
  117022. /**
  117023. * The list of skeletons added to the scene
  117024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117025. */
  117026. skeletons: Skeleton[];
  117027. /**
  117028. * All of the particle systems added to this scene
  117029. * @see http://doc.babylonjs.com/babylon101/particles
  117030. */
  117031. particleSystems: IParticleSystem[];
  117032. /**
  117033. * Gets a list of Animations associated with the scene
  117034. */
  117035. animations: Animation[];
  117036. /**
  117037. * All of the animation groups added to this scene
  117038. * @see http://doc.babylonjs.com/how_to/group
  117039. */
  117040. animationGroups: AnimationGroup[];
  117041. /**
  117042. * All of the multi-materials added to this scene
  117043. * @see http://doc.babylonjs.com/how_to/multi_materials
  117044. */
  117045. multiMaterials: MultiMaterial[];
  117046. /**
  117047. * All of the materials added to this scene
  117048. * In the context of a Scene, it is not supposed to be modified manually.
  117049. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117050. * Note also that the order of the Material within the array is not significant and might change.
  117051. * @see http://doc.babylonjs.com/babylon101/materials
  117052. */
  117053. materials: Material[];
  117054. /**
  117055. * The list of morph target managers added to the scene
  117056. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117057. */
  117058. morphTargetManagers: MorphTargetManager[];
  117059. /**
  117060. * The list of geometries used in the scene.
  117061. */
  117062. geometries: Geometry[];
  117063. /**
  117064. * All of the tranform nodes added to this scene
  117065. * In the context of a Scene, it is not supposed to be modified manually.
  117066. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117067. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117068. * @see http://doc.babylonjs.com/how_to/transformnode
  117069. */
  117070. transformNodes: TransformNode[];
  117071. /**
  117072. * ActionManagers available on the scene.
  117073. */
  117074. actionManagers: AbstractActionManager[];
  117075. /**
  117076. * Textures to keep.
  117077. */
  117078. textures: BaseTexture[];
  117079. /**
  117080. * Environment texture for the scene
  117081. */
  117082. environmentTexture: Nullable<BaseTexture>;
  117083. /**
  117084. * @returns all meshes, lights, cameras, transformNodes and bones
  117085. */
  117086. getNodes(): Array<Node>;
  117087. }
  117088. }
  117089. declare module BABYLON {
  117090. /**
  117091. * Interface used to define options for Sound class
  117092. */
  117093. export interface ISoundOptions {
  117094. /**
  117095. * Does the sound autoplay once loaded.
  117096. */
  117097. autoplay?: boolean;
  117098. /**
  117099. * Does the sound loop after it finishes playing once.
  117100. */
  117101. loop?: boolean;
  117102. /**
  117103. * Sound's volume
  117104. */
  117105. volume?: number;
  117106. /**
  117107. * Is it a spatial sound?
  117108. */
  117109. spatialSound?: boolean;
  117110. /**
  117111. * Maximum distance to hear that sound
  117112. */
  117113. maxDistance?: number;
  117114. /**
  117115. * Uses user defined attenuation function
  117116. */
  117117. useCustomAttenuation?: boolean;
  117118. /**
  117119. * Define the roll off factor of spatial sounds.
  117120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117121. */
  117122. rolloffFactor?: number;
  117123. /**
  117124. * Define the reference distance the sound should be heard perfectly.
  117125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117126. */
  117127. refDistance?: number;
  117128. /**
  117129. * Define the distance attenuation model the sound will follow.
  117130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117131. */
  117132. distanceModel?: string;
  117133. /**
  117134. * Defines the playback speed (1 by default)
  117135. */
  117136. playbackRate?: number;
  117137. /**
  117138. * Defines if the sound is from a streaming source
  117139. */
  117140. streaming?: boolean;
  117141. /**
  117142. * Defines an optional length (in seconds) inside the sound file
  117143. */
  117144. length?: number;
  117145. /**
  117146. * Defines an optional offset (in seconds) inside the sound file
  117147. */
  117148. offset?: number;
  117149. /**
  117150. * If true, URLs will not be required to state the audio file codec to use.
  117151. */
  117152. skipCodecCheck?: boolean;
  117153. }
  117154. /**
  117155. * Defines a sound that can be played in the application.
  117156. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117158. */
  117159. export class Sound {
  117160. /**
  117161. * The name of the sound in the scene.
  117162. */
  117163. name: string;
  117164. /**
  117165. * Does the sound autoplay once loaded.
  117166. */
  117167. autoplay: boolean;
  117168. /**
  117169. * Does the sound loop after it finishes playing once.
  117170. */
  117171. loop: boolean;
  117172. /**
  117173. * Does the sound use a custom attenuation curve to simulate the falloff
  117174. * happening when the source gets further away from the camera.
  117175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117176. */
  117177. useCustomAttenuation: boolean;
  117178. /**
  117179. * The sound track id this sound belongs to.
  117180. */
  117181. soundTrackId: number;
  117182. /**
  117183. * Is this sound currently played.
  117184. */
  117185. isPlaying: boolean;
  117186. /**
  117187. * Is this sound currently paused.
  117188. */
  117189. isPaused: boolean;
  117190. /**
  117191. * Does this sound enables spatial sound.
  117192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117193. */
  117194. spatialSound: boolean;
  117195. /**
  117196. * Define the reference distance the sound should be heard perfectly.
  117197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117198. */
  117199. refDistance: number;
  117200. /**
  117201. * Define the roll off factor of spatial sounds.
  117202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117203. */
  117204. rolloffFactor: number;
  117205. /**
  117206. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117208. */
  117209. maxDistance: number;
  117210. /**
  117211. * Define the distance attenuation model the sound will follow.
  117212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117213. */
  117214. distanceModel: string;
  117215. /**
  117216. * @hidden
  117217. * Back Compat
  117218. **/
  117219. onended: () => any;
  117220. /**
  117221. * Gets or sets an object used to store user defined information for the sound.
  117222. */
  117223. metadata: any;
  117224. /**
  117225. * Observable event when the current playing sound finishes.
  117226. */
  117227. onEndedObservable: Observable<Sound>;
  117228. private _panningModel;
  117229. private _playbackRate;
  117230. private _streaming;
  117231. private _startTime;
  117232. private _startOffset;
  117233. private _position;
  117234. /** @hidden */
  117235. _positionInEmitterSpace: boolean;
  117236. private _localDirection;
  117237. private _volume;
  117238. private _isReadyToPlay;
  117239. private _isDirectional;
  117240. private _readyToPlayCallback;
  117241. private _audioBuffer;
  117242. private _soundSource;
  117243. private _streamingSource;
  117244. private _soundPanner;
  117245. private _soundGain;
  117246. private _inputAudioNode;
  117247. private _outputAudioNode;
  117248. private _coneInnerAngle;
  117249. private _coneOuterAngle;
  117250. private _coneOuterGain;
  117251. private _scene;
  117252. private _connectedTransformNode;
  117253. private _customAttenuationFunction;
  117254. private _registerFunc;
  117255. private _isOutputConnected;
  117256. private _htmlAudioElement;
  117257. private _urlType;
  117258. private _length?;
  117259. private _offset?;
  117260. /** @hidden */
  117261. static _SceneComponentInitialization: (scene: Scene) => void;
  117262. /**
  117263. * Create a sound and attach it to a scene
  117264. * @param name Name of your sound
  117265. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  117266. * @param scene defines the scene the sound belongs to
  117267. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  117268. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  117269. */
  117270. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  117271. /**
  117272. * Release the sound and its associated resources
  117273. */
  117274. dispose(): void;
  117275. /**
  117276. * Gets if the sounds is ready to be played or not.
  117277. * @returns true if ready, otherwise false
  117278. */
  117279. isReady(): boolean;
  117280. private _soundLoaded;
  117281. /**
  117282. * Sets the data of the sound from an audiobuffer
  117283. * @param audioBuffer The audioBuffer containing the data
  117284. */
  117285. setAudioBuffer(audioBuffer: AudioBuffer): void;
  117286. /**
  117287. * Updates the current sounds options such as maxdistance, loop...
  117288. * @param options A JSON object containing values named as the object properties
  117289. */
  117290. updateOptions(options: ISoundOptions): void;
  117291. private _createSpatialParameters;
  117292. private _updateSpatialParameters;
  117293. /**
  117294. * Switch the panning model to HRTF:
  117295. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117297. */
  117298. switchPanningModelToHRTF(): void;
  117299. /**
  117300. * Switch the panning model to Equal Power:
  117301. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117303. */
  117304. switchPanningModelToEqualPower(): void;
  117305. private _switchPanningModel;
  117306. /**
  117307. * Connect this sound to a sound track audio node like gain...
  117308. * @param soundTrackAudioNode the sound track audio node to connect to
  117309. */
  117310. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  117311. /**
  117312. * Transform this sound into a directional source
  117313. * @param coneInnerAngle Size of the inner cone in degree
  117314. * @param coneOuterAngle Size of the outer cone in degree
  117315. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  117316. */
  117317. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  117318. /**
  117319. * Gets or sets the inner angle for the directional cone.
  117320. */
  117321. get directionalConeInnerAngle(): number;
  117322. /**
  117323. * Gets or sets the inner angle for the directional cone.
  117324. */
  117325. set directionalConeInnerAngle(value: number);
  117326. /**
  117327. * Gets or sets the outer angle for the directional cone.
  117328. */
  117329. get directionalConeOuterAngle(): number;
  117330. /**
  117331. * Gets or sets the outer angle for the directional cone.
  117332. */
  117333. set directionalConeOuterAngle(value: number);
  117334. /**
  117335. * Sets the position of the emitter if spatial sound is enabled
  117336. * @param newPosition Defines the new posisiton
  117337. */
  117338. setPosition(newPosition: Vector3): void;
  117339. /**
  117340. * Sets the local direction of the emitter if spatial sound is enabled
  117341. * @param newLocalDirection Defines the new local direction
  117342. */
  117343. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  117344. private _updateDirection;
  117345. /** @hidden */
  117346. updateDistanceFromListener(): void;
  117347. /**
  117348. * Sets a new custom attenuation function for the sound.
  117349. * @param callback Defines the function used for the attenuation
  117350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117351. */
  117352. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  117353. /**
  117354. * Play the sound
  117355. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  117356. * @param offset (optional) Start the sound at a specific time in seconds
  117357. * @param length (optional) Sound duration (in seconds)
  117358. */
  117359. play(time?: number, offset?: number, length?: number): void;
  117360. private _onended;
  117361. /**
  117362. * Stop the sound
  117363. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  117364. */
  117365. stop(time?: number): void;
  117366. /**
  117367. * Put the sound in pause
  117368. */
  117369. pause(): void;
  117370. /**
  117371. * Sets a dedicated volume for this sounds
  117372. * @param newVolume Define the new volume of the sound
  117373. * @param time Define time for gradual change to new volume
  117374. */
  117375. setVolume(newVolume: number, time?: number): void;
  117376. /**
  117377. * Set the sound play back rate
  117378. * @param newPlaybackRate Define the playback rate the sound should be played at
  117379. */
  117380. setPlaybackRate(newPlaybackRate: number): void;
  117381. /**
  117382. * Gets the volume of the sound.
  117383. * @returns the volume of the sound
  117384. */
  117385. getVolume(): number;
  117386. /**
  117387. * Attach the sound to a dedicated mesh
  117388. * @param transformNode The transform node to connect the sound with
  117389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117390. */
  117391. attachToMesh(transformNode: TransformNode): void;
  117392. /**
  117393. * Detach the sound from the previously attached mesh
  117394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117395. */
  117396. detachFromMesh(): void;
  117397. private _onRegisterAfterWorldMatrixUpdate;
  117398. /**
  117399. * Clone the current sound in the scene.
  117400. * @returns the new sound clone
  117401. */
  117402. clone(): Nullable<Sound>;
  117403. /**
  117404. * Gets the current underlying audio buffer containing the data
  117405. * @returns the audio buffer
  117406. */
  117407. getAudioBuffer(): Nullable<AudioBuffer>;
  117408. /**
  117409. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  117410. * @returns the source node
  117411. */
  117412. getSoundSource(): Nullable<AudioBufferSourceNode>;
  117413. /**
  117414. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  117415. * @returns the gain node
  117416. */
  117417. getSoundGain(): Nullable<GainNode>;
  117418. /**
  117419. * Serializes the Sound in a JSON representation
  117420. * @returns the JSON representation of the sound
  117421. */
  117422. serialize(): any;
  117423. /**
  117424. * Parse a JSON representation of a sound to innstantiate in a given scene
  117425. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  117426. * @param scene Define the scene the new parsed sound should be created in
  117427. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  117428. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  117429. * @returns the newly parsed sound
  117430. */
  117431. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  117432. }
  117433. }
  117434. declare module BABYLON {
  117435. /**
  117436. * This defines an action helpful to play a defined sound on a triggered action.
  117437. */
  117438. export class PlaySoundAction extends Action {
  117439. private _sound;
  117440. /**
  117441. * Instantiate the action
  117442. * @param triggerOptions defines the trigger options
  117443. * @param sound defines the sound to play
  117444. * @param condition defines the trigger related conditions
  117445. */
  117446. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117447. /** @hidden */
  117448. _prepare(): void;
  117449. /**
  117450. * Execute the action and play the sound.
  117451. */
  117452. execute(): void;
  117453. /**
  117454. * Serializes the actions and its related information.
  117455. * @param parent defines the object to serialize in
  117456. * @returns the serialized object
  117457. */
  117458. serialize(parent: any): any;
  117459. }
  117460. /**
  117461. * This defines an action helpful to stop a defined sound on a triggered action.
  117462. */
  117463. export class StopSoundAction extends Action {
  117464. private _sound;
  117465. /**
  117466. * Instantiate the action
  117467. * @param triggerOptions defines the trigger options
  117468. * @param sound defines the sound to stop
  117469. * @param condition defines the trigger related conditions
  117470. */
  117471. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117472. /** @hidden */
  117473. _prepare(): void;
  117474. /**
  117475. * Execute the action and stop the sound.
  117476. */
  117477. execute(): void;
  117478. /**
  117479. * Serializes the actions and its related information.
  117480. * @param parent defines the object to serialize in
  117481. * @returns the serialized object
  117482. */
  117483. serialize(parent: any): any;
  117484. }
  117485. }
  117486. declare module BABYLON {
  117487. /**
  117488. * This defines an action responsible to change the value of a property
  117489. * by interpolating between its current value and the newly set one once triggered.
  117490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  117491. */
  117492. export class InterpolateValueAction extends Action {
  117493. /**
  117494. * Defines the path of the property where the value should be interpolated
  117495. */
  117496. propertyPath: string;
  117497. /**
  117498. * Defines the target value at the end of the interpolation.
  117499. */
  117500. value: any;
  117501. /**
  117502. * Defines the time it will take for the property to interpolate to the value.
  117503. */
  117504. duration: number;
  117505. /**
  117506. * Defines if the other scene animations should be stopped when the action has been triggered
  117507. */
  117508. stopOtherAnimations?: boolean;
  117509. /**
  117510. * Defines a callback raised once the interpolation animation has been done.
  117511. */
  117512. onInterpolationDone?: () => void;
  117513. /**
  117514. * Observable triggered once the interpolation animation has been done.
  117515. */
  117516. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  117517. private _target;
  117518. private _effectiveTarget;
  117519. private _property;
  117520. /**
  117521. * Instantiate the action
  117522. * @param triggerOptions defines the trigger options
  117523. * @param target defines the object containing the value to interpolate
  117524. * @param propertyPath defines the path to the property in the target object
  117525. * @param value defines the target value at the end of the interpolation
  117526. * @param duration deines the time it will take for the property to interpolate to the value.
  117527. * @param condition defines the trigger related conditions
  117528. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  117529. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  117530. */
  117531. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  117532. /** @hidden */
  117533. _prepare(): void;
  117534. /**
  117535. * Execute the action starts the value interpolation.
  117536. */
  117537. execute(): void;
  117538. /**
  117539. * Serializes the actions and its related information.
  117540. * @param parent defines the object to serialize in
  117541. * @returns the serialized object
  117542. */
  117543. serialize(parent: any): any;
  117544. }
  117545. }
  117546. declare module BABYLON {
  117547. /**
  117548. * Options allowed during the creation of a sound track.
  117549. */
  117550. export interface ISoundTrackOptions {
  117551. /**
  117552. * The volume the sound track should take during creation
  117553. */
  117554. volume?: number;
  117555. /**
  117556. * Define if the sound track is the main sound track of the scene
  117557. */
  117558. mainTrack?: boolean;
  117559. }
  117560. /**
  117561. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  117562. * It will be also used in a future release to apply effects on a specific track.
  117563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117564. */
  117565. export class SoundTrack {
  117566. /**
  117567. * The unique identifier of the sound track in the scene.
  117568. */
  117569. id: number;
  117570. /**
  117571. * The list of sounds included in the sound track.
  117572. */
  117573. soundCollection: Array<Sound>;
  117574. private _outputAudioNode;
  117575. private _scene;
  117576. private _connectedAnalyser;
  117577. private _options;
  117578. private _isInitialized;
  117579. /**
  117580. * Creates a new sound track.
  117581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117582. * @param scene Define the scene the sound track belongs to
  117583. * @param options
  117584. */
  117585. constructor(scene: Scene, options?: ISoundTrackOptions);
  117586. private _initializeSoundTrackAudioGraph;
  117587. /**
  117588. * Release the sound track and its associated resources
  117589. */
  117590. dispose(): void;
  117591. /**
  117592. * Adds a sound to this sound track
  117593. * @param sound define the cound to add
  117594. * @ignoreNaming
  117595. */
  117596. AddSound(sound: Sound): void;
  117597. /**
  117598. * Removes a sound to this sound track
  117599. * @param sound define the cound to remove
  117600. * @ignoreNaming
  117601. */
  117602. RemoveSound(sound: Sound): void;
  117603. /**
  117604. * Set a global volume for the full sound track.
  117605. * @param newVolume Define the new volume of the sound track
  117606. */
  117607. setVolume(newVolume: number): void;
  117608. /**
  117609. * Switch the panning model to HRTF:
  117610. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117612. */
  117613. switchPanningModelToHRTF(): void;
  117614. /**
  117615. * Switch the panning model to Equal Power:
  117616. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117618. */
  117619. switchPanningModelToEqualPower(): void;
  117620. /**
  117621. * Connect the sound track to an audio analyser allowing some amazing
  117622. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117624. * @param analyser The analyser to connect to the engine
  117625. */
  117626. connectToAnalyser(analyser: Analyser): void;
  117627. }
  117628. }
  117629. declare module BABYLON {
  117630. interface AbstractScene {
  117631. /**
  117632. * The list of sounds used in the scene.
  117633. */
  117634. sounds: Nullable<Array<Sound>>;
  117635. }
  117636. interface Scene {
  117637. /**
  117638. * @hidden
  117639. * Backing field
  117640. */
  117641. _mainSoundTrack: SoundTrack;
  117642. /**
  117643. * The main sound track played by the scene.
  117644. * It cotains your primary collection of sounds.
  117645. */
  117646. mainSoundTrack: SoundTrack;
  117647. /**
  117648. * The list of sound tracks added to the scene
  117649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117650. */
  117651. soundTracks: Nullable<Array<SoundTrack>>;
  117652. /**
  117653. * Gets a sound using a given name
  117654. * @param name defines the name to search for
  117655. * @return the found sound or null if not found at all.
  117656. */
  117657. getSoundByName(name: string): Nullable<Sound>;
  117658. /**
  117659. * Gets or sets if audio support is enabled
  117660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117661. */
  117662. audioEnabled: boolean;
  117663. /**
  117664. * Gets or sets if audio will be output to headphones
  117665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117666. */
  117667. headphone: boolean;
  117668. /**
  117669. * Gets or sets custom audio listener position provider
  117670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117671. */
  117672. audioListenerPositionProvider: Nullable<() => Vector3>;
  117673. /**
  117674. * Gets or sets a refresh rate when using 3D audio positioning
  117675. */
  117676. audioPositioningRefreshRate: number;
  117677. }
  117678. /**
  117679. * Defines the sound scene component responsible to manage any sounds
  117680. * in a given scene.
  117681. */
  117682. export class AudioSceneComponent implements ISceneSerializableComponent {
  117683. /**
  117684. * The component name helpfull to identify the component in the list of scene components.
  117685. */
  117686. readonly name: string;
  117687. /**
  117688. * The scene the component belongs to.
  117689. */
  117690. scene: Scene;
  117691. private _audioEnabled;
  117692. /**
  117693. * Gets whether audio is enabled or not.
  117694. * Please use related enable/disable method to switch state.
  117695. */
  117696. get audioEnabled(): boolean;
  117697. private _headphone;
  117698. /**
  117699. * Gets whether audio is outputing to headphone or not.
  117700. * Please use the according Switch methods to change output.
  117701. */
  117702. get headphone(): boolean;
  117703. /**
  117704. * Gets or sets a refresh rate when using 3D audio positioning
  117705. */
  117706. audioPositioningRefreshRate: number;
  117707. private _audioListenerPositionProvider;
  117708. /**
  117709. * Gets the current audio listener position provider
  117710. */
  117711. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  117712. /**
  117713. * Sets a custom listener position for all sounds in the scene
  117714. * By default, this is the position of the first active camera
  117715. */
  117716. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  117717. /**
  117718. * Creates a new instance of the component for the given scene
  117719. * @param scene Defines the scene to register the component in
  117720. */
  117721. constructor(scene: Scene);
  117722. /**
  117723. * Registers the component in a given scene
  117724. */
  117725. register(): void;
  117726. /**
  117727. * Rebuilds the elements related to this component in case of
  117728. * context lost for instance.
  117729. */
  117730. rebuild(): void;
  117731. /**
  117732. * Serializes the component data to the specified json object
  117733. * @param serializationObject The object to serialize to
  117734. */
  117735. serialize(serializationObject: any): void;
  117736. /**
  117737. * Adds all the elements from the container to the scene
  117738. * @param container the container holding the elements
  117739. */
  117740. addFromContainer(container: AbstractScene): void;
  117741. /**
  117742. * Removes all the elements in the container from the scene
  117743. * @param container contains the elements to remove
  117744. * @param dispose if the removed element should be disposed (default: false)
  117745. */
  117746. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117747. /**
  117748. * Disposes the component and the associated ressources.
  117749. */
  117750. dispose(): void;
  117751. /**
  117752. * Disables audio in the associated scene.
  117753. */
  117754. disableAudio(): void;
  117755. /**
  117756. * Enables audio in the associated scene.
  117757. */
  117758. enableAudio(): void;
  117759. /**
  117760. * Switch audio to headphone output.
  117761. */
  117762. switchAudioModeForHeadphones(): void;
  117763. /**
  117764. * Switch audio to normal speakers.
  117765. */
  117766. switchAudioModeForNormalSpeakers(): void;
  117767. private _cachedCameraDirection;
  117768. private _cachedCameraPosition;
  117769. private _lastCheck;
  117770. private _afterRender;
  117771. }
  117772. }
  117773. declare module BABYLON {
  117774. /**
  117775. * Wraps one or more Sound objects and selects one with random weight for playback.
  117776. */
  117777. export class WeightedSound {
  117778. /** When true a Sound will be selected and played when the current playing Sound completes. */
  117779. loop: boolean;
  117780. private _coneInnerAngle;
  117781. private _coneOuterAngle;
  117782. private _volume;
  117783. /** A Sound is currently playing. */
  117784. isPlaying: boolean;
  117785. /** A Sound is currently paused. */
  117786. isPaused: boolean;
  117787. private _sounds;
  117788. private _weights;
  117789. private _currentIndex?;
  117790. /**
  117791. * Creates a new WeightedSound from the list of sounds given.
  117792. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  117793. * @param sounds Array of Sounds that will be selected from.
  117794. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  117795. */
  117796. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  117797. /**
  117798. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  117799. */
  117800. get directionalConeInnerAngle(): number;
  117801. /**
  117802. * The size of cone in degress for a directional sound in which there will be no attenuation.
  117803. */
  117804. set directionalConeInnerAngle(value: number);
  117805. /**
  117806. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  117807. * Listener angles between innerAngle and outerAngle will falloff linearly.
  117808. */
  117809. get directionalConeOuterAngle(): number;
  117810. /**
  117811. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  117812. * Listener angles between innerAngle and outerAngle will falloff linearly.
  117813. */
  117814. set directionalConeOuterAngle(value: number);
  117815. /**
  117816. * Playback volume.
  117817. */
  117818. get volume(): number;
  117819. /**
  117820. * Playback volume.
  117821. */
  117822. set volume(value: number);
  117823. private _onended;
  117824. /**
  117825. * Suspend playback
  117826. */
  117827. pause(): void;
  117828. /**
  117829. * Stop playback
  117830. */
  117831. stop(): void;
  117832. /**
  117833. * Start playback.
  117834. * @param startOffset Position the clip head at a specific time in seconds.
  117835. */
  117836. play(startOffset?: number): void;
  117837. }
  117838. }
  117839. declare module BABYLON {
  117840. /**
  117841. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  117842. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  117843. */
  117844. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  117845. /**
  117846. * Gets the name of the behavior.
  117847. */
  117848. get name(): string;
  117849. /**
  117850. * The easing function used by animations
  117851. */
  117852. static EasingFunction: BackEase;
  117853. /**
  117854. * The easing mode used by animations
  117855. */
  117856. static EasingMode: number;
  117857. /**
  117858. * The duration of the animation, in milliseconds
  117859. */
  117860. transitionDuration: number;
  117861. /**
  117862. * Length of the distance animated by the transition when lower radius is reached
  117863. */
  117864. lowerRadiusTransitionRange: number;
  117865. /**
  117866. * Length of the distance animated by the transition when upper radius is reached
  117867. */
  117868. upperRadiusTransitionRange: number;
  117869. private _autoTransitionRange;
  117870. /**
  117871. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  117872. */
  117873. get autoTransitionRange(): boolean;
  117874. /**
  117875. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  117876. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  117877. */
  117878. set autoTransitionRange(value: boolean);
  117879. private _attachedCamera;
  117880. private _onAfterCheckInputsObserver;
  117881. private _onMeshTargetChangedObserver;
  117882. /**
  117883. * Initializes the behavior.
  117884. */
  117885. init(): void;
  117886. /**
  117887. * Attaches the behavior to its arc rotate camera.
  117888. * @param camera Defines the camera to attach the behavior to
  117889. */
  117890. attach(camera: ArcRotateCamera): void;
  117891. /**
  117892. * Detaches the behavior from its current arc rotate camera.
  117893. */
  117894. detach(): void;
  117895. private _radiusIsAnimating;
  117896. private _radiusBounceTransition;
  117897. private _animatables;
  117898. private _cachedWheelPrecision;
  117899. /**
  117900. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  117901. * @param radiusLimit The limit to check against.
  117902. * @return Bool to indicate if at limit.
  117903. */
  117904. private _isRadiusAtLimit;
  117905. /**
  117906. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  117907. * @param radiusDelta The delta by which to animate to. Can be negative.
  117908. */
  117909. private _applyBoundRadiusAnimation;
  117910. /**
  117911. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  117912. */
  117913. protected _clearAnimationLocks(): void;
  117914. /**
  117915. * Stops and removes all animations that have been applied to the camera
  117916. */
  117917. stopAllAnimations(): void;
  117918. }
  117919. }
  117920. declare module BABYLON {
  117921. /**
  117922. * 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.
  117923. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  117924. */
  117925. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  117926. /**
  117927. * Gets the name of the behavior.
  117928. */
  117929. get name(): string;
  117930. private _mode;
  117931. private _radiusScale;
  117932. private _positionScale;
  117933. private _defaultElevation;
  117934. private _elevationReturnTime;
  117935. private _elevationReturnWaitTime;
  117936. private _zoomStopsAnimation;
  117937. private _framingTime;
  117938. /**
  117939. * The easing function used by animations
  117940. */
  117941. static EasingFunction: ExponentialEase;
  117942. /**
  117943. * The easing mode used by animations
  117944. */
  117945. static EasingMode: number;
  117946. /**
  117947. * Sets the current mode used by the behavior
  117948. */
  117949. set mode(mode: number);
  117950. /**
  117951. * Gets current mode used by the behavior.
  117952. */
  117953. get mode(): number;
  117954. /**
  117955. * Sets the scale applied to the radius (1 by default)
  117956. */
  117957. set radiusScale(radius: number);
  117958. /**
  117959. * Gets the scale applied to the radius
  117960. */
  117961. get radiusScale(): number;
  117962. /**
  117963. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  117964. */
  117965. set positionScale(scale: number);
  117966. /**
  117967. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  117968. */
  117969. get positionScale(): number;
  117970. /**
  117971. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  117972. * behaviour is triggered, in radians.
  117973. */
  117974. set defaultElevation(elevation: number);
  117975. /**
  117976. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  117977. * behaviour is triggered, in radians.
  117978. */
  117979. get defaultElevation(): number;
  117980. /**
  117981. * Sets the time (in milliseconds) taken to return to the default beta position.
  117982. * Negative value indicates camera should not return to default.
  117983. */
  117984. set elevationReturnTime(speed: number);
  117985. /**
  117986. * Gets the time (in milliseconds) taken to return to the default beta position.
  117987. * Negative value indicates camera should not return to default.
  117988. */
  117989. get elevationReturnTime(): number;
  117990. /**
  117991. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  117992. */
  117993. set elevationReturnWaitTime(time: number);
  117994. /**
  117995. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  117996. */
  117997. get elevationReturnWaitTime(): number;
  117998. /**
  117999. * Sets the flag that indicates if user zooming should stop animation.
  118000. */
  118001. set zoomStopsAnimation(flag: boolean);
  118002. /**
  118003. * Gets the flag that indicates if user zooming should stop animation.
  118004. */
  118005. get zoomStopsAnimation(): boolean;
  118006. /**
  118007. * Sets the transition time when framing the mesh, in milliseconds
  118008. */
  118009. set framingTime(time: number);
  118010. /**
  118011. * Gets the transition time when framing the mesh, in milliseconds
  118012. */
  118013. get framingTime(): number;
  118014. /**
  118015. * Define if the behavior should automatically change the configured
  118016. * camera limits and sensibilities.
  118017. */
  118018. autoCorrectCameraLimitsAndSensibility: boolean;
  118019. private _onPrePointerObservableObserver;
  118020. private _onAfterCheckInputsObserver;
  118021. private _onMeshTargetChangedObserver;
  118022. private _attachedCamera;
  118023. private _isPointerDown;
  118024. private _lastInteractionTime;
  118025. /**
  118026. * Initializes the behavior.
  118027. */
  118028. init(): void;
  118029. /**
  118030. * Attaches the behavior to its arc rotate camera.
  118031. * @param camera Defines the camera to attach the behavior to
  118032. */
  118033. attach(camera: ArcRotateCamera): void;
  118034. /**
  118035. * Detaches the behavior from its current arc rotate camera.
  118036. */
  118037. detach(): void;
  118038. private _animatables;
  118039. private _betaIsAnimating;
  118040. private _betaTransition;
  118041. private _radiusTransition;
  118042. private _vectorTransition;
  118043. /**
  118044. * Targets the given mesh and updates zoom level accordingly.
  118045. * @param mesh The mesh to target.
  118046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118048. */
  118049. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118050. /**
  118051. * Targets the given mesh with its children and updates zoom level accordingly.
  118052. * @param mesh The mesh to target.
  118053. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118054. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118055. */
  118056. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118057. /**
  118058. * Targets the given meshes with their children and updates zoom level accordingly.
  118059. * @param meshes The mesh to target.
  118060. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118061. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118062. */
  118063. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118064. /**
  118065. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118066. * @param minimumWorld Determines the smaller position of the bounding box extend
  118067. * @param maximumWorld Determines the bigger position of the bounding box extend
  118068. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118069. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118070. */
  118071. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118072. /**
  118073. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118074. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118075. * frustum width.
  118076. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118077. * to fully enclose the mesh in the viewing frustum.
  118078. */
  118079. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118080. /**
  118081. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118082. * is automatically returned to its default position (expected to be above ground plane).
  118083. */
  118084. private _maintainCameraAboveGround;
  118085. /**
  118086. * Returns the frustum slope based on the canvas ratio and camera FOV
  118087. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118088. */
  118089. private _getFrustumSlope;
  118090. /**
  118091. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118092. */
  118093. private _clearAnimationLocks;
  118094. /**
  118095. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118096. */
  118097. private _applyUserInteraction;
  118098. /**
  118099. * Stops and removes all animations that have been applied to the camera
  118100. */
  118101. stopAllAnimations(): void;
  118102. /**
  118103. * Gets a value indicating if the user is moving the camera
  118104. */
  118105. get isUserIsMoving(): boolean;
  118106. /**
  118107. * The camera can move all the way towards the mesh.
  118108. */
  118109. static IgnoreBoundsSizeMode: number;
  118110. /**
  118111. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118112. */
  118113. static FitFrustumSidesMode: number;
  118114. }
  118115. }
  118116. declare module BABYLON {
  118117. /**
  118118. * Base class for Camera Pointer Inputs.
  118119. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118120. * for example usage.
  118121. */
  118122. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118123. /**
  118124. * Defines the camera the input is attached to.
  118125. */
  118126. abstract camera: Camera;
  118127. /**
  118128. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118129. */
  118130. protected _altKey: boolean;
  118131. protected _ctrlKey: boolean;
  118132. protected _metaKey: boolean;
  118133. protected _shiftKey: boolean;
  118134. /**
  118135. * Which mouse buttons were pressed at time of last mouse event.
  118136. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118137. */
  118138. protected _buttonsPressed: number;
  118139. /**
  118140. * Defines the buttons associated with the input to handle camera move.
  118141. */
  118142. buttons: number[];
  118143. /**
  118144. * Attach the input controls to a specific dom element to get the input from.
  118145. * @param element Defines the element the controls should be listened from
  118146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118147. */
  118148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118149. /**
  118150. * Detach the current controls from the specified dom element.
  118151. * @param element Defines the element to stop listening the inputs from
  118152. */
  118153. detachControl(element: Nullable<HTMLElement>): void;
  118154. /**
  118155. * Gets the class name of the current input.
  118156. * @returns the class name
  118157. */
  118158. getClassName(): string;
  118159. /**
  118160. * Get the friendly name associated with the input class.
  118161. * @returns the input friendly name
  118162. */
  118163. getSimpleName(): string;
  118164. /**
  118165. * Called on pointer POINTERDOUBLETAP event.
  118166. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118167. */
  118168. protected onDoubleTap(type: string): void;
  118169. /**
  118170. * Called on pointer POINTERMOVE event if only a single touch is active.
  118171. * Override this method to provide functionality.
  118172. */
  118173. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118174. /**
  118175. * Called on pointer POINTERMOVE event if multiple touches are active.
  118176. * Override this method to provide functionality.
  118177. */
  118178. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118179. /**
  118180. * Called on JS contextmenu event.
  118181. * Override this method to provide functionality.
  118182. */
  118183. protected onContextMenu(evt: PointerEvent): void;
  118184. /**
  118185. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118186. * press.
  118187. * Override this method to provide functionality.
  118188. */
  118189. protected onButtonDown(evt: PointerEvent): void;
  118190. /**
  118191. * Called each time a new POINTERUP event occurs. Ie, for each button
  118192. * release.
  118193. * Override this method to provide functionality.
  118194. */
  118195. protected onButtonUp(evt: PointerEvent): void;
  118196. /**
  118197. * Called when window becomes inactive.
  118198. * Override this method to provide functionality.
  118199. */
  118200. protected onLostFocus(): void;
  118201. private _pointerInput;
  118202. private _observer;
  118203. private _onLostFocus;
  118204. private pointA;
  118205. private pointB;
  118206. }
  118207. }
  118208. declare module BABYLON {
  118209. /**
  118210. * Manage the pointers inputs to control an arc rotate camera.
  118211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118212. */
  118213. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118214. /**
  118215. * Defines the camera the input is attached to.
  118216. */
  118217. camera: ArcRotateCamera;
  118218. /**
  118219. * Gets the class name of the current input.
  118220. * @returns the class name
  118221. */
  118222. getClassName(): string;
  118223. /**
  118224. * Defines the buttons associated with the input to handle camera move.
  118225. */
  118226. buttons: number[];
  118227. /**
  118228. * Defines the pointer angular sensibility along the X axis or how fast is
  118229. * the camera rotating.
  118230. */
  118231. angularSensibilityX: number;
  118232. /**
  118233. * Defines the pointer angular sensibility along the Y axis or how fast is
  118234. * the camera rotating.
  118235. */
  118236. angularSensibilityY: number;
  118237. /**
  118238. * Defines the pointer pinch precision or how fast is the camera zooming.
  118239. */
  118240. pinchPrecision: number;
  118241. /**
  118242. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  118243. * from 0.
  118244. * It defines the percentage of current camera.radius to use as delta when
  118245. * pinch zoom is used.
  118246. */
  118247. pinchDeltaPercentage: number;
  118248. /**
  118249. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118250. * that any object in the plane at the camera's target point will scale
  118251. * perfectly with finger motion.
  118252. * Overrides pinchDeltaPercentage and pinchPrecision.
  118253. */
  118254. useNaturalPinchZoom: boolean;
  118255. /**
  118256. * Defines the pointer panning sensibility or how fast is the camera moving.
  118257. */
  118258. panningSensibility: number;
  118259. /**
  118260. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  118261. */
  118262. multiTouchPanning: boolean;
  118263. /**
  118264. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  118265. * zoom (pinch) through multitouch.
  118266. */
  118267. multiTouchPanAndZoom: boolean;
  118268. /**
  118269. * Revers pinch action direction.
  118270. */
  118271. pinchInwards: boolean;
  118272. private _isPanClick;
  118273. private _twoFingerActivityCount;
  118274. private _isPinching;
  118275. /**
  118276. * Called on pointer POINTERMOVE event if only a single touch is active.
  118277. */
  118278. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118279. /**
  118280. * Called on pointer POINTERDOUBLETAP event.
  118281. */
  118282. protected onDoubleTap(type: string): void;
  118283. /**
  118284. * Called on pointer POINTERMOVE event if multiple touches are active.
  118285. */
  118286. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118287. /**
  118288. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118289. * press.
  118290. */
  118291. protected onButtonDown(evt: PointerEvent): void;
  118292. /**
  118293. * Called each time a new POINTERUP event occurs. Ie, for each button
  118294. * release.
  118295. */
  118296. protected onButtonUp(evt: PointerEvent): void;
  118297. /**
  118298. * Called when window becomes inactive.
  118299. */
  118300. protected onLostFocus(): void;
  118301. }
  118302. }
  118303. declare module BABYLON {
  118304. /**
  118305. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  118306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118307. */
  118308. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  118309. /**
  118310. * Defines the camera the input is attached to.
  118311. */
  118312. camera: ArcRotateCamera;
  118313. /**
  118314. * Defines the list of key codes associated with the up action (increase alpha)
  118315. */
  118316. keysUp: number[];
  118317. /**
  118318. * Defines the list of key codes associated with the down action (decrease alpha)
  118319. */
  118320. keysDown: number[];
  118321. /**
  118322. * Defines the list of key codes associated with the left action (increase beta)
  118323. */
  118324. keysLeft: number[];
  118325. /**
  118326. * Defines the list of key codes associated with the right action (decrease beta)
  118327. */
  118328. keysRight: number[];
  118329. /**
  118330. * Defines the list of key codes associated with the reset action.
  118331. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  118332. */
  118333. keysReset: number[];
  118334. /**
  118335. * Defines the panning sensibility of the inputs.
  118336. * (How fast is the camera panning)
  118337. */
  118338. panningSensibility: number;
  118339. /**
  118340. * Defines the zooming sensibility of the inputs.
  118341. * (How fast is the camera zooming)
  118342. */
  118343. zoomingSensibility: number;
  118344. /**
  118345. * Defines whether maintaining the alt key down switch the movement mode from
  118346. * orientation to zoom.
  118347. */
  118348. useAltToZoom: boolean;
  118349. /**
  118350. * Rotation speed of the camera
  118351. */
  118352. angularSpeed: number;
  118353. private _keys;
  118354. private _ctrlPressed;
  118355. private _altPressed;
  118356. private _onCanvasBlurObserver;
  118357. private _onKeyboardObserver;
  118358. private _engine;
  118359. private _scene;
  118360. /**
  118361. * Attach the input controls to a specific dom element to get the input from.
  118362. * @param element Defines the element the controls should be listened from
  118363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118364. */
  118365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118366. /**
  118367. * Detach the current controls from the specified dom element.
  118368. * @param element Defines the element to stop listening the inputs from
  118369. */
  118370. detachControl(element: Nullable<HTMLElement>): void;
  118371. /**
  118372. * Update the current camera state depending on the inputs that have been used this frame.
  118373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  118374. */
  118375. checkInputs(): void;
  118376. /**
  118377. * Gets the class name of the current intput.
  118378. * @returns the class name
  118379. */
  118380. getClassName(): string;
  118381. /**
  118382. * Get the friendly name associated with the input class.
  118383. * @returns the input friendly name
  118384. */
  118385. getSimpleName(): string;
  118386. }
  118387. }
  118388. declare module BABYLON {
  118389. /**
  118390. * Manage the mouse wheel inputs to control an arc rotate camera.
  118391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118392. */
  118393. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  118394. /**
  118395. * Defines the camera the input is attached to.
  118396. */
  118397. camera: ArcRotateCamera;
  118398. /**
  118399. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118400. */
  118401. wheelPrecision: number;
  118402. /**
  118403. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  118404. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  118405. */
  118406. wheelDeltaPercentage: number;
  118407. private _wheel;
  118408. private _observer;
  118409. private computeDeltaFromMouseWheelLegacyEvent;
  118410. /**
  118411. * Attach the input controls to a specific dom element to get the input from.
  118412. * @param element Defines the element the controls should be listened from
  118413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118414. */
  118415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118416. /**
  118417. * Detach the current controls from the specified dom element.
  118418. * @param element Defines the element to stop listening the inputs from
  118419. */
  118420. detachControl(element: Nullable<HTMLElement>): void;
  118421. /**
  118422. * Gets the class name of the current intput.
  118423. * @returns the class name
  118424. */
  118425. getClassName(): string;
  118426. /**
  118427. * Get the friendly name associated with the input class.
  118428. * @returns the input friendly name
  118429. */
  118430. getSimpleName(): string;
  118431. }
  118432. }
  118433. declare module BABYLON {
  118434. /**
  118435. * Default Inputs manager for the ArcRotateCamera.
  118436. * It groups all the default supported inputs for ease of use.
  118437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118438. */
  118439. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  118440. /**
  118441. * Instantiates a new ArcRotateCameraInputsManager.
  118442. * @param camera Defines the camera the inputs belong to
  118443. */
  118444. constructor(camera: ArcRotateCamera);
  118445. /**
  118446. * Add mouse wheel input support to the input manager.
  118447. * @returns the current input manager
  118448. */
  118449. addMouseWheel(): ArcRotateCameraInputsManager;
  118450. /**
  118451. * Add pointers input support to the input manager.
  118452. * @returns the current input manager
  118453. */
  118454. addPointers(): ArcRotateCameraInputsManager;
  118455. /**
  118456. * Add keyboard input support to the input manager.
  118457. * @returns the current input manager
  118458. */
  118459. addKeyboard(): ArcRotateCameraInputsManager;
  118460. }
  118461. }
  118462. declare module BABYLON {
  118463. /**
  118464. * This represents an orbital type of camera.
  118465. *
  118466. * 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.
  118467. * 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.
  118468. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  118469. */
  118470. export class ArcRotateCamera extends TargetCamera {
  118471. /**
  118472. * Defines the rotation angle of the camera along the longitudinal axis.
  118473. */
  118474. alpha: number;
  118475. /**
  118476. * Defines the rotation angle of the camera along the latitudinal axis.
  118477. */
  118478. beta: number;
  118479. /**
  118480. * Defines the radius of the camera from it s target point.
  118481. */
  118482. radius: number;
  118483. protected _target: Vector3;
  118484. protected _targetHost: Nullable<AbstractMesh>;
  118485. /**
  118486. * Defines the target point of the camera.
  118487. * The camera looks towards it form the radius distance.
  118488. */
  118489. get target(): Vector3;
  118490. set target(value: Vector3);
  118491. /**
  118492. * Define the current local position of the camera in the scene
  118493. */
  118494. get position(): Vector3;
  118495. set position(newPosition: Vector3);
  118496. protected _upVector: Vector3;
  118497. protected _upToYMatrix: Matrix;
  118498. protected _YToUpMatrix: Matrix;
  118499. /**
  118500. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  118501. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  118502. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  118503. */
  118504. set upVector(vec: Vector3);
  118505. get upVector(): Vector3;
  118506. /**
  118507. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  118508. */
  118509. setMatUp(): void;
  118510. /**
  118511. * Current inertia value on the longitudinal axis.
  118512. * The bigger this number the longer it will take for the camera to stop.
  118513. */
  118514. inertialAlphaOffset: number;
  118515. /**
  118516. * Current inertia value on the latitudinal axis.
  118517. * The bigger this number the longer it will take for the camera to stop.
  118518. */
  118519. inertialBetaOffset: number;
  118520. /**
  118521. * Current inertia value on the radius axis.
  118522. * The bigger this number the longer it will take for the camera to stop.
  118523. */
  118524. inertialRadiusOffset: number;
  118525. /**
  118526. * Minimum allowed angle on the longitudinal axis.
  118527. * This can help limiting how the Camera is able to move in the scene.
  118528. */
  118529. lowerAlphaLimit: Nullable<number>;
  118530. /**
  118531. * Maximum allowed angle on the longitudinal axis.
  118532. * This can help limiting how the Camera is able to move in the scene.
  118533. */
  118534. upperAlphaLimit: Nullable<number>;
  118535. /**
  118536. * Minimum allowed angle on the latitudinal axis.
  118537. * This can help limiting how the Camera is able to move in the scene.
  118538. */
  118539. lowerBetaLimit: number;
  118540. /**
  118541. * Maximum allowed angle on the latitudinal axis.
  118542. * This can help limiting how the Camera is able to move in the scene.
  118543. */
  118544. upperBetaLimit: number;
  118545. /**
  118546. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  118547. * This can help limiting how the Camera is able to move in the scene.
  118548. */
  118549. lowerRadiusLimit: Nullable<number>;
  118550. /**
  118551. * Maximum allowed distance of the camera to the target (The camera can not get further).
  118552. * This can help limiting how the Camera is able to move in the scene.
  118553. */
  118554. upperRadiusLimit: Nullable<number>;
  118555. /**
  118556. * Defines the current inertia value used during panning of the camera along the X axis.
  118557. */
  118558. inertialPanningX: number;
  118559. /**
  118560. * Defines the current inertia value used during panning of the camera along the Y axis.
  118561. */
  118562. inertialPanningY: number;
  118563. /**
  118564. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  118565. * Basically if your fingers moves away from more than this distance you will be considered
  118566. * in pinch mode.
  118567. */
  118568. pinchToPanMaxDistance: number;
  118569. /**
  118570. * Defines the maximum distance the camera can pan.
  118571. * This could help keeping the cammera always in your scene.
  118572. */
  118573. panningDistanceLimit: Nullable<number>;
  118574. /**
  118575. * Defines the target of the camera before paning.
  118576. */
  118577. panningOriginTarget: Vector3;
  118578. /**
  118579. * Defines the value of the inertia used during panning.
  118580. * 0 would mean stop inertia and one would mean no decelleration at all.
  118581. */
  118582. panningInertia: number;
  118583. /**
  118584. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  118585. */
  118586. get angularSensibilityX(): number;
  118587. set angularSensibilityX(value: number);
  118588. /**
  118589. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  118590. */
  118591. get angularSensibilityY(): number;
  118592. set angularSensibilityY(value: number);
  118593. /**
  118594. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  118595. */
  118596. get pinchPrecision(): number;
  118597. set pinchPrecision(value: number);
  118598. /**
  118599. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  118600. * It will be used instead of pinchDeltaPrecision if different from 0.
  118601. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118602. */
  118603. get pinchDeltaPercentage(): number;
  118604. set pinchDeltaPercentage(value: number);
  118605. /**
  118606. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  118607. * and pinch delta percentage.
  118608. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118609. * that any object in the plane at the camera's target point will scale
  118610. * perfectly with finger motion.
  118611. */
  118612. get useNaturalPinchZoom(): boolean;
  118613. set useNaturalPinchZoom(value: boolean);
  118614. /**
  118615. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  118616. */
  118617. get panningSensibility(): number;
  118618. set panningSensibility(value: number);
  118619. /**
  118620. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  118621. */
  118622. get keysUp(): number[];
  118623. set keysUp(value: number[]);
  118624. /**
  118625. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  118626. */
  118627. get keysDown(): number[];
  118628. set keysDown(value: number[]);
  118629. /**
  118630. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  118631. */
  118632. get keysLeft(): number[];
  118633. set keysLeft(value: number[]);
  118634. /**
  118635. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  118636. */
  118637. get keysRight(): number[];
  118638. set keysRight(value: number[]);
  118639. /**
  118640. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118641. */
  118642. get wheelPrecision(): number;
  118643. set wheelPrecision(value: number);
  118644. /**
  118645. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  118646. * It will be used instead of pinchDeltaPrecision if different from 0.
  118647. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118648. */
  118649. get wheelDeltaPercentage(): number;
  118650. set wheelDeltaPercentage(value: number);
  118651. /**
  118652. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  118653. */
  118654. zoomOnFactor: number;
  118655. /**
  118656. * Defines a screen offset for the camera position.
  118657. */
  118658. targetScreenOffset: Vector2;
  118659. /**
  118660. * Allows the camera to be completely reversed.
  118661. * If false the camera can not arrive upside down.
  118662. */
  118663. allowUpsideDown: boolean;
  118664. /**
  118665. * Define if double tap/click is used to restore the previously saved state of the camera.
  118666. */
  118667. useInputToRestoreState: boolean;
  118668. /** @hidden */
  118669. _viewMatrix: Matrix;
  118670. /** @hidden */
  118671. _useCtrlForPanning: boolean;
  118672. /** @hidden */
  118673. _panningMouseButton: number;
  118674. /**
  118675. * Defines the input associated to the camera.
  118676. */
  118677. inputs: ArcRotateCameraInputsManager;
  118678. /** @hidden */
  118679. _reset: () => void;
  118680. /**
  118681. * Defines the allowed panning axis.
  118682. */
  118683. panningAxis: Vector3;
  118684. protected _localDirection: Vector3;
  118685. protected _transformedDirection: Vector3;
  118686. private _bouncingBehavior;
  118687. /**
  118688. * Gets the bouncing behavior of the camera if it has been enabled.
  118689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118690. */
  118691. get bouncingBehavior(): Nullable<BouncingBehavior>;
  118692. /**
  118693. * Defines if the bouncing behavior of the camera is enabled on the camera.
  118694. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118695. */
  118696. get useBouncingBehavior(): boolean;
  118697. set useBouncingBehavior(value: boolean);
  118698. private _framingBehavior;
  118699. /**
  118700. * Gets the framing behavior of the camera if it has been enabled.
  118701. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118702. */
  118703. get framingBehavior(): Nullable<FramingBehavior>;
  118704. /**
  118705. * Defines if the framing behavior of the camera is enabled on the camera.
  118706. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118707. */
  118708. get useFramingBehavior(): boolean;
  118709. set useFramingBehavior(value: boolean);
  118710. private _autoRotationBehavior;
  118711. /**
  118712. * Gets the auto rotation behavior of the camera if it has been enabled.
  118713. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  118714. */
  118715. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  118716. /**
  118717. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  118718. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  118719. */
  118720. get useAutoRotationBehavior(): boolean;
  118721. set useAutoRotationBehavior(value: boolean);
  118722. /**
  118723. * Observable triggered when the mesh target has been changed on the camera.
  118724. */
  118725. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  118726. /**
  118727. * Event raised when the camera is colliding with a mesh.
  118728. */
  118729. onCollide: (collidedMesh: AbstractMesh) => void;
  118730. /**
  118731. * Defines whether the camera should check collision with the objects oh the scene.
  118732. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  118733. */
  118734. checkCollisions: boolean;
  118735. /**
  118736. * Defines the collision radius of the camera.
  118737. * This simulates a sphere around the camera.
  118738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  118739. */
  118740. collisionRadius: Vector3;
  118741. protected _collider: Collider;
  118742. protected _previousPosition: Vector3;
  118743. protected _collisionVelocity: Vector3;
  118744. protected _newPosition: Vector3;
  118745. protected _previousAlpha: number;
  118746. protected _previousBeta: number;
  118747. protected _previousRadius: number;
  118748. protected _collisionTriggered: boolean;
  118749. protected _targetBoundingCenter: Nullable<Vector3>;
  118750. private _computationVector;
  118751. /**
  118752. * Instantiates a new ArcRotateCamera in a given scene
  118753. * @param name Defines the name of the camera
  118754. * @param alpha Defines the camera rotation along the logitudinal axis
  118755. * @param beta Defines the camera rotation along the latitudinal axis
  118756. * @param radius Defines the camera distance from its target
  118757. * @param target Defines the camera target
  118758. * @param scene Defines the scene the camera belongs to
  118759. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  118760. */
  118761. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118762. /** @hidden */
  118763. _initCache(): void;
  118764. /** @hidden */
  118765. _updateCache(ignoreParentClass?: boolean): void;
  118766. protected _getTargetPosition(): Vector3;
  118767. private _storedAlpha;
  118768. private _storedBeta;
  118769. private _storedRadius;
  118770. private _storedTarget;
  118771. private _storedTargetScreenOffset;
  118772. /**
  118773. * Stores the current state of the camera (alpha, beta, radius and target)
  118774. * @returns the camera itself
  118775. */
  118776. storeState(): Camera;
  118777. /**
  118778. * @hidden
  118779. * Restored camera state. You must call storeState() first
  118780. */
  118781. _restoreStateValues(): boolean;
  118782. /** @hidden */
  118783. _isSynchronizedViewMatrix(): boolean;
  118784. /**
  118785. * Attached controls to the current camera.
  118786. * @param element Defines the element the controls should be listened from
  118787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118788. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  118789. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  118790. */
  118791. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  118792. /**
  118793. * Detach the current controls from the camera.
  118794. * The camera will stop reacting to inputs.
  118795. * @param element Defines the element to stop listening the inputs from
  118796. */
  118797. detachControl(element: HTMLElement): void;
  118798. /** @hidden */
  118799. _checkInputs(): void;
  118800. protected _checkLimits(): void;
  118801. /**
  118802. * Rebuilds angles (alpha, beta) and radius from the give position and target
  118803. */
  118804. rebuildAnglesAndRadius(): void;
  118805. /**
  118806. * Use a position to define the current camera related information like alpha, beta and radius
  118807. * @param position Defines the position to set the camera at
  118808. */
  118809. setPosition(position: Vector3): void;
  118810. /**
  118811. * Defines the target the camera should look at.
  118812. * This will automatically adapt alpha beta and radius to fit within the new target.
  118813. * @param target Defines the new target as a Vector or a mesh
  118814. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  118815. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  118816. */
  118817. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  118818. /** @hidden */
  118819. _getViewMatrix(): Matrix;
  118820. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  118821. /**
  118822. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  118823. * @param meshes Defines the mesh to zoom on
  118824. * @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)
  118825. */
  118826. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  118827. /**
  118828. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  118829. * The target will be changed but the radius
  118830. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  118831. * @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)
  118832. */
  118833. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  118834. min: Vector3;
  118835. max: Vector3;
  118836. distance: number;
  118837. }, doNotUpdateMaxZ?: boolean): void;
  118838. /**
  118839. * @override
  118840. * Override Camera.createRigCamera
  118841. */
  118842. createRigCamera(name: string, cameraIndex: number): Camera;
  118843. /**
  118844. * @hidden
  118845. * @override
  118846. * Override Camera._updateRigCameras
  118847. */
  118848. _updateRigCameras(): void;
  118849. /**
  118850. * Destroy the camera and release the current resources hold by it.
  118851. */
  118852. dispose(): void;
  118853. /**
  118854. * Gets the current object class name.
  118855. * @return the class name
  118856. */
  118857. getClassName(): string;
  118858. }
  118859. }
  118860. declare module BABYLON {
  118861. /**
  118862. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  118863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  118864. */
  118865. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  118866. /**
  118867. * Gets the name of the behavior.
  118868. */
  118869. get name(): string;
  118870. private _zoomStopsAnimation;
  118871. private _idleRotationSpeed;
  118872. private _idleRotationWaitTime;
  118873. private _idleRotationSpinupTime;
  118874. /**
  118875. * Sets the flag that indicates if user zooming should stop animation.
  118876. */
  118877. set zoomStopsAnimation(flag: boolean);
  118878. /**
  118879. * Gets the flag that indicates if user zooming should stop animation.
  118880. */
  118881. get zoomStopsAnimation(): boolean;
  118882. /**
  118883. * Sets the default speed at which the camera rotates around the model.
  118884. */
  118885. set idleRotationSpeed(speed: number);
  118886. /**
  118887. * Gets the default speed at which the camera rotates around the model.
  118888. */
  118889. get idleRotationSpeed(): number;
  118890. /**
  118891. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  118892. */
  118893. set idleRotationWaitTime(time: number);
  118894. /**
  118895. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  118896. */
  118897. get idleRotationWaitTime(): number;
  118898. /**
  118899. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  118900. */
  118901. set idleRotationSpinupTime(time: number);
  118902. /**
  118903. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  118904. */
  118905. get idleRotationSpinupTime(): number;
  118906. /**
  118907. * Gets a value indicating if the camera is currently rotating because of this behavior
  118908. */
  118909. get rotationInProgress(): boolean;
  118910. private _onPrePointerObservableObserver;
  118911. private _onAfterCheckInputsObserver;
  118912. private _attachedCamera;
  118913. private _isPointerDown;
  118914. private _lastFrameTime;
  118915. private _lastInteractionTime;
  118916. private _cameraRotationSpeed;
  118917. /**
  118918. * Initializes the behavior.
  118919. */
  118920. init(): void;
  118921. /**
  118922. * Attaches the behavior to its arc rotate camera.
  118923. * @param camera Defines the camera to attach the behavior to
  118924. */
  118925. attach(camera: ArcRotateCamera): void;
  118926. /**
  118927. * Detaches the behavior from its current arc rotate camera.
  118928. */
  118929. detach(): void;
  118930. /**
  118931. * Returns true if user is scrolling.
  118932. * @return true if user is scrolling.
  118933. */
  118934. private _userIsZooming;
  118935. private _lastFrameRadius;
  118936. private _shouldAnimationStopForInteraction;
  118937. /**
  118938. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118939. */
  118940. private _applyUserInteraction;
  118941. private _userIsMoving;
  118942. }
  118943. }
  118944. declare module BABYLON {
  118945. /**
  118946. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  118947. */
  118948. export class AttachToBoxBehavior implements Behavior<Mesh> {
  118949. private ui;
  118950. /**
  118951. * The name of the behavior
  118952. */
  118953. name: string;
  118954. /**
  118955. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  118956. */
  118957. distanceAwayFromFace: number;
  118958. /**
  118959. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  118960. */
  118961. distanceAwayFromBottomOfFace: number;
  118962. private _faceVectors;
  118963. private _target;
  118964. private _scene;
  118965. private _onRenderObserver;
  118966. private _tmpMatrix;
  118967. private _tmpVector;
  118968. /**
  118969. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  118970. * @param ui The transform node that should be attched to the mesh
  118971. */
  118972. constructor(ui: TransformNode);
  118973. /**
  118974. * Initializes the behavior
  118975. */
  118976. init(): void;
  118977. private _closestFace;
  118978. private _zeroVector;
  118979. private _lookAtTmpMatrix;
  118980. private _lookAtToRef;
  118981. /**
  118982. * Attaches the AttachToBoxBehavior to the passed in mesh
  118983. * @param target The mesh that the specified node will be attached to
  118984. */
  118985. attach(target: Mesh): void;
  118986. /**
  118987. * Detaches the behavior from the mesh
  118988. */
  118989. detach(): void;
  118990. }
  118991. }
  118992. declare module BABYLON {
  118993. /**
  118994. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  118995. */
  118996. export class FadeInOutBehavior implements Behavior<Mesh> {
  118997. /**
  118998. * Time in milliseconds to delay before fading in (Default: 0)
  118999. */
  119000. delay: number;
  119001. /**
  119002. * Time in milliseconds for the mesh to fade in (Default: 300)
  119003. */
  119004. fadeInTime: number;
  119005. private _millisecondsPerFrame;
  119006. private _hovered;
  119007. private _hoverValue;
  119008. private _ownerNode;
  119009. /**
  119010. * Instatiates the FadeInOutBehavior
  119011. */
  119012. constructor();
  119013. /**
  119014. * The name of the behavior
  119015. */
  119016. get name(): string;
  119017. /**
  119018. * Initializes the behavior
  119019. */
  119020. init(): void;
  119021. /**
  119022. * Attaches the fade behavior on the passed in mesh
  119023. * @param ownerNode The mesh that will be faded in/out once attached
  119024. */
  119025. attach(ownerNode: Mesh): void;
  119026. /**
  119027. * Detaches the behavior from the mesh
  119028. */
  119029. detach(): void;
  119030. /**
  119031. * Triggers the mesh to begin fading in or out
  119032. * @param value if the object should fade in or out (true to fade in)
  119033. */
  119034. fadeIn(value: boolean): void;
  119035. private _update;
  119036. private _setAllVisibility;
  119037. }
  119038. }
  119039. declare module BABYLON {
  119040. /**
  119041. * Class containing a set of static utilities functions for managing Pivots
  119042. * @hidden
  119043. */
  119044. export class PivotTools {
  119045. private static _PivotCached;
  119046. private static _OldPivotPoint;
  119047. private static _PivotTranslation;
  119048. private static _PivotTmpVector;
  119049. /** @hidden */
  119050. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119051. /** @hidden */
  119052. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119053. }
  119054. }
  119055. declare module BABYLON {
  119056. /**
  119057. * Class containing static functions to help procedurally build meshes
  119058. */
  119059. export class PlaneBuilder {
  119060. /**
  119061. * Creates a plane mesh
  119062. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119063. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119064. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119068. * @param name defines the name of the mesh
  119069. * @param options defines the options used to create the mesh
  119070. * @param scene defines the hosting scene
  119071. * @returns the plane mesh
  119072. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119073. */
  119074. static CreatePlane(name: string, options: {
  119075. size?: number;
  119076. width?: number;
  119077. height?: number;
  119078. sideOrientation?: number;
  119079. frontUVs?: Vector4;
  119080. backUVs?: Vector4;
  119081. updatable?: boolean;
  119082. sourcePlane?: Plane;
  119083. }, scene?: Nullable<Scene>): Mesh;
  119084. }
  119085. }
  119086. declare module BABYLON {
  119087. /**
  119088. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119089. */
  119090. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119091. private static _AnyMouseID;
  119092. /**
  119093. * Abstract mesh the behavior is set on
  119094. */
  119095. attachedNode: AbstractMesh;
  119096. private _dragPlane;
  119097. private _scene;
  119098. private _pointerObserver;
  119099. private _beforeRenderObserver;
  119100. private static _planeScene;
  119101. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119102. /**
  119103. * 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)
  119104. */
  119105. maxDragAngle: number;
  119106. /**
  119107. * @hidden
  119108. */
  119109. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119110. /**
  119111. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119112. */
  119113. currentDraggingPointerID: number;
  119114. /**
  119115. * The last position where the pointer hit the drag plane in world space
  119116. */
  119117. lastDragPosition: Vector3;
  119118. /**
  119119. * If the behavior is currently in a dragging state
  119120. */
  119121. dragging: boolean;
  119122. /**
  119123. * 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)
  119124. */
  119125. dragDeltaRatio: number;
  119126. /**
  119127. * If the drag plane orientation should be updated during the dragging (Default: true)
  119128. */
  119129. updateDragPlane: boolean;
  119130. private _debugMode;
  119131. private _moving;
  119132. /**
  119133. * Fires each time the attached mesh is dragged with the pointer
  119134. * * delta between last drag position and current drag position in world space
  119135. * * dragDistance along the drag axis
  119136. * * dragPlaneNormal normal of the current drag plane used during the drag
  119137. * * dragPlanePoint in world space where the drag intersects the drag plane
  119138. */
  119139. onDragObservable: Observable<{
  119140. delta: Vector3;
  119141. dragPlanePoint: Vector3;
  119142. dragPlaneNormal: Vector3;
  119143. dragDistance: number;
  119144. pointerId: number;
  119145. }>;
  119146. /**
  119147. * Fires each time a drag begins (eg. mouse down on mesh)
  119148. */
  119149. onDragStartObservable: Observable<{
  119150. dragPlanePoint: Vector3;
  119151. pointerId: number;
  119152. }>;
  119153. /**
  119154. * Fires each time a drag ends (eg. mouse release after drag)
  119155. */
  119156. onDragEndObservable: Observable<{
  119157. dragPlanePoint: Vector3;
  119158. pointerId: number;
  119159. }>;
  119160. /**
  119161. * If the attached mesh should be moved when dragged
  119162. */
  119163. moveAttached: boolean;
  119164. /**
  119165. * If the drag behavior will react to drag events (Default: true)
  119166. */
  119167. enabled: boolean;
  119168. /**
  119169. * If pointer events should start and release the drag (Default: true)
  119170. */
  119171. startAndReleaseDragOnPointerEvents: boolean;
  119172. /**
  119173. * If camera controls should be detached during the drag
  119174. */
  119175. detachCameraControls: boolean;
  119176. /**
  119177. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119178. */
  119179. useObjectOrientationForDragging: boolean;
  119180. private _options;
  119181. /**
  119182. * Gets the options used by the behavior
  119183. */
  119184. get options(): {
  119185. dragAxis?: Vector3;
  119186. dragPlaneNormal?: Vector3;
  119187. };
  119188. /**
  119189. * Sets the options used by the behavior
  119190. */
  119191. set options(options: {
  119192. dragAxis?: Vector3;
  119193. dragPlaneNormal?: Vector3;
  119194. });
  119195. /**
  119196. * Creates a pointer drag behavior that can be attached to a mesh
  119197. * @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)
  119198. */
  119199. constructor(options?: {
  119200. dragAxis?: Vector3;
  119201. dragPlaneNormal?: Vector3;
  119202. });
  119203. /**
  119204. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119205. */
  119206. validateDrag: (targetPosition: Vector3) => boolean;
  119207. /**
  119208. * The name of the behavior
  119209. */
  119210. get name(): string;
  119211. /**
  119212. * Initializes the behavior
  119213. */
  119214. init(): void;
  119215. private _tmpVector;
  119216. private _alternatePickedPoint;
  119217. private _worldDragAxis;
  119218. private _targetPosition;
  119219. private _attachedElement;
  119220. /**
  119221. * Attaches the drag behavior the passed in mesh
  119222. * @param ownerNode The mesh that will be dragged around once attached
  119223. * @param predicate Predicate to use for pick filtering
  119224. */
  119225. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119226. /**
  119227. * Force relase the drag action by code.
  119228. */
  119229. releaseDrag(): void;
  119230. private _startDragRay;
  119231. private _lastPointerRay;
  119232. /**
  119233. * Simulates the start of a pointer drag event on the behavior
  119234. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  119235. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  119236. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  119237. */
  119238. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  119239. private _startDrag;
  119240. private _dragDelta;
  119241. private _moveDrag;
  119242. private _pickWithRayOnDragPlane;
  119243. private _pointA;
  119244. private _pointB;
  119245. private _pointC;
  119246. private _lineA;
  119247. private _lineB;
  119248. private _localAxis;
  119249. private _lookAt;
  119250. private _updateDragPlanePosition;
  119251. /**
  119252. * Detaches the behavior from the mesh
  119253. */
  119254. detach(): void;
  119255. }
  119256. }
  119257. declare module BABYLON {
  119258. /**
  119259. * A behavior that when attached to a mesh will allow the mesh to be scaled
  119260. */
  119261. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  119262. private _dragBehaviorA;
  119263. private _dragBehaviorB;
  119264. private _startDistance;
  119265. private _initialScale;
  119266. private _targetScale;
  119267. private _ownerNode;
  119268. private _sceneRenderObserver;
  119269. /**
  119270. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  119271. */
  119272. constructor();
  119273. /**
  119274. * The name of the behavior
  119275. */
  119276. get name(): string;
  119277. /**
  119278. * Initializes the behavior
  119279. */
  119280. init(): void;
  119281. private _getCurrentDistance;
  119282. /**
  119283. * Attaches the scale behavior the passed in mesh
  119284. * @param ownerNode The mesh that will be scaled around once attached
  119285. */
  119286. attach(ownerNode: Mesh): void;
  119287. /**
  119288. * Detaches the behavior from the mesh
  119289. */
  119290. detach(): void;
  119291. }
  119292. }
  119293. declare module BABYLON {
  119294. /**
  119295. * 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
  119296. */
  119297. export class SixDofDragBehavior implements Behavior<Mesh> {
  119298. private static _virtualScene;
  119299. private _ownerNode;
  119300. private _sceneRenderObserver;
  119301. private _scene;
  119302. private _targetPosition;
  119303. private _virtualOriginMesh;
  119304. private _virtualDragMesh;
  119305. private _pointerObserver;
  119306. private _moving;
  119307. private _startingOrientation;
  119308. private _attachedElement;
  119309. /**
  119310. * 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)
  119311. */
  119312. private zDragFactor;
  119313. /**
  119314. * If the object should rotate to face the drag origin
  119315. */
  119316. rotateDraggedObject: boolean;
  119317. /**
  119318. * If the behavior is currently in a dragging state
  119319. */
  119320. dragging: boolean;
  119321. /**
  119322. * 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)
  119323. */
  119324. dragDeltaRatio: number;
  119325. /**
  119326. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119327. */
  119328. currentDraggingPointerID: number;
  119329. /**
  119330. * If camera controls should be detached during the drag
  119331. */
  119332. detachCameraControls: boolean;
  119333. /**
  119334. * Fires each time a drag starts
  119335. */
  119336. onDragStartObservable: Observable<{}>;
  119337. /**
  119338. * Fires each time a drag ends (eg. mouse release after drag)
  119339. */
  119340. onDragEndObservable: Observable<{}>;
  119341. /**
  119342. * 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
  119343. */
  119344. constructor();
  119345. /**
  119346. * The name of the behavior
  119347. */
  119348. get name(): string;
  119349. /**
  119350. * Initializes the behavior
  119351. */
  119352. init(): void;
  119353. /**
  119354. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  119355. */
  119356. private get _pointerCamera();
  119357. /**
  119358. * Attaches the scale behavior the passed in mesh
  119359. * @param ownerNode The mesh that will be scaled around once attached
  119360. */
  119361. attach(ownerNode: Mesh): void;
  119362. /**
  119363. * Detaches the behavior from the mesh
  119364. */
  119365. detach(): void;
  119366. }
  119367. }
  119368. declare module BABYLON {
  119369. /**
  119370. * Class used to apply inverse kinematics to bones
  119371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  119372. */
  119373. export class BoneIKController {
  119374. private static _tmpVecs;
  119375. private static _tmpQuat;
  119376. private static _tmpMats;
  119377. /**
  119378. * Gets or sets the target mesh
  119379. */
  119380. targetMesh: AbstractMesh;
  119381. /** Gets or sets the mesh used as pole */
  119382. poleTargetMesh: AbstractMesh;
  119383. /**
  119384. * Gets or sets the bone used as pole
  119385. */
  119386. poleTargetBone: Nullable<Bone>;
  119387. /**
  119388. * Gets or sets the target position
  119389. */
  119390. targetPosition: Vector3;
  119391. /**
  119392. * Gets or sets the pole target position
  119393. */
  119394. poleTargetPosition: Vector3;
  119395. /**
  119396. * Gets or sets the pole target local offset
  119397. */
  119398. poleTargetLocalOffset: Vector3;
  119399. /**
  119400. * Gets or sets the pole angle
  119401. */
  119402. poleAngle: number;
  119403. /**
  119404. * Gets or sets the mesh associated with the controller
  119405. */
  119406. mesh: AbstractMesh;
  119407. /**
  119408. * 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)
  119409. */
  119410. slerpAmount: number;
  119411. private _bone1Quat;
  119412. private _bone1Mat;
  119413. private _bone2Ang;
  119414. private _bone1;
  119415. private _bone2;
  119416. private _bone1Length;
  119417. private _bone2Length;
  119418. private _maxAngle;
  119419. private _maxReach;
  119420. private _rightHandedSystem;
  119421. private _bendAxis;
  119422. private _slerping;
  119423. private _adjustRoll;
  119424. /**
  119425. * Gets or sets maximum allowed angle
  119426. */
  119427. get maxAngle(): number;
  119428. set maxAngle(value: number);
  119429. /**
  119430. * Creates a new BoneIKController
  119431. * @param mesh defines the mesh to control
  119432. * @param bone defines the bone to control
  119433. * @param options defines options to set up the controller
  119434. */
  119435. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  119436. targetMesh?: AbstractMesh;
  119437. poleTargetMesh?: AbstractMesh;
  119438. poleTargetBone?: Bone;
  119439. poleTargetLocalOffset?: Vector3;
  119440. poleAngle?: number;
  119441. bendAxis?: Vector3;
  119442. maxAngle?: number;
  119443. slerpAmount?: number;
  119444. });
  119445. private _setMaxAngle;
  119446. /**
  119447. * Force the controller to update the bones
  119448. */
  119449. update(): void;
  119450. }
  119451. }
  119452. declare module BABYLON {
  119453. /**
  119454. * Class used to make a bone look toward a point in space
  119455. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  119456. */
  119457. export class BoneLookController {
  119458. private static _tmpVecs;
  119459. private static _tmpQuat;
  119460. private static _tmpMats;
  119461. /**
  119462. * The target Vector3 that the bone will look at
  119463. */
  119464. target: Vector3;
  119465. /**
  119466. * The mesh that the bone is attached to
  119467. */
  119468. mesh: AbstractMesh;
  119469. /**
  119470. * The bone that will be looking to the target
  119471. */
  119472. bone: Bone;
  119473. /**
  119474. * The up axis of the coordinate system that is used when the bone is rotated
  119475. */
  119476. upAxis: Vector3;
  119477. /**
  119478. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  119479. */
  119480. upAxisSpace: Space;
  119481. /**
  119482. * Used to make an adjustment to the yaw of the bone
  119483. */
  119484. adjustYaw: number;
  119485. /**
  119486. * Used to make an adjustment to the pitch of the bone
  119487. */
  119488. adjustPitch: number;
  119489. /**
  119490. * Used to make an adjustment to the roll of the bone
  119491. */
  119492. adjustRoll: number;
  119493. /**
  119494. * 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)
  119495. */
  119496. slerpAmount: number;
  119497. private _minYaw;
  119498. private _maxYaw;
  119499. private _minPitch;
  119500. private _maxPitch;
  119501. private _minYawSin;
  119502. private _minYawCos;
  119503. private _maxYawSin;
  119504. private _maxYawCos;
  119505. private _midYawConstraint;
  119506. private _minPitchTan;
  119507. private _maxPitchTan;
  119508. private _boneQuat;
  119509. private _slerping;
  119510. private _transformYawPitch;
  119511. private _transformYawPitchInv;
  119512. private _firstFrameSkipped;
  119513. private _yawRange;
  119514. private _fowardAxis;
  119515. /**
  119516. * Gets or sets the minimum yaw angle that the bone can look to
  119517. */
  119518. get minYaw(): number;
  119519. set minYaw(value: number);
  119520. /**
  119521. * Gets or sets the maximum yaw angle that the bone can look to
  119522. */
  119523. get maxYaw(): number;
  119524. set maxYaw(value: number);
  119525. /**
  119526. * Gets or sets the minimum pitch angle that the bone can look to
  119527. */
  119528. get minPitch(): number;
  119529. set minPitch(value: number);
  119530. /**
  119531. * Gets or sets the maximum pitch angle that the bone can look to
  119532. */
  119533. get maxPitch(): number;
  119534. set maxPitch(value: number);
  119535. /**
  119536. * Create a BoneLookController
  119537. * @param mesh the mesh that the bone belongs to
  119538. * @param bone the bone that will be looking to the target
  119539. * @param target the target Vector3 to look at
  119540. * @param options optional settings:
  119541. * * maxYaw: the maximum angle the bone will yaw to
  119542. * * minYaw: the minimum angle the bone will yaw to
  119543. * * maxPitch: the maximum angle the bone will pitch to
  119544. * * minPitch: the minimum angle the bone will yaw to
  119545. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  119546. * * upAxis: the up axis of the coordinate system
  119547. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  119548. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  119549. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  119550. * * adjustYaw: used to make an adjustment to the yaw of the bone
  119551. * * adjustPitch: used to make an adjustment to the pitch of the bone
  119552. * * adjustRoll: used to make an adjustment to the roll of the bone
  119553. **/
  119554. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  119555. maxYaw?: number;
  119556. minYaw?: number;
  119557. maxPitch?: number;
  119558. minPitch?: number;
  119559. slerpAmount?: number;
  119560. upAxis?: Vector3;
  119561. upAxisSpace?: Space;
  119562. yawAxis?: Vector3;
  119563. pitchAxis?: Vector3;
  119564. adjustYaw?: number;
  119565. adjustPitch?: number;
  119566. adjustRoll?: number;
  119567. });
  119568. /**
  119569. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  119570. */
  119571. update(): void;
  119572. private _getAngleDiff;
  119573. private _getAngleBetween;
  119574. private _isAngleBetween;
  119575. }
  119576. }
  119577. declare module BABYLON {
  119578. /**
  119579. * Manage the gamepad inputs to control an arc rotate camera.
  119580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119581. */
  119582. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  119583. /**
  119584. * Defines the camera the input is attached to.
  119585. */
  119586. camera: ArcRotateCamera;
  119587. /**
  119588. * Defines the gamepad the input is gathering event from.
  119589. */
  119590. gamepad: Nullable<Gamepad>;
  119591. /**
  119592. * Defines the gamepad rotation sensiblity.
  119593. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  119594. */
  119595. gamepadRotationSensibility: number;
  119596. /**
  119597. * Defines the gamepad move sensiblity.
  119598. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  119599. */
  119600. gamepadMoveSensibility: number;
  119601. private _yAxisScale;
  119602. /**
  119603. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  119604. */
  119605. get invertYAxis(): boolean;
  119606. set invertYAxis(value: boolean);
  119607. private _onGamepadConnectedObserver;
  119608. private _onGamepadDisconnectedObserver;
  119609. /**
  119610. * Attach the input controls to a specific dom element to get the input from.
  119611. * @param element Defines the element the controls should be listened from
  119612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119613. */
  119614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119615. /**
  119616. * Detach the current controls from the specified dom element.
  119617. * @param element Defines the element to stop listening the inputs from
  119618. */
  119619. detachControl(element: Nullable<HTMLElement>): void;
  119620. /**
  119621. * Update the current camera state depending on the inputs that have been used this frame.
  119622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119623. */
  119624. checkInputs(): void;
  119625. /**
  119626. * Gets the class name of the current intput.
  119627. * @returns the class name
  119628. */
  119629. getClassName(): string;
  119630. /**
  119631. * Get the friendly name associated with the input class.
  119632. * @returns the input friendly name
  119633. */
  119634. getSimpleName(): string;
  119635. }
  119636. }
  119637. declare module BABYLON {
  119638. interface ArcRotateCameraInputsManager {
  119639. /**
  119640. * Add orientation input support to the input manager.
  119641. * @returns the current input manager
  119642. */
  119643. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  119644. }
  119645. /**
  119646. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  119647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119648. */
  119649. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  119650. /**
  119651. * Defines the camera the input is attached to.
  119652. */
  119653. camera: ArcRotateCamera;
  119654. /**
  119655. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  119656. */
  119657. alphaCorrection: number;
  119658. /**
  119659. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  119660. */
  119661. gammaCorrection: number;
  119662. private _alpha;
  119663. private _gamma;
  119664. private _dirty;
  119665. private _deviceOrientationHandler;
  119666. /**
  119667. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  119668. */
  119669. constructor();
  119670. /**
  119671. * Attach the input controls to a specific dom element to get the input from.
  119672. * @param element Defines the element the controls should be listened from
  119673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119674. */
  119675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119676. /** @hidden */
  119677. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  119678. /**
  119679. * Update the current camera state depending on the inputs that have been used this frame.
  119680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119681. */
  119682. checkInputs(): void;
  119683. /**
  119684. * Detach the current controls from the specified dom element.
  119685. * @param element Defines the element to stop listening the inputs from
  119686. */
  119687. detachControl(element: Nullable<HTMLElement>): void;
  119688. /**
  119689. * Gets the class name of the current intput.
  119690. * @returns the class name
  119691. */
  119692. getClassName(): string;
  119693. /**
  119694. * Get the friendly name associated with the input class.
  119695. * @returns the input friendly name
  119696. */
  119697. getSimpleName(): string;
  119698. }
  119699. }
  119700. declare module BABYLON {
  119701. /**
  119702. * Listen to mouse events to control the camera.
  119703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119704. */
  119705. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  119706. /**
  119707. * Defines the camera the input is attached to.
  119708. */
  119709. camera: FlyCamera;
  119710. /**
  119711. * Defines if touch is enabled. (Default is true.)
  119712. */
  119713. touchEnabled: boolean;
  119714. /**
  119715. * Defines the buttons associated with the input to handle camera rotation.
  119716. */
  119717. buttons: number[];
  119718. /**
  119719. * Assign buttons for Yaw control.
  119720. */
  119721. buttonsYaw: number[];
  119722. /**
  119723. * Assign buttons for Pitch control.
  119724. */
  119725. buttonsPitch: number[];
  119726. /**
  119727. * Assign buttons for Roll control.
  119728. */
  119729. buttonsRoll: number[];
  119730. /**
  119731. * Detect if any button is being pressed while mouse is moved.
  119732. * -1 = Mouse locked.
  119733. * 0 = Left button.
  119734. * 1 = Middle Button.
  119735. * 2 = Right Button.
  119736. */
  119737. activeButton: number;
  119738. /**
  119739. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  119740. * Higher values reduce its sensitivity.
  119741. */
  119742. angularSensibility: number;
  119743. private _mousemoveCallback;
  119744. private _observer;
  119745. private _rollObserver;
  119746. private previousPosition;
  119747. private noPreventDefault;
  119748. private element;
  119749. /**
  119750. * Listen to mouse events to control the camera.
  119751. * @param touchEnabled Define if touch is enabled. (Default is true.)
  119752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119753. */
  119754. constructor(touchEnabled?: boolean);
  119755. /**
  119756. * Attach the mouse control to the HTML DOM element.
  119757. * @param element Defines the element that listens to the input events.
  119758. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  119759. */
  119760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119761. /**
  119762. * Detach the current controls from the specified dom element.
  119763. * @param element Defines the element to stop listening the inputs from
  119764. */
  119765. detachControl(element: Nullable<HTMLElement>): void;
  119766. /**
  119767. * Gets the class name of the current input.
  119768. * @returns the class name.
  119769. */
  119770. getClassName(): string;
  119771. /**
  119772. * Get the friendly name associated with the input class.
  119773. * @returns the input's friendly name.
  119774. */
  119775. getSimpleName(): string;
  119776. private _pointerInput;
  119777. private _onMouseMove;
  119778. /**
  119779. * Rotate camera by mouse offset.
  119780. */
  119781. private rotateCamera;
  119782. }
  119783. }
  119784. declare module BABYLON {
  119785. /**
  119786. * Default Inputs manager for the FlyCamera.
  119787. * It groups all the default supported inputs for ease of use.
  119788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119789. */
  119790. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  119791. /**
  119792. * Instantiates a new FlyCameraInputsManager.
  119793. * @param camera Defines the camera the inputs belong to.
  119794. */
  119795. constructor(camera: FlyCamera);
  119796. /**
  119797. * Add keyboard input support to the input manager.
  119798. * @returns the new FlyCameraKeyboardMoveInput().
  119799. */
  119800. addKeyboard(): FlyCameraInputsManager;
  119801. /**
  119802. * Add mouse input support to the input manager.
  119803. * @param touchEnabled Enable touch screen support.
  119804. * @returns the new FlyCameraMouseInput().
  119805. */
  119806. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  119807. }
  119808. }
  119809. declare module BABYLON {
  119810. /**
  119811. * This is a flying camera, designed for 3D movement and rotation in all directions,
  119812. * such as in a 3D Space Shooter or a Flight Simulator.
  119813. */
  119814. export class FlyCamera extends TargetCamera {
  119815. /**
  119816. * Define the collision ellipsoid of the camera.
  119817. * This is helpful for simulating a camera body, like a player's body.
  119818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119819. */
  119820. ellipsoid: Vector3;
  119821. /**
  119822. * Define an offset for the position of the ellipsoid around the camera.
  119823. * This can be helpful if the camera is attached away from the player's body center,
  119824. * such as at its head.
  119825. */
  119826. ellipsoidOffset: Vector3;
  119827. /**
  119828. * Enable or disable collisions of the camera with the rest of the scene objects.
  119829. */
  119830. checkCollisions: boolean;
  119831. /**
  119832. * Enable or disable gravity on the camera.
  119833. */
  119834. applyGravity: boolean;
  119835. /**
  119836. * Define the current direction the camera is moving to.
  119837. */
  119838. cameraDirection: Vector3;
  119839. /**
  119840. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  119841. * This overrides and empties cameraRotation.
  119842. */
  119843. rotationQuaternion: Quaternion;
  119844. /**
  119845. * Track Roll to maintain the wanted Rolling when looking around.
  119846. */
  119847. _trackRoll: number;
  119848. /**
  119849. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  119850. */
  119851. rollCorrect: number;
  119852. /**
  119853. * Mimic a banked turn, Rolling the camera when Yawing.
  119854. * It's recommended to use rollCorrect = 10 for faster banking correction.
  119855. */
  119856. bankedTurn: boolean;
  119857. /**
  119858. * Limit in radians for how much Roll banking will add. (Default: 90°)
  119859. */
  119860. bankedTurnLimit: number;
  119861. /**
  119862. * Value of 0 disables the banked Roll.
  119863. * Value of 1 is equal to the Yaw angle in radians.
  119864. */
  119865. bankedTurnMultiplier: number;
  119866. /**
  119867. * The inputs manager loads all the input sources, such as keyboard and mouse.
  119868. */
  119869. inputs: FlyCameraInputsManager;
  119870. /**
  119871. * Gets the input sensibility for mouse input.
  119872. * Higher values reduce sensitivity.
  119873. */
  119874. get angularSensibility(): number;
  119875. /**
  119876. * Sets the input sensibility for a mouse input.
  119877. * Higher values reduce sensitivity.
  119878. */
  119879. set angularSensibility(value: number);
  119880. /**
  119881. * Get the keys for camera movement forward.
  119882. */
  119883. get keysForward(): number[];
  119884. /**
  119885. * Set the keys for camera movement forward.
  119886. */
  119887. set keysForward(value: number[]);
  119888. /**
  119889. * Get the keys for camera movement backward.
  119890. */
  119891. get keysBackward(): number[];
  119892. set keysBackward(value: number[]);
  119893. /**
  119894. * Get the keys for camera movement up.
  119895. */
  119896. get keysUp(): number[];
  119897. /**
  119898. * Set the keys for camera movement up.
  119899. */
  119900. set keysUp(value: number[]);
  119901. /**
  119902. * Get the keys for camera movement down.
  119903. */
  119904. get keysDown(): number[];
  119905. /**
  119906. * Set the keys for camera movement down.
  119907. */
  119908. set keysDown(value: number[]);
  119909. /**
  119910. * Get the keys for camera movement left.
  119911. */
  119912. get keysLeft(): number[];
  119913. /**
  119914. * Set the keys for camera movement left.
  119915. */
  119916. set keysLeft(value: number[]);
  119917. /**
  119918. * Set the keys for camera movement right.
  119919. */
  119920. get keysRight(): number[];
  119921. /**
  119922. * Set the keys for camera movement right.
  119923. */
  119924. set keysRight(value: number[]);
  119925. /**
  119926. * Event raised when the camera collides with a mesh in the scene.
  119927. */
  119928. onCollide: (collidedMesh: AbstractMesh) => void;
  119929. private _collider;
  119930. private _needMoveForGravity;
  119931. private _oldPosition;
  119932. private _diffPosition;
  119933. private _newPosition;
  119934. /** @hidden */
  119935. _localDirection: Vector3;
  119936. /** @hidden */
  119937. _transformedDirection: Vector3;
  119938. /**
  119939. * Instantiates a FlyCamera.
  119940. * This is a flying camera, designed for 3D movement and rotation in all directions,
  119941. * such as in a 3D Space Shooter or a Flight Simulator.
  119942. * @param name Define the name of the camera in the scene.
  119943. * @param position Define the starting position of the camera in the scene.
  119944. * @param scene Define the scene the camera belongs to.
  119945. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  119946. */
  119947. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119948. /**
  119949. * Attach a control to the HTML DOM element.
  119950. * @param element Defines the element that listens to the input events.
  119951. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  119952. */
  119953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119954. /**
  119955. * Detach a control from the HTML DOM element.
  119956. * The camera will stop reacting to that input.
  119957. * @param element Defines the element that listens to the input events.
  119958. */
  119959. detachControl(element: HTMLElement): void;
  119960. private _collisionMask;
  119961. /**
  119962. * Get the mask that the camera ignores in collision events.
  119963. */
  119964. get collisionMask(): number;
  119965. /**
  119966. * Set the mask that the camera ignores in collision events.
  119967. */
  119968. set collisionMask(mask: number);
  119969. /** @hidden */
  119970. _collideWithWorld(displacement: Vector3): void;
  119971. /** @hidden */
  119972. private _onCollisionPositionChange;
  119973. /** @hidden */
  119974. _checkInputs(): void;
  119975. /** @hidden */
  119976. _decideIfNeedsToMove(): boolean;
  119977. /** @hidden */
  119978. _updatePosition(): void;
  119979. /**
  119980. * Restore the Roll to its target value at the rate specified.
  119981. * @param rate - Higher means slower restoring.
  119982. * @hidden
  119983. */
  119984. restoreRoll(rate: number): void;
  119985. /**
  119986. * Destroy the camera and release the current resources held by it.
  119987. */
  119988. dispose(): void;
  119989. /**
  119990. * Get the current object class name.
  119991. * @returns the class name.
  119992. */
  119993. getClassName(): string;
  119994. }
  119995. }
  119996. declare module BABYLON {
  119997. /**
  119998. * Listen to keyboard events to control the camera.
  119999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120000. */
  120001. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120002. /**
  120003. * Defines the camera the input is attached to.
  120004. */
  120005. camera: FlyCamera;
  120006. /**
  120007. * The list of keyboard keys used to control the forward move of the camera.
  120008. */
  120009. keysForward: number[];
  120010. /**
  120011. * The list of keyboard keys used to control the backward move of the camera.
  120012. */
  120013. keysBackward: number[];
  120014. /**
  120015. * The list of keyboard keys used to control the forward move of the camera.
  120016. */
  120017. keysUp: number[];
  120018. /**
  120019. * The list of keyboard keys used to control the backward move of the camera.
  120020. */
  120021. keysDown: number[];
  120022. /**
  120023. * The list of keyboard keys used to control the right strafe move of the camera.
  120024. */
  120025. keysRight: number[];
  120026. /**
  120027. * The list of keyboard keys used to control the left strafe move of the camera.
  120028. */
  120029. keysLeft: number[];
  120030. private _keys;
  120031. private _onCanvasBlurObserver;
  120032. private _onKeyboardObserver;
  120033. private _engine;
  120034. private _scene;
  120035. /**
  120036. * Attach the input controls to a specific dom element to get the input from.
  120037. * @param element Defines the element the controls should be listened from
  120038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120039. */
  120040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120041. /**
  120042. * Detach the current controls from the specified dom element.
  120043. * @param element Defines the element to stop listening the inputs from
  120044. */
  120045. detachControl(element: Nullable<HTMLElement>): void;
  120046. /**
  120047. * Gets the class name of the current intput.
  120048. * @returns the class name
  120049. */
  120050. getClassName(): string;
  120051. /** @hidden */
  120052. _onLostFocus(e: FocusEvent): void;
  120053. /**
  120054. * Get the friendly name associated with the input class.
  120055. * @returns the input friendly name
  120056. */
  120057. getSimpleName(): string;
  120058. /**
  120059. * Update the current camera state depending on the inputs that have been used this frame.
  120060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120061. */
  120062. checkInputs(): void;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /**
  120067. * Manage the mouse wheel inputs to control a follow camera.
  120068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120069. */
  120070. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120071. /**
  120072. * Defines the camera the input is attached to.
  120073. */
  120074. camera: FollowCamera;
  120075. /**
  120076. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120077. */
  120078. axisControlRadius: boolean;
  120079. /**
  120080. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120081. */
  120082. axisControlHeight: boolean;
  120083. /**
  120084. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120085. */
  120086. axisControlRotation: boolean;
  120087. /**
  120088. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120089. * relation to mouseWheel events.
  120090. */
  120091. wheelPrecision: number;
  120092. /**
  120093. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120094. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120095. */
  120096. wheelDeltaPercentage: number;
  120097. private _wheel;
  120098. private _observer;
  120099. /**
  120100. * Attach the input controls to a specific dom element to get the input from.
  120101. * @param element Defines the element the controls should be listened from
  120102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120103. */
  120104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120105. /**
  120106. * Detach the current controls from the specified dom element.
  120107. * @param element Defines the element to stop listening the inputs from
  120108. */
  120109. detachControl(element: Nullable<HTMLElement>): void;
  120110. /**
  120111. * Gets the class name of the current intput.
  120112. * @returns the class name
  120113. */
  120114. getClassName(): string;
  120115. /**
  120116. * Get the friendly name associated with the input class.
  120117. * @returns the input friendly name
  120118. */
  120119. getSimpleName(): string;
  120120. }
  120121. }
  120122. declare module BABYLON {
  120123. /**
  120124. * Manage the pointers inputs to control an follow camera.
  120125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120126. */
  120127. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120128. /**
  120129. * Defines the camera the input is attached to.
  120130. */
  120131. camera: FollowCamera;
  120132. /**
  120133. * Gets the class name of the current input.
  120134. * @returns the class name
  120135. */
  120136. getClassName(): string;
  120137. /**
  120138. * Defines the pointer angular sensibility along the X axis or how fast is
  120139. * the camera rotating.
  120140. * A negative number will reverse the axis direction.
  120141. */
  120142. angularSensibilityX: number;
  120143. /**
  120144. * Defines the pointer angular sensibility along the Y axis or how fast is
  120145. * the camera rotating.
  120146. * A negative number will reverse the axis direction.
  120147. */
  120148. angularSensibilityY: number;
  120149. /**
  120150. * Defines the pointer pinch precision or how fast is the camera zooming.
  120151. * A negative number will reverse the axis direction.
  120152. */
  120153. pinchPrecision: number;
  120154. /**
  120155. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120156. * from 0.
  120157. * It defines the percentage of current camera.radius to use as delta when
  120158. * pinch zoom is used.
  120159. */
  120160. pinchDeltaPercentage: number;
  120161. /**
  120162. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120163. */
  120164. axisXControlRadius: boolean;
  120165. /**
  120166. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120167. */
  120168. axisXControlHeight: boolean;
  120169. /**
  120170. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120171. */
  120172. axisXControlRotation: boolean;
  120173. /**
  120174. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120175. */
  120176. axisYControlRadius: boolean;
  120177. /**
  120178. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120179. */
  120180. axisYControlHeight: boolean;
  120181. /**
  120182. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120183. */
  120184. axisYControlRotation: boolean;
  120185. /**
  120186. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120187. */
  120188. axisPinchControlRadius: boolean;
  120189. /**
  120190. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120191. */
  120192. axisPinchControlHeight: boolean;
  120193. /**
  120194. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120195. */
  120196. axisPinchControlRotation: boolean;
  120197. /**
  120198. * Log error messages if basic misconfiguration has occurred.
  120199. */
  120200. warningEnable: boolean;
  120201. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120202. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120203. private _warningCounter;
  120204. private _warning;
  120205. }
  120206. }
  120207. declare module BABYLON {
  120208. /**
  120209. * Default Inputs manager for the FollowCamera.
  120210. * It groups all the default supported inputs for ease of use.
  120211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120212. */
  120213. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120214. /**
  120215. * Instantiates a new FollowCameraInputsManager.
  120216. * @param camera Defines the camera the inputs belong to
  120217. */
  120218. constructor(camera: FollowCamera);
  120219. /**
  120220. * Add keyboard input support to the input manager.
  120221. * @returns the current input manager
  120222. */
  120223. addKeyboard(): FollowCameraInputsManager;
  120224. /**
  120225. * Add mouse wheel input support to the input manager.
  120226. * @returns the current input manager
  120227. */
  120228. addMouseWheel(): FollowCameraInputsManager;
  120229. /**
  120230. * Add pointers input support to the input manager.
  120231. * @returns the current input manager
  120232. */
  120233. addPointers(): FollowCameraInputsManager;
  120234. /**
  120235. * Add orientation input support to the input manager.
  120236. * @returns the current input manager
  120237. */
  120238. addVRDeviceOrientation(): FollowCameraInputsManager;
  120239. }
  120240. }
  120241. declare module BABYLON {
  120242. /**
  120243. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  120244. * an arc rotate version arcFollowCamera are available.
  120245. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120246. */
  120247. export class FollowCamera extends TargetCamera {
  120248. /**
  120249. * Distance the follow camera should follow an object at
  120250. */
  120251. radius: number;
  120252. /**
  120253. * Minimum allowed distance of the camera to the axis of rotation
  120254. * (The camera can not get closer).
  120255. * This can help limiting how the Camera is able to move in the scene.
  120256. */
  120257. lowerRadiusLimit: Nullable<number>;
  120258. /**
  120259. * Maximum allowed distance of the camera to the axis of rotation
  120260. * (The camera can not get further).
  120261. * This can help limiting how the Camera is able to move in the scene.
  120262. */
  120263. upperRadiusLimit: Nullable<number>;
  120264. /**
  120265. * Define a rotation offset between the camera and the object it follows
  120266. */
  120267. rotationOffset: number;
  120268. /**
  120269. * Minimum allowed angle to camera position relative to target object.
  120270. * This can help limiting how the Camera is able to move in the scene.
  120271. */
  120272. lowerRotationOffsetLimit: Nullable<number>;
  120273. /**
  120274. * Maximum allowed angle to camera position relative to target object.
  120275. * This can help limiting how the Camera is able to move in the scene.
  120276. */
  120277. upperRotationOffsetLimit: Nullable<number>;
  120278. /**
  120279. * Define a height offset between the camera and the object it follows.
  120280. * It can help following an object from the top (like a car chaing a plane)
  120281. */
  120282. heightOffset: number;
  120283. /**
  120284. * Minimum allowed height of camera position relative to target object.
  120285. * This can help limiting how the Camera is able to move in the scene.
  120286. */
  120287. lowerHeightOffsetLimit: Nullable<number>;
  120288. /**
  120289. * Maximum allowed height of camera position relative to target object.
  120290. * This can help limiting how the Camera is able to move in the scene.
  120291. */
  120292. upperHeightOffsetLimit: Nullable<number>;
  120293. /**
  120294. * Define how fast the camera can accelerate to follow it s target.
  120295. */
  120296. cameraAcceleration: number;
  120297. /**
  120298. * Define the speed limit of the camera following an object.
  120299. */
  120300. maxCameraSpeed: number;
  120301. /**
  120302. * Define the target of the camera.
  120303. */
  120304. lockedTarget: Nullable<AbstractMesh>;
  120305. /**
  120306. * Defines the input associated with the camera.
  120307. */
  120308. inputs: FollowCameraInputsManager;
  120309. /**
  120310. * Instantiates the follow camera.
  120311. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120312. * @param name Define the name of the camera in the scene
  120313. * @param position Define the position of the camera
  120314. * @param scene Define the scene the camera belong to
  120315. * @param lockedTarget Define the target of the camera
  120316. */
  120317. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  120318. private _follow;
  120319. /**
  120320. * Attached controls to the current camera.
  120321. * @param element Defines the element the controls should be listened from
  120322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120323. */
  120324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120325. /**
  120326. * Detach the current controls from the camera.
  120327. * The camera will stop reacting to inputs.
  120328. * @param element Defines the element to stop listening the inputs from
  120329. */
  120330. detachControl(element: HTMLElement): void;
  120331. /** @hidden */
  120332. _checkInputs(): void;
  120333. private _checkLimits;
  120334. /**
  120335. * Gets the camera class name.
  120336. * @returns the class name
  120337. */
  120338. getClassName(): string;
  120339. }
  120340. /**
  120341. * Arc Rotate version of the follow camera.
  120342. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  120343. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120344. */
  120345. export class ArcFollowCamera extends TargetCamera {
  120346. /** The longitudinal angle of the camera */
  120347. alpha: number;
  120348. /** The latitudinal angle of the camera */
  120349. beta: number;
  120350. /** The radius of the camera from its target */
  120351. radius: number;
  120352. /** Define the camera target (the messh it should follow) */
  120353. target: Nullable<AbstractMesh>;
  120354. private _cartesianCoordinates;
  120355. /**
  120356. * Instantiates a new ArcFollowCamera
  120357. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120358. * @param name Define the name of the camera
  120359. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  120360. * @param beta Define the rotation angle of the camera around the elevation axis
  120361. * @param radius Define the radius of the camera from its target point
  120362. * @param target Define the target of the camera
  120363. * @param scene Define the scene the camera belongs to
  120364. */
  120365. constructor(name: string,
  120366. /** The longitudinal angle of the camera */
  120367. alpha: number,
  120368. /** The latitudinal angle of the camera */
  120369. beta: number,
  120370. /** The radius of the camera from its target */
  120371. radius: number,
  120372. /** Define the camera target (the messh it should follow) */
  120373. target: Nullable<AbstractMesh>, scene: Scene);
  120374. private _follow;
  120375. /** @hidden */
  120376. _checkInputs(): void;
  120377. /**
  120378. * Returns the class name of the object.
  120379. * It is mostly used internally for serialization purposes.
  120380. */
  120381. getClassName(): string;
  120382. }
  120383. }
  120384. declare module BABYLON {
  120385. /**
  120386. * Manage the keyboard inputs to control the movement of a follow camera.
  120387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120388. */
  120389. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  120390. /**
  120391. * Defines the camera the input is attached to.
  120392. */
  120393. camera: FollowCamera;
  120394. /**
  120395. * Defines the list of key codes associated with the up action (increase heightOffset)
  120396. */
  120397. keysHeightOffsetIncr: number[];
  120398. /**
  120399. * Defines the list of key codes associated with the down action (decrease heightOffset)
  120400. */
  120401. keysHeightOffsetDecr: number[];
  120402. /**
  120403. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  120404. */
  120405. keysHeightOffsetModifierAlt: boolean;
  120406. /**
  120407. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  120408. */
  120409. keysHeightOffsetModifierCtrl: boolean;
  120410. /**
  120411. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  120412. */
  120413. keysHeightOffsetModifierShift: boolean;
  120414. /**
  120415. * Defines the list of key codes associated with the left action (increase rotationOffset)
  120416. */
  120417. keysRotationOffsetIncr: number[];
  120418. /**
  120419. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  120420. */
  120421. keysRotationOffsetDecr: number[];
  120422. /**
  120423. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  120424. */
  120425. keysRotationOffsetModifierAlt: boolean;
  120426. /**
  120427. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  120428. */
  120429. keysRotationOffsetModifierCtrl: boolean;
  120430. /**
  120431. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  120432. */
  120433. keysRotationOffsetModifierShift: boolean;
  120434. /**
  120435. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  120436. */
  120437. keysRadiusIncr: number[];
  120438. /**
  120439. * Defines the list of key codes associated with the zoom-out action (increase radius)
  120440. */
  120441. keysRadiusDecr: number[];
  120442. /**
  120443. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  120444. */
  120445. keysRadiusModifierAlt: boolean;
  120446. /**
  120447. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  120448. */
  120449. keysRadiusModifierCtrl: boolean;
  120450. /**
  120451. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  120452. */
  120453. keysRadiusModifierShift: boolean;
  120454. /**
  120455. * Defines the rate of change of heightOffset.
  120456. */
  120457. heightSensibility: number;
  120458. /**
  120459. * Defines the rate of change of rotationOffset.
  120460. */
  120461. rotationSensibility: number;
  120462. /**
  120463. * Defines the rate of change of radius.
  120464. */
  120465. radiusSensibility: number;
  120466. private _keys;
  120467. private _ctrlPressed;
  120468. private _altPressed;
  120469. private _shiftPressed;
  120470. private _onCanvasBlurObserver;
  120471. private _onKeyboardObserver;
  120472. private _engine;
  120473. private _scene;
  120474. /**
  120475. * Attach the input controls to a specific dom element to get the input from.
  120476. * @param element Defines the element the controls should be listened from
  120477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120478. */
  120479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120480. /**
  120481. * Detach the current controls from the specified dom element.
  120482. * @param element Defines the element to stop listening the inputs from
  120483. */
  120484. detachControl(element: Nullable<HTMLElement>): void;
  120485. /**
  120486. * Update the current camera state depending on the inputs that have been used this frame.
  120487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120488. */
  120489. checkInputs(): void;
  120490. /**
  120491. * Gets the class name of the current input.
  120492. * @returns the class name
  120493. */
  120494. getClassName(): string;
  120495. /**
  120496. * Get the friendly name associated with the input class.
  120497. * @returns the input friendly name
  120498. */
  120499. getSimpleName(): string;
  120500. /**
  120501. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120502. * allow modification of the heightOffset value.
  120503. */
  120504. private _modifierHeightOffset;
  120505. /**
  120506. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120507. * allow modification of the rotationOffset value.
  120508. */
  120509. private _modifierRotationOffset;
  120510. /**
  120511. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120512. * allow modification of the radius value.
  120513. */
  120514. private _modifierRadius;
  120515. }
  120516. }
  120517. declare module BABYLON {
  120518. interface FreeCameraInputsManager {
  120519. /**
  120520. * @hidden
  120521. */
  120522. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  120523. /**
  120524. * Add orientation input support to the input manager.
  120525. * @returns the current input manager
  120526. */
  120527. addDeviceOrientation(): FreeCameraInputsManager;
  120528. }
  120529. /**
  120530. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  120531. * Screen rotation is taken into account.
  120532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120533. */
  120534. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  120535. private _camera;
  120536. private _screenOrientationAngle;
  120537. private _constantTranform;
  120538. private _screenQuaternion;
  120539. private _alpha;
  120540. private _beta;
  120541. private _gamma;
  120542. /**
  120543. * Can be used to detect if a device orientation sensor is available on a device
  120544. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  120545. * @returns a promise that will resolve on orientation change
  120546. */
  120547. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  120548. /**
  120549. * @hidden
  120550. */
  120551. _onDeviceOrientationChangedObservable: Observable<void>;
  120552. /**
  120553. * Instantiates a new input
  120554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120555. */
  120556. constructor();
  120557. /**
  120558. * Define the camera controlled by the input.
  120559. */
  120560. get camera(): FreeCamera;
  120561. set camera(camera: FreeCamera);
  120562. /**
  120563. * Attach the input controls to a specific dom element to get the input from.
  120564. * @param element Defines the element the controls should be listened from
  120565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120566. */
  120567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120568. private _orientationChanged;
  120569. private _deviceOrientation;
  120570. /**
  120571. * Detach the current controls from the specified dom element.
  120572. * @param element Defines the element to stop listening the inputs from
  120573. */
  120574. detachControl(element: Nullable<HTMLElement>): void;
  120575. /**
  120576. * Update the current camera state depending on the inputs that have been used this frame.
  120577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120578. */
  120579. checkInputs(): void;
  120580. /**
  120581. * Gets the class name of the current intput.
  120582. * @returns the class name
  120583. */
  120584. getClassName(): string;
  120585. /**
  120586. * Get the friendly name associated with the input class.
  120587. * @returns the input friendly name
  120588. */
  120589. getSimpleName(): string;
  120590. }
  120591. }
  120592. declare module BABYLON {
  120593. /**
  120594. * Manage the gamepad inputs to control a free camera.
  120595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120596. */
  120597. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  120598. /**
  120599. * Define the camera the input is attached to.
  120600. */
  120601. camera: FreeCamera;
  120602. /**
  120603. * Define the Gamepad controlling the input
  120604. */
  120605. gamepad: Nullable<Gamepad>;
  120606. /**
  120607. * Defines the gamepad rotation sensiblity.
  120608. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120609. */
  120610. gamepadAngularSensibility: number;
  120611. /**
  120612. * Defines the gamepad move sensiblity.
  120613. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120614. */
  120615. gamepadMoveSensibility: number;
  120616. private _yAxisScale;
  120617. /**
  120618. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120619. */
  120620. get invertYAxis(): boolean;
  120621. set invertYAxis(value: boolean);
  120622. private _onGamepadConnectedObserver;
  120623. private _onGamepadDisconnectedObserver;
  120624. private _cameraTransform;
  120625. private _deltaTransform;
  120626. private _vector3;
  120627. private _vector2;
  120628. /**
  120629. * Attach the input controls to a specific dom element to get the input from.
  120630. * @param element Defines the element the controls should be listened from
  120631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120632. */
  120633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120634. /**
  120635. * Detach the current controls from the specified dom element.
  120636. * @param element Defines the element to stop listening the inputs from
  120637. */
  120638. detachControl(element: Nullable<HTMLElement>): void;
  120639. /**
  120640. * Update the current camera state depending on the inputs that have been used this frame.
  120641. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120642. */
  120643. checkInputs(): void;
  120644. /**
  120645. * Gets the class name of the current intput.
  120646. * @returns the class name
  120647. */
  120648. getClassName(): string;
  120649. /**
  120650. * Get the friendly name associated with the input class.
  120651. * @returns the input friendly name
  120652. */
  120653. getSimpleName(): string;
  120654. }
  120655. }
  120656. declare module BABYLON {
  120657. /**
  120658. * Defines the potential axis of a Joystick
  120659. */
  120660. export enum JoystickAxis {
  120661. /** X axis */
  120662. X = 0,
  120663. /** Y axis */
  120664. Y = 1,
  120665. /** Z axis */
  120666. Z = 2
  120667. }
  120668. /**
  120669. * Class used to define virtual joystick (used in touch mode)
  120670. */
  120671. export class VirtualJoystick {
  120672. /**
  120673. * Gets or sets a boolean indicating that left and right values must be inverted
  120674. */
  120675. reverseLeftRight: boolean;
  120676. /**
  120677. * Gets or sets a boolean indicating that up and down values must be inverted
  120678. */
  120679. reverseUpDown: boolean;
  120680. /**
  120681. * Gets the offset value for the position (ie. the change of the position value)
  120682. */
  120683. deltaPosition: Vector3;
  120684. /**
  120685. * Gets a boolean indicating if the virtual joystick was pressed
  120686. */
  120687. pressed: boolean;
  120688. /**
  120689. * Canvas the virtual joystick will render onto, default z-index of this is 5
  120690. */
  120691. static Canvas: Nullable<HTMLCanvasElement>;
  120692. private static _globalJoystickIndex;
  120693. private static vjCanvasContext;
  120694. private static vjCanvasWidth;
  120695. private static vjCanvasHeight;
  120696. private static halfWidth;
  120697. private _action;
  120698. private _axisTargetedByLeftAndRight;
  120699. private _axisTargetedByUpAndDown;
  120700. private _joystickSensibility;
  120701. private _inversedSensibility;
  120702. private _joystickPointerID;
  120703. private _joystickColor;
  120704. private _joystickPointerPos;
  120705. private _joystickPreviousPointerPos;
  120706. private _joystickPointerStartPos;
  120707. private _deltaJoystickVector;
  120708. private _leftJoystick;
  120709. private _touches;
  120710. private _onPointerDownHandlerRef;
  120711. private _onPointerMoveHandlerRef;
  120712. private _onPointerUpHandlerRef;
  120713. private _onResize;
  120714. /**
  120715. * Creates a new virtual joystick
  120716. * @param leftJoystick defines that the joystick is for left hand (false by default)
  120717. */
  120718. constructor(leftJoystick?: boolean);
  120719. /**
  120720. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  120721. * @param newJoystickSensibility defines the new sensibility
  120722. */
  120723. setJoystickSensibility(newJoystickSensibility: number): void;
  120724. private _onPointerDown;
  120725. private _onPointerMove;
  120726. private _onPointerUp;
  120727. /**
  120728. * Change the color of the virtual joystick
  120729. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  120730. */
  120731. setJoystickColor(newColor: string): void;
  120732. /**
  120733. * Defines a callback to call when the joystick is touched
  120734. * @param action defines the callback
  120735. */
  120736. setActionOnTouch(action: () => any): void;
  120737. /**
  120738. * Defines which axis you'd like to control for left & right
  120739. * @param axis defines the axis to use
  120740. */
  120741. setAxisForLeftRight(axis: JoystickAxis): void;
  120742. /**
  120743. * Defines which axis you'd like to control for up & down
  120744. * @param axis defines the axis to use
  120745. */
  120746. setAxisForUpDown(axis: JoystickAxis): void;
  120747. private _drawVirtualJoystick;
  120748. /**
  120749. * Release internal HTML canvas
  120750. */
  120751. releaseCanvas(): void;
  120752. }
  120753. }
  120754. declare module BABYLON {
  120755. interface FreeCameraInputsManager {
  120756. /**
  120757. * Add virtual joystick input support to the input manager.
  120758. * @returns the current input manager
  120759. */
  120760. addVirtualJoystick(): FreeCameraInputsManager;
  120761. }
  120762. /**
  120763. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  120764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120765. */
  120766. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  120767. /**
  120768. * Defines the camera the input is attached to.
  120769. */
  120770. camera: FreeCamera;
  120771. private _leftjoystick;
  120772. private _rightjoystick;
  120773. /**
  120774. * Gets the left stick of the virtual joystick.
  120775. * @returns The virtual Joystick
  120776. */
  120777. getLeftJoystick(): VirtualJoystick;
  120778. /**
  120779. * Gets the right stick of the virtual joystick.
  120780. * @returns The virtual Joystick
  120781. */
  120782. getRightJoystick(): VirtualJoystick;
  120783. /**
  120784. * Update the current camera state depending on the inputs that have been used this frame.
  120785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120786. */
  120787. checkInputs(): void;
  120788. /**
  120789. * Attach the input controls to a specific dom element to get the input from.
  120790. * @param element Defines the element the controls should be listened from
  120791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120792. */
  120793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120794. /**
  120795. * Detach the current controls from the specified dom element.
  120796. * @param element Defines the element to stop listening the inputs from
  120797. */
  120798. detachControl(element: Nullable<HTMLElement>): void;
  120799. /**
  120800. * Gets the class name of the current intput.
  120801. * @returns the class name
  120802. */
  120803. getClassName(): string;
  120804. /**
  120805. * Get the friendly name associated with the input class.
  120806. * @returns the input friendly name
  120807. */
  120808. getSimpleName(): string;
  120809. }
  120810. }
  120811. declare module BABYLON {
  120812. /**
  120813. * This represents a FPS type of camera controlled by touch.
  120814. * This is like a universal camera minus the Gamepad controls.
  120815. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  120816. */
  120817. export class TouchCamera extends FreeCamera {
  120818. /**
  120819. * Defines the touch sensibility for rotation.
  120820. * The higher the faster.
  120821. */
  120822. get touchAngularSensibility(): number;
  120823. set touchAngularSensibility(value: number);
  120824. /**
  120825. * Defines the touch sensibility for move.
  120826. * The higher the faster.
  120827. */
  120828. get touchMoveSensibility(): number;
  120829. set touchMoveSensibility(value: number);
  120830. /**
  120831. * Instantiates a new touch camera.
  120832. * This represents a FPS type of camera controlled by touch.
  120833. * This is like a universal camera minus the Gamepad controls.
  120834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  120835. * @param name Define the name of the camera in the scene
  120836. * @param position Define the start position of the camera in the scene
  120837. * @param scene Define the scene the camera belongs to
  120838. */
  120839. constructor(name: string, position: Vector3, scene: Scene);
  120840. /**
  120841. * Gets the current object class name.
  120842. * @return the class name
  120843. */
  120844. getClassName(): string;
  120845. /** @hidden */
  120846. _setupInputs(): void;
  120847. }
  120848. }
  120849. declare module BABYLON {
  120850. /**
  120851. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  120852. * being tilted forward or back and left or right.
  120853. */
  120854. export class DeviceOrientationCamera extends FreeCamera {
  120855. private _initialQuaternion;
  120856. private _quaternionCache;
  120857. private _tmpDragQuaternion;
  120858. private _disablePointerInputWhenUsingDeviceOrientation;
  120859. /**
  120860. * Creates a new device orientation camera
  120861. * @param name The name of the camera
  120862. * @param position The start position camera
  120863. * @param scene The scene the camera belongs to
  120864. */
  120865. constructor(name: string, position: Vector3, scene: Scene);
  120866. /**
  120867. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  120868. */
  120869. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  120870. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  120871. private _dragFactor;
  120872. /**
  120873. * Enabled turning on the y axis when the orientation sensor is active
  120874. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  120875. */
  120876. enableHorizontalDragging(dragFactor?: number): void;
  120877. /**
  120878. * Gets the current instance class name ("DeviceOrientationCamera").
  120879. * This helps avoiding instanceof at run time.
  120880. * @returns the class name
  120881. */
  120882. getClassName(): string;
  120883. /**
  120884. * @hidden
  120885. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  120886. */
  120887. _checkInputs(): void;
  120888. /**
  120889. * Reset the camera to its default orientation on the specified axis only.
  120890. * @param axis The axis to reset
  120891. */
  120892. resetToCurrentRotation(axis?: Axis): void;
  120893. }
  120894. }
  120895. declare module BABYLON {
  120896. /**
  120897. * Defines supported buttons for XBox360 compatible gamepads
  120898. */
  120899. export enum Xbox360Button {
  120900. /** A */
  120901. A = 0,
  120902. /** B */
  120903. B = 1,
  120904. /** X */
  120905. X = 2,
  120906. /** Y */
  120907. Y = 3,
  120908. /** Left button */
  120909. LB = 4,
  120910. /** Right button */
  120911. RB = 5,
  120912. /** Back */
  120913. Back = 8,
  120914. /** Start */
  120915. Start = 9,
  120916. /** Left stick */
  120917. LeftStick = 10,
  120918. /** Right stick */
  120919. RightStick = 11
  120920. }
  120921. /** Defines values for XBox360 DPad */
  120922. export enum Xbox360Dpad {
  120923. /** Up */
  120924. Up = 12,
  120925. /** Down */
  120926. Down = 13,
  120927. /** Left */
  120928. Left = 14,
  120929. /** Right */
  120930. Right = 15
  120931. }
  120932. /**
  120933. * Defines a XBox360 gamepad
  120934. */
  120935. export class Xbox360Pad extends Gamepad {
  120936. private _leftTrigger;
  120937. private _rightTrigger;
  120938. private _onlefttriggerchanged;
  120939. private _onrighttriggerchanged;
  120940. private _onbuttondown;
  120941. private _onbuttonup;
  120942. private _ondpaddown;
  120943. private _ondpadup;
  120944. /** Observable raised when a button is pressed */
  120945. onButtonDownObservable: Observable<Xbox360Button>;
  120946. /** Observable raised when a button is released */
  120947. onButtonUpObservable: Observable<Xbox360Button>;
  120948. /** Observable raised when a pad is pressed */
  120949. onPadDownObservable: Observable<Xbox360Dpad>;
  120950. /** Observable raised when a pad is released */
  120951. onPadUpObservable: Observable<Xbox360Dpad>;
  120952. private _buttonA;
  120953. private _buttonB;
  120954. private _buttonX;
  120955. private _buttonY;
  120956. private _buttonBack;
  120957. private _buttonStart;
  120958. private _buttonLB;
  120959. private _buttonRB;
  120960. private _buttonLeftStick;
  120961. private _buttonRightStick;
  120962. private _dPadUp;
  120963. private _dPadDown;
  120964. private _dPadLeft;
  120965. private _dPadRight;
  120966. private _isXboxOnePad;
  120967. /**
  120968. * Creates a new XBox360 gamepad object
  120969. * @param id defines the id of this gamepad
  120970. * @param index defines its index
  120971. * @param gamepad defines the internal HTML gamepad object
  120972. * @param xboxOne defines if it is a XBox One gamepad
  120973. */
  120974. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  120975. /**
  120976. * Defines the callback to call when left trigger is pressed
  120977. * @param callback defines the callback to use
  120978. */
  120979. onlefttriggerchanged(callback: (value: number) => void): void;
  120980. /**
  120981. * Defines the callback to call when right trigger is pressed
  120982. * @param callback defines the callback to use
  120983. */
  120984. onrighttriggerchanged(callback: (value: number) => void): void;
  120985. /**
  120986. * Gets the left trigger value
  120987. */
  120988. get leftTrigger(): number;
  120989. /**
  120990. * Sets the left trigger value
  120991. */
  120992. set leftTrigger(newValue: number);
  120993. /**
  120994. * Gets the right trigger value
  120995. */
  120996. get rightTrigger(): number;
  120997. /**
  120998. * Sets the right trigger value
  120999. */
  121000. set rightTrigger(newValue: number);
  121001. /**
  121002. * Defines the callback to call when a button is pressed
  121003. * @param callback defines the callback to use
  121004. */
  121005. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121006. /**
  121007. * Defines the callback to call when a button is released
  121008. * @param callback defines the callback to use
  121009. */
  121010. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121011. /**
  121012. * Defines the callback to call when a pad is pressed
  121013. * @param callback defines the callback to use
  121014. */
  121015. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121016. /**
  121017. * Defines the callback to call when a pad is released
  121018. * @param callback defines the callback to use
  121019. */
  121020. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121021. private _setButtonValue;
  121022. private _setDPadValue;
  121023. /**
  121024. * Gets the value of the `A` button
  121025. */
  121026. get buttonA(): number;
  121027. /**
  121028. * Sets the value of the `A` button
  121029. */
  121030. set buttonA(value: number);
  121031. /**
  121032. * Gets the value of the `B` button
  121033. */
  121034. get buttonB(): number;
  121035. /**
  121036. * Sets the value of the `B` button
  121037. */
  121038. set buttonB(value: number);
  121039. /**
  121040. * Gets the value of the `X` button
  121041. */
  121042. get buttonX(): number;
  121043. /**
  121044. * Sets the value of the `X` button
  121045. */
  121046. set buttonX(value: number);
  121047. /**
  121048. * Gets the value of the `Y` button
  121049. */
  121050. get buttonY(): number;
  121051. /**
  121052. * Sets the value of the `Y` button
  121053. */
  121054. set buttonY(value: number);
  121055. /**
  121056. * Gets the value of the `Start` button
  121057. */
  121058. get buttonStart(): number;
  121059. /**
  121060. * Sets the value of the `Start` button
  121061. */
  121062. set buttonStart(value: number);
  121063. /**
  121064. * Gets the value of the `Back` button
  121065. */
  121066. get buttonBack(): number;
  121067. /**
  121068. * Sets the value of the `Back` button
  121069. */
  121070. set buttonBack(value: number);
  121071. /**
  121072. * Gets the value of the `Left` button
  121073. */
  121074. get buttonLB(): number;
  121075. /**
  121076. * Sets the value of the `Left` button
  121077. */
  121078. set buttonLB(value: number);
  121079. /**
  121080. * Gets the value of the `Right` button
  121081. */
  121082. get buttonRB(): number;
  121083. /**
  121084. * Sets the value of the `Right` button
  121085. */
  121086. set buttonRB(value: number);
  121087. /**
  121088. * Gets the value of the Left joystick
  121089. */
  121090. get buttonLeftStick(): number;
  121091. /**
  121092. * Sets the value of the Left joystick
  121093. */
  121094. set buttonLeftStick(value: number);
  121095. /**
  121096. * Gets the value of the Right joystick
  121097. */
  121098. get buttonRightStick(): number;
  121099. /**
  121100. * Sets the value of the Right joystick
  121101. */
  121102. set buttonRightStick(value: number);
  121103. /**
  121104. * Gets the value of D-pad up
  121105. */
  121106. get dPadUp(): number;
  121107. /**
  121108. * Sets the value of D-pad up
  121109. */
  121110. set dPadUp(value: number);
  121111. /**
  121112. * Gets the value of D-pad down
  121113. */
  121114. get dPadDown(): number;
  121115. /**
  121116. * Sets the value of D-pad down
  121117. */
  121118. set dPadDown(value: number);
  121119. /**
  121120. * Gets the value of D-pad left
  121121. */
  121122. get dPadLeft(): number;
  121123. /**
  121124. * Sets the value of D-pad left
  121125. */
  121126. set dPadLeft(value: number);
  121127. /**
  121128. * Gets the value of D-pad right
  121129. */
  121130. get dPadRight(): number;
  121131. /**
  121132. * Sets the value of D-pad right
  121133. */
  121134. set dPadRight(value: number);
  121135. /**
  121136. * Force the gamepad to synchronize with device values
  121137. */
  121138. update(): void;
  121139. /**
  121140. * Disposes the gamepad
  121141. */
  121142. dispose(): void;
  121143. }
  121144. }
  121145. declare module BABYLON {
  121146. /**
  121147. * Defines supported buttons for DualShock compatible gamepads
  121148. */
  121149. export enum DualShockButton {
  121150. /** Cross */
  121151. Cross = 0,
  121152. /** Circle */
  121153. Circle = 1,
  121154. /** Square */
  121155. Square = 2,
  121156. /** Triangle */
  121157. Triangle = 3,
  121158. /** L1 */
  121159. L1 = 4,
  121160. /** R1 */
  121161. R1 = 5,
  121162. /** Share */
  121163. Share = 8,
  121164. /** Options */
  121165. Options = 9,
  121166. /** Left stick */
  121167. LeftStick = 10,
  121168. /** Right stick */
  121169. RightStick = 11
  121170. }
  121171. /** Defines values for DualShock DPad */
  121172. export enum DualShockDpad {
  121173. /** Up */
  121174. Up = 12,
  121175. /** Down */
  121176. Down = 13,
  121177. /** Left */
  121178. Left = 14,
  121179. /** Right */
  121180. Right = 15
  121181. }
  121182. /**
  121183. * Defines a DualShock gamepad
  121184. */
  121185. export class DualShockPad extends Gamepad {
  121186. private _leftTrigger;
  121187. private _rightTrigger;
  121188. private _onlefttriggerchanged;
  121189. private _onrighttriggerchanged;
  121190. private _onbuttondown;
  121191. private _onbuttonup;
  121192. private _ondpaddown;
  121193. private _ondpadup;
  121194. /** Observable raised when a button is pressed */
  121195. onButtonDownObservable: Observable<DualShockButton>;
  121196. /** Observable raised when a button is released */
  121197. onButtonUpObservable: Observable<DualShockButton>;
  121198. /** Observable raised when a pad is pressed */
  121199. onPadDownObservable: Observable<DualShockDpad>;
  121200. /** Observable raised when a pad is released */
  121201. onPadUpObservable: Observable<DualShockDpad>;
  121202. private _buttonCross;
  121203. private _buttonCircle;
  121204. private _buttonSquare;
  121205. private _buttonTriangle;
  121206. private _buttonShare;
  121207. private _buttonOptions;
  121208. private _buttonL1;
  121209. private _buttonR1;
  121210. private _buttonLeftStick;
  121211. private _buttonRightStick;
  121212. private _dPadUp;
  121213. private _dPadDown;
  121214. private _dPadLeft;
  121215. private _dPadRight;
  121216. /**
  121217. * Creates a new DualShock gamepad object
  121218. * @param id defines the id of this gamepad
  121219. * @param index defines its index
  121220. * @param gamepad defines the internal HTML gamepad object
  121221. */
  121222. constructor(id: string, index: number, gamepad: any);
  121223. /**
  121224. * Defines the callback to call when left trigger is pressed
  121225. * @param callback defines the callback to use
  121226. */
  121227. onlefttriggerchanged(callback: (value: number) => void): void;
  121228. /**
  121229. * Defines the callback to call when right trigger is pressed
  121230. * @param callback defines the callback to use
  121231. */
  121232. onrighttriggerchanged(callback: (value: number) => void): void;
  121233. /**
  121234. * Gets the left trigger value
  121235. */
  121236. get leftTrigger(): number;
  121237. /**
  121238. * Sets the left trigger value
  121239. */
  121240. set leftTrigger(newValue: number);
  121241. /**
  121242. * Gets the right trigger value
  121243. */
  121244. get rightTrigger(): number;
  121245. /**
  121246. * Sets the right trigger value
  121247. */
  121248. set rightTrigger(newValue: number);
  121249. /**
  121250. * Defines the callback to call when a button is pressed
  121251. * @param callback defines the callback to use
  121252. */
  121253. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  121254. /**
  121255. * Defines the callback to call when a button is released
  121256. * @param callback defines the callback to use
  121257. */
  121258. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  121259. /**
  121260. * Defines the callback to call when a pad is pressed
  121261. * @param callback defines the callback to use
  121262. */
  121263. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121264. /**
  121265. * Defines the callback to call when a pad is released
  121266. * @param callback defines the callback to use
  121267. */
  121268. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  121269. private _setButtonValue;
  121270. private _setDPadValue;
  121271. /**
  121272. * Gets the value of the `Cross` button
  121273. */
  121274. get buttonCross(): number;
  121275. /**
  121276. * Sets the value of the `Cross` button
  121277. */
  121278. set buttonCross(value: number);
  121279. /**
  121280. * Gets the value of the `Circle` button
  121281. */
  121282. get buttonCircle(): number;
  121283. /**
  121284. * Sets the value of the `Circle` button
  121285. */
  121286. set buttonCircle(value: number);
  121287. /**
  121288. * Gets the value of the `Square` button
  121289. */
  121290. get buttonSquare(): number;
  121291. /**
  121292. * Sets the value of the `Square` button
  121293. */
  121294. set buttonSquare(value: number);
  121295. /**
  121296. * Gets the value of the `Triangle` button
  121297. */
  121298. get buttonTriangle(): number;
  121299. /**
  121300. * Sets the value of the `Triangle` button
  121301. */
  121302. set buttonTriangle(value: number);
  121303. /**
  121304. * Gets the value of the `Options` button
  121305. */
  121306. get buttonOptions(): number;
  121307. /**
  121308. * Sets the value of the `Options` button
  121309. */
  121310. set buttonOptions(value: number);
  121311. /**
  121312. * Gets the value of the `Share` button
  121313. */
  121314. get buttonShare(): number;
  121315. /**
  121316. * Sets the value of the `Share` button
  121317. */
  121318. set buttonShare(value: number);
  121319. /**
  121320. * Gets the value of the `L1` button
  121321. */
  121322. get buttonL1(): number;
  121323. /**
  121324. * Sets the value of the `L1` button
  121325. */
  121326. set buttonL1(value: number);
  121327. /**
  121328. * Gets the value of the `R1` button
  121329. */
  121330. get buttonR1(): number;
  121331. /**
  121332. * Sets the value of the `R1` button
  121333. */
  121334. set buttonR1(value: number);
  121335. /**
  121336. * Gets the value of the Left joystick
  121337. */
  121338. get buttonLeftStick(): number;
  121339. /**
  121340. * Sets the value of the Left joystick
  121341. */
  121342. set buttonLeftStick(value: number);
  121343. /**
  121344. * Gets the value of the Right joystick
  121345. */
  121346. get buttonRightStick(): number;
  121347. /**
  121348. * Sets the value of the Right joystick
  121349. */
  121350. set buttonRightStick(value: number);
  121351. /**
  121352. * Gets the value of D-pad up
  121353. */
  121354. get dPadUp(): number;
  121355. /**
  121356. * Sets the value of D-pad up
  121357. */
  121358. set dPadUp(value: number);
  121359. /**
  121360. * Gets the value of D-pad down
  121361. */
  121362. get dPadDown(): number;
  121363. /**
  121364. * Sets the value of D-pad down
  121365. */
  121366. set dPadDown(value: number);
  121367. /**
  121368. * Gets the value of D-pad left
  121369. */
  121370. get dPadLeft(): number;
  121371. /**
  121372. * Sets the value of D-pad left
  121373. */
  121374. set dPadLeft(value: number);
  121375. /**
  121376. * Gets the value of D-pad right
  121377. */
  121378. get dPadRight(): number;
  121379. /**
  121380. * Sets the value of D-pad right
  121381. */
  121382. set dPadRight(value: number);
  121383. /**
  121384. * Force the gamepad to synchronize with device values
  121385. */
  121386. update(): void;
  121387. /**
  121388. * Disposes the gamepad
  121389. */
  121390. dispose(): void;
  121391. }
  121392. }
  121393. declare module BABYLON {
  121394. /**
  121395. * Manager for handling gamepads
  121396. */
  121397. export class GamepadManager {
  121398. private _scene?;
  121399. private _babylonGamepads;
  121400. private _oneGamepadConnected;
  121401. /** @hidden */
  121402. _isMonitoring: boolean;
  121403. private _gamepadEventSupported;
  121404. private _gamepadSupport?;
  121405. /**
  121406. * observable to be triggered when the gamepad controller has been connected
  121407. */
  121408. onGamepadConnectedObservable: Observable<Gamepad>;
  121409. /**
  121410. * observable to be triggered when the gamepad controller has been disconnected
  121411. */
  121412. onGamepadDisconnectedObservable: Observable<Gamepad>;
  121413. private _onGamepadConnectedEvent;
  121414. private _onGamepadDisconnectedEvent;
  121415. /**
  121416. * Initializes the gamepad manager
  121417. * @param _scene BabylonJS scene
  121418. */
  121419. constructor(_scene?: Scene | undefined);
  121420. /**
  121421. * The gamepads in the game pad manager
  121422. */
  121423. get gamepads(): Gamepad[];
  121424. /**
  121425. * Get the gamepad controllers based on type
  121426. * @param type The type of gamepad controller
  121427. * @returns Nullable gamepad
  121428. */
  121429. getGamepadByType(type?: number): Nullable<Gamepad>;
  121430. /**
  121431. * Disposes the gamepad manager
  121432. */
  121433. dispose(): void;
  121434. private _addNewGamepad;
  121435. private _startMonitoringGamepads;
  121436. private _stopMonitoringGamepads;
  121437. /** @hidden */
  121438. _checkGamepadsStatus(): void;
  121439. private _updateGamepadObjects;
  121440. }
  121441. }
  121442. declare module BABYLON {
  121443. interface Scene {
  121444. /** @hidden */
  121445. _gamepadManager: Nullable<GamepadManager>;
  121446. /**
  121447. * Gets the gamepad manager associated with the scene
  121448. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  121449. */
  121450. gamepadManager: GamepadManager;
  121451. }
  121452. /**
  121453. * Interface representing a free camera inputs manager
  121454. */
  121455. interface FreeCameraInputsManager {
  121456. /**
  121457. * Adds gamepad input support to the FreeCameraInputsManager.
  121458. * @returns the FreeCameraInputsManager
  121459. */
  121460. addGamepad(): FreeCameraInputsManager;
  121461. }
  121462. /**
  121463. * Interface representing an arc rotate camera inputs manager
  121464. */
  121465. interface ArcRotateCameraInputsManager {
  121466. /**
  121467. * Adds gamepad input support to the ArcRotateCamera InputManager.
  121468. * @returns the camera inputs manager
  121469. */
  121470. addGamepad(): ArcRotateCameraInputsManager;
  121471. }
  121472. /**
  121473. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  121474. */
  121475. export class GamepadSystemSceneComponent implements ISceneComponent {
  121476. /**
  121477. * The component name helpfull to identify the component in the list of scene components.
  121478. */
  121479. readonly name: string;
  121480. /**
  121481. * The scene the component belongs to.
  121482. */
  121483. scene: Scene;
  121484. /**
  121485. * Creates a new instance of the component for the given scene
  121486. * @param scene Defines the scene to register the component in
  121487. */
  121488. constructor(scene: Scene);
  121489. /**
  121490. * Registers the component in a given scene
  121491. */
  121492. register(): void;
  121493. /**
  121494. * Rebuilds the elements related to this component in case of
  121495. * context lost for instance.
  121496. */
  121497. rebuild(): void;
  121498. /**
  121499. * Disposes the component and the associated ressources
  121500. */
  121501. dispose(): void;
  121502. private _beforeCameraUpdate;
  121503. }
  121504. }
  121505. declare module BABYLON {
  121506. /**
  121507. * 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,
  121508. * which still works and will still be found in many Playgrounds.
  121509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121510. */
  121511. export class UniversalCamera extends TouchCamera {
  121512. /**
  121513. * Defines the gamepad rotation sensiblity.
  121514. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121515. */
  121516. get gamepadAngularSensibility(): number;
  121517. set gamepadAngularSensibility(value: number);
  121518. /**
  121519. * Defines the gamepad move sensiblity.
  121520. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121521. */
  121522. get gamepadMoveSensibility(): number;
  121523. set gamepadMoveSensibility(value: number);
  121524. /**
  121525. * 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,
  121526. * which still works and will still be found in many Playgrounds.
  121527. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121528. * @param name Define the name of the camera in the scene
  121529. * @param position Define the start position of the camera in the scene
  121530. * @param scene Define the scene the camera belongs to
  121531. */
  121532. constructor(name: string, position: Vector3, scene: Scene);
  121533. /**
  121534. * Gets the current object class name.
  121535. * @return the class name
  121536. */
  121537. getClassName(): string;
  121538. }
  121539. }
  121540. declare module BABYLON {
  121541. /**
  121542. * This represents a FPS type of camera. This is only here for back compat purpose.
  121543. * Please use the UniversalCamera instead as both are identical.
  121544. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121545. */
  121546. export class GamepadCamera extends UniversalCamera {
  121547. /**
  121548. * Instantiates a new Gamepad Camera
  121549. * This represents a FPS type of camera. This is only here for back compat purpose.
  121550. * Please use the UniversalCamera instead as both are identical.
  121551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121552. * @param name Define the name of the camera in the scene
  121553. * @param position Define the start position of the camera in the scene
  121554. * @param scene Define the scene the camera belongs to
  121555. */
  121556. constructor(name: string, position: Vector3, scene: Scene);
  121557. /**
  121558. * Gets the current object class name.
  121559. * @return the class name
  121560. */
  121561. getClassName(): string;
  121562. }
  121563. }
  121564. declare module BABYLON {
  121565. /** @hidden */
  121566. export var passPixelShader: {
  121567. name: string;
  121568. shader: string;
  121569. };
  121570. }
  121571. declare module BABYLON {
  121572. /** @hidden */
  121573. export var passCubePixelShader: {
  121574. name: string;
  121575. shader: string;
  121576. };
  121577. }
  121578. declare module BABYLON {
  121579. /**
  121580. * PassPostProcess which produces an output the same as it's input
  121581. */
  121582. export class PassPostProcess extends PostProcess {
  121583. /**
  121584. * Creates the PassPostProcess
  121585. * @param name The name of the effect.
  121586. * @param options The required width/height ratio to downsize to before computing the render pass.
  121587. * @param camera The camera to apply the render pass to.
  121588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121589. * @param engine The engine which the post process will be applied. (default: current engine)
  121590. * @param reusable If the post process can be reused on the same frame. (default: false)
  121591. * @param textureType The type of texture to be used when performing the post processing.
  121592. * @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)
  121593. */
  121594. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121595. }
  121596. /**
  121597. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  121598. */
  121599. export class PassCubePostProcess extends PostProcess {
  121600. private _face;
  121601. /**
  121602. * Gets or sets the cube face to display.
  121603. * * 0 is +X
  121604. * * 1 is -X
  121605. * * 2 is +Y
  121606. * * 3 is -Y
  121607. * * 4 is +Z
  121608. * * 5 is -Z
  121609. */
  121610. get face(): number;
  121611. set face(value: number);
  121612. /**
  121613. * Creates the PassCubePostProcess
  121614. * @param name The name of the effect.
  121615. * @param options The required width/height ratio to downsize to before computing the render pass.
  121616. * @param camera The camera to apply the render pass to.
  121617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121618. * @param engine The engine which the post process will be applied. (default: current engine)
  121619. * @param reusable If the post process can be reused on the same frame. (default: false)
  121620. * @param textureType The type of texture to be used when performing the post processing.
  121621. * @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)
  121622. */
  121623. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121624. }
  121625. }
  121626. declare module BABYLON {
  121627. /** @hidden */
  121628. export var anaglyphPixelShader: {
  121629. name: string;
  121630. shader: string;
  121631. };
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Postprocess used to generate anaglyphic rendering
  121636. */
  121637. export class AnaglyphPostProcess extends PostProcess {
  121638. private _passedProcess;
  121639. /**
  121640. * Creates a new AnaglyphPostProcess
  121641. * @param name defines postprocess name
  121642. * @param options defines creation options or target ratio scale
  121643. * @param rigCameras defines cameras using this postprocess
  121644. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  121645. * @param engine defines hosting engine
  121646. * @param reusable defines if the postprocess will be reused multiple times per frame
  121647. */
  121648. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  121649. }
  121650. }
  121651. declare module BABYLON {
  121652. /**
  121653. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  121654. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121655. */
  121656. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  121657. /**
  121658. * Creates a new AnaglyphArcRotateCamera
  121659. * @param name defines camera name
  121660. * @param alpha defines alpha angle (in radians)
  121661. * @param beta defines beta angle (in radians)
  121662. * @param radius defines radius
  121663. * @param target defines camera target
  121664. * @param interaxialDistance defines distance between each color axis
  121665. * @param scene defines the hosting scene
  121666. */
  121667. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  121668. /**
  121669. * Gets camera class name
  121670. * @returns AnaglyphArcRotateCamera
  121671. */
  121672. getClassName(): string;
  121673. }
  121674. }
  121675. declare module BABYLON {
  121676. /**
  121677. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  121678. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121679. */
  121680. export class AnaglyphFreeCamera extends FreeCamera {
  121681. /**
  121682. * Creates a new AnaglyphFreeCamera
  121683. * @param name defines camera name
  121684. * @param position defines initial position
  121685. * @param interaxialDistance defines distance between each color axis
  121686. * @param scene defines the hosting scene
  121687. */
  121688. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  121689. /**
  121690. * Gets camera class name
  121691. * @returns AnaglyphFreeCamera
  121692. */
  121693. getClassName(): string;
  121694. }
  121695. }
  121696. declare module BABYLON {
  121697. /**
  121698. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  121699. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121700. */
  121701. export class AnaglyphGamepadCamera extends GamepadCamera {
  121702. /**
  121703. * Creates a new AnaglyphGamepadCamera
  121704. * @param name defines camera name
  121705. * @param position defines initial position
  121706. * @param interaxialDistance defines distance between each color axis
  121707. * @param scene defines the hosting scene
  121708. */
  121709. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  121710. /**
  121711. * Gets camera class name
  121712. * @returns AnaglyphGamepadCamera
  121713. */
  121714. getClassName(): string;
  121715. }
  121716. }
  121717. declare module BABYLON {
  121718. /**
  121719. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  121720. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121721. */
  121722. export class AnaglyphUniversalCamera extends UniversalCamera {
  121723. /**
  121724. * Creates a new AnaglyphUniversalCamera
  121725. * @param name defines camera name
  121726. * @param position defines initial position
  121727. * @param interaxialDistance defines distance between each color axis
  121728. * @param scene defines the hosting scene
  121729. */
  121730. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  121731. /**
  121732. * Gets camera class name
  121733. * @returns AnaglyphUniversalCamera
  121734. */
  121735. getClassName(): string;
  121736. }
  121737. }
  121738. declare module BABYLON {
  121739. /**
  121740. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  121741. * @see http://doc.babylonjs.com/features/cameras
  121742. */
  121743. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  121744. /**
  121745. * Creates a new StereoscopicArcRotateCamera
  121746. * @param name defines camera name
  121747. * @param alpha defines alpha angle (in radians)
  121748. * @param beta defines beta angle (in radians)
  121749. * @param radius defines radius
  121750. * @param target defines camera target
  121751. * @param interaxialDistance defines distance between each color axis
  121752. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121753. * @param scene defines the hosting scene
  121754. */
  121755. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121756. /**
  121757. * Gets camera class name
  121758. * @returns StereoscopicArcRotateCamera
  121759. */
  121760. getClassName(): string;
  121761. }
  121762. }
  121763. declare module BABYLON {
  121764. /**
  121765. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  121766. * @see http://doc.babylonjs.com/features/cameras
  121767. */
  121768. export class StereoscopicFreeCamera extends FreeCamera {
  121769. /**
  121770. * Creates a new StereoscopicFreeCamera
  121771. * @param name defines camera name
  121772. * @param position defines initial position
  121773. * @param interaxialDistance defines distance between each color axis
  121774. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121775. * @param scene defines the hosting scene
  121776. */
  121777. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121778. /**
  121779. * Gets camera class name
  121780. * @returns StereoscopicFreeCamera
  121781. */
  121782. getClassName(): string;
  121783. }
  121784. }
  121785. declare module BABYLON {
  121786. /**
  121787. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  121788. * @see http://doc.babylonjs.com/features/cameras
  121789. */
  121790. export class StereoscopicGamepadCamera extends GamepadCamera {
  121791. /**
  121792. * Creates a new StereoscopicGamepadCamera
  121793. * @param name defines camera name
  121794. * @param position defines initial position
  121795. * @param interaxialDistance defines distance between each color axis
  121796. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121797. * @param scene defines the hosting scene
  121798. */
  121799. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121800. /**
  121801. * Gets camera class name
  121802. * @returns StereoscopicGamepadCamera
  121803. */
  121804. getClassName(): string;
  121805. }
  121806. }
  121807. declare module BABYLON {
  121808. /**
  121809. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  121810. * @see http://doc.babylonjs.com/features/cameras
  121811. */
  121812. export class StereoscopicUniversalCamera extends UniversalCamera {
  121813. /**
  121814. * Creates a new StereoscopicUniversalCamera
  121815. * @param name defines camera name
  121816. * @param position defines initial position
  121817. * @param interaxialDistance defines distance between each color axis
  121818. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121819. * @param scene defines the hosting scene
  121820. */
  121821. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121822. /**
  121823. * Gets camera class name
  121824. * @returns StereoscopicUniversalCamera
  121825. */
  121826. getClassName(): string;
  121827. }
  121828. }
  121829. declare module BABYLON {
  121830. /**
  121831. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  121832. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  121833. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  121834. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  121835. */
  121836. export class VirtualJoysticksCamera extends FreeCamera {
  121837. /**
  121838. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  121839. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  121840. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  121841. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  121842. * @param name Define the name of the camera in the scene
  121843. * @param position Define the start position of the camera in the scene
  121844. * @param scene Define the scene the camera belongs to
  121845. */
  121846. constructor(name: string, position: Vector3, scene: Scene);
  121847. /**
  121848. * Gets the current object class name.
  121849. * @return the class name
  121850. */
  121851. getClassName(): string;
  121852. }
  121853. }
  121854. declare module BABYLON {
  121855. /**
  121856. * This represents all the required metrics to create a VR camera.
  121857. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  121858. */
  121859. export class VRCameraMetrics {
  121860. /**
  121861. * Define the horizontal resolution off the screen.
  121862. */
  121863. hResolution: number;
  121864. /**
  121865. * Define the vertical resolution off the screen.
  121866. */
  121867. vResolution: number;
  121868. /**
  121869. * Define the horizontal screen size.
  121870. */
  121871. hScreenSize: number;
  121872. /**
  121873. * Define the vertical screen size.
  121874. */
  121875. vScreenSize: number;
  121876. /**
  121877. * Define the vertical screen center position.
  121878. */
  121879. vScreenCenter: number;
  121880. /**
  121881. * Define the distance of the eyes to the screen.
  121882. */
  121883. eyeToScreenDistance: number;
  121884. /**
  121885. * Define the distance between both lenses
  121886. */
  121887. lensSeparationDistance: number;
  121888. /**
  121889. * Define the distance between both viewer's eyes.
  121890. */
  121891. interpupillaryDistance: number;
  121892. /**
  121893. * Define the distortion factor of the VR postprocess.
  121894. * Please, touch with care.
  121895. */
  121896. distortionK: number[];
  121897. /**
  121898. * Define the chromatic aberration correction factors for the VR post process.
  121899. */
  121900. chromaAbCorrection: number[];
  121901. /**
  121902. * Define the scale factor of the post process.
  121903. * The smaller the better but the slower.
  121904. */
  121905. postProcessScaleFactor: number;
  121906. /**
  121907. * Define an offset for the lens center.
  121908. */
  121909. lensCenterOffset: number;
  121910. /**
  121911. * Define if the current vr camera should compensate the distortion of the lense or not.
  121912. */
  121913. compensateDistortion: boolean;
  121914. /**
  121915. * Defines if multiview should be enabled when rendering (Default: false)
  121916. */
  121917. multiviewEnabled: boolean;
  121918. /**
  121919. * Gets the rendering aspect ratio based on the provided resolutions.
  121920. */
  121921. get aspectRatio(): number;
  121922. /**
  121923. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  121924. */
  121925. get aspectRatioFov(): number;
  121926. /**
  121927. * @hidden
  121928. */
  121929. get leftHMatrix(): Matrix;
  121930. /**
  121931. * @hidden
  121932. */
  121933. get rightHMatrix(): Matrix;
  121934. /**
  121935. * @hidden
  121936. */
  121937. get leftPreViewMatrix(): Matrix;
  121938. /**
  121939. * @hidden
  121940. */
  121941. get rightPreViewMatrix(): Matrix;
  121942. /**
  121943. * Get the default VRMetrics based on the most generic setup.
  121944. * @returns the default vr metrics
  121945. */
  121946. static GetDefault(): VRCameraMetrics;
  121947. }
  121948. }
  121949. declare module BABYLON {
  121950. /** @hidden */
  121951. export var vrDistortionCorrectionPixelShader: {
  121952. name: string;
  121953. shader: string;
  121954. };
  121955. }
  121956. declare module BABYLON {
  121957. /**
  121958. * VRDistortionCorrectionPostProcess used for mobile VR
  121959. */
  121960. export class VRDistortionCorrectionPostProcess extends PostProcess {
  121961. private _isRightEye;
  121962. private _distortionFactors;
  121963. private _postProcessScaleFactor;
  121964. private _lensCenterOffset;
  121965. private _scaleIn;
  121966. private _scaleFactor;
  121967. private _lensCenter;
  121968. /**
  121969. * Initializes the VRDistortionCorrectionPostProcess
  121970. * @param name The name of the effect.
  121971. * @param camera The camera to apply the render pass to.
  121972. * @param isRightEye If this is for the right eye distortion
  121973. * @param vrMetrics All the required metrics for the VR camera
  121974. */
  121975. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  121976. }
  121977. }
  121978. declare module BABYLON {
  121979. /**
  121980. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  121981. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  121982. */
  121983. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  121984. /**
  121985. * Creates a new VRDeviceOrientationArcRotateCamera
  121986. * @param name defines camera name
  121987. * @param alpha defines the camera rotation along the logitudinal axis
  121988. * @param beta defines the camera rotation along the latitudinal axis
  121989. * @param radius defines the camera distance from its target
  121990. * @param target defines the camera target
  121991. * @param scene defines the scene the camera belongs to
  121992. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  121993. * @param vrCameraMetrics defines the vr metrics associated to the camera
  121994. */
  121995. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  121996. /**
  121997. * Gets camera class name
  121998. * @returns VRDeviceOrientationArcRotateCamera
  121999. */
  122000. getClassName(): string;
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Camera used to simulate VR rendering (based on FreeCamera)
  122006. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122007. */
  122008. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122009. /**
  122010. * Creates a new VRDeviceOrientationFreeCamera
  122011. * @param name defines camera name
  122012. * @param position defines the start position of the camera
  122013. * @param scene defines the scene the camera belongs to
  122014. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122015. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122016. */
  122017. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122018. /**
  122019. * Gets camera class name
  122020. * @returns VRDeviceOrientationFreeCamera
  122021. */
  122022. getClassName(): string;
  122023. }
  122024. }
  122025. declare module BABYLON {
  122026. /**
  122027. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122028. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122029. */
  122030. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122031. /**
  122032. * Creates a new VRDeviceOrientationGamepadCamera
  122033. * @param name defines camera name
  122034. * @param position defines the start position of the camera
  122035. * @param scene defines the scene the camera belongs to
  122036. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122037. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122038. */
  122039. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122040. /**
  122041. * Gets camera class name
  122042. * @returns VRDeviceOrientationGamepadCamera
  122043. */
  122044. getClassName(): string;
  122045. }
  122046. }
  122047. declare module BABYLON {
  122048. /** @hidden */
  122049. export var imageProcessingPixelShader: {
  122050. name: string;
  122051. shader: string;
  122052. };
  122053. }
  122054. declare module BABYLON {
  122055. /**
  122056. * ImageProcessingPostProcess
  122057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122058. */
  122059. export class ImageProcessingPostProcess extends PostProcess {
  122060. /**
  122061. * Default configuration related to image processing available in the PBR Material.
  122062. */
  122063. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122064. /**
  122065. * Gets the image processing configuration used either in this material.
  122066. */
  122067. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122068. /**
  122069. * Sets the Default image processing configuration used either in the this material.
  122070. *
  122071. * If sets to null, the scene one is in use.
  122072. */
  122073. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122074. /**
  122075. * Keep track of the image processing observer to allow dispose and replace.
  122076. */
  122077. private _imageProcessingObserver;
  122078. /**
  122079. * Attaches a new image processing configuration to the PBR Material.
  122080. * @param configuration
  122081. */
  122082. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122083. /**
  122084. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122085. */
  122086. get colorCurves(): Nullable<ColorCurves>;
  122087. /**
  122088. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122089. */
  122090. set colorCurves(value: Nullable<ColorCurves>);
  122091. /**
  122092. * Gets wether the color curves effect is enabled.
  122093. */
  122094. get colorCurvesEnabled(): boolean;
  122095. /**
  122096. * Sets wether the color curves effect is enabled.
  122097. */
  122098. set colorCurvesEnabled(value: boolean);
  122099. /**
  122100. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122101. */
  122102. get colorGradingTexture(): Nullable<BaseTexture>;
  122103. /**
  122104. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122105. */
  122106. set colorGradingTexture(value: Nullable<BaseTexture>);
  122107. /**
  122108. * Gets wether the color grading effect is enabled.
  122109. */
  122110. get colorGradingEnabled(): boolean;
  122111. /**
  122112. * Gets wether the color grading effect is enabled.
  122113. */
  122114. set colorGradingEnabled(value: boolean);
  122115. /**
  122116. * Gets exposure used in the effect.
  122117. */
  122118. get exposure(): number;
  122119. /**
  122120. * Sets exposure used in the effect.
  122121. */
  122122. set exposure(value: number);
  122123. /**
  122124. * Gets wether tonemapping is enabled or not.
  122125. */
  122126. get toneMappingEnabled(): boolean;
  122127. /**
  122128. * Sets wether tonemapping is enabled or not
  122129. */
  122130. set toneMappingEnabled(value: boolean);
  122131. /**
  122132. * Gets the type of tone mapping effect.
  122133. */
  122134. get toneMappingType(): number;
  122135. /**
  122136. * Sets the type of tone mapping effect.
  122137. */
  122138. set toneMappingType(value: number);
  122139. /**
  122140. * Gets contrast used in the effect.
  122141. */
  122142. get contrast(): number;
  122143. /**
  122144. * Sets contrast used in the effect.
  122145. */
  122146. set contrast(value: number);
  122147. /**
  122148. * Gets Vignette stretch size.
  122149. */
  122150. get vignetteStretch(): number;
  122151. /**
  122152. * Sets Vignette stretch size.
  122153. */
  122154. set vignetteStretch(value: number);
  122155. /**
  122156. * Gets Vignette centre X Offset.
  122157. */
  122158. get vignetteCentreX(): number;
  122159. /**
  122160. * Sets Vignette centre X Offset.
  122161. */
  122162. set vignetteCentreX(value: number);
  122163. /**
  122164. * Gets Vignette centre Y Offset.
  122165. */
  122166. get vignetteCentreY(): number;
  122167. /**
  122168. * Sets Vignette centre Y Offset.
  122169. */
  122170. set vignetteCentreY(value: number);
  122171. /**
  122172. * Gets Vignette weight or intensity of the vignette effect.
  122173. */
  122174. get vignetteWeight(): number;
  122175. /**
  122176. * Sets Vignette weight or intensity of the vignette effect.
  122177. */
  122178. set vignetteWeight(value: number);
  122179. /**
  122180. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122181. * if vignetteEnabled is set to true.
  122182. */
  122183. get vignetteColor(): Color4;
  122184. /**
  122185. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122186. * if vignetteEnabled is set to true.
  122187. */
  122188. set vignetteColor(value: Color4);
  122189. /**
  122190. * Gets Camera field of view used by the Vignette effect.
  122191. */
  122192. get vignetteCameraFov(): number;
  122193. /**
  122194. * Sets Camera field of view used by the Vignette effect.
  122195. */
  122196. set vignetteCameraFov(value: number);
  122197. /**
  122198. * Gets the vignette blend mode allowing different kind of effect.
  122199. */
  122200. get vignetteBlendMode(): number;
  122201. /**
  122202. * Sets the vignette blend mode allowing different kind of effect.
  122203. */
  122204. set vignetteBlendMode(value: number);
  122205. /**
  122206. * Gets wether the vignette effect is enabled.
  122207. */
  122208. get vignetteEnabled(): boolean;
  122209. /**
  122210. * Sets wether the vignette effect is enabled.
  122211. */
  122212. set vignetteEnabled(value: boolean);
  122213. private _fromLinearSpace;
  122214. /**
  122215. * Gets wether the input of the processing is in Gamma or Linear Space.
  122216. */
  122217. get fromLinearSpace(): boolean;
  122218. /**
  122219. * Sets wether the input of the processing is in Gamma or Linear Space.
  122220. */
  122221. set fromLinearSpace(value: boolean);
  122222. /**
  122223. * Defines cache preventing GC.
  122224. */
  122225. private _defines;
  122226. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122227. /**
  122228. * "ImageProcessingPostProcess"
  122229. * @returns "ImageProcessingPostProcess"
  122230. */
  122231. getClassName(): string;
  122232. protected _updateParameters(): void;
  122233. dispose(camera?: Camera): void;
  122234. }
  122235. }
  122236. declare module BABYLON {
  122237. /**
  122238. * Class containing static functions to help procedurally build meshes
  122239. */
  122240. export class GroundBuilder {
  122241. /**
  122242. * Creates a ground mesh
  122243. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122244. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122246. * @param name defines the name of the mesh
  122247. * @param options defines the options used to create the mesh
  122248. * @param scene defines the hosting scene
  122249. * @returns the ground mesh
  122250. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122251. */
  122252. static CreateGround(name: string, options: {
  122253. width?: number;
  122254. height?: number;
  122255. subdivisions?: number;
  122256. subdivisionsX?: number;
  122257. subdivisionsY?: number;
  122258. updatable?: boolean;
  122259. }, scene: any): Mesh;
  122260. /**
  122261. * Creates a tiled ground mesh
  122262. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122263. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122264. * * 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
  122265. * * 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
  122266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122267. * @param name defines the name of the mesh
  122268. * @param options defines the options used to create the mesh
  122269. * @param scene defines the hosting scene
  122270. * @returns the tiled ground mesh
  122271. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122272. */
  122273. static CreateTiledGround(name: string, options: {
  122274. xmin: number;
  122275. zmin: number;
  122276. xmax: number;
  122277. zmax: number;
  122278. subdivisions?: {
  122279. w: number;
  122280. h: number;
  122281. };
  122282. precision?: {
  122283. w: number;
  122284. h: number;
  122285. };
  122286. updatable?: boolean;
  122287. }, scene?: Nullable<Scene>): Mesh;
  122288. /**
  122289. * Creates a ground mesh from a height map
  122290. * * The parameter `url` sets the URL of the height map image resource.
  122291. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122292. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122293. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122294. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122295. * * 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.
  122296. * * 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).
  122297. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122299. * @param name defines the name of the mesh
  122300. * @param url defines the url to the height map
  122301. * @param options defines the options used to create the mesh
  122302. * @param scene defines the hosting scene
  122303. * @returns the ground mesh
  122304. * @see https://doc.babylonjs.com/babylon101/height_map
  122305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122306. */
  122307. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122308. width?: number;
  122309. height?: number;
  122310. subdivisions?: number;
  122311. minHeight?: number;
  122312. maxHeight?: number;
  122313. colorFilter?: Color3;
  122314. alphaFilter?: number;
  122315. updatable?: boolean;
  122316. onReady?: (mesh: GroundMesh) => void;
  122317. }, scene?: Nullable<Scene>): GroundMesh;
  122318. }
  122319. }
  122320. declare module BABYLON {
  122321. /**
  122322. * Class containing static functions to help procedurally build meshes
  122323. */
  122324. export class TorusBuilder {
  122325. /**
  122326. * Creates a torus mesh
  122327. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122328. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122329. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122333. * @param name defines the name of the mesh
  122334. * @param options defines the options used to create the mesh
  122335. * @param scene defines the hosting scene
  122336. * @returns the torus mesh
  122337. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122338. */
  122339. static CreateTorus(name: string, options: {
  122340. diameter?: number;
  122341. thickness?: number;
  122342. tessellation?: number;
  122343. updatable?: boolean;
  122344. sideOrientation?: number;
  122345. frontUVs?: Vector4;
  122346. backUVs?: Vector4;
  122347. }, scene: any): Mesh;
  122348. }
  122349. }
  122350. declare module BABYLON {
  122351. /**
  122352. * Class containing static functions to help procedurally build meshes
  122353. */
  122354. export class CylinderBuilder {
  122355. /**
  122356. * Creates a cylinder or a cone mesh
  122357. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122358. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122359. * * 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.
  122360. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122361. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122362. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122363. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122364. * * 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).
  122365. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122366. * * 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).
  122367. * * 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
  122368. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122369. * * 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
  122370. * * 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.
  122371. * * If `enclose` is false, a ring surface is one element.
  122372. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122373. * * 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
  122374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122377. * @param name defines the name of the mesh
  122378. * @param options defines the options used to create the mesh
  122379. * @param scene defines the hosting scene
  122380. * @returns the cylinder mesh
  122381. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122382. */
  122383. static CreateCylinder(name: string, options: {
  122384. height?: number;
  122385. diameterTop?: number;
  122386. diameterBottom?: number;
  122387. diameter?: number;
  122388. tessellation?: number;
  122389. subdivisions?: number;
  122390. arc?: number;
  122391. faceColors?: Color4[];
  122392. faceUV?: Vector4[];
  122393. updatable?: boolean;
  122394. hasRings?: boolean;
  122395. enclose?: boolean;
  122396. cap?: number;
  122397. sideOrientation?: number;
  122398. frontUVs?: Vector4;
  122399. backUVs?: Vector4;
  122400. }, scene: any): Mesh;
  122401. }
  122402. }
  122403. declare module BABYLON {
  122404. /**
  122405. * States of the webXR experience
  122406. */
  122407. export enum WebXRState {
  122408. /**
  122409. * Transitioning to being in XR mode
  122410. */
  122411. ENTERING_XR = 0,
  122412. /**
  122413. * Transitioning to non XR mode
  122414. */
  122415. EXITING_XR = 1,
  122416. /**
  122417. * In XR mode and presenting
  122418. */
  122419. IN_XR = 2,
  122420. /**
  122421. * Not entered XR mode
  122422. */
  122423. NOT_IN_XR = 3
  122424. }
  122425. /**
  122426. * Abstraction of the XR render target
  122427. */
  122428. export interface WebXRRenderTarget extends IDisposable {
  122429. /**
  122430. * xrpresent context of the canvas which can be used to display/mirror xr content
  122431. */
  122432. canvasContext: WebGLRenderingContext;
  122433. /**
  122434. * xr layer for the canvas
  122435. */
  122436. xrLayer: Nullable<XRWebGLLayer>;
  122437. /**
  122438. * Initializes the xr layer for the session
  122439. * @param xrSession xr session
  122440. * @returns a promise that will resolve once the XR Layer has been created
  122441. */
  122442. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122443. }
  122444. }
  122445. declare module BABYLON {
  122446. /**
  122447. * COnfiguration object for WebXR output canvas
  122448. */
  122449. export class WebXRManagedOutputCanvasOptions {
  122450. /**
  122451. * An optional canvas in case you wish to create it yourself and provide it here.
  122452. * If not provided, a new canvas will be created
  122453. */
  122454. canvasElement?: HTMLCanvasElement;
  122455. /**
  122456. * Options for this XR Layer output
  122457. */
  122458. canvasOptions?: XRWebGLLayerOptions;
  122459. /**
  122460. * CSS styling for a newly created canvas (if not provided)
  122461. */
  122462. newCanvasCssStyle?: string;
  122463. /**
  122464. * Get the default values of the configuration object
  122465. * @returns default values of this configuration object
  122466. */
  122467. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  122468. }
  122469. /**
  122470. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  122471. */
  122472. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  122473. private _options;
  122474. private _canvas;
  122475. private _engine;
  122476. /**
  122477. * Rendering context of the canvas which can be used to display/mirror xr content
  122478. */
  122479. canvasContext: WebGLRenderingContext;
  122480. /**
  122481. * xr layer for the canvas
  122482. */
  122483. xrLayer: Nullable<XRWebGLLayer>;
  122484. /**
  122485. * Initializes the canvas to be added/removed upon entering/exiting xr
  122486. * @param _xrSessionManager The XR Session manager
  122487. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  122488. */
  122489. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  122490. /**
  122491. * Disposes of the object
  122492. */
  122493. dispose(): void;
  122494. /**
  122495. * Initializes the xr layer for the session
  122496. * @param xrSession xr session
  122497. * @returns a promise that will resolve once the XR Layer has been created
  122498. */
  122499. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122500. private _addCanvas;
  122501. private _removeCanvas;
  122502. private _setManagedOutputCanvas;
  122503. }
  122504. }
  122505. declare module BABYLON {
  122506. /**
  122507. * Manages an XRSession to work with Babylon's engine
  122508. * @see https://doc.babylonjs.com/how_to/webxr
  122509. */
  122510. export class WebXRSessionManager implements IDisposable {
  122511. /** The scene which the session should be created for */
  122512. scene: Scene;
  122513. private _referenceSpace;
  122514. private _rttProvider;
  122515. private _sessionEnded;
  122516. private _xrNavigator;
  122517. private baseLayer;
  122518. /**
  122519. * The base reference space from which the session started. good if you want to reset your
  122520. * reference space
  122521. */
  122522. baseReferenceSpace: XRReferenceSpace;
  122523. /**
  122524. * Current XR frame
  122525. */
  122526. currentFrame: Nullable<XRFrame>;
  122527. /** WebXR timestamp updated every frame */
  122528. currentTimestamp: number;
  122529. /**
  122530. * Used just in case of a failure to initialize an immersive session.
  122531. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  122532. */
  122533. defaultHeightCompensation: number;
  122534. /**
  122535. * Fires every time a new xrFrame arrives which can be used to update the camera
  122536. */
  122537. onXRFrameObservable: Observable<XRFrame>;
  122538. /**
  122539. * Fires when the reference space changed
  122540. */
  122541. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  122542. /**
  122543. * Fires when the xr session is ended either by the device or manually done
  122544. */
  122545. onXRSessionEnded: Observable<any>;
  122546. /**
  122547. * Fires when the xr session is ended either by the device or manually done
  122548. */
  122549. onXRSessionInit: Observable<XRSession>;
  122550. /**
  122551. * Underlying xr session
  122552. */
  122553. session: XRSession;
  122554. /**
  122555. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  122556. * or get the offset the player is currently at.
  122557. */
  122558. viewerReferenceSpace: XRReferenceSpace;
  122559. /**
  122560. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  122561. * @param scene The scene which the session should be created for
  122562. */
  122563. constructor(
  122564. /** The scene which the session should be created for */
  122565. scene: Scene);
  122566. /**
  122567. * The current reference space used in this session. This reference space can constantly change!
  122568. * It is mainly used to offset the camera's position.
  122569. */
  122570. get referenceSpace(): XRReferenceSpace;
  122571. /**
  122572. * Set a new reference space and triggers the observable
  122573. */
  122574. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  122575. /**
  122576. * Disposes of the session manager
  122577. */
  122578. dispose(): void;
  122579. /**
  122580. * Stops the xrSession and restores the render loop
  122581. * @returns Promise which resolves after it exits XR
  122582. */
  122583. exitXRAsync(): Promise<void>;
  122584. /**
  122585. * Gets the correct render target texture to be rendered this frame for this eye
  122586. * @param eye the eye for which to get the render target
  122587. * @returns the render target for the specified eye
  122588. */
  122589. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  122590. /**
  122591. * Creates a WebXRRenderTarget object for the XR session
  122592. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  122593. * @param options optional options to provide when creating a new render target
  122594. * @returns a WebXR render target to which the session can render
  122595. */
  122596. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  122597. /**
  122598. * Initializes the manager
  122599. * After initialization enterXR can be called to start an XR session
  122600. * @returns Promise which resolves after it is initialized
  122601. */
  122602. initializeAsync(): Promise<void>;
  122603. /**
  122604. * Initializes an xr session
  122605. * @param xrSessionMode mode to initialize
  122606. * @param xrSessionInit defines optional and required values to pass to the session builder
  122607. * @returns a promise which will resolve once the session has been initialized
  122608. */
  122609. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  122610. /**
  122611. * Checks if a session would be supported for the creation options specified
  122612. * @param sessionMode session mode to check if supported eg. immersive-vr
  122613. * @returns A Promise that resolves to true if supported and false if not
  122614. */
  122615. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122616. /**
  122617. * Resets the reference space to the one started the session
  122618. */
  122619. resetReferenceSpace(): void;
  122620. /**
  122621. * Starts rendering to the xr layer
  122622. */
  122623. runXRRenderLoop(): void;
  122624. /**
  122625. * Sets the reference space on the xr session
  122626. * @param referenceSpaceType space to set
  122627. * @returns a promise that will resolve once the reference space has been set
  122628. */
  122629. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122630. /**
  122631. * Updates the render state of the session
  122632. * @param state state to set
  122633. * @returns a promise that resolves once the render state has been updated
  122634. */
  122635. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  122636. /**
  122637. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  122638. * @param sessionMode defines the session to test
  122639. * @returns a promise with boolean as final value
  122640. */
  122641. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122642. private _createRenderTargetTexture;
  122643. }
  122644. }
  122645. declare module BABYLON {
  122646. /**
  122647. * WebXR Camera which holds the views for the xrSession
  122648. * @see https://doc.babylonjs.com/how_to/webxr_camera
  122649. */
  122650. export class WebXRCamera extends FreeCamera {
  122651. private _xrSessionManager;
  122652. private _firstFrame;
  122653. private _referenceQuaternion;
  122654. private _referencedPosition;
  122655. private _xrInvPositionCache;
  122656. private _xrInvQuaternionCache;
  122657. /**
  122658. * Should position compensation execute on first frame.
  122659. * This is used when copying the position from a native (non XR) camera
  122660. */
  122661. compensateOnFirstFrame: boolean;
  122662. /**
  122663. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  122664. * @param name the name of the camera
  122665. * @param scene the scene to add the camera to
  122666. * @param _xrSessionManager a constructed xr session manager
  122667. */
  122668. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  122669. /**
  122670. * Return the user's height, unrelated to the current ground.
  122671. * This will be the y position of this camera, when ground level is 0.
  122672. */
  122673. get realWorldHeight(): number;
  122674. /** @hidden */
  122675. _updateForDualEyeDebugging(): void;
  122676. /**
  122677. * Sets this camera's transformation based on a non-vr camera
  122678. * @param otherCamera the non-vr camera to copy the transformation from
  122679. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  122680. */
  122681. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  122682. /**
  122683. * Gets the current instance class name ("WebXRCamera").
  122684. * @returns the class name
  122685. */
  122686. getClassName(): string;
  122687. /**
  122688. * Overriding the _getViewMatrix function, as it is computed by WebXR
  122689. */
  122690. _getViewMatrix(): Matrix;
  122691. private _updateFromXRSession;
  122692. private _updateNumberOfRigCameras;
  122693. private _updateReferenceSpace;
  122694. private _updateReferenceSpaceOffset;
  122695. }
  122696. }
  122697. declare module BABYLON {
  122698. /**
  122699. * Defining the interface required for a (webxr) feature
  122700. */
  122701. export interface IWebXRFeature extends IDisposable {
  122702. /**
  122703. * Is this feature attached
  122704. */
  122705. attached: boolean;
  122706. /**
  122707. * Should auto-attach be disabled?
  122708. */
  122709. disableAutoAttach: boolean;
  122710. /**
  122711. * Attach the feature to the session
  122712. * Will usually be called by the features manager
  122713. *
  122714. * @param force should attachment be forced (even when already attached)
  122715. * @returns true if successful.
  122716. */
  122717. attach(force?: boolean): boolean;
  122718. /**
  122719. * Detach the feature from the session
  122720. * Will usually be called by the features manager
  122721. *
  122722. * @returns true if successful.
  122723. */
  122724. detach(): boolean;
  122725. }
  122726. /**
  122727. * A list of the currently available features without referencing them
  122728. */
  122729. export class WebXRFeatureName {
  122730. /**
  122731. * The name of the anchor system feature
  122732. */
  122733. static ANCHOR_SYSTEM: string;
  122734. /**
  122735. * The name of the background remover feature
  122736. */
  122737. static BACKGROUND_REMOVER: string;
  122738. /**
  122739. * The name of the hit test feature
  122740. */
  122741. static HIT_TEST: string;
  122742. /**
  122743. * physics impostors for xr controllers feature
  122744. */
  122745. static PHYSICS_CONTROLLERS: string;
  122746. /**
  122747. * The name of the plane detection feature
  122748. */
  122749. static PLANE_DETECTION: string;
  122750. /**
  122751. * The name of the pointer selection feature
  122752. */
  122753. static POINTER_SELECTION: string;
  122754. /**
  122755. * The name of the teleportation feature
  122756. */
  122757. static TELEPORTATION: string;
  122758. }
  122759. /**
  122760. * Defining the constructor of a feature. Used to register the modules.
  122761. */
  122762. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  122763. /**
  122764. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  122765. * It is mainly used in AR sessions.
  122766. *
  122767. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  122768. */
  122769. export class WebXRFeaturesManager implements IDisposable {
  122770. private _xrSessionManager;
  122771. private static readonly _AvailableFeatures;
  122772. private _features;
  122773. /**
  122774. * constructs a new features manages.
  122775. *
  122776. * @param _xrSessionManager an instance of WebXRSessionManager
  122777. */
  122778. constructor(_xrSessionManager: WebXRSessionManager);
  122779. /**
  122780. * Used to register a module. After calling this function a developer can use this feature in the scene.
  122781. * Mainly used internally.
  122782. *
  122783. * @param featureName the name of the feature to register
  122784. * @param constructorFunction the function used to construct the module
  122785. * @param version the (babylon) version of the module
  122786. * @param stable is that a stable version of this module
  122787. */
  122788. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  122789. /**
  122790. * Returns a constructor of a specific feature.
  122791. *
  122792. * @param featureName the name of the feature to construct
  122793. * @param version the version of the feature to load
  122794. * @param xrSessionManager the xrSessionManager. Used to construct the module
  122795. * @param options optional options provided to the module.
  122796. * @returns a function that, when called, will return a new instance of this feature
  122797. */
  122798. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  122799. /**
  122800. * Can be used to return the list of features currently registered
  122801. *
  122802. * @returns an Array of available features
  122803. */
  122804. static GetAvailableFeatures(): string[];
  122805. /**
  122806. * Gets the versions available for a specific feature
  122807. * @param featureName the name of the feature
  122808. * @returns an array with the available versions
  122809. */
  122810. static GetAvailableVersions(featureName: string): string[];
  122811. /**
  122812. * Return the latest unstable version of this feature
  122813. * @param featureName the name of the feature to search
  122814. * @returns the version number. if not found will return -1
  122815. */
  122816. static GetLatestVersionOfFeature(featureName: string): number;
  122817. /**
  122818. * Return the latest stable version of this feature
  122819. * @param featureName the name of the feature to search
  122820. * @returns the version number. if not found will return -1
  122821. */
  122822. static GetStableVersionOfFeature(featureName: string): number;
  122823. /**
  122824. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  122825. * Can be used during a session to start a feature
  122826. * @param featureName the name of feature to attach
  122827. */
  122828. attachFeature(featureName: string): void;
  122829. /**
  122830. * Can be used inside a session or when the session ends to detach a specific feature
  122831. * @param featureName the name of the feature to detach
  122832. */
  122833. detachFeature(featureName: string): void;
  122834. /**
  122835. * Used to disable an already-enabled feature
  122836. * The feature will be disposed and will be recreated once enabled.
  122837. * @param featureName the feature to disable
  122838. * @returns true if disable was successful
  122839. */
  122840. disableFeature(featureName: string | {
  122841. Name: string;
  122842. }): boolean;
  122843. /**
  122844. * dispose this features manager
  122845. */
  122846. dispose(): void;
  122847. /**
  122848. * 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.
  122849. * 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.
  122850. *
  122851. * @param featureName the name of the feature to load or the class of the feature
  122852. * @param version optional version to load. if not provided the latest version will be enabled
  122853. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  122854. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  122855. * @returns a new constructed feature or throws an error if feature not found.
  122856. */
  122857. enableFeature(featureName: string | {
  122858. Name: string;
  122859. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  122860. /**
  122861. * get the implementation of an enabled feature.
  122862. * @param featureName the name of the feature to load
  122863. * @returns the feature class, if found
  122864. */
  122865. getEnabledFeature(featureName: string): IWebXRFeature;
  122866. /**
  122867. * Get the list of enabled features
  122868. * @returns an array of enabled features
  122869. */
  122870. getEnabledFeatures(): string[];
  122871. }
  122872. }
  122873. declare module BABYLON {
  122874. /**
  122875. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  122876. * @see https://doc.babylonjs.com/how_to/webxr
  122877. */
  122878. export class WebXRExperienceHelper implements IDisposable {
  122879. private scene;
  122880. private _nonVRCamera;
  122881. private _originalSceneAutoClear;
  122882. private _supported;
  122883. /**
  122884. * Camera used to render xr content
  122885. */
  122886. camera: WebXRCamera;
  122887. /** A features manager for this xr session */
  122888. featuresManager: WebXRFeaturesManager;
  122889. /**
  122890. * Observers registered here will be triggered after the camera's initial transformation is set
  122891. * This can be used to set a different ground level or an extra rotation.
  122892. *
  122893. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  122894. * to the position set after this observable is done executing.
  122895. */
  122896. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  122897. /**
  122898. * Fires when the state of the experience helper has changed
  122899. */
  122900. onStateChangedObservable: Observable<WebXRState>;
  122901. /** Session manager used to keep track of xr session */
  122902. sessionManager: WebXRSessionManager;
  122903. /**
  122904. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  122905. */
  122906. state: WebXRState;
  122907. /**
  122908. * Creates a WebXRExperienceHelper
  122909. * @param scene The scene the helper should be created in
  122910. */
  122911. private constructor();
  122912. /**
  122913. * Creates the experience helper
  122914. * @param scene the scene to attach the experience helper to
  122915. * @returns a promise for the experience helper
  122916. */
  122917. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  122918. /**
  122919. * Disposes of the experience helper
  122920. */
  122921. dispose(): void;
  122922. /**
  122923. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  122924. * @param sessionMode options for the XR session
  122925. * @param referenceSpaceType frame of reference of the XR session
  122926. * @param renderTarget the output canvas that will be used to enter XR mode
  122927. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  122928. * @returns promise that resolves after xr mode has entered
  122929. */
  122930. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  122931. /**
  122932. * Exits XR mode and returns the scene to its original state
  122933. * @returns promise that resolves after xr mode has exited
  122934. */
  122935. exitXRAsync(): Promise<void>;
  122936. private _nonXRToXRCamera;
  122937. private _setState;
  122938. }
  122939. }
  122940. declare module BABYLON {
  122941. /**
  122942. * X-Y values for axes in WebXR
  122943. */
  122944. export interface IWebXRMotionControllerAxesValue {
  122945. /**
  122946. * The value of the x axis
  122947. */
  122948. x: number;
  122949. /**
  122950. * The value of the y-axis
  122951. */
  122952. y: number;
  122953. }
  122954. /**
  122955. * changed / previous values for the values of this component
  122956. */
  122957. export interface IWebXRMotionControllerComponentChangesValues<T> {
  122958. /**
  122959. * current (this frame) value
  122960. */
  122961. current: T;
  122962. /**
  122963. * previous (last change) value
  122964. */
  122965. previous: T;
  122966. }
  122967. /**
  122968. * Represents changes in the component between current frame and last values recorded
  122969. */
  122970. export interface IWebXRMotionControllerComponentChanges {
  122971. /**
  122972. * will be populated with previous and current values if axes changed
  122973. */
  122974. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  122975. /**
  122976. * will be populated with previous and current values if pressed changed
  122977. */
  122978. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  122979. /**
  122980. * will be populated with previous and current values if touched changed
  122981. */
  122982. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  122983. /**
  122984. * will be populated with previous and current values if value changed
  122985. */
  122986. value?: IWebXRMotionControllerComponentChangesValues<number>;
  122987. }
  122988. /**
  122989. * This class represents a single component (for example button or thumbstick) of a motion controller
  122990. */
  122991. export class WebXRControllerComponent implements IDisposable {
  122992. /**
  122993. * the id of this component
  122994. */
  122995. id: string;
  122996. /**
  122997. * the type of the component
  122998. */
  122999. type: MotionControllerComponentType;
  123000. private _buttonIndex;
  123001. private _axesIndices;
  123002. private _axes;
  123003. private _changes;
  123004. private _currentValue;
  123005. private _hasChanges;
  123006. private _pressed;
  123007. private _touched;
  123008. /**
  123009. * button component type
  123010. */
  123011. static BUTTON_TYPE: MotionControllerComponentType;
  123012. /**
  123013. * squeeze component type
  123014. */
  123015. static SQUEEZE_TYPE: MotionControllerComponentType;
  123016. /**
  123017. * Thumbstick component type
  123018. */
  123019. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123020. /**
  123021. * Touchpad component type
  123022. */
  123023. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123024. /**
  123025. * trigger component type
  123026. */
  123027. static TRIGGER_TYPE: MotionControllerComponentType;
  123028. /**
  123029. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123030. * the axes data changes
  123031. */
  123032. onAxisValueChangedObservable: Observable<{
  123033. x: number;
  123034. y: number;
  123035. }>;
  123036. /**
  123037. * Observers registered here will be triggered when the state of a button changes
  123038. * State change is either pressed / touched / value
  123039. */
  123040. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123041. /**
  123042. * Creates a new component for a motion controller.
  123043. * It is created by the motion controller itself
  123044. *
  123045. * @param id the id of this component
  123046. * @param type the type of the component
  123047. * @param _buttonIndex index in the buttons array of the gamepad
  123048. * @param _axesIndices indices of the values in the axes array of the gamepad
  123049. */
  123050. constructor(
  123051. /**
  123052. * the id of this component
  123053. */
  123054. id: string,
  123055. /**
  123056. * the type of the component
  123057. */
  123058. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123059. /**
  123060. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123061. */
  123062. get axes(): IWebXRMotionControllerAxesValue;
  123063. /**
  123064. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123065. */
  123066. get changes(): IWebXRMotionControllerComponentChanges;
  123067. /**
  123068. * Return whether or not the component changed the last frame
  123069. */
  123070. get hasChanges(): boolean;
  123071. /**
  123072. * is the button currently pressed
  123073. */
  123074. get pressed(): boolean;
  123075. /**
  123076. * is the button currently touched
  123077. */
  123078. get touched(): boolean;
  123079. /**
  123080. * Get the current value of this component
  123081. */
  123082. get value(): number;
  123083. /**
  123084. * Dispose this component
  123085. */
  123086. dispose(): void;
  123087. /**
  123088. * Are there axes correlating to this component
  123089. * @return true is axes data is available
  123090. */
  123091. isAxes(): boolean;
  123092. /**
  123093. * Is this component a button (hence - pressable)
  123094. * @returns true if can be pressed
  123095. */
  123096. isButton(): boolean;
  123097. /**
  123098. * update this component using the gamepad object it is in. Called on every frame
  123099. * @param nativeController the native gamepad controller object
  123100. */
  123101. update(nativeController: IMinimalMotionControllerObject): void;
  123102. }
  123103. }
  123104. declare module BABYLON {
  123105. /**
  123106. * Class used to represent data loading progression
  123107. */
  123108. export class SceneLoaderProgressEvent {
  123109. /** defines if data length to load can be evaluated */
  123110. readonly lengthComputable: boolean;
  123111. /** defines the loaded data length */
  123112. readonly loaded: number;
  123113. /** defines the data length to load */
  123114. readonly total: number;
  123115. /**
  123116. * Create a new progress event
  123117. * @param lengthComputable defines if data length to load can be evaluated
  123118. * @param loaded defines the loaded data length
  123119. * @param total defines the data length to load
  123120. */
  123121. constructor(
  123122. /** defines if data length to load can be evaluated */
  123123. lengthComputable: boolean,
  123124. /** defines the loaded data length */
  123125. loaded: number,
  123126. /** defines the data length to load */
  123127. total: number);
  123128. /**
  123129. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123130. * @param event defines the source event
  123131. * @returns a new SceneLoaderProgressEvent
  123132. */
  123133. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123134. }
  123135. /**
  123136. * Interface used by SceneLoader plugins to define supported file extensions
  123137. */
  123138. export interface ISceneLoaderPluginExtensions {
  123139. /**
  123140. * Defines the list of supported extensions
  123141. */
  123142. [extension: string]: {
  123143. isBinary: boolean;
  123144. };
  123145. }
  123146. /**
  123147. * Interface used by SceneLoader plugin factory
  123148. */
  123149. export interface ISceneLoaderPluginFactory {
  123150. /**
  123151. * Defines the name of the factory
  123152. */
  123153. name: string;
  123154. /**
  123155. * Function called to create a new plugin
  123156. * @return the new plugin
  123157. */
  123158. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123159. /**
  123160. * The callback that returns true if the data can be directly loaded.
  123161. * @param data string containing the file data
  123162. * @returns if the data can be loaded directly
  123163. */
  123164. canDirectLoad?(data: string): boolean;
  123165. }
  123166. /**
  123167. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123168. */
  123169. export interface ISceneLoaderPluginBase {
  123170. /**
  123171. * The friendly name of this plugin.
  123172. */
  123173. name: string;
  123174. /**
  123175. * The file extensions supported by this plugin.
  123176. */
  123177. extensions: string | ISceneLoaderPluginExtensions;
  123178. /**
  123179. * The callback called when loading from a url.
  123180. * @param scene scene loading this url
  123181. * @param url url to load
  123182. * @param onSuccess callback called when the file successfully loads
  123183. * @param onProgress callback called while file is loading (if the server supports this mode)
  123184. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123185. * @param onError callback called when the file fails to load
  123186. * @returns a file request object
  123187. */
  123188. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123189. /**
  123190. * The callback called when loading from a file object.
  123191. * @param scene scene loading this file
  123192. * @param file defines the file to load
  123193. * @param onSuccess defines the callback to call when data is loaded
  123194. * @param onProgress defines the callback to call during loading process
  123195. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123196. * @param onError defines the callback to call when an error occurs
  123197. * @returns a file request object
  123198. */
  123199. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123200. /**
  123201. * The callback that returns true if the data can be directly loaded.
  123202. * @param data string containing the file data
  123203. * @returns if the data can be loaded directly
  123204. */
  123205. canDirectLoad?(data: string): boolean;
  123206. /**
  123207. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123208. * @param scene scene loading this data
  123209. * @param data string containing the data
  123210. * @returns data to pass to the plugin
  123211. */
  123212. directLoad?(scene: Scene, data: string): any;
  123213. /**
  123214. * The callback that allows custom handling of the root url based on the response url.
  123215. * @param rootUrl the original root url
  123216. * @param responseURL the response url if available
  123217. * @returns the new root url
  123218. */
  123219. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123220. }
  123221. /**
  123222. * Interface used to define a SceneLoader plugin
  123223. */
  123224. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123225. /**
  123226. * Import meshes into a scene.
  123227. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123228. * @param scene The scene to import into
  123229. * @param data The data to import
  123230. * @param rootUrl The root url for scene and resources
  123231. * @param meshes The meshes array to import into
  123232. * @param particleSystems The particle systems array to import into
  123233. * @param skeletons The skeletons array to import into
  123234. * @param onError The callback when import fails
  123235. * @returns True if successful or false otherwise
  123236. */
  123237. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  123238. /**
  123239. * Load into a scene.
  123240. * @param scene The scene to load into
  123241. * @param data The data to import
  123242. * @param rootUrl The root url for scene and resources
  123243. * @param onError The callback when import fails
  123244. * @returns True if successful or false otherwise
  123245. */
  123246. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  123247. /**
  123248. * Load into an asset container.
  123249. * @param scene The scene to load into
  123250. * @param data The data to import
  123251. * @param rootUrl The root url for scene and resources
  123252. * @param onError The callback when import fails
  123253. * @returns The loaded asset container
  123254. */
  123255. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  123256. }
  123257. /**
  123258. * Interface used to define an async SceneLoader plugin
  123259. */
  123260. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  123261. /**
  123262. * Import meshes into a scene.
  123263. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123264. * @param scene The scene to import into
  123265. * @param data The data to import
  123266. * @param rootUrl The root url for scene and resources
  123267. * @param onProgress The callback when the load progresses
  123268. * @param fileName Defines the name of the file to load
  123269. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  123270. */
  123271. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  123272. meshes: AbstractMesh[];
  123273. particleSystems: IParticleSystem[];
  123274. skeletons: Skeleton[];
  123275. animationGroups: AnimationGroup[];
  123276. }>;
  123277. /**
  123278. * Load into a scene.
  123279. * @param scene The scene to load into
  123280. * @param data The data to import
  123281. * @param rootUrl The root url for scene and resources
  123282. * @param onProgress The callback when the load progresses
  123283. * @param fileName Defines the name of the file to load
  123284. * @returns Nothing
  123285. */
  123286. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  123287. /**
  123288. * Load into an asset container.
  123289. * @param scene The scene to load into
  123290. * @param data The data to import
  123291. * @param rootUrl The root url for scene and resources
  123292. * @param onProgress The callback when the load progresses
  123293. * @param fileName Defines the name of the file to load
  123294. * @returns The loaded asset container
  123295. */
  123296. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  123297. }
  123298. /**
  123299. * Mode that determines how to handle old animation groups before loading new ones.
  123300. */
  123301. export enum SceneLoaderAnimationGroupLoadingMode {
  123302. /**
  123303. * Reset all old animations to initial state then dispose them.
  123304. */
  123305. Clean = 0,
  123306. /**
  123307. * Stop all old animations.
  123308. */
  123309. Stop = 1,
  123310. /**
  123311. * Restart old animations from first frame.
  123312. */
  123313. Sync = 2,
  123314. /**
  123315. * Old animations remains untouched.
  123316. */
  123317. NoSync = 3
  123318. }
  123319. /**
  123320. * Class used to load scene from various file formats using registered plugins
  123321. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  123322. */
  123323. export class SceneLoader {
  123324. /**
  123325. * No logging while loading
  123326. */
  123327. static readonly NO_LOGGING: number;
  123328. /**
  123329. * Minimal logging while loading
  123330. */
  123331. static readonly MINIMAL_LOGGING: number;
  123332. /**
  123333. * Summary logging while loading
  123334. */
  123335. static readonly SUMMARY_LOGGING: number;
  123336. /**
  123337. * Detailled logging while loading
  123338. */
  123339. static readonly DETAILED_LOGGING: number;
  123340. /**
  123341. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  123342. */
  123343. static get ForceFullSceneLoadingForIncremental(): boolean;
  123344. static set ForceFullSceneLoadingForIncremental(value: boolean);
  123345. /**
  123346. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  123347. */
  123348. static get ShowLoadingScreen(): boolean;
  123349. static set ShowLoadingScreen(value: boolean);
  123350. /**
  123351. * Defines the current logging level (while loading the scene)
  123352. * @ignorenaming
  123353. */
  123354. static get loggingLevel(): number;
  123355. static set loggingLevel(value: number);
  123356. /**
  123357. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  123358. */
  123359. static get CleanBoneMatrixWeights(): boolean;
  123360. static set CleanBoneMatrixWeights(value: boolean);
  123361. /**
  123362. * Event raised when a plugin is used to load a scene
  123363. */
  123364. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123365. private static _registeredPlugins;
  123366. private static _getDefaultPlugin;
  123367. private static _getPluginForExtension;
  123368. private static _getPluginForDirectLoad;
  123369. private static _getPluginForFilename;
  123370. private static _getDirectLoad;
  123371. private static _loadData;
  123372. private static _getFileInfo;
  123373. /**
  123374. * Gets a plugin that can load the given extension
  123375. * @param extension defines the extension to load
  123376. * @returns a plugin or null if none works
  123377. */
  123378. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  123379. /**
  123380. * Gets a boolean indicating that the given extension can be loaded
  123381. * @param extension defines the extension to load
  123382. * @returns true if the extension is supported
  123383. */
  123384. static IsPluginForExtensionAvailable(extension: string): boolean;
  123385. /**
  123386. * Adds a new plugin to the list of registered plugins
  123387. * @param plugin defines the plugin to add
  123388. */
  123389. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  123390. /**
  123391. * Import meshes into a scene
  123392. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123393. * @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)
  123394. * @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)
  123395. * @param scene the instance of BABYLON.Scene to append to
  123396. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  123397. * @param onProgress a callback with a progress event for each file being loaded
  123398. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123399. * @param pluginExtension the extension used to determine the plugin
  123400. * @returns The loaded plugin
  123401. */
  123402. 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>;
  123403. /**
  123404. * Import meshes into a scene
  123405. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123406. * @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)
  123407. * @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)
  123408. * @param scene the instance of BABYLON.Scene to append to
  123409. * @param onProgress a callback with a progress event for each file being loaded
  123410. * @param pluginExtension the extension used to determine the plugin
  123411. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  123412. */
  123413. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  123414. meshes: AbstractMesh[];
  123415. particleSystems: IParticleSystem[];
  123416. skeletons: Skeleton[];
  123417. animationGroups: AnimationGroup[];
  123418. }>;
  123419. /**
  123420. * Load a scene
  123421. * @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)
  123422. * @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)
  123423. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123424. * @param onSuccess a callback with the scene when import succeeds
  123425. * @param onProgress a callback with a progress event for each file being loaded
  123426. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123427. * @param pluginExtension the extension used to determine the plugin
  123428. * @returns The loaded plugin
  123429. */
  123430. 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>;
  123431. /**
  123432. * Load a scene
  123433. * @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)
  123434. * @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)
  123435. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123436. * @param onProgress a callback with a progress event for each file being loaded
  123437. * @param pluginExtension the extension used to determine the plugin
  123438. * @returns The loaded scene
  123439. */
  123440. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123441. /**
  123442. * Append a scene
  123443. * @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)
  123444. * @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)
  123445. * @param scene is the instance of BABYLON.Scene to append to
  123446. * @param onSuccess a callback with the scene when import succeeds
  123447. * @param onProgress a callback with a progress event for each file being loaded
  123448. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123449. * @param pluginExtension the extension used to determine the plugin
  123450. * @returns The loaded plugin
  123451. */
  123452. 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>;
  123453. /**
  123454. * Append a scene
  123455. * @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)
  123456. * @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)
  123457. * @param scene is the instance of BABYLON.Scene to append to
  123458. * @param onProgress a callback with a progress event for each file being loaded
  123459. * @param pluginExtension the extension used to determine the plugin
  123460. * @returns The given scene
  123461. */
  123462. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123463. /**
  123464. * Load a scene into an asset container
  123465. * @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)
  123466. * @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)
  123467. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123468. * @param onSuccess a callback with the scene when import succeeds
  123469. * @param onProgress a callback with a progress event for each file being loaded
  123470. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123471. * @param pluginExtension the extension used to determine the plugin
  123472. * @returns The loaded plugin
  123473. */
  123474. 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>;
  123475. /**
  123476. * Load a scene into an asset container
  123477. * @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)
  123478. * @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)
  123479. * @param scene is the instance of Scene to append to
  123480. * @param onProgress a callback with a progress event for each file being loaded
  123481. * @param pluginExtension the extension used to determine the plugin
  123482. * @returns The loaded asset container
  123483. */
  123484. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  123485. /**
  123486. * Import animations from a file into a scene
  123487. * @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)
  123488. * @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)
  123489. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123490. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123491. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123492. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123493. * @param onSuccess a callback with the scene when import succeeds
  123494. * @param onProgress a callback with a progress event for each file being loaded
  123495. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123496. */
  123497. 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;
  123498. /**
  123499. * Import animations from a file into a scene
  123500. * @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)
  123501. * @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)
  123502. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123503. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123504. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123505. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123506. * @param onSuccess a callback with the scene when import succeeds
  123507. * @param onProgress a callback with a progress event for each file being loaded
  123508. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123509. * @returns the updated scene with imported animations
  123510. */
  123511. 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>;
  123512. }
  123513. }
  123514. declare module BABYLON {
  123515. /**
  123516. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  123517. */
  123518. export type MotionControllerHandedness = "none" | "left" | "right";
  123519. /**
  123520. * The type of components available in motion controllers.
  123521. * This is not the name of the component.
  123522. */
  123523. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  123524. /**
  123525. * The state of a controller component
  123526. */
  123527. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  123528. /**
  123529. * The schema of motion controller layout.
  123530. * No object will be initialized using this interface
  123531. * This is used just to define the profile.
  123532. */
  123533. export interface IMotionControllerLayout {
  123534. /**
  123535. * Path to load the assets. Usually relative to the base path
  123536. */
  123537. assetPath: string;
  123538. /**
  123539. * Available components (unsorted)
  123540. */
  123541. components: {
  123542. /**
  123543. * A map of component Ids
  123544. */
  123545. [componentId: string]: {
  123546. /**
  123547. * The type of input the component outputs
  123548. */
  123549. type: MotionControllerComponentType;
  123550. /**
  123551. * The indices of this component in the gamepad object
  123552. */
  123553. gamepadIndices: {
  123554. /**
  123555. * Index of button
  123556. */
  123557. button?: number;
  123558. /**
  123559. * If available, index of x-axis
  123560. */
  123561. xAxis?: number;
  123562. /**
  123563. * If available, index of y-axis
  123564. */
  123565. yAxis?: number;
  123566. };
  123567. /**
  123568. * The mesh's root node name
  123569. */
  123570. rootNodeName: string;
  123571. /**
  123572. * Animation definitions for this model
  123573. */
  123574. visualResponses: {
  123575. [stateKey: string]: {
  123576. /**
  123577. * What property will be animated
  123578. */
  123579. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  123580. /**
  123581. * What states influence this visual response
  123582. */
  123583. states: MotionControllerComponentStateType[];
  123584. /**
  123585. * Type of animation - movement or visibility
  123586. */
  123587. valueNodeProperty: "transform" | "visibility";
  123588. /**
  123589. * Base node name to move. Its position will be calculated according to the min and max nodes
  123590. */
  123591. valueNodeName?: string;
  123592. /**
  123593. * Minimum movement node
  123594. */
  123595. minNodeName?: string;
  123596. /**
  123597. * Max movement node
  123598. */
  123599. maxNodeName?: string;
  123600. };
  123601. };
  123602. /**
  123603. * If touch enabled, what is the name of node to display user feedback
  123604. */
  123605. touchPointNodeName?: string;
  123606. };
  123607. };
  123608. /**
  123609. * Is it xr standard mapping or not
  123610. */
  123611. gamepadMapping: "" | "xr-standard";
  123612. /**
  123613. * Base root node of this entire model
  123614. */
  123615. rootNodeName: string;
  123616. /**
  123617. * Defines the main button component id
  123618. */
  123619. selectComponentId: string;
  123620. }
  123621. /**
  123622. * A definition for the layout map in the input profile
  123623. */
  123624. export interface IMotionControllerLayoutMap {
  123625. /**
  123626. * Layouts with handedness type as a key
  123627. */
  123628. [handedness: string]: IMotionControllerLayout;
  123629. }
  123630. /**
  123631. * The XR Input profile schema
  123632. * Profiles can be found here:
  123633. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  123634. */
  123635. export interface IMotionControllerProfile {
  123636. /**
  123637. * fallback profiles for this profileId
  123638. */
  123639. fallbackProfileIds: string[];
  123640. /**
  123641. * The layout map, with handedness as key
  123642. */
  123643. layouts: IMotionControllerLayoutMap;
  123644. /**
  123645. * The id of this profile
  123646. * correlates to the profile(s) in the xrInput.profiles array
  123647. */
  123648. profileId: string;
  123649. }
  123650. /**
  123651. * A helper-interface for the 3 meshes needed for controller button animation
  123652. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  123653. */
  123654. export interface IMotionControllerButtonMeshMap {
  123655. /**
  123656. * the mesh that defines the pressed value mesh position.
  123657. * This is used to find the max-position of this button
  123658. */
  123659. pressedMesh: AbstractMesh;
  123660. /**
  123661. * the mesh that defines the unpressed value mesh position.
  123662. * This is used to find the min (or initial) position of this button
  123663. */
  123664. unpressedMesh: AbstractMesh;
  123665. /**
  123666. * The mesh that will be changed when value changes
  123667. */
  123668. valueMesh: AbstractMesh;
  123669. }
  123670. /**
  123671. * A helper-interface for the 3 meshes needed for controller axis animation.
  123672. * This will be expanded when touchpad animations are fully supported
  123673. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  123674. */
  123675. export interface IMotionControllerMeshMap {
  123676. /**
  123677. * the mesh that defines the maximum value mesh position.
  123678. */
  123679. maxMesh?: AbstractMesh;
  123680. /**
  123681. * the mesh that defines the minimum value mesh position.
  123682. */
  123683. minMesh?: AbstractMesh;
  123684. /**
  123685. * The mesh that will be changed when axis value changes
  123686. */
  123687. valueMesh: AbstractMesh;
  123688. }
  123689. /**
  123690. * The elements needed for change-detection of the gamepad objects in motion controllers
  123691. */
  123692. export interface IMinimalMotionControllerObject {
  123693. /**
  123694. * Available axes of this controller
  123695. */
  123696. axes: number[];
  123697. /**
  123698. * An array of available buttons
  123699. */
  123700. buttons: Array<{
  123701. /**
  123702. * Value of the button/trigger
  123703. */
  123704. value: number;
  123705. /**
  123706. * If the button/trigger is currently touched
  123707. */
  123708. touched: boolean;
  123709. /**
  123710. * If the button/trigger is currently pressed
  123711. */
  123712. pressed: boolean;
  123713. }>;
  123714. /**
  123715. * EXPERIMENTAL haptic support.
  123716. */
  123717. hapticActuators?: Array<{
  123718. pulse: (value: number, duration: number) => Promise<boolean>;
  123719. }>;
  123720. }
  123721. /**
  123722. * An Abstract Motion controller
  123723. * This class receives an xrInput and a profile layout and uses those to initialize the components
  123724. * Each component has an observable to check for changes in value and state
  123725. */
  123726. export abstract class WebXRAbstractMotionController implements IDisposable {
  123727. protected scene: Scene;
  123728. protected layout: IMotionControllerLayout;
  123729. /**
  123730. * The gamepad object correlating to this controller
  123731. */
  123732. gamepadObject: IMinimalMotionControllerObject;
  123733. /**
  123734. * handedness (left/right/none) of this controller
  123735. */
  123736. handedness: MotionControllerHandedness;
  123737. private _initComponent;
  123738. private _modelReady;
  123739. /**
  123740. * A map of components (WebXRControllerComponent) in this motion controller
  123741. * Components have a ComponentType and can also have both button and axis definitions
  123742. */
  123743. readonly components: {
  123744. [id: string]: WebXRControllerComponent;
  123745. };
  123746. /**
  123747. * Disable the model's animation. Can be set at any time.
  123748. */
  123749. disableAnimation: boolean;
  123750. /**
  123751. * Observers registered here will be triggered when the model of this controller is done loading
  123752. */
  123753. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  123754. /**
  123755. * The profile id of this motion controller
  123756. */
  123757. abstract profileId: string;
  123758. /**
  123759. * The root mesh of the model. It is null if the model was not yet initialized
  123760. */
  123761. rootMesh: Nullable<AbstractMesh>;
  123762. /**
  123763. * constructs a new abstract motion controller
  123764. * @param scene the scene to which the model of the controller will be added
  123765. * @param layout The profile layout to load
  123766. * @param gamepadObject The gamepad object correlating to this controller
  123767. * @param handedness handedness (left/right/none) of this controller
  123768. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  123769. */
  123770. constructor(scene: Scene, layout: IMotionControllerLayout,
  123771. /**
  123772. * The gamepad object correlating to this controller
  123773. */
  123774. gamepadObject: IMinimalMotionControllerObject,
  123775. /**
  123776. * handedness (left/right/none) of this controller
  123777. */
  123778. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  123779. /**
  123780. * Dispose this controller, the model mesh and all its components
  123781. */
  123782. dispose(): void;
  123783. /**
  123784. * Returns all components of specific type
  123785. * @param type the type to search for
  123786. * @return an array of components with this type
  123787. */
  123788. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  123789. /**
  123790. * get a component based an its component id as defined in layout.components
  123791. * @param id the id of the component
  123792. * @returns the component correlates to the id or undefined if not found
  123793. */
  123794. getComponent(id: string): WebXRControllerComponent;
  123795. /**
  123796. * Get the list of components available in this motion controller
  123797. * @returns an array of strings correlating to available components
  123798. */
  123799. getComponentIds(): string[];
  123800. /**
  123801. * Get the first component of specific type
  123802. * @param type type of component to find
  123803. * @return a controller component or null if not found
  123804. */
  123805. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  123806. /**
  123807. * Get the main (Select) component of this controller as defined in the layout
  123808. * @returns the main component of this controller
  123809. */
  123810. getMainComponent(): WebXRControllerComponent;
  123811. /**
  123812. * Loads the model correlating to this controller
  123813. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  123814. * @returns A promise fulfilled with the result of the model loading
  123815. */
  123816. loadModel(): Promise<boolean>;
  123817. /**
  123818. * Update this model using the current XRFrame
  123819. * @param xrFrame the current xr frame to use and update the model
  123820. */
  123821. updateFromXRFrame(xrFrame: XRFrame): void;
  123822. /**
  123823. * Backwards compatibility due to a deeply-integrated typo
  123824. */
  123825. get handness(): XREye;
  123826. /**
  123827. * Pulse (vibrate) this controller
  123828. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  123829. * Consecutive calls to this function will cancel the last pulse call
  123830. *
  123831. * @param value the strength of the pulse in 0.0...1.0 range
  123832. * @param duration Duration of the pulse in milliseconds
  123833. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  123834. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  123835. */
  123836. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  123837. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  123838. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  123839. /**
  123840. * Moves the axis on the controller mesh based on its current state
  123841. * @param axis the index of the axis
  123842. * @param axisValue the value of the axis which determines the meshes new position
  123843. * @hidden
  123844. */
  123845. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  123846. /**
  123847. * Update the model itself with the current frame data
  123848. * @param xrFrame the frame to use for updating the model mesh
  123849. */
  123850. protected updateModel(xrFrame: XRFrame): void;
  123851. /**
  123852. * Get the filename and path for this controller's model
  123853. * @returns a map of filename and path
  123854. */
  123855. protected abstract _getFilenameAndPath(): {
  123856. filename: string;
  123857. path: string;
  123858. };
  123859. /**
  123860. * This function is called before the mesh is loaded. It checks for loading constraints.
  123861. * For example, this function can check if the GLB loader is available
  123862. * If this function returns false, the generic controller will be loaded instead
  123863. * @returns Is the client ready to load the mesh
  123864. */
  123865. protected abstract _getModelLoadingConstraints(): boolean;
  123866. /**
  123867. * This function will be called after the model was successfully loaded and can be used
  123868. * for mesh transformations before it is available for the user
  123869. * @param meshes the loaded meshes
  123870. */
  123871. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  123872. /**
  123873. * Set the root mesh for this controller. Important for the WebXR controller class
  123874. * @param meshes the loaded meshes
  123875. */
  123876. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  123877. /**
  123878. * A function executed each frame that updates the mesh (if needed)
  123879. * @param xrFrame the current xrFrame
  123880. */
  123881. protected abstract _updateModel(xrFrame: XRFrame): void;
  123882. private _getGenericFilenameAndPath;
  123883. private _getGenericParentMesh;
  123884. }
  123885. }
  123886. declare module BABYLON {
  123887. /**
  123888. * A generic trigger-only motion controller for WebXR
  123889. */
  123890. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  123891. /**
  123892. * Static version of the profile id of this controller
  123893. */
  123894. static ProfileId: string;
  123895. profileId: string;
  123896. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  123897. protected _getFilenameAndPath(): {
  123898. filename: string;
  123899. path: string;
  123900. };
  123901. protected _getModelLoadingConstraints(): boolean;
  123902. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  123903. protected _setRootMesh(meshes: AbstractMesh[]): void;
  123904. protected _updateModel(): void;
  123905. }
  123906. }
  123907. declare module BABYLON {
  123908. /**
  123909. * Class containing static functions to help procedurally build meshes
  123910. */
  123911. export class SphereBuilder {
  123912. /**
  123913. * Creates a sphere mesh
  123914. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123915. * * 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`)
  123916. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123917. * * 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
  123918. * * 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)
  123919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123922. * @param name defines the name of the mesh
  123923. * @param options defines the options used to create the mesh
  123924. * @param scene defines the hosting scene
  123925. * @returns the sphere mesh
  123926. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123927. */
  123928. static CreateSphere(name: string, options: {
  123929. segments?: number;
  123930. diameter?: number;
  123931. diameterX?: number;
  123932. diameterY?: number;
  123933. diameterZ?: number;
  123934. arc?: number;
  123935. slice?: number;
  123936. sideOrientation?: number;
  123937. frontUVs?: Vector4;
  123938. backUVs?: Vector4;
  123939. updatable?: boolean;
  123940. }, scene?: Nullable<Scene>): Mesh;
  123941. }
  123942. }
  123943. declare module BABYLON {
  123944. /**
  123945. * A profiled motion controller has its profile loaded from an online repository.
  123946. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  123947. */
  123948. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  123949. private _repositoryUrl;
  123950. private _buttonMeshMapping;
  123951. private _touchDots;
  123952. /**
  123953. * The profile ID of this controller. Will be populated when the controller initializes.
  123954. */
  123955. profileId: string;
  123956. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  123957. dispose(): void;
  123958. protected _getFilenameAndPath(): {
  123959. filename: string;
  123960. path: string;
  123961. };
  123962. protected _getModelLoadingConstraints(): boolean;
  123963. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  123964. protected _setRootMesh(meshes: AbstractMesh[]): void;
  123965. protected _updateModel(_xrFrame: XRFrame): void;
  123966. }
  123967. }
  123968. declare module BABYLON {
  123969. /**
  123970. * A construction function type to create a new controller based on an xrInput object
  123971. */
  123972. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  123973. /**
  123974. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  123975. *
  123976. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  123977. * it should be replaced with auto-loaded controllers.
  123978. *
  123979. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  123980. */
  123981. export class WebXRMotionControllerManager {
  123982. private static _AvailableControllers;
  123983. private static _Fallbacks;
  123984. private static _ProfileLoadingPromises;
  123985. private static _ProfilesList;
  123986. /**
  123987. * The base URL of the online controller repository. Can be changed at any time.
  123988. */
  123989. static BaseRepositoryUrl: string;
  123990. /**
  123991. * Which repository gets priority - local or online
  123992. */
  123993. static PrioritizeOnlineRepository: boolean;
  123994. /**
  123995. * Use the online repository, or use only locally-defined controllers
  123996. */
  123997. static UseOnlineRepository: boolean;
  123998. /**
  123999. * Clear the cache used for profile loading and reload when requested again
  124000. */
  124001. static ClearProfilesCache(): void;
  124002. /**
  124003. * Register the default fallbacks.
  124004. * This function is called automatically when this file is imported.
  124005. */
  124006. static DefaultFallbacks(): void;
  124007. /**
  124008. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124009. * @param profileId the profile to which a fallback needs to be found
  124010. * @return an array with corresponding fallback profiles
  124011. */
  124012. static FindFallbackWithProfileId(profileId: string): string[];
  124013. /**
  124014. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124015. * The order of search:
  124016. *
  124017. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124018. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124019. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124020. * 4) return the generic trigger controller if none were found
  124021. *
  124022. * @param xrInput the xrInput to which a new controller is initialized
  124023. * @param scene the scene to which the model will be added
  124024. * @param forceProfile force a certain profile for this controller
  124025. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124026. */
  124027. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124028. /**
  124029. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124030. *
  124031. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124032. *
  124033. * @param type the profile type to register
  124034. * @param constructFunction the function to be called when loading this profile
  124035. */
  124036. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124037. /**
  124038. * Register a fallback to a specific profile.
  124039. * @param profileId the profileId that will receive the fallbacks
  124040. * @param fallbacks A list of fallback profiles
  124041. */
  124042. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124043. /**
  124044. * Will update the list of profiles available in the repository
  124045. * @return a promise that resolves to a map of profiles available online
  124046. */
  124047. static UpdateProfilesList(): Promise<{
  124048. [profile: string]: string;
  124049. }>;
  124050. private static _LoadProfileFromRepository;
  124051. private static _LoadProfilesFromAvailableControllers;
  124052. }
  124053. }
  124054. declare module BABYLON {
  124055. /**
  124056. * Configuration options for the WebXR controller creation
  124057. */
  124058. export interface IWebXRControllerOptions {
  124059. /**
  124060. * Should the controller mesh be animated when a user interacts with it
  124061. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124062. */
  124063. disableMotionControllerAnimation?: boolean;
  124064. /**
  124065. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124066. */
  124067. doNotLoadControllerMesh?: boolean;
  124068. /**
  124069. * Force a specific controller type for this controller.
  124070. * This can be used when creating your own profile or when testing different controllers
  124071. */
  124072. forceControllerProfile?: string;
  124073. /**
  124074. * Defines a rendering group ID for meshes that will be loaded.
  124075. * This is for the default controllers only.
  124076. */
  124077. renderingGroupId?: number;
  124078. }
  124079. /**
  124080. * Represents an XR controller
  124081. */
  124082. export class WebXRInputSource {
  124083. private _scene;
  124084. /** The underlying input source for the controller */
  124085. inputSource: XRInputSource;
  124086. private _options;
  124087. private _tmpVector;
  124088. private _uniqueId;
  124089. /**
  124090. * 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
  124091. */
  124092. grip?: AbstractMesh;
  124093. /**
  124094. * If available, this is the gamepad object related to this controller.
  124095. * Using this object it is possible to get click events and trackpad changes of the
  124096. * webxr controller that is currently being used.
  124097. */
  124098. motionController?: WebXRAbstractMotionController;
  124099. /**
  124100. * Event that fires when the controller is removed/disposed.
  124101. * The object provided as event data is this controller, after associated assets were disposed.
  124102. * uniqueId is still available.
  124103. */
  124104. onDisposeObservable: Observable<WebXRInputSource>;
  124105. /**
  124106. * Will be triggered when the mesh associated with the motion controller is done loading.
  124107. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124108. * A shortened version of controller -> motion controller -> on mesh loaded.
  124109. */
  124110. onMeshLoadedObservable: Observable<AbstractMesh>;
  124111. /**
  124112. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124113. */
  124114. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124115. /**
  124116. * Pointer which can be used to select objects or attach a visible laser to
  124117. */
  124118. pointer: AbstractMesh;
  124119. /**
  124120. * Creates the controller
  124121. * @see https://doc.babylonjs.com/how_to/webxr
  124122. * @param _scene the scene which the controller should be associated to
  124123. * @param inputSource the underlying input source for the controller
  124124. * @param _options options for this controller creation
  124125. */
  124126. constructor(_scene: Scene,
  124127. /** The underlying input source for the controller */
  124128. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124129. /**
  124130. * Get this controllers unique id
  124131. */
  124132. get uniqueId(): string;
  124133. /**
  124134. * Disposes of the object
  124135. */
  124136. dispose(): void;
  124137. /**
  124138. * Gets a world space ray coming from the pointer or grip
  124139. * @param result the resulting ray
  124140. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124141. */
  124142. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124143. /**
  124144. * Updates the controller pose based on the given XRFrame
  124145. * @param xrFrame xr frame to update the pose with
  124146. * @param referenceSpace reference space to use
  124147. */
  124148. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124149. }
  124150. }
  124151. declare module BABYLON {
  124152. /**
  124153. * The schema for initialization options of the XR Input class
  124154. */
  124155. export interface IWebXRInputOptions {
  124156. /**
  124157. * If set to true no model will be automatically loaded
  124158. */
  124159. doNotLoadControllerMeshes?: boolean;
  124160. /**
  124161. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124162. * If not found, the xr input profile data will be used.
  124163. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124164. */
  124165. forceInputProfile?: string;
  124166. /**
  124167. * Do not send a request to the controller repository to load the profile.
  124168. *
  124169. * Instead, use the controllers available in babylon itself.
  124170. */
  124171. disableOnlineControllerRepository?: boolean;
  124172. /**
  124173. * A custom URL for the controllers repository
  124174. */
  124175. customControllersRepositoryURL?: string;
  124176. /**
  124177. * Should the controller model's components not move according to the user input
  124178. */
  124179. disableControllerAnimation?: boolean;
  124180. /**
  124181. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124182. */
  124183. controllerOptions?: IWebXRControllerOptions;
  124184. }
  124185. /**
  124186. * XR input used to track XR inputs such as controllers/rays
  124187. */
  124188. export class WebXRInput implements IDisposable {
  124189. /**
  124190. * the xr session manager for this session
  124191. */
  124192. xrSessionManager: WebXRSessionManager;
  124193. /**
  124194. * the WebXR camera for this session. Mainly used for teleportation
  124195. */
  124196. xrCamera: WebXRCamera;
  124197. private readonly options;
  124198. /**
  124199. * XR controllers being tracked
  124200. */
  124201. controllers: Array<WebXRInputSource>;
  124202. private _frameObserver;
  124203. private _sessionEndedObserver;
  124204. private _sessionInitObserver;
  124205. /**
  124206. * Event when a controller has been connected/added
  124207. */
  124208. onControllerAddedObservable: Observable<WebXRInputSource>;
  124209. /**
  124210. * Event when a controller has been removed/disconnected
  124211. */
  124212. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124213. /**
  124214. * Initializes the WebXRInput
  124215. * @param xrSessionManager the xr session manager for this session
  124216. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124217. * @param options = initialization options for this xr input
  124218. */
  124219. constructor(
  124220. /**
  124221. * the xr session manager for this session
  124222. */
  124223. xrSessionManager: WebXRSessionManager,
  124224. /**
  124225. * the WebXR camera for this session. Mainly used for teleportation
  124226. */
  124227. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  124228. private _onInputSourcesChange;
  124229. private _addAndRemoveControllers;
  124230. /**
  124231. * Disposes of the object
  124232. */
  124233. dispose(): void;
  124234. }
  124235. }
  124236. declare module BABYLON {
  124237. /**
  124238. * This is the base class for all WebXR features.
  124239. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  124240. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  124241. */
  124242. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  124243. protected _xrSessionManager: WebXRSessionManager;
  124244. private _attached;
  124245. private _removeOnDetach;
  124246. /**
  124247. * Should auto-attach be disabled?
  124248. */
  124249. disableAutoAttach: boolean;
  124250. /**
  124251. * Construct a new (abstract) WebXR feature
  124252. * @param _xrSessionManager the xr session manager for this feature
  124253. */
  124254. constructor(_xrSessionManager: WebXRSessionManager);
  124255. /**
  124256. * Is this feature attached
  124257. */
  124258. get attached(): boolean;
  124259. /**
  124260. * attach this feature
  124261. *
  124262. * @param force should attachment be forced (even when already attached)
  124263. * @returns true if successful, false is failed or already attached
  124264. */
  124265. attach(force?: boolean): boolean;
  124266. /**
  124267. * detach this feature.
  124268. *
  124269. * @returns true if successful, false if failed or already detached
  124270. */
  124271. detach(): boolean;
  124272. /**
  124273. * Dispose this feature and all of the resources attached
  124274. */
  124275. dispose(): void;
  124276. /**
  124277. * This is used to register callbacks that will automatically be removed when detach is called.
  124278. * @param observable the observable to which the observer will be attached
  124279. * @param callback the callback to register
  124280. */
  124281. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  124282. /**
  124283. * Code in this function will be executed on each xrFrame received from the browser.
  124284. * This function will not execute after the feature is detached.
  124285. * @param _xrFrame the current frame
  124286. */
  124287. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  124288. }
  124289. }
  124290. declare module BABYLON {
  124291. /**
  124292. * Renders a layer on top of an existing scene
  124293. */
  124294. export class UtilityLayerRenderer implements IDisposable {
  124295. /** the original scene that will be rendered on top of */
  124296. originalScene: Scene;
  124297. private _pointerCaptures;
  124298. private _lastPointerEvents;
  124299. private static _DefaultUtilityLayer;
  124300. private static _DefaultKeepDepthUtilityLayer;
  124301. private _sharedGizmoLight;
  124302. private _renderCamera;
  124303. /**
  124304. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  124305. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  124306. * @returns the camera that is used when rendering the utility layer
  124307. */
  124308. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  124309. /**
  124310. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  124311. * @param cam the camera that should be used when rendering the utility layer
  124312. */
  124313. setRenderCamera(cam: Nullable<Camera>): void;
  124314. /**
  124315. * @hidden
  124316. * Light which used by gizmos to get light shading
  124317. */
  124318. _getSharedGizmoLight(): HemisphericLight;
  124319. /**
  124320. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124321. */
  124322. pickUtilitySceneFirst: boolean;
  124323. /**
  124324. * 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)
  124325. */
  124326. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  124327. /**
  124328. * 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)
  124329. */
  124330. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  124331. /**
  124332. * The scene that is rendered on top of the original scene
  124333. */
  124334. utilityLayerScene: Scene;
  124335. /**
  124336. * If the utility layer should automatically be rendered on top of existing scene
  124337. */
  124338. shouldRender: boolean;
  124339. /**
  124340. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124341. */
  124342. onlyCheckPointerDownEvents: boolean;
  124343. /**
  124344. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124345. */
  124346. processAllEvents: boolean;
  124347. /**
  124348. * Observable raised when the pointer move from the utility layer scene to the main scene
  124349. */
  124350. onPointerOutObservable: Observable<number>;
  124351. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  124352. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  124353. private _afterRenderObserver;
  124354. private _sceneDisposeObserver;
  124355. private _originalPointerObserver;
  124356. /**
  124357. * Instantiates a UtilityLayerRenderer
  124358. * @param originalScene the original scene that will be rendered on top of
  124359. * @param handleEvents boolean indicating if the utility layer should handle events
  124360. */
  124361. constructor(
  124362. /** the original scene that will be rendered on top of */
  124363. originalScene: Scene, handleEvents?: boolean);
  124364. private _notifyObservers;
  124365. /**
  124366. * Renders the utility layers scene on top of the original scene
  124367. */
  124368. render(): void;
  124369. /**
  124370. * Disposes of the renderer
  124371. */
  124372. dispose(): void;
  124373. private _updateCamera;
  124374. }
  124375. }
  124376. declare module BABYLON {
  124377. /**
  124378. * Options interface for the pointer selection module
  124379. */
  124380. export interface IWebXRControllerPointerSelectionOptions {
  124381. /**
  124382. * if provided, this scene will be used to render meshes.
  124383. */
  124384. customUtilityLayerScene?: Scene;
  124385. /**
  124386. * 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)
  124387. * If not disabled, the last picked point will be used to execute a pointer up event
  124388. * If disabled, pointer up event will be triggered right after the pointer down event.
  124389. * Used in screen and gaze target ray mode only
  124390. */
  124391. disablePointerUpOnTouchOut: boolean;
  124392. /**
  124393. * For gaze mode (time to select instead of press)
  124394. */
  124395. forceGazeMode: boolean;
  124396. /**
  124397. * 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
  124398. * to start a new countdown to the pointer down event.
  124399. * Defaults to 1.
  124400. */
  124401. gazeModePointerMovedFactor?: number;
  124402. /**
  124403. * Different button type to use instead of the main component
  124404. */
  124405. overrideButtonId?: string;
  124406. /**
  124407. * use this rendering group id for the meshes (optional)
  124408. */
  124409. renderingGroupId?: number;
  124410. /**
  124411. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  124412. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  124413. * 3000 means 3 seconds between pointing at something and selecting it
  124414. */
  124415. timeToSelect?: number;
  124416. /**
  124417. * Should meshes created here be added to a utility layer or the main scene
  124418. */
  124419. useUtilityLayer?: boolean;
  124420. /**
  124421. * the xr input to use with this pointer selection
  124422. */
  124423. xrInput: WebXRInput;
  124424. }
  124425. /**
  124426. * A module that will enable pointer selection for motion controllers of XR Input Sources
  124427. */
  124428. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  124429. private readonly _options;
  124430. private static _idCounter;
  124431. private _attachController;
  124432. private _controllers;
  124433. private _scene;
  124434. private _tmpVectorForPickCompare;
  124435. /**
  124436. * The module's name
  124437. */
  124438. static readonly Name: string;
  124439. /**
  124440. * The (Babylon) version of this module.
  124441. * This is an integer representing the implementation version.
  124442. * This number does not correspond to the WebXR specs version
  124443. */
  124444. static readonly Version: number;
  124445. /**
  124446. * Disable lighting on the laser pointer (so it will always be visible)
  124447. */
  124448. disablePointerLighting: boolean;
  124449. /**
  124450. * Disable lighting on the selection mesh (so it will always be visible)
  124451. */
  124452. disableSelectionMeshLighting: boolean;
  124453. /**
  124454. * Should the laser pointer be displayed
  124455. */
  124456. displayLaserPointer: boolean;
  124457. /**
  124458. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  124459. */
  124460. displaySelectionMesh: boolean;
  124461. /**
  124462. * This color will be set to the laser pointer when selection is triggered
  124463. */
  124464. laserPointerPickedColor: Color3;
  124465. /**
  124466. * Default color of the laser pointer
  124467. */
  124468. lasterPointerDefaultColor: Color3;
  124469. /**
  124470. * default color of the selection ring
  124471. */
  124472. selectionMeshDefaultColor: Color3;
  124473. /**
  124474. * This color will be applied to the selection ring when selection is triggered
  124475. */
  124476. selectionMeshPickedColor: Color3;
  124477. /**
  124478. * Optional filter to be used for ray selection. This predicate shares behavior with
  124479. * scene.pointerMovePredicate which takes priority if it is also assigned.
  124480. */
  124481. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  124482. /**
  124483. * constructs a new background remover module
  124484. * @param _xrSessionManager the session manager for this module
  124485. * @param _options read-only options to be used in this module
  124486. */
  124487. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  124488. /**
  124489. * attach this feature
  124490. * Will usually be called by the features manager
  124491. *
  124492. * @returns true if successful.
  124493. */
  124494. attach(): boolean;
  124495. /**
  124496. * detach this feature.
  124497. * Will usually be called by the features manager
  124498. *
  124499. * @returns true if successful.
  124500. */
  124501. detach(): boolean;
  124502. /**
  124503. * Will get the mesh under a specific pointer.
  124504. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  124505. * @param controllerId the controllerId to check
  124506. * @returns The mesh under pointer or null if no mesh is under the pointer
  124507. */
  124508. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  124509. /**
  124510. * Get the xr controller that correlates to the pointer id in the pointer event
  124511. *
  124512. * @param id the pointer id to search for
  124513. * @returns the controller that correlates to this id or null if not found
  124514. */
  124515. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  124516. protected _onXRFrame(_xrFrame: XRFrame): void;
  124517. private _attachGazeMode;
  124518. private _attachScreenRayMode;
  124519. private _attachTrackedPointerRayMode;
  124520. private _convertNormalToDirectionOfRay;
  124521. private _detachController;
  124522. private _generateNewMeshPair;
  124523. private _pickingMoved;
  124524. private _updatePointerDistance;
  124525. }
  124526. }
  124527. declare module BABYLON {
  124528. /**
  124529. * Button which can be used to enter a different mode of XR
  124530. */
  124531. export class WebXREnterExitUIButton {
  124532. /** button element */
  124533. element: HTMLElement;
  124534. /** XR initialization options for the button */
  124535. sessionMode: XRSessionMode;
  124536. /** Reference space type */
  124537. referenceSpaceType: XRReferenceSpaceType;
  124538. /**
  124539. * Creates a WebXREnterExitUIButton
  124540. * @param element button element
  124541. * @param sessionMode XR initialization session mode
  124542. * @param referenceSpaceType the type of reference space to be used
  124543. */
  124544. constructor(
  124545. /** button element */
  124546. element: HTMLElement,
  124547. /** XR initialization options for the button */
  124548. sessionMode: XRSessionMode,
  124549. /** Reference space type */
  124550. referenceSpaceType: XRReferenceSpaceType);
  124551. /**
  124552. * Extendable function which can be used to update the button's visuals when the state changes
  124553. * @param activeButton the current active button in the UI
  124554. */
  124555. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  124556. }
  124557. /**
  124558. * Options to create the webXR UI
  124559. */
  124560. export class WebXREnterExitUIOptions {
  124561. /**
  124562. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  124563. */
  124564. customButtons?: Array<WebXREnterExitUIButton>;
  124565. /**
  124566. * A reference space type to use when creating the default button.
  124567. * Default is local-floor
  124568. */
  124569. referenceSpaceType?: XRReferenceSpaceType;
  124570. /**
  124571. * Context to enter xr with
  124572. */
  124573. renderTarget?: Nullable<WebXRRenderTarget>;
  124574. /**
  124575. * A session mode to use when creating the default button.
  124576. * Default is immersive-vr
  124577. */
  124578. sessionMode?: XRSessionMode;
  124579. /**
  124580. * A list of optional features to init the session with
  124581. */
  124582. optionalFeatures?: string[];
  124583. }
  124584. /**
  124585. * UI to allow the user to enter/exit XR mode
  124586. */
  124587. export class WebXREnterExitUI implements IDisposable {
  124588. private scene;
  124589. /** version of the options passed to this UI */
  124590. options: WebXREnterExitUIOptions;
  124591. private _activeButton;
  124592. private _buttons;
  124593. private _overlay;
  124594. /**
  124595. * Fired every time the active button is changed.
  124596. *
  124597. * When xr is entered via a button that launches xr that button will be the callback parameter
  124598. *
  124599. * When exiting xr the callback parameter will be null)
  124600. */
  124601. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  124602. /**
  124603. *
  124604. * @param scene babylon scene object to use
  124605. * @param options (read-only) version of the options passed to this UI
  124606. */
  124607. private constructor();
  124608. /**
  124609. * Creates UI to allow the user to enter/exit XR mode
  124610. * @param scene the scene to add the ui to
  124611. * @param helper the xr experience helper to enter/exit xr with
  124612. * @param options options to configure the UI
  124613. * @returns the created ui
  124614. */
  124615. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  124616. /**
  124617. * Disposes of the XR UI component
  124618. */
  124619. dispose(): void;
  124620. private _updateButtons;
  124621. }
  124622. }
  124623. declare module BABYLON {
  124624. /**
  124625. * Class containing static functions to help procedurally build meshes
  124626. */
  124627. export class LinesBuilder {
  124628. /**
  124629. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124630. * * 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
  124631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124632. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124633. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124634. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124635. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124636. * * 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
  124637. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124640. * @param name defines the name of the new line system
  124641. * @param options defines the options used to create the line system
  124642. * @param scene defines the hosting scene
  124643. * @returns a new line system mesh
  124644. */
  124645. static CreateLineSystem(name: string, options: {
  124646. lines: Vector3[][];
  124647. updatable?: boolean;
  124648. instance?: Nullable<LinesMesh>;
  124649. colors?: Nullable<Color4[][]>;
  124650. useVertexAlpha?: boolean;
  124651. }, scene: Nullable<Scene>): LinesMesh;
  124652. /**
  124653. * Creates a line mesh
  124654. * 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
  124655. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124656. * * The parameter `points` is an array successive Vector3
  124657. * * 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
  124658. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124659. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124660. * * When updating an instance, remember that only point positions can change, not the number of points
  124661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124663. * @param name defines the name of the new line system
  124664. * @param options defines the options used to create the line system
  124665. * @param scene defines the hosting scene
  124666. * @returns a new line mesh
  124667. */
  124668. static CreateLines(name: string, options: {
  124669. points: Vector3[];
  124670. updatable?: boolean;
  124671. instance?: Nullable<LinesMesh>;
  124672. colors?: Color4[];
  124673. useVertexAlpha?: boolean;
  124674. }, scene?: Nullable<Scene>): LinesMesh;
  124675. /**
  124676. * Creates a dashed line mesh
  124677. * * 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
  124678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124679. * * The parameter `points` is an array successive Vector3
  124680. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124681. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124682. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124683. * * 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
  124684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124685. * * When updating an instance, remember that only point positions can change, not the number of points
  124686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124687. * @param name defines the name of the mesh
  124688. * @param options defines the options used to create the mesh
  124689. * @param scene defines the hosting scene
  124690. * @returns the dashed line mesh
  124691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124692. */
  124693. static CreateDashedLines(name: string, options: {
  124694. points: Vector3[];
  124695. dashSize?: number;
  124696. gapSize?: number;
  124697. dashNb?: number;
  124698. updatable?: boolean;
  124699. instance?: LinesMesh;
  124700. useVertexAlpha?: boolean;
  124701. }, scene?: Nullable<Scene>): LinesMesh;
  124702. }
  124703. }
  124704. declare module BABYLON {
  124705. /**
  124706. * The options container for the teleportation module
  124707. */
  124708. export interface IWebXRTeleportationOptions {
  124709. /**
  124710. * if provided, this scene will be used to render meshes.
  124711. */
  124712. customUtilityLayerScene?: Scene;
  124713. /**
  124714. * Values to configure the default target mesh
  124715. */
  124716. defaultTargetMeshOptions?: {
  124717. /**
  124718. * Fill color of the teleportation area
  124719. */
  124720. teleportationFillColor?: string;
  124721. /**
  124722. * Border color for the teleportation area
  124723. */
  124724. teleportationBorderColor?: string;
  124725. /**
  124726. * Disable the mesh's animation sequence
  124727. */
  124728. disableAnimation?: boolean;
  124729. /**
  124730. * Disable lighting on the material or the ring and arrow
  124731. */
  124732. disableLighting?: boolean;
  124733. /**
  124734. * Override the default material of the torus and arrow
  124735. */
  124736. torusArrowMaterial?: Material;
  124737. };
  124738. /**
  124739. * A list of meshes to use as floor meshes.
  124740. * Meshes can be added and removed after initializing the feature using the
  124741. * addFloorMesh and removeFloorMesh functions
  124742. * If empty, rotation will still work
  124743. */
  124744. floorMeshes?: AbstractMesh[];
  124745. /**
  124746. * use this rendering group id for the meshes (optional)
  124747. */
  124748. renderingGroupId?: number;
  124749. /**
  124750. * Should teleportation move only to snap points
  124751. */
  124752. snapPointsOnly?: boolean;
  124753. /**
  124754. * An array of points to which the teleportation will snap to.
  124755. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  124756. */
  124757. snapPositions?: Vector3[];
  124758. /**
  124759. * How close should the teleportation ray be in order to snap to position.
  124760. * Default to 0.8 units (meters)
  124761. */
  124762. snapToPositionRadius?: number;
  124763. /**
  124764. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  124765. * If you want to support rotation, make sure your mesh has a direction indicator.
  124766. *
  124767. * When left untouched, the default mesh will be initialized.
  124768. */
  124769. teleportationTargetMesh?: AbstractMesh;
  124770. /**
  124771. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  124772. */
  124773. timeToTeleport?: number;
  124774. /**
  124775. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  124776. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  124777. */
  124778. useMainComponentOnly?: boolean;
  124779. /**
  124780. * Should meshes created here be added to a utility layer or the main scene
  124781. */
  124782. useUtilityLayer?: boolean;
  124783. /**
  124784. * Babylon XR Input class for controller
  124785. */
  124786. xrInput: WebXRInput;
  124787. }
  124788. /**
  124789. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  124790. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  124791. * the input of the attached controllers.
  124792. */
  124793. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  124794. private _options;
  124795. private _controllers;
  124796. private _currentTeleportationControllerId;
  124797. private _floorMeshes;
  124798. private _quadraticBezierCurve;
  124799. private _selectionFeature;
  124800. private _snapToPositions;
  124801. private _snappedToPoint;
  124802. private _teleportationRingMaterial?;
  124803. private _tmpRay;
  124804. private _tmpVector;
  124805. /**
  124806. * The module's name
  124807. */
  124808. static readonly Name: string;
  124809. /**
  124810. * The (Babylon) version of this module.
  124811. * This is an integer representing the implementation version.
  124812. * This number does not correspond to the webxr specs version
  124813. */
  124814. static readonly Version: number;
  124815. /**
  124816. * Is movement backwards enabled
  124817. */
  124818. backwardsMovementEnabled: boolean;
  124819. /**
  124820. * Distance to travel when moving backwards
  124821. */
  124822. backwardsTeleportationDistance: number;
  124823. /**
  124824. * The distance from the user to the inspection point in the direction of the controller
  124825. * A higher number will allow the user to move further
  124826. * defaults to 5 (meters, in xr units)
  124827. */
  124828. parabolicCheckRadius: number;
  124829. /**
  124830. * Should the module support parabolic ray on top of direct ray
  124831. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  124832. * Very helpful when moving between floors / different heights
  124833. */
  124834. parabolicRayEnabled: boolean;
  124835. /**
  124836. * How much rotation should be applied when rotating right and left
  124837. */
  124838. rotationAngle: number;
  124839. /**
  124840. * Is rotation enabled when moving forward?
  124841. * Disabling this feature will prevent the user from deciding the direction when teleporting
  124842. */
  124843. rotationEnabled: boolean;
  124844. /**
  124845. * constructs a new anchor system
  124846. * @param _xrSessionManager an instance of WebXRSessionManager
  124847. * @param _options configuration object for this feature
  124848. */
  124849. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  124850. /**
  124851. * Get the snapPointsOnly flag
  124852. */
  124853. get snapPointsOnly(): boolean;
  124854. /**
  124855. * Sets the snapPointsOnly flag
  124856. * @param snapToPoints should teleportation be exclusively to snap points
  124857. */
  124858. set snapPointsOnly(snapToPoints: boolean);
  124859. /**
  124860. * Add a new mesh to the floor meshes array
  124861. * @param mesh the mesh to use as floor mesh
  124862. */
  124863. addFloorMesh(mesh: AbstractMesh): void;
  124864. /**
  124865. * Add a new snap-to point to fix teleportation to this position
  124866. * @param newSnapPoint The new Snap-To point
  124867. */
  124868. addSnapPoint(newSnapPoint: Vector3): void;
  124869. attach(): boolean;
  124870. detach(): boolean;
  124871. dispose(): void;
  124872. /**
  124873. * Remove a mesh from the floor meshes array
  124874. * @param mesh the mesh to remove
  124875. */
  124876. removeFloorMesh(mesh: AbstractMesh): void;
  124877. /**
  124878. * Remove a mesh from the floor meshes array using its name
  124879. * @param name the mesh name to remove
  124880. */
  124881. removeFloorMeshByName(name: string): void;
  124882. /**
  124883. * 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
  124884. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  124885. * @returns was the point found and removed or not
  124886. */
  124887. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  124888. /**
  124889. * This function sets a selection feature that will be disabled when
  124890. * the forward ray is shown and will be reattached when hidden.
  124891. * This is used to remove the selection rays when moving.
  124892. * @param selectionFeature the feature to disable when forward movement is enabled
  124893. */
  124894. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  124895. protected _onXRFrame(_xrFrame: XRFrame): void;
  124896. private _attachController;
  124897. private _createDefaultTargetMesh;
  124898. private _detachController;
  124899. private _findClosestSnapPointWithRadius;
  124900. private _setTargetMeshPosition;
  124901. private _setTargetMeshVisibility;
  124902. private _showParabolicPath;
  124903. private _teleportForward;
  124904. }
  124905. }
  124906. declare module BABYLON {
  124907. /**
  124908. * Options for the default xr helper
  124909. */
  124910. export class WebXRDefaultExperienceOptions {
  124911. /**
  124912. * Enable or disable default UI to enter XR
  124913. */
  124914. disableDefaultUI?: boolean;
  124915. /**
  124916. * Should teleportation not initialize. defaults to false.
  124917. */
  124918. disableTeleportation?: boolean;
  124919. /**
  124920. * Floor meshes that will be used for teleport
  124921. */
  124922. floorMeshes?: Array<AbstractMesh>;
  124923. /**
  124924. * If set to true, the first frame will not be used to reset position
  124925. * The first frame is mainly used when copying transformation from the old camera
  124926. * Mainly used in AR
  124927. */
  124928. ignoreNativeCameraTransformation?: boolean;
  124929. /**
  124930. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  124931. */
  124932. inputOptions?: IWebXRInputOptions;
  124933. /**
  124934. * optional configuration for the output canvas
  124935. */
  124936. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  124937. /**
  124938. * optional UI options. This can be used among other to change session mode and reference space type
  124939. */
  124940. uiOptions?: WebXREnterExitUIOptions;
  124941. /**
  124942. * When loading teleportation and pointer select, use stable versions instead of latest.
  124943. */
  124944. useStablePlugins?: boolean;
  124945. /**
  124946. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  124947. */
  124948. renderingGroupId?: number;
  124949. /**
  124950. * A list of optional features to init the session with
  124951. * If set to true, all features we support will be added
  124952. */
  124953. optionalFeatures?: boolean | string[];
  124954. }
  124955. /**
  124956. * Default experience which provides a similar setup to the previous webVRExperience
  124957. */
  124958. export class WebXRDefaultExperience {
  124959. /**
  124960. * Base experience
  124961. */
  124962. baseExperience: WebXRExperienceHelper;
  124963. /**
  124964. * Enables ui for entering/exiting xr
  124965. */
  124966. enterExitUI: WebXREnterExitUI;
  124967. /**
  124968. * Input experience extension
  124969. */
  124970. input: WebXRInput;
  124971. /**
  124972. * Enables laser pointer and selection
  124973. */
  124974. pointerSelection: WebXRControllerPointerSelection;
  124975. /**
  124976. * Default target xr should render to
  124977. */
  124978. renderTarget: WebXRRenderTarget;
  124979. /**
  124980. * Enables teleportation
  124981. */
  124982. teleportation: WebXRMotionControllerTeleportation;
  124983. private constructor();
  124984. /**
  124985. * Creates the default xr experience
  124986. * @param scene scene
  124987. * @param options options for basic configuration
  124988. * @returns resulting WebXRDefaultExperience
  124989. */
  124990. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  124991. /**
  124992. * DIsposes of the experience helper
  124993. */
  124994. dispose(): void;
  124995. }
  124996. }
  124997. declare module BABYLON {
  124998. /**
  124999. * Options to modify the vr teleportation behavior.
  125000. */
  125001. export interface VRTeleportationOptions {
  125002. /**
  125003. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125004. */
  125005. floorMeshName?: string;
  125006. /**
  125007. * A list of meshes to be used as the teleportation floor. (default: empty)
  125008. */
  125009. floorMeshes?: Mesh[];
  125010. /**
  125011. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125012. */
  125013. teleportationMode?: number;
  125014. /**
  125015. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125016. */
  125017. teleportationTime?: number;
  125018. /**
  125019. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125020. */
  125021. teleportationSpeed?: number;
  125022. /**
  125023. * The easing function used in the animation or null for Linear. (default CircleEase)
  125024. */
  125025. easingFunction?: EasingFunction;
  125026. }
  125027. /**
  125028. * Options to modify the vr experience helper's behavior.
  125029. */
  125030. export interface VRExperienceHelperOptions extends WebVROptions {
  125031. /**
  125032. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125033. */
  125034. createDeviceOrientationCamera?: boolean;
  125035. /**
  125036. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125037. */
  125038. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125039. /**
  125040. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125041. */
  125042. laserToggle?: boolean;
  125043. /**
  125044. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125045. */
  125046. floorMeshes?: Mesh[];
  125047. /**
  125048. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125049. */
  125050. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125051. /**
  125052. * Defines if WebXR should be used instead of WebVR (if available)
  125053. */
  125054. useXR?: boolean;
  125055. }
  125056. /**
  125057. * Event containing information after VR has been entered
  125058. */
  125059. export class OnAfterEnteringVRObservableEvent {
  125060. /**
  125061. * If entering vr was successful
  125062. */
  125063. success: boolean;
  125064. }
  125065. /**
  125066. * Helps to quickly add VR support to an existing scene.
  125067. * See http://doc.babylonjs.com/how_to/webvr_helper
  125068. */
  125069. export class VRExperienceHelper {
  125070. /** Options to modify the vr experience helper's behavior. */
  125071. webVROptions: VRExperienceHelperOptions;
  125072. private _scene;
  125073. private _position;
  125074. private _btnVR;
  125075. private _btnVRDisplayed;
  125076. private _webVRsupported;
  125077. private _webVRready;
  125078. private _webVRrequesting;
  125079. private _webVRpresenting;
  125080. private _hasEnteredVR;
  125081. private _fullscreenVRpresenting;
  125082. private _inputElement;
  125083. private _webVRCamera;
  125084. private _vrDeviceOrientationCamera;
  125085. private _deviceOrientationCamera;
  125086. private _existingCamera;
  125087. private _onKeyDown;
  125088. private _onVrDisplayPresentChange;
  125089. private _onVRDisplayChanged;
  125090. private _onVRRequestPresentStart;
  125091. private _onVRRequestPresentComplete;
  125092. /**
  125093. * 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)
  125094. */
  125095. enableGazeEvenWhenNoPointerLock: boolean;
  125096. /**
  125097. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  125098. */
  125099. exitVROnDoubleTap: boolean;
  125100. /**
  125101. * Observable raised right before entering VR.
  125102. */
  125103. onEnteringVRObservable: Observable<VRExperienceHelper>;
  125104. /**
  125105. * Observable raised when entering VR has completed.
  125106. */
  125107. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  125108. /**
  125109. * Observable raised when exiting VR.
  125110. */
  125111. onExitingVRObservable: Observable<VRExperienceHelper>;
  125112. /**
  125113. * Observable raised when controller mesh is loaded.
  125114. */
  125115. onControllerMeshLoadedObservable: Observable<WebVRController>;
  125116. /** Return this.onEnteringVRObservable
  125117. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  125118. */
  125119. get onEnteringVR(): Observable<VRExperienceHelper>;
  125120. /** Return this.onExitingVRObservable
  125121. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  125122. */
  125123. get onExitingVR(): Observable<VRExperienceHelper>;
  125124. /** Return this.onControllerMeshLoadedObservable
  125125. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  125126. */
  125127. get onControllerMeshLoaded(): Observable<WebVRController>;
  125128. private _rayLength;
  125129. private _useCustomVRButton;
  125130. private _teleportationRequested;
  125131. private _teleportActive;
  125132. private _floorMeshName;
  125133. private _floorMeshesCollection;
  125134. private _teleportationMode;
  125135. private _teleportationTime;
  125136. private _teleportationSpeed;
  125137. private _teleportationEasing;
  125138. private _rotationAllowed;
  125139. private _teleportBackwardsVector;
  125140. private _teleportationTarget;
  125141. private _isDefaultTeleportationTarget;
  125142. private _postProcessMove;
  125143. private _teleportationFillColor;
  125144. private _teleportationBorderColor;
  125145. private _rotationAngle;
  125146. private _haloCenter;
  125147. private _cameraGazer;
  125148. private _padSensibilityUp;
  125149. private _padSensibilityDown;
  125150. private _leftController;
  125151. private _rightController;
  125152. private _gazeColor;
  125153. private _laserColor;
  125154. private _pickedLaserColor;
  125155. private _pickedGazeColor;
  125156. /**
  125157. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  125158. */
  125159. onNewMeshSelected: Observable<AbstractMesh>;
  125160. /**
  125161. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  125162. * This observable will provide the mesh and the controller used to select the mesh
  125163. */
  125164. onMeshSelectedWithController: Observable<{
  125165. mesh: AbstractMesh;
  125166. controller: WebVRController;
  125167. }>;
  125168. /**
  125169. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  125170. */
  125171. onNewMeshPicked: Observable<PickingInfo>;
  125172. private _circleEase;
  125173. /**
  125174. * Observable raised before camera teleportation
  125175. */
  125176. onBeforeCameraTeleport: Observable<Vector3>;
  125177. /**
  125178. * Observable raised after camera teleportation
  125179. */
  125180. onAfterCameraTeleport: Observable<Vector3>;
  125181. /**
  125182. * Observable raised when current selected mesh gets unselected
  125183. */
  125184. onSelectedMeshUnselected: Observable<AbstractMesh>;
  125185. private _raySelectionPredicate;
  125186. /**
  125187. * To be optionaly changed by user to define custom ray selection
  125188. */
  125189. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125190. /**
  125191. * To be optionaly changed by user to define custom selection logic (after ray selection)
  125192. */
  125193. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  125194. /**
  125195. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  125196. */
  125197. teleportationEnabled: boolean;
  125198. private _defaultHeight;
  125199. private _teleportationInitialized;
  125200. private _interactionsEnabled;
  125201. private _interactionsRequested;
  125202. private _displayGaze;
  125203. private _displayLaserPointer;
  125204. /**
  125205. * The mesh used to display where the user is going to teleport.
  125206. */
  125207. get teleportationTarget(): Mesh;
  125208. /**
  125209. * Sets the mesh to be used to display where the user is going to teleport.
  125210. */
  125211. set teleportationTarget(value: Mesh);
  125212. /**
  125213. * 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
  125214. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  125215. * See http://doc.babylonjs.com/resources/baking_transformations
  125216. */
  125217. get gazeTrackerMesh(): Mesh;
  125218. set gazeTrackerMesh(value: Mesh);
  125219. /**
  125220. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  125221. */
  125222. updateGazeTrackerScale: boolean;
  125223. /**
  125224. * If the gaze trackers color should be updated when selecting meshes
  125225. */
  125226. updateGazeTrackerColor: boolean;
  125227. /**
  125228. * If the controller laser color should be updated when selecting meshes
  125229. */
  125230. updateControllerLaserColor: boolean;
  125231. /**
  125232. * The gaze tracking mesh corresponding to the left controller
  125233. */
  125234. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  125235. /**
  125236. * The gaze tracking mesh corresponding to the right controller
  125237. */
  125238. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  125239. /**
  125240. * If the ray of the gaze should be displayed.
  125241. */
  125242. get displayGaze(): boolean;
  125243. /**
  125244. * Sets if the ray of the gaze should be displayed.
  125245. */
  125246. set displayGaze(value: boolean);
  125247. /**
  125248. * If the ray of the LaserPointer should be displayed.
  125249. */
  125250. get displayLaserPointer(): boolean;
  125251. /**
  125252. * Sets if the ray of the LaserPointer should be displayed.
  125253. */
  125254. set displayLaserPointer(value: boolean);
  125255. /**
  125256. * The deviceOrientationCamera used as the camera when not in VR.
  125257. */
  125258. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  125259. /**
  125260. * Based on the current WebVR support, returns the current VR camera used.
  125261. */
  125262. get currentVRCamera(): Nullable<Camera>;
  125263. /**
  125264. * The webVRCamera which is used when in VR.
  125265. */
  125266. get webVRCamera(): WebVRFreeCamera;
  125267. /**
  125268. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  125269. */
  125270. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  125271. /**
  125272. * The html button that is used to trigger entering into VR.
  125273. */
  125274. get vrButton(): Nullable<HTMLButtonElement>;
  125275. private get _teleportationRequestInitiated();
  125276. /**
  125277. * Defines whether or not Pointer lock should be requested when switching to
  125278. * full screen.
  125279. */
  125280. requestPointerLockOnFullScreen: boolean;
  125281. /**
  125282. * If asking to force XR, this will be populated with the default xr experience
  125283. */
  125284. xr: WebXRDefaultExperience;
  125285. /**
  125286. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  125287. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  125288. */
  125289. xrTestDone: boolean;
  125290. /**
  125291. * Instantiates a VRExperienceHelper.
  125292. * Helps to quickly add VR support to an existing scene.
  125293. * @param scene The scene the VRExperienceHelper belongs to.
  125294. * @param webVROptions Options to modify the vr experience helper's behavior.
  125295. */
  125296. constructor(scene: Scene,
  125297. /** Options to modify the vr experience helper's behavior. */
  125298. webVROptions?: VRExperienceHelperOptions);
  125299. private completeVRInit;
  125300. private _onDefaultMeshLoaded;
  125301. private _onResize;
  125302. private _onFullscreenChange;
  125303. /**
  125304. * Gets a value indicating if we are currently in VR mode.
  125305. */
  125306. get isInVRMode(): boolean;
  125307. private onVrDisplayPresentChange;
  125308. private onVRDisplayChanged;
  125309. private moveButtonToBottomRight;
  125310. private displayVRButton;
  125311. private updateButtonVisibility;
  125312. private _cachedAngularSensibility;
  125313. /**
  125314. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  125315. * Otherwise, will use the fullscreen API.
  125316. */
  125317. enterVR(): void;
  125318. /**
  125319. * Attempt to exit VR, or fullscreen.
  125320. */
  125321. exitVR(): void;
  125322. /**
  125323. * The position of the vr experience helper.
  125324. */
  125325. get position(): Vector3;
  125326. /**
  125327. * Sets the position of the vr experience helper.
  125328. */
  125329. set position(value: Vector3);
  125330. /**
  125331. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  125332. */
  125333. enableInteractions(): void;
  125334. private get _noControllerIsActive();
  125335. private beforeRender;
  125336. private _isTeleportationFloor;
  125337. /**
  125338. * Adds a floor mesh to be used for teleportation.
  125339. * @param floorMesh the mesh to be used for teleportation.
  125340. */
  125341. addFloorMesh(floorMesh: Mesh): void;
  125342. /**
  125343. * Removes a floor mesh from being used for teleportation.
  125344. * @param floorMesh the mesh to be removed.
  125345. */
  125346. removeFloorMesh(floorMesh: Mesh): void;
  125347. /**
  125348. * Enables interactions and teleportation using the VR controllers and gaze.
  125349. * @param vrTeleportationOptions options to modify teleportation behavior.
  125350. */
  125351. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  125352. private _onNewGamepadConnected;
  125353. private _tryEnableInteractionOnController;
  125354. private _onNewGamepadDisconnected;
  125355. private _enableInteractionOnController;
  125356. private _checkTeleportWithRay;
  125357. private _checkRotate;
  125358. private _checkTeleportBackwards;
  125359. private _enableTeleportationOnController;
  125360. private _createTeleportationCircles;
  125361. private _displayTeleportationTarget;
  125362. private _hideTeleportationTarget;
  125363. private _rotateCamera;
  125364. private _moveTeleportationSelectorTo;
  125365. private _workingVector;
  125366. private _workingQuaternion;
  125367. private _workingMatrix;
  125368. /**
  125369. * Time Constant Teleportation Mode
  125370. */
  125371. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  125372. /**
  125373. * Speed Constant Teleportation Mode
  125374. */
  125375. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  125376. /**
  125377. * Teleports the users feet to the desired location
  125378. * @param location The location where the user's feet should be placed
  125379. */
  125380. teleportCamera(location: Vector3): void;
  125381. private _convertNormalToDirectionOfRay;
  125382. private _castRayAndSelectObject;
  125383. private _notifySelectedMeshUnselected;
  125384. /**
  125385. * Permanently set new colors for the laser pointer
  125386. * @param color the new laser color
  125387. * @param pickedColor the new laser color when picked mesh detected
  125388. */
  125389. setLaserColor(color: Color3, pickedColor?: Color3): void;
  125390. /**
  125391. * Set lighting enabled / disabled on the laser pointer of both controllers
  125392. * @param enabled should the lighting be enabled on the laser pointer
  125393. */
  125394. setLaserLightingState(enabled?: boolean): void;
  125395. /**
  125396. * Permanently set new colors for the gaze pointer
  125397. * @param color the new gaze color
  125398. * @param pickedColor the new gaze color when picked mesh detected
  125399. */
  125400. setGazeColor(color: Color3, pickedColor?: Color3): void;
  125401. /**
  125402. * Sets the color of the laser ray from the vr controllers.
  125403. * @param color new color for the ray.
  125404. */
  125405. changeLaserColor(color: Color3): void;
  125406. /**
  125407. * Sets the color of the ray from the vr headsets gaze.
  125408. * @param color new color for the ray.
  125409. */
  125410. changeGazeColor(color: Color3): void;
  125411. /**
  125412. * Exits VR and disposes of the vr experience helper
  125413. */
  125414. dispose(): void;
  125415. /**
  125416. * Gets the name of the VRExperienceHelper class
  125417. * @returns "VRExperienceHelper"
  125418. */
  125419. getClassName(): string;
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /**
  125424. * Contains an array of blocks representing the octree
  125425. */
  125426. export interface IOctreeContainer<T> {
  125427. /**
  125428. * Blocks within the octree
  125429. */
  125430. blocks: Array<OctreeBlock<T>>;
  125431. }
  125432. /**
  125433. * Class used to store a cell in an octree
  125434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125435. */
  125436. export class OctreeBlock<T> {
  125437. /**
  125438. * Gets the content of the current block
  125439. */
  125440. entries: T[];
  125441. /**
  125442. * Gets the list of block children
  125443. */
  125444. blocks: Array<OctreeBlock<T>>;
  125445. private _depth;
  125446. private _maxDepth;
  125447. private _capacity;
  125448. private _minPoint;
  125449. private _maxPoint;
  125450. private _boundingVectors;
  125451. private _creationFunc;
  125452. /**
  125453. * Creates a new block
  125454. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  125455. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  125456. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125457. * @param depth defines the current depth of this block in the octree
  125458. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  125459. * @param creationFunc defines a callback to call when an element is added to the block
  125460. */
  125461. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  125462. /**
  125463. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125464. */
  125465. get capacity(): number;
  125466. /**
  125467. * Gets the minimum vector (in world space) of the block's bounding box
  125468. */
  125469. get minPoint(): Vector3;
  125470. /**
  125471. * Gets the maximum vector (in world space) of the block's bounding box
  125472. */
  125473. get maxPoint(): Vector3;
  125474. /**
  125475. * Add a new element to this block
  125476. * @param entry defines the element to add
  125477. */
  125478. addEntry(entry: T): void;
  125479. /**
  125480. * Remove an element from this block
  125481. * @param entry defines the element to remove
  125482. */
  125483. removeEntry(entry: T): void;
  125484. /**
  125485. * Add an array of elements to this block
  125486. * @param entries defines the array of elements to add
  125487. */
  125488. addEntries(entries: T[]): void;
  125489. /**
  125490. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  125491. * @param frustumPlanes defines the frustum planes to test
  125492. * @param selection defines the array to store current content if selection is positive
  125493. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125494. */
  125495. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125496. /**
  125497. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  125498. * @param sphereCenter defines the bounding sphere center
  125499. * @param sphereRadius defines the bounding sphere radius
  125500. * @param selection defines the array to store current content if selection is positive
  125501. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125502. */
  125503. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125504. /**
  125505. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  125506. * @param ray defines the ray to test with
  125507. * @param selection defines the array to store current content if selection is positive
  125508. */
  125509. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  125510. /**
  125511. * Subdivide the content into child blocks (this block will then be empty)
  125512. */
  125513. createInnerBlocks(): void;
  125514. /**
  125515. * @hidden
  125516. */
  125517. 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;
  125518. }
  125519. }
  125520. declare module BABYLON {
  125521. /**
  125522. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  125523. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125524. */
  125525. export class Octree<T> {
  125526. /** 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.) */
  125527. maxDepth: number;
  125528. /**
  125529. * Blocks within the octree containing objects
  125530. */
  125531. blocks: Array<OctreeBlock<T>>;
  125532. /**
  125533. * Content stored in the octree
  125534. */
  125535. dynamicContent: T[];
  125536. private _maxBlockCapacity;
  125537. private _selectionContent;
  125538. private _creationFunc;
  125539. /**
  125540. * Creates a octree
  125541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125542. * @param creationFunc function to be used to instatiate the octree
  125543. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  125544. * @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.)
  125545. */
  125546. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  125547. /** 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.) */
  125548. maxDepth?: number);
  125549. /**
  125550. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  125551. * @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);
  125552. * @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);
  125553. * @param entries meshes to be added to the octree blocks
  125554. */
  125555. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  125556. /**
  125557. * Adds a mesh to the octree
  125558. * @param entry Mesh to add to the octree
  125559. */
  125560. addMesh(entry: T): void;
  125561. /**
  125562. * Remove an element from the octree
  125563. * @param entry defines the element to remove
  125564. */
  125565. removeMesh(entry: T): void;
  125566. /**
  125567. * Selects an array of meshes within the frustum
  125568. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  125569. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  125570. * @returns array of meshes within the frustum
  125571. */
  125572. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  125573. /**
  125574. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  125575. * @param sphereCenter defines the bounding sphere center
  125576. * @param sphereRadius defines the bounding sphere radius
  125577. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125578. * @returns an array of objects that intersect the sphere
  125579. */
  125580. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  125581. /**
  125582. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  125583. * @param ray defines the ray to test with
  125584. * @returns array of intersected objects
  125585. */
  125586. intersectsRay(ray: Ray): SmartArray<T>;
  125587. /**
  125588. * Adds a mesh into the octree block if it intersects the block
  125589. */
  125590. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  125591. /**
  125592. * Adds a submesh into the octree block if it intersects the block
  125593. */
  125594. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  125595. }
  125596. }
  125597. declare module BABYLON {
  125598. interface Scene {
  125599. /**
  125600. * @hidden
  125601. * Backing Filed
  125602. */
  125603. _selectionOctree: Octree<AbstractMesh>;
  125604. /**
  125605. * Gets the octree used to boost mesh selection (picking)
  125606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125607. */
  125608. selectionOctree: Octree<AbstractMesh>;
  125609. /**
  125610. * Creates or updates the octree used to boost selection (picking)
  125611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125612. * @param maxCapacity defines the maximum capacity per leaf
  125613. * @param maxDepth defines the maximum depth of the octree
  125614. * @returns an octree of AbstractMesh
  125615. */
  125616. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  125617. }
  125618. interface AbstractMesh {
  125619. /**
  125620. * @hidden
  125621. * Backing Field
  125622. */
  125623. _submeshesOctree: Octree<SubMesh>;
  125624. /**
  125625. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  125626. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  125627. * @param maxCapacity defines the maximum size of each block (64 by default)
  125628. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  125629. * @returns the new octree
  125630. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  125631. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125632. */
  125633. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  125634. }
  125635. /**
  125636. * Defines the octree scene component responsible to manage any octrees
  125637. * in a given scene.
  125638. */
  125639. export class OctreeSceneComponent {
  125640. /**
  125641. * The component name help to identify the component in the list of scene components.
  125642. */
  125643. readonly name: string;
  125644. /**
  125645. * The scene the component belongs to.
  125646. */
  125647. scene: Scene;
  125648. /**
  125649. * Indicates if the meshes have been checked to make sure they are isEnabled()
  125650. */
  125651. readonly checksIsEnabled: boolean;
  125652. /**
  125653. * Creates a new instance of the component for the given scene
  125654. * @param scene Defines the scene to register the component in
  125655. */
  125656. constructor(scene: Scene);
  125657. /**
  125658. * Registers the component in a given scene
  125659. */
  125660. register(): void;
  125661. /**
  125662. * Return the list of active meshes
  125663. * @returns the list of active meshes
  125664. */
  125665. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125666. /**
  125667. * Return the list of active sub meshes
  125668. * @param mesh The mesh to get the candidates sub meshes from
  125669. * @returns the list of active sub meshes
  125670. */
  125671. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125672. private _tempRay;
  125673. /**
  125674. * Return the list of sub meshes intersecting with a given local ray
  125675. * @param mesh defines the mesh to find the submesh for
  125676. * @param localRay defines the ray in local space
  125677. * @returns the list of intersecting sub meshes
  125678. */
  125679. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  125680. /**
  125681. * Return the list of sub meshes colliding with a collider
  125682. * @param mesh defines the mesh to find the submesh for
  125683. * @param collider defines the collider to evaluate the collision against
  125684. * @returns the list of colliding sub meshes
  125685. */
  125686. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  125687. /**
  125688. * Rebuilds the elements related to this component in case of
  125689. * context lost for instance.
  125690. */
  125691. rebuild(): void;
  125692. /**
  125693. * Disposes the component and the associated ressources.
  125694. */
  125695. dispose(): void;
  125696. }
  125697. }
  125698. declare module BABYLON {
  125699. /**
  125700. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  125701. */
  125702. export class Gizmo implements IDisposable {
  125703. /** The utility layer the gizmo will be added to */
  125704. gizmoLayer: UtilityLayerRenderer;
  125705. /**
  125706. * The root mesh of the gizmo
  125707. */
  125708. _rootMesh: Mesh;
  125709. private _attachedMesh;
  125710. /**
  125711. * Ratio for the scale of the gizmo (Default: 1)
  125712. */
  125713. scaleRatio: number;
  125714. /**
  125715. * If a custom mesh has been set (Default: false)
  125716. */
  125717. protected _customMeshSet: boolean;
  125718. /**
  125719. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  125720. * * When set, interactions will be enabled
  125721. */
  125722. get attachedMesh(): Nullable<AbstractMesh>;
  125723. set attachedMesh(value: Nullable<AbstractMesh>);
  125724. /**
  125725. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  125726. * @param mesh The mesh to replace the default mesh of the gizmo
  125727. */
  125728. setCustomMesh(mesh: Mesh): void;
  125729. /**
  125730. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  125731. */
  125732. updateGizmoRotationToMatchAttachedMesh: boolean;
  125733. /**
  125734. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  125735. */
  125736. updateGizmoPositionToMatchAttachedMesh: boolean;
  125737. /**
  125738. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  125739. */
  125740. updateScale: boolean;
  125741. protected _interactionsEnabled: boolean;
  125742. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125743. private _beforeRenderObserver;
  125744. private _tempVector;
  125745. /**
  125746. * Creates a gizmo
  125747. * @param gizmoLayer The utility layer the gizmo will be added to
  125748. */
  125749. constructor(
  125750. /** The utility layer the gizmo will be added to */
  125751. gizmoLayer?: UtilityLayerRenderer);
  125752. /**
  125753. * Updates the gizmo to match the attached mesh's position/rotation
  125754. */
  125755. protected _update(): void;
  125756. /**
  125757. * Disposes of the gizmo
  125758. */
  125759. dispose(): void;
  125760. }
  125761. }
  125762. declare module BABYLON {
  125763. /**
  125764. * Single plane drag gizmo
  125765. */
  125766. export class PlaneDragGizmo extends Gizmo {
  125767. /**
  125768. * Drag behavior responsible for the gizmos dragging interactions
  125769. */
  125770. dragBehavior: PointerDragBehavior;
  125771. private _pointerObserver;
  125772. /**
  125773. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125774. */
  125775. snapDistance: number;
  125776. /**
  125777. * Event that fires each time the gizmo snaps to a new location.
  125778. * * snapDistance is the the change in distance
  125779. */
  125780. onSnapObservable: Observable<{
  125781. snapDistance: number;
  125782. }>;
  125783. private _plane;
  125784. private _coloredMaterial;
  125785. private _hoverMaterial;
  125786. private _isEnabled;
  125787. private _parent;
  125788. /** @hidden */
  125789. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  125790. /** @hidden */
  125791. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  125792. /**
  125793. * Creates a PlaneDragGizmo
  125794. * @param gizmoLayer The utility layer the gizmo will be added to
  125795. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  125796. * @param color The color of the gizmo
  125797. */
  125798. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  125799. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125800. /**
  125801. * If the gizmo is enabled
  125802. */
  125803. set isEnabled(value: boolean);
  125804. get isEnabled(): boolean;
  125805. /**
  125806. * Disposes of the gizmo
  125807. */
  125808. dispose(): void;
  125809. }
  125810. }
  125811. declare module BABYLON {
  125812. /**
  125813. * Gizmo that enables dragging a mesh along 3 axis
  125814. */
  125815. export class PositionGizmo extends Gizmo {
  125816. /**
  125817. * Internal gizmo used for interactions on the x axis
  125818. */
  125819. xGizmo: AxisDragGizmo;
  125820. /**
  125821. * Internal gizmo used for interactions on the y axis
  125822. */
  125823. yGizmo: AxisDragGizmo;
  125824. /**
  125825. * Internal gizmo used for interactions on the z axis
  125826. */
  125827. zGizmo: AxisDragGizmo;
  125828. /**
  125829. * Internal gizmo used for interactions on the yz plane
  125830. */
  125831. xPlaneGizmo: PlaneDragGizmo;
  125832. /**
  125833. * Internal gizmo used for interactions on the xz plane
  125834. */
  125835. yPlaneGizmo: PlaneDragGizmo;
  125836. /**
  125837. * Internal gizmo used for interactions on the xy plane
  125838. */
  125839. zPlaneGizmo: PlaneDragGizmo;
  125840. /**
  125841. * private variables
  125842. */
  125843. private _meshAttached;
  125844. private _updateGizmoRotationToMatchAttachedMesh;
  125845. private _snapDistance;
  125846. private _scaleRatio;
  125847. /** Fires an event when any of it's sub gizmos are dragged */
  125848. onDragStartObservable: Observable<unknown>;
  125849. /** Fires an event when any of it's sub gizmos are released from dragging */
  125850. onDragEndObservable: Observable<unknown>;
  125851. /**
  125852. * If set to true, planar drag is enabled
  125853. */
  125854. private _planarGizmoEnabled;
  125855. get attachedMesh(): Nullable<AbstractMesh>;
  125856. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125857. /**
  125858. * Creates a PositionGizmo
  125859. * @param gizmoLayer The utility layer the gizmo will be added to
  125860. */
  125861. constructor(gizmoLayer?: UtilityLayerRenderer);
  125862. /**
  125863. * If the planar drag gizmo is enabled
  125864. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  125865. */
  125866. set planarGizmoEnabled(value: boolean);
  125867. get planarGizmoEnabled(): boolean;
  125868. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125869. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125870. /**
  125871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125872. */
  125873. set snapDistance(value: number);
  125874. get snapDistance(): number;
  125875. /**
  125876. * Ratio for the scale of the gizmo (Default: 1)
  125877. */
  125878. set scaleRatio(value: number);
  125879. get scaleRatio(): number;
  125880. /**
  125881. * Disposes of the gizmo
  125882. */
  125883. dispose(): void;
  125884. /**
  125885. * CustomMeshes are not supported by this gizmo
  125886. * @param mesh The mesh to replace the default mesh of the gizmo
  125887. */
  125888. setCustomMesh(mesh: Mesh): void;
  125889. }
  125890. }
  125891. declare module BABYLON {
  125892. /**
  125893. * Single axis drag gizmo
  125894. */
  125895. export class AxisDragGizmo extends Gizmo {
  125896. /**
  125897. * Drag behavior responsible for the gizmos dragging interactions
  125898. */
  125899. dragBehavior: PointerDragBehavior;
  125900. private _pointerObserver;
  125901. /**
  125902. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125903. */
  125904. snapDistance: number;
  125905. /**
  125906. * Event that fires each time the gizmo snaps to a new location.
  125907. * * snapDistance is the the change in distance
  125908. */
  125909. onSnapObservable: Observable<{
  125910. snapDistance: number;
  125911. }>;
  125912. private _isEnabled;
  125913. private _parent;
  125914. private _arrow;
  125915. private _coloredMaterial;
  125916. private _hoverMaterial;
  125917. /** @hidden */
  125918. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  125919. /** @hidden */
  125920. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  125921. /**
  125922. * Creates an AxisDragGizmo
  125923. * @param gizmoLayer The utility layer the gizmo will be added to
  125924. * @param dragAxis The axis which the gizmo will be able to drag on
  125925. * @param color The color of the gizmo
  125926. */
  125927. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  125928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125929. /**
  125930. * If the gizmo is enabled
  125931. */
  125932. set isEnabled(value: boolean);
  125933. get isEnabled(): boolean;
  125934. /**
  125935. * Disposes of the gizmo
  125936. */
  125937. dispose(): void;
  125938. }
  125939. }
  125940. declare module BABYLON.Debug {
  125941. /**
  125942. * The Axes viewer will show 3 axes in a specific point in space
  125943. */
  125944. export class AxesViewer {
  125945. private _xAxis;
  125946. private _yAxis;
  125947. private _zAxis;
  125948. private _scaleLinesFactor;
  125949. private _instanced;
  125950. /**
  125951. * Gets the hosting scene
  125952. */
  125953. scene: Scene;
  125954. /**
  125955. * Gets or sets a number used to scale line length
  125956. */
  125957. scaleLines: number;
  125958. /** Gets the node hierarchy used to render x-axis */
  125959. get xAxis(): TransformNode;
  125960. /** Gets the node hierarchy used to render y-axis */
  125961. get yAxis(): TransformNode;
  125962. /** Gets the node hierarchy used to render z-axis */
  125963. get zAxis(): TransformNode;
  125964. /**
  125965. * Creates a new AxesViewer
  125966. * @param scene defines the hosting scene
  125967. * @param scaleLines defines a number used to scale line length (1 by default)
  125968. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  125969. * @param xAxis defines the node hierarchy used to render the x-axis
  125970. * @param yAxis defines the node hierarchy used to render the y-axis
  125971. * @param zAxis defines the node hierarchy used to render the z-axis
  125972. */
  125973. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  125974. /**
  125975. * Force the viewer to update
  125976. * @param position defines the position of the viewer
  125977. * @param xaxis defines the x axis of the viewer
  125978. * @param yaxis defines the y axis of the viewer
  125979. * @param zaxis defines the z axis of the viewer
  125980. */
  125981. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  125982. /**
  125983. * Creates an instance of this axes viewer.
  125984. * @returns a new axes viewer with instanced meshes
  125985. */
  125986. createInstance(): AxesViewer;
  125987. /** Releases resources */
  125988. dispose(): void;
  125989. private static _SetRenderingGroupId;
  125990. }
  125991. }
  125992. declare module BABYLON.Debug {
  125993. /**
  125994. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  125995. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  125996. */
  125997. export class BoneAxesViewer extends AxesViewer {
  125998. /**
  125999. * Gets or sets the target mesh where to display the axes viewer
  126000. */
  126001. mesh: Nullable<Mesh>;
  126002. /**
  126003. * Gets or sets the target bone where to display the axes viewer
  126004. */
  126005. bone: Nullable<Bone>;
  126006. /** Gets current position */
  126007. pos: Vector3;
  126008. /** Gets direction of X axis */
  126009. xaxis: Vector3;
  126010. /** Gets direction of Y axis */
  126011. yaxis: Vector3;
  126012. /** Gets direction of Z axis */
  126013. zaxis: Vector3;
  126014. /**
  126015. * Creates a new BoneAxesViewer
  126016. * @param scene defines the hosting scene
  126017. * @param bone defines the target bone
  126018. * @param mesh defines the target mesh
  126019. * @param scaleLines defines a scaling factor for line length (1 by default)
  126020. */
  126021. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126022. /**
  126023. * Force the viewer to update
  126024. */
  126025. update(): void;
  126026. /** Releases resources */
  126027. dispose(): void;
  126028. }
  126029. }
  126030. declare module BABYLON {
  126031. /**
  126032. * Interface used to define scene explorer extensibility option
  126033. */
  126034. export interface IExplorerExtensibilityOption {
  126035. /**
  126036. * Define the option label
  126037. */
  126038. label: string;
  126039. /**
  126040. * Defines the action to execute on click
  126041. */
  126042. action: (entity: any) => void;
  126043. }
  126044. /**
  126045. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126046. */
  126047. export interface IExplorerExtensibilityGroup {
  126048. /**
  126049. * Defines a predicate to test if a given type mut be extended
  126050. */
  126051. predicate: (entity: any) => boolean;
  126052. /**
  126053. * Gets the list of options added to a type
  126054. */
  126055. entries: IExplorerExtensibilityOption[];
  126056. }
  126057. /**
  126058. * Interface used to define the options to use to create the Inspector
  126059. */
  126060. export interface IInspectorOptions {
  126061. /**
  126062. * Display in overlay mode (default: false)
  126063. */
  126064. overlay?: boolean;
  126065. /**
  126066. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126067. */
  126068. globalRoot?: HTMLElement;
  126069. /**
  126070. * Display the Scene explorer
  126071. */
  126072. showExplorer?: boolean;
  126073. /**
  126074. * Display the property inspector
  126075. */
  126076. showInspector?: boolean;
  126077. /**
  126078. * Display in embed mode (both panes on the right)
  126079. */
  126080. embedMode?: boolean;
  126081. /**
  126082. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  126083. */
  126084. handleResize?: boolean;
  126085. /**
  126086. * Allow the panes to popup (default: true)
  126087. */
  126088. enablePopup?: boolean;
  126089. /**
  126090. * Allow the panes to be closed by users (default: true)
  126091. */
  126092. enableClose?: boolean;
  126093. /**
  126094. * Optional list of extensibility entries
  126095. */
  126096. explorerExtensibility?: IExplorerExtensibilityGroup[];
  126097. /**
  126098. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126099. */
  126100. inspectorURL?: string;
  126101. /**
  126102. * Optional initial tab (default to DebugLayerTab.Properties)
  126103. */
  126104. initialTab?: DebugLayerTab;
  126105. }
  126106. interface Scene {
  126107. /**
  126108. * @hidden
  126109. * Backing field
  126110. */
  126111. _debugLayer: DebugLayer;
  126112. /**
  126113. * Gets the debug layer (aka Inspector) associated with the scene
  126114. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126115. */
  126116. debugLayer: DebugLayer;
  126117. }
  126118. /**
  126119. * Enum of inspector action tab
  126120. */
  126121. export enum DebugLayerTab {
  126122. /**
  126123. * Properties tag (default)
  126124. */
  126125. Properties = 0,
  126126. /**
  126127. * Debug tab
  126128. */
  126129. Debug = 1,
  126130. /**
  126131. * Statistics tab
  126132. */
  126133. Statistics = 2,
  126134. /**
  126135. * Tools tab
  126136. */
  126137. Tools = 3,
  126138. /**
  126139. * Settings tab
  126140. */
  126141. Settings = 4
  126142. }
  126143. /**
  126144. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126145. * what is happening in your scene
  126146. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126147. */
  126148. export class DebugLayer {
  126149. /**
  126150. * Define the url to get the inspector script from.
  126151. * By default it uses the babylonjs CDN.
  126152. * @ignoreNaming
  126153. */
  126154. static InspectorURL: string;
  126155. private _scene;
  126156. private BJSINSPECTOR;
  126157. private _onPropertyChangedObservable?;
  126158. /**
  126159. * Observable triggered when a property is changed through the inspector.
  126160. */
  126161. get onPropertyChangedObservable(): any;
  126162. /**
  126163. * Instantiates a new debug layer.
  126164. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126165. * what is happening in your scene
  126166. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126167. * @param scene Defines the scene to inspect
  126168. */
  126169. constructor(scene: Scene);
  126170. /** Creates the inspector window. */
  126171. private _createInspector;
  126172. /**
  126173. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  126174. * @param entity defines the entity to select
  126175. * @param lineContainerTitle defines the specific block to highlight
  126176. */
  126177. select(entity: any, lineContainerTitle?: string): void;
  126178. /** Get the inspector from bundle or global */
  126179. private _getGlobalInspector;
  126180. /**
  126181. * Get if the inspector is visible or not.
  126182. * @returns true if visible otherwise, false
  126183. */
  126184. isVisible(): boolean;
  126185. /**
  126186. * Hide the inspector and close its window.
  126187. */
  126188. hide(): void;
  126189. /**
  126190. * Update the scene in the inspector
  126191. */
  126192. setAsActiveScene(): void;
  126193. /**
  126194. * Launch the debugLayer.
  126195. * @param config Define the configuration of the inspector
  126196. * @return a promise fulfilled when the debug layer is visible
  126197. */
  126198. show(config?: IInspectorOptions): Promise<DebugLayer>;
  126199. }
  126200. }
  126201. declare module BABYLON {
  126202. /**
  126203. * Class containing static functions to help procedurally build meshes
  126204. */
  126205. export class BoxBuilder {
  126206. /**
  126207. * Creates a box mesh
  126208. * * The parameter `size` sets the size (float) of each box side (default 1)
  126209. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126210. * * 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)
  126211. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126215. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126216. * @param name defines the name of the mesh
  126217. * @param options defines the options used to create the mesh
  126218. * @param scene defines the hosting scene
  126219. * @returns the box mesh
  126220. */
  126221. static CreateBox(name: string, options: {
  126222. size?: number;
  126223. width?: number;
  126224. height?: number;
  126225. depth?: number;
  126226. faceUV?: Vector4[];
  126227. faceColors?: Color4[];
  126228. sideOrientation?: number;
  126229. frontUVs?: Vector4;
  126230. backUVs?: Vector4;
  126231. wrap?: boolean;
  126232. topBaseAt?: number;
  126233. bottomBaseAt?: number;
  126234. updatable?: boolean;
  126235. }, scene?: Nullable<Scene>): Mesh;
  126236. }
  126237. }
  126238. declare module BABYLON.Debug {
  126239. /**
  126240. * Used to show the physics impostor around the specific mesh
  126241. */
  126242. export class PhysicsViewer {
  126243. /** @hidden */
  126244. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  126245. /** @hidden */
  126246. protected _meshes: Array<Nullable<AbstractMesh>>;
  126247. /** @hidden */
  126248. protected _scene: Nullable<Scene>;
  126249. /** @hidden */
  126250. protected _numMeshes: number;
  126251. /** @hidden */
  126252. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  126253. private _renderFunction;
  126254. private _utilityLayer;
  126255. private _debugBoxMesh;
  126256. private _debugSphereMesh;
  126257. private _debugCylinderMesh;
  126258. private _debugMaterial;
  126259. private _debugMeshMeshes;
  126260. /**
  126261. * Creates a new PhysicsViewer
  126262. * @param scene defines the hosting scene
  126263. */
  126264. constructor(scene: Scene);
  126265. /** @hidden */
  126266. protected _updateDebugMeshes(): void;
  126267. /**
  126268. * Renders a specified physic impostor
  126269. * @param impostor defines the impostor to render
  126270. * @param targetMesh defines the mesh represented by the impostor
  126271. * @returns the new debug mesh used to render the impostor
  126272. */
  126273. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  126274. /**
  126275. * Hides a specified physic impostor
  126276. * @param impostor defines the impostor to hide
  126277. */
  126278. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  126279. private _getDebugMaterial;
  126280. private _getDebugBoxMesh;
  126281. private _getDebugSphereMesh;
  126282. private _getDebugCylinderMesh;
  126283. private _getDebugMeshMesh;
  126284. private _getDebugMesh;
  126285. /** Releases all resources */
  126286. dispose(): void;
  126287. }
  126288. }
  126289. declare module BABYLON {
  126290. /**
  126291. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126292. * in order to better appreciate the issue one might have.
  126293. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126294. */
  126295. export class RayHelper {
  126296. /**
  126297. * Defines the ray we are currently tryin to visualize.
  126298. */
  126299. ray: Nullable<Ray>;
  126300. private _renderPoints;
  126301. private _renderLine;
  126302. private _renderFunction;
  126303. private _scene;
  126304. private _updateToMeshFunction;
  126305. private _attachedToMesh;
  126306. private _meshSpaceDirection;
  126307. private _meshSpaceOrigin;
  126308. /**
  126309. * Helper function to create a colored helper in a scene in one line.
  126310. * @param ray Defines the ray we are currently tryin to visualize
  126311. * @param scene Defines the scene the ray is used in
  126312. * @param color Defines the color we want to see the ray in
  126313. * @returns The newly created ray helper.
  126314. */
  126315. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  126316. /**
  126317. * Instantiate a new ray helper.
  126318. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126319. * in order to better appreciate the issue one might have.
  126320. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126321. * @param ray Defines the ray we are currently tryin to visualize
  126322. */
  126323. constructor(ray: Ray);
  126324. /**
  126325. * Shows the ray we are willing to debug.
  126326. * @param scene Defines the scene the ray needs to be rendered in
  126327. * @param color Defines the color the ray needs to be rendered in
  126328. */
  126329. show(scene: Scene, color?: Color3): void;
  126330. /**
  126331. * Hides the ray we are debugging.
  126332. */
  126333. hide(): void;
  126334. private _render;
  126335. /**
  126336. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  126337. * @param mesh Defines the mesh we want the helper attached to
  126338. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  126339. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  126340. * @param length Defines the length of the ray
  126341. */
  126342. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  126343. /**
  126344. * Detach the ray helper from the mesh it has previously been attached to.
  126345. */
  126346. detachFromMesh(): void;
  126347. private _updateToMesh;
  126348. /**
  126349. * Dispose the helper and release its associated resources.
  126350. */
  126351. dispose(): void;
  126352. }
  126353. }
  126354. declare module BABYLON.Debug {
  126355. /**
  126356. * Class used to render a debug view of a given skeleton
  126357. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  126358. */
  126359. export class SkeletonViewer {
  126360. /** defines the skeleton to render */
  126361. skeleton: Skeleton;
  126362. /** defines the mesh attached to the skeleton */
  126363. mesh: AbstractMesh;
  126364. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126365. autoUpdateBonesMatrices: boolean;
  126366. /** defines the rendering group id to use with the viewer */
  126367. renderingGroupId: number;
  126368. /** Gets or sets the color used to render the skeleton */
  126369. color: Color3;
  126370. private _scene;
  126371. private _debugLines;
  126372. private _debugMesh;
  126373. private _isEnabled;
  126374. private _renderFunction;
  126375. private _utilityLayer;
  126376. /**
  126377. * Returns the mesh used to render the bones
  126378. */
  126379. get debugMesh(): Nullable<LinesMesh>;
  126380. /**
  126381. * Creates a new SkeletonViewer
  126382. * @param skeleton defines the skeleton to render
  126383. * @param mesh defines the mesh attached to the skeleton
  126384. * @param scene defines the hosting scene
  126385. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  126386. * @param renderingGroupId defines the rendering group id to use with the viewer
  126387. */
  126388. constructor(
  126389. /** defines the skeleton to render */
  126390. skeleton: Skeleton,
  126391. /** defines the mesh attached to the skeleton */
  126392. mesh: AbstractMesh, scene: Scene,
  126393. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126394. autoUpdateBonesMatrices?: boolean,
  126395. /** defines the rendering group id to use with the viewer */
  126396. renderingGroupId?: number);
  126397. /** Gets or sets a boolean indicating if the viewer is enabled */
  126398. set isEnabled(value: boolean);
  126399. get isEnabled(): boolean;
  126400. private _getBonePosition;
  126401. private _getLinesForBonesWithLength;
  126402. private _getLinesForBonesNoLength;
  126403. /** Update the viewer to sync with current skeleton state */
  126404. update(): void;
  126405. /** Release associated resources */
  126406. dispose(): void;
  126407. }
  126408. }
  126409. declare module BABYLON {
  126410. /**
  126411. * Enum for Device Types
  126412. */
  126413. export enum DeviceType {
  126414. /** Generic */
  126415. Generic = 0,
  126416. /** Keyboard */
  126417. Keyboard = 1,
  126418. /** Mouse */
  126419. Mouse = 2,
  126420. /** Touch Pointers */
  126421. Touch = 3,
  126422. /** PS4 Dual Shock */
  126423. DualShock = 4,
  126424. /** Xbox */
  126425. Xbox = 5,
  126426. /** Switch Controller */
  126427. Switch = 6
  126428. }
  126429. /**
  126430. * Enum for All Pointers (Touch/Mouse)
  126431. */
  126432. export enum PointerInput {
  126433. /** Horizontal Axis */
  126434. Horizontal = 0,
  126435. /** Vertical Axis */
  126436. Vertical = 1,
  126437. /** Left Click or Touch */
  126438. LeftClick = 2,
  126439. /** Middle Click */
  126440. MiddleClick = 3,
  126441. /** Right Click */
  126442. RightClick = 4,
  126443. /** Browser Back */
  126444. BrowserBack = 5,
  126445. /** Browser Forward */
  126446. BrowserForward = 6
  126447. }
  126448. /**
  126449. * Enum for Dual Shock Gamepad
  126450. */
  126451. export enum DualShockInput {
  126452. /** Cross */
  126453. Cross = 0,
  126454. /** Circle */
  126455. Circle = 1,
  126456. /** Square */
  126457. Square = 2,
  126458. /** Triangle */
  126459. Triangle = 3,
  126460. /** L1 */
  126461. L1 = 4,
  126462. /** R1 */
  126463. R1 = 5,
  126464. /** L2 */
  126465. L2 = 6,
  126466. /** R2 */
  126467. R2 = 7,
  126468. /** Share */
  126469. Share = 8,
  126470. /** Options */
  126471. Options = 9,
  126472. /** L3 */
  126473. L3 = 10,
  126474. /** R3 */
  126475. R3 = 11,
  126476. /** DPadUp */
  126477. DPadUp = 12,
  126478. /** DPadDown */
  126479. DPadDown = 13,
  126480. /** DPadLeft */
  126481. DPadLeft = 14,
  126482. /** DRight */
  126483. DPadRight = 15,
  126484. /** Home */
  126485. Home = 16,
  126486. /** TouchPad */
  126487. TouchPad = 17,
  126488. /** LStickXAxis */
  126489. LStickXAxis = 18,
  126490. /** LStickYAxis */
  126491. LStickYAxis = 19,
  126492. /** RStickXAxis */
  126493. RStickXAxis = 20,
  126494. /** RStickYAxis */
  126495. RStickYAxis = 21
  126496. }
  126497. /**
  126498. * Enum for Xbox Gamepad
  126499. */
  126500. export enum XboxInput {
  126501. /** A */
  126502. A = 0,
  126503. /** B */
  126504. B = 1,
  126505. /** X */
  126506. X = 2,
  126507. /** Y */
  126508. Y = 3,
  126509. /** LB */
  126510. LB = 4,
  126511. /** RB */
  126512. RB = 5,
  126513. /** LT */
  126514. LT = 6,
  126515. /** RT */
  126516. RT = 7,
  126517. /** Back */
  126518. Back = 8,
  126519. /** Start */
  126520. Start = 9,
  126521. /** LS */
  126522. LS = 10,
  126523. /** RS */
  126524. RS = 11,
  126525. /** DPadUp */
  126526. DPadUp = 12,
  126527. /** DPadDown */
  126528. DPadDown = 13,
  126529. /** DPadLeft */
  126530. DPadLeft = 14,
  126531. /** DRight */
  126532. DPadRight = 15,
  126533. /** Home */
  126534. Home = 16,
  126535. /** LStickXAxis */
  126536. LStickXAxis = 17,
  126537. /** LStickYAxis */
  126538. LStickYAxis = 18,
  126539. /** RStickXAxis */
  126540. RStickXAxis = 19,
  126541. /** RStickYAxis */
  126542. RStickYAxis = 20
  126543. }
  126544. /**
  126545. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  126546. */
  126547. export enum SwitchInput {
  126548. /** B */
  126549. B = 0,
  126550. /** A */
  126551. A = 1,
  126552. /** Y */
  126553. Y = 2,
  126554. /** X */
  126555. X = 3,
  126556. /** L */
  126557. L = 4,
  126558. /** R */
  126559. R = 5,
  126560. /** ZL */
  126561. ZL = 6,
  126562. /** ZR */
  126563. ZR = 7,
  126564. /** Minus */
  126565. Minus = 8,
  126566. /** Plus */
  126567. Plus = 9,
  126568. /** LS */
  126569. LS = 10,
  126570. /** RS */
  126571. RS = 11,
  126572. /** DPadUp */
  126573. DPadUp = 12,
  126574. /** DPadDown */
  126575. DPadDown = 13,
  126576. /** DPadLeft */
  126577. DPadLeft = 14,
  126578. /** DRight */
  126579. DPadRight = 15,
  126580. /** Home */
  126581. Home = 16,
  126582. /** Capture */
  126583. Capture = 17,
  126584. /** LStickXAxis */
  126585. LStickXAxis = 18,
  126586. /** LStickYAxis */
  126587. LStickYAxis = 19,
  126588. /** RStickXAxis */
  126589. RStickXAxis = 20,
  126590. /** RStickYAxis */
  126591. RStickYAxis = 21
  126592. }
  126593. }
  126594. declare module BABYLON {
  126595. /**
  126596. * This class will take all inputs from Keyboard, Pointer, and
  126597. * any Gamepads and provide a polling system that all devices
  126598. * will use. This class assumes that there will only be one
  126599. * pointer device and one keyboard.
  126600. */
  126601. export class DeviceInputSystem implements IDisposable {
  126602. /**
  126603. * Callback to be triggered when a device is connected
  126604. */
  126605. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126606. /**
  126607. * Callback to be triggered when a device is disconnected
  126608. */
  126609. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126610. /**
  126611. * Callback to be triggered when event driven input is updated
  126612. */
  126613. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  126614. private _inputs;
  126615. private _gamepads;
  126616. private _keyboardActive;
  126617. private _pointerActive;
  126618. private _elementToAttachTo;
  126619. private _keyboardDownEvent;
  126620. private _keyboardUpEvent;
  126621. private _pointerMoveEvent;
  126622. private _pointerDownEvent;
  126623. private _pointerUpEvent;
  126624. private _gamepadConnectedEvent;
  126625. private _gamepadDisconnectedEvent;
  126626. private static _MAX_KEYCODES;
  126627. private static _MAX_POINTER_INPUTS;
  126628. /**
  126629. * Default Constructor
  126630. * @param engine - engine to pull input element from
  126631. */
  126632. constructor(engine: Engine);
  126633. /**
  126634. * Checks for current device input value, given an id and input index
  126635. * @param deviceName Id of connected device
  126636. * @param inputIndex Index of device input
  126637. * @returns Current value of input
  126638. */
  126639. /**
  126640. * Checks for current device input value, given an id and input index
  126641. * @param deviceType Enum specifiying device type
  126642. * @param deviceSlot "Slot" or index that device is referenced in
  126643. * @param inputIndex Id of input to be checked
  126644. * @returns Current value of input
  126645. */
  126646. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  126647. /**
  126648. * Dispose of all the eventlisteners
  126649. */
  126650. dispose(): void;
  126651. /**
  126652. * Add device and inputs to device array
  126653. * @param deviceType Enum specifiying device type
  126654. * @param deviceSlot "Slot" or index that device is referenced in
  126655. * @param numberOfInputs Number of input entries to create for given device
  126656. */
  126657. private _registerDevice;
  126658. /**
  126659. * Given a specific device name, remove that device from the device map
  126660. * @param deviceType Enum specifiying device type
  126661. * @param deviceSlot "Slot" or index that device is referenced in
  126662. */
  126663. private _unregisterDevice;
  126664. /**
  126665. * Handle all actions that come from keyboard interaction
  126666. */
  126667. private _handleKeyActions;
  126668. /**
  126669. * Handle all actions that come from pointer interaction
  126670. */
  126671. private _handlePointerActions;
  126672. /**
  126673. * Handle all actions that come from gamepad interaction
  126674. */
  126675. private _handleGamepadActions;
  126676. /**
  126677. * Update all non-event based devices with each frame
  126678. * @param deviceType Enum specifiying device type
  126679. * @param deviceSlot "Slot" or index that device is referenced in
  126680. * @param inputIndex Id of input to be checked
  126681. */
  126682. private _updateDevice;
  126683. /**
  126684. * Gets DeviceType from the device name
  126685. * @param deviceName Name of Device from DeviceInputSystem
  126686. * @returns DeviceType enum value
  126687. */
  126688. private _getGamepadDeviceType;
  126689. }
  126690. }
  126691. declare module BABYLON {
  126692. /**
  126693. * Type to handle enforcement of inputs
  126694. */
  126695. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  126696. }
  126697. declare module BABYLON {
  126698. /**
  126699. * Class that handles all input for a specific device
  126700. */
  126701. export class DeviceSource<T extends DeviceType> {
  126702. /** Type of device */
  126703. readonly deviceType: DeviceType;
  126704. /** "Slot" or index that device is referenced in */
  126705. readonly deviceSlot: number;
  126706. /**
  126707. * Observable to handle device input changes per device
  126708. */
  126709. readonly onInputChangedObservable: Observable<{
  126710. inputIndex: DeviceInput<T>;
  126711. previousState: Nullable<number>;
  126712. currentState: Nullable<number>;
  126713. }>;
  126714. private readonly _deviceInputSystem;
  126715. /**
  126716. * Default Constructor
  126717. * @param deviceInputSystem Reference to DeviceInputSystem
  126718. * @param deviceType Type of device
  126719. * @param deviceSlot "Slot" or index that device is referenced in
  126720. */
  126721. constructor(deviceInputSystem: DeviceInputSystem,
  126722. /** Type of device */
  126723. deviceType: DeviceType,
  126724. /** "Slot" or index that device is referenced in */
  126725. deviceSlot?: number);
  126726. /**
  126727. * Get input for specific input
  126728. * @param inputIndex index of specific input on device
  126729. * @returns Input value from DeviceInputSystem
  126730. */
  126731. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  126732. }
  126733. /**
  126734. * Class to keep track of devices
  126735. */
  126736. export class DeviceSourceManager implements IDisposable {
  126737. /**
  126738. * Observable to be triggered when before a device is connected
  126739. */
  126740. readonly onBeforeDeviceConnectedObservable: Observable<{
  126741. deviceType: DeviceType;
  126742. deviceSlot: number;
  126743. }>;
  126744. /**
  126745. * Observable to be triggered when before a device is disconnected
  126746. */
  126747. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  126748. deviceType: DeviceType;
  126749. deviceSlot: number;
  126750. }>;
  126751. /**
  126752. * Observable to be triggered when after a device is connected
  126753. */
  126754. readonly onAfterDeviceConnectedObservable: Observable<{
  126755. deviceType: DeviceType;
  126756. deviceSlot: number;
  126757. }>;
  126758. /**
  126759. * Observable to be triggered when after a device is disconnected
  126760. */
  126761. readonly onAfterDeviceDisconnectedObservable: Observable<{
  126762. deviceType: DeviceType;
  126763. deviceSlot: number;
  126764. }>;
  126765. private readonly _devices;
  126766. private readonly _firstDevice;
  126767. private readonly _deviceInputSystem;
  126768. /**
  126769. * Default Constructor
  126770. * @param engine engine to pull input element from
  126771. */
  126772. constructor(engine: Engine);
  126773. /**
  126774. * Gets a DeviceSource, given a type and slot
  126775. * @param deviceType Enum specifying device type
  126776. * @param deviceSlot "Slot" or index that device is referenced in
  126777. * @returns DeviceSource object
  126778. */
  126779. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  126780. /**
  126781. * Gets an array of DeviceSource objects for a given device type
  126782. * @param deviceType Enum specifying device type
  126783. * @returns Array of DeviceSource objects
  126784. */
  126785. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  126786. /**
  126787. * Dispose of DeviceInputSystem and other parts
  126788. */
  126789. dispose(): void;
  126790. /**
  126791. * Function to add device name to device list
  126792. * @param deviceType Enum specifying device type
  126793. * @param deviceSlot "Slot" or index that device is referenced in
  126794. */
  126795. private _addDevice;
  126796. /**
  126797. * Function to remove device name to device list
  126798. * @param deviceType Enum specifying device type
  126799. * @param deviceSlot "Slot" or index that device is referenced in
  126800. */
  126801. private _removeDevice;
  126802. /**
  126803. * Updates array storing first connected device of each type
  126804. * @param type Type of Device
  126805. */
  126806. private _updateFirstDevices;
  126807. }
  126808. }
  126809. declare module BABYLON {
  126810. /**
  126811. * Options to create the null engine
  126812. */
  126813. export class NullEngineOptions {
  126814. /**
  126815. * Render width (Default: 512)
  126816. */
  126817. renderWidth: number;
  126818. /**
  126819. * Render height (Default: 256)
  126820. */
  126821. renderHeight: number;
  126822. /**
  126823. * Texture size (Default: 512)
  126824. */
  126825. textureSize: number;
  126826. /**
  126827. * If delta time between frames should be constant
  126828. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126829. */
  126830. deterministicLockstep: boolean;
  126831. /**
  126832. * Maximum about of steps between frames (Default: 4)
  126833. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126834. */
  126835. lockstepMaxSteps: number;
  126836. }
  126837. /**
  126838. * The null engine class provides support for headless version of babylon.js.
  126839. * This can be used in server side scenario or for testing purposes
  126840. */
  126841. export class NullEngine extends Engine {
  126842. private _options;
  126843. /**
  126844. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  126845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126846. * @returns true if engine is in deterministic lock step mode
  126847. */
  126848. isDeterministicLockStep(): boolean;
  126849. /**
  126850. * Gets the max steps when engine is running in deterministic lock step
  126851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126852. * @returns the max steps
  126853. */
  126854. getLockstepMaxSteps(): number;
  126855. /**
  126856. * Gets the current hardware scaling level.
  126857. * By default the hardware scaling level is computed from the window device ratio.
  126858. * 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.
  126859. * @returns a number indicating the current hardware scaling level
  126860. */
  126861. getHardwareScalingLevel(): number;
  126862. constructor(options?: NullEngineOptions);
  126863. /**
  126864. * Creates a vertex buffer
  126865. * @param vertices the data for the vertex buffer
  126866. * @returns the new WebGL static buffer
  126867. */
  126868. createVertexBuffer(vertices: FloatArray): DataBuffer;
  126869. /**
  126870. * Creates a new index buffer
  126871. * @param indices defines the content of the index buffer
  126872. * @param updatable defines if the index buffer must be updatable
  126873. * @returns a new webGL buffer
  126874. */
  126875. createIndexBuffer(indices: IndicesArray): DataBuffer;
  126876. /**
  126877. * Clear the current render buffer or the current render target (if any is set up)
  126878. * @param color defines the color to use
  126879. * @param backBuffer defines if the back buffer must be cleared
  126880. * @param depth defines if the depth buffer must be cleared
  126881. * @param stencil defines if the stencil buffer must be cleared
  126882. */
  126883. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  126884. /**
  126885. * Gets the current render width
  126886. * @param useScreen defines if screen size must be used (or the current render target if any)
  126887. * @returns a number defining the current render width
  126888. */
  126889. getRenderWidth(useScreen?: boolean): number;
  126890. /**
  126891. * Gets the current render height
  126892. * @param useScreen defines if screen size must be used (or the current render target if any)
  126893. * @returns a number defining the current render height
  126894. */
  126895. getRenderHeight(useScreen?: boolean): number;
  126896. /**
  126897. * Set the WebGL's viewport
  126898. * @param viewport defines the viewport element to be used
  126899. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  126900. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  126901. */
  126902. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  126903. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  126904. /**
  126905. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  126906. * @param pipelineContext defines the pipeline context to use
  126907. * @param uniformsNames defines the list of uniform names
  126908. * @returns an array of webGL uniform locations
  126909. */
  126910. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  126911. /**
  126912. * Gets the lsit of active attributes for a given webGL program
  126913. * @param pipelineContext defines the pipeline context to use
  126914. * @param attributesNames defines the list of attribute names to get
  126915. * @returns an array of indices indicating the offset of each attribute
  126916. */
  126917. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  126918. /**
  126919. * Binds an effect to the webGL context
  126920. * @param effect defines the effect to bind
  126921. */
  126922. bindSamplers(effect: Effect): void;
  126923. /**
  126924. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  126925. * @param effect defines the effect to activate
  126926. */
  126927. enableEffect(effect: Effect): void;
  126928. /**
  126929. * Set various states to the webGL context
  126930. * @param culling defines backface culling state
  126931. * @param zOffset defines the value to apply to zOffset (0 by default)
  126932. * @param force defines if states must be applied even if cache is up to date
  126933. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  126934. */
  126935. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  126936. /**
  126937. * Set the value of an uniform to an array of int32
  126938. * @param uniform defines the webGL uniform location where to store the value
  126939. * @param array defines the array of int32 to store
  126940. */
  126941. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  126942. /**
  126943. * Set the value of an uniform to an array of int32 (stored as vec2)
  126944. * @param uniform defines the webGL uniform location where to store the value
  126945. * @param array defines the array of int32 to store
  126946. */
  126947. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  126948. /**
  126949. * Set the value of an uniform to an array of int32 (stored as vec3)
  126950. * @param uniform defines the webGL uniform location where to store the value
  126951. * @param array defines the array of int32 to store
  126952. */
  126953. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  126954. /**
  126955. * Set the value of an uniform to an array of int32 (stored as vec4)
  126956. * @param uniform defines the webGL uniform location where to store the value
  126957. * @param array defines the array of int32 to store
  126958. */
  126959. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  126960. /**
  126961. * Set the value of an uniform to an array of float32
  126962. * @param uniform defines the webGL uniform location where to store the value
  126963. * @param array defines the array of float32 to store
  126964. */
  126965. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  126966. /**
  126967. * Set the value of an uniform to an array of float32 (stored as vec2)
  126968. * @param uniform defines the webGL uniform location where to store the value
  126969. * @param array defines the array of float32 to store
  126970. */
  126971. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  126972. /**
  126973. * Set the value of an uniform to an array of float32 (stored as vec3)
  126974. * @param uniform defines the webGL uniform location where to store the value
  126975. * @param array defines the array of float32 to store
  126976. */
  126977. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  126978. /**
  126979. * Set the value of an uniform to an array of float32 (stored as vec4)
  126980. * @param uniform defines the webGL uniform location where to store the value
  126981. * @param array defines the array of float32 to store
  126982. */
  126983. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  126984. /**
  126985. * Set the value of an uniform to an array of number
  126986. * @param uniform defines the webGL uniform location where to store the value
  126987. * @param array defines the array of number to store
  126988. */
  126989. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  126990. /**
  126991. * Set the value of an uniform to an array of number (stored as vec2)
  126992. * @param uniform defines the webGL uniform location where to store the value
  126993. * @param array defines the array of number to store
  126994. */
  126995. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  126996. /**
  126997. * Set the value of an uniform to an array of number (stored as vec3)
  126998. * @param uniform defines the webGL uniform location where to store the value
  126999. * @param array defines the array of number to store
  127000. */
  127001. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127002. /**
  127003. * Set the value of an uniform to an array of number (stored as vec4)
  127004. * @param uniform defines the webGL uniform location where to store the value
  127005. * @param array defines the array of number to store
  127006. */
  127007. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127008. /**
  127009. * Set the value of an uniform to an array of float32 (stored as matrices)
  127010. * @param uniform defines the webGL uniform location where to store the value
  127011. * @param matrices defines the array of float32 to store
  127012. */
  127013. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127014. /**
  127015. * Set the value of an uniform to a matrix (3x3)
  127016. * @param uniform defines the webGL uniform location where to store the value
  127017. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127018. */
  127019. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127020. /**
  127021. * Set the value of an uniform to a matrix (2x2)
  127022. * @param uniform defines the webGL uniform location where to store the value
  127023. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127024. */
  127025. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127026. /**
  127027. * Set the value of an uniform to a number (float)
  127028. * @param uniform defines the webGL uniform location where to store the value
  127029. * @param value defines the float number to store
  127030. */
  127031. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127032. /**
  127033. * Set the value of an uniform to a vec2
  127034. * @param uniform defines the webGL uniform location where to store the value
  127035. * @param x defines the 1st component of the value
  127036. * @param y defines the 2nd component of the value
  127037. */
  127038. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127039. /**
  127040. * Set the value of an uniform to a vec3
  127041. * @param uniform defines the webGL uniform location where to store the value
  127042. * @param x defines the 1st component of the value
  127043. * @param y defines the 2nd component of the value
  127044. * @param z defines the 3rd component of the value
  127045. */
  127046. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127047. /**
  127048. * Set the value of an uniform to a boolean
  127049. * @param uniform defines the webGL uniform location where to store the value
  127050. * @param bool defines the boolean to store
  127051. */
  127052. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127053. /**
  127054. * Set the value of an uniform to a vec4
  127055. * @param uniform defines the webGL uniform location where to store the value
  127056. * @param x defines the 1st component of the value
  127057. * @param y defines the 2nd component of the value
  127058. * @param z defines the 3rd component of the value
  127059. * @param w defines the 4th component of the value
  127060. */
  127061. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127062. /**
  127063. * Sets the current alpha mode
  127064. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127065. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127067. */
  127068. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127069. /**
  127070. * Bind webGl buffers directly to the webGL context
  127071. * @param vertexBuffers defines the vertex buffer to bind
  127072. * @param indexBuffer defines the index buffer to bind
  127073. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  127074. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  127075. * @param effect defines the effect associated with the vertex buffer
  127076. */
  127077. bindBuffers(vertexBuffers: {
  127078. [key: string]: VertexBuffer;
  127079. }, indexBuffer: DataBuffer, effect: Effect): void;
  127080. /**
  127081. * Force the entire cache to be cleared
  127082. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  127083. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  127084. */
  127085. wipeCaches(bruteForce?: boolean): void;
  127086. /**
  127087. * Send a draw order
  127088. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  127089. * @param indexStart defines the starting index
  127090. * @param indexCount defines the number of index to draw
  127091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127092. */
  127093. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  127094. /**
  127095. * Draw a list of indexed primitives
  127096. * @param fillMode defines the primitive to use
  127097. * @param indexStart defines the starting index
  127098. * @param indexCount defines the number of index to draw
  127099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127100. */
  127101. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127102. /**
  127103. * Draw a list of unindexed primitives
  127104. * @param fillMode defines the primitive to use
  127105. * @param verticesStart defines the index of first vertex to draw
  127106. * @param verticesCount defines the count of vertices to draw
  127107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127108. */
  127109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127110. /** @hidden */
  127111. _createTexture(): WebGLTexture;
  127112. /** @hidden */
  127113. _releaseTexture(texture: InternalTexture): void;
  127114. /**
  127115. * Usually called from Texture.ts.
  127116. * Passed information to create a WebGLTexture
  127117. * @param urlArg defines a value which contains one of the following:
  127118. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  127119. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  127120. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  127121. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  127122. * @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)
  127123. * @param scene needed for loading to the correct scene
  127124. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  127125. * @param onLoad optional callback to be called upon successful completion
  127126. * @param onError optional callback to be called upon failure
  127127. * @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
  127128. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  127129. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  127130. * @param forcedExtension defines the extension to use to pick the right loader
  127131. * @param mimeType defines an optional mime type
  127132. * @returns a InternalTexture for assignment back into BABYLON.Texture
  127133. */
  127134. 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;
  127135. /**
  127136. * Creates a new render target texture
  127137. * @param size defines the size of the texture
  127138. * @param options defines the options used to create the texture
  127139. * @returns a new render target texture stored in an InternalTexture
  127140. */
  127141. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  127142. /**
  127143. * Update the sampling mode of a given texture
  127144. * @param samplingMode defines the required sampling mode
  127145. * @param texture defines the texture to update
  127146. */
  127147. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  127148. /**
  127149. * Binds the frame buffer to the specified texture.
  127150. * @param texture The texture to render to or null for the default canvas
  127151. * @param faceIndex The face of the texture to render to in case of cube texture
  127152. * @param requiredWidth The width of the target to render to
  127153. * @param requiredHeight The height of the target to render to
  127154. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  127155. * @param lodLevel defines le lod level to bind to the frame buffer
  127156. */
  127157. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  127158. /**
  127159. * Unbind the current render target texture from the webGL context
  127160. * @param texture defines the render target texture to unbind
  127161. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127162. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127163. */
  127164. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  127165. /**
  127166. * Creates a dynamic vertex buffer
  127167. * @param vertices the data for the dynamic vertex buffer
  127168. * @returns the new WebGL dynamic buffer
  127169. */
  127170. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  127171. /**
  127172. * Update the content of a dynamic texture
  127173. * @param texture defines the texture to update
  127174. * @param canvas defines the canvas containing the source
  127175. * @param invertY defines if data must be stored with Y axis inverted
  127176. * @param premulAlpha defines if alpha is stored as premultiplied
  127177. * @param format defines the format of the data
  127178. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  127179. */
  127180. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  127181. /**
  127182. * Gets a boolean indicating if all created effects are ready
  127183. * @returns true if all effects are ready
  127184. */
  127185. areAllEffectsReady(): boolean;
  127186. /**
  127187. * @hidden
  127188. * Get the current error code of the webGL context
  127189. * @returns the error code
  127190. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  127191. */
  127192. getError(): number;
  127193. /** @hidden */
  127194. _getUnpackAlignement(): number;
  127195. /** @hidden */
  127196. _unpackFlipY(value: boolean): void;
  127197. /**
  127198. * Update a dynamic index buffer
  127199. * @param indexBuffer defines the target index buffer
  127200. * @param indices defines the data to update
  127201. * @param offset defines the offset in the target index buffer where update should start
  127202. */
  127203. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  127204. /**
  127205. * Updates a dynamic vertex buffer.
  127206. * @param vertexBuffer the vertex buffer to update
  127207. * @param vertices the data used to update the vertex buffer
  127208. * @param byteOffset the byte offset of the data (optional)
  127209. * @param byteLength the byte length of the data (optional)
  127210. */
  127211. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  127212. /** @hidden */
  127213. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  127214. /** @hidden */
  127215. _bindTexture(channel: number, texture: InternalTexture): void;
  127216. protected _deleteBuffer(buffer: WebGLBuffer): void;
  127217. /**
  127218. * 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
  127219. */
  127220. releaseEffects(): void;
  127221. displayLoadingUI(): void;
  127222. hideLoadingUI(): void;
  127223. /** @hidden */
  127224. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127225. /** @hidden */
  127226. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127227. /** @hidden */
  127228. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127229. /** @hidden */
  127230. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  127231. }
  127232. }
  127233. declare module BABYLON {
  127234. /**
  127235. * @hidden
  127236. **/
  127237. export class _TimeToken {
  127238. _startTimeQuery: Nullable<WebGLQuery>;
  127239. _endTimeQuery: Nullable<WebGLQuery>;
  127240. _timeElapsedQuery: Nullable<WebGLQuery>;
  127241. _timeElapsedQueryEnded: boolean;
  127242. }
  127243. }
  127244. declare module BABYLON {
  127245. /** @hidden */
  127246. export class _OcclusionDataStorage {
  127247. /** @hidden */
  127248. occlusionInternalRetryCounter: number;
  127249. /** @hidden */
  127250. isOcclusionQueryInProgress: boolean;
  127251. /** @hidden */
  127252. isOccluded: boolean;
  127253. /** @hidden */
  127254. occlusionRetryCount: number;
  127255. /** @hidden */
  127256. occlusionType: number;
  127257. /** @hidden */
  127258. occlusionQueryAlgorithmType: number;
  127259. }
  127260. interface Engine {
  127261. /**
  127262. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  127263. * @return the new query
  127264. */
  127265. createQuery(): WebGLQuery;
  127266. /**
  127267. * Delete and release a webGL query
  127268. * @param query defines the query to delete
  127269. * @return the current engine
  127270. */
  127271. deleteQuery(query: WebGLQuery): Engine;
  127272. /**
  127273. * Check if a given query has resolved and got its value
  127274. * @param query defines the query to check
  127275. * @returns true if the query got its value
  127276. */
  127277. isQueryResultAvailable(query: WebGLQuery): boolean;
  127278. /**
  127279. * Gets the value of a given query
  127280. * @param query defines the query to check
  127281. * @returns the value of the query
  127282. */
  127283. getQueryResult(query: WebGLQuery): number;
  127284. /**
  127285. * Initiates an occlusion query
  127286. * @param algorithmType defines the algorithm to use
  127287. * @param query defines the query to use
  127288. * @returns the current engine
  127289. * @see http://doc.babylonjs.com/features/occlusionquery
  127290. */
  127291. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  127292. /**
  127293. * Ends an occlusion query
  127294. * @see http://doc.babylonjs.com/features/occlusionquery
  127295. * @param algorithmType defines the algorithm to use
  127296. * @returns the current engine
  127297. */
  127298. endOcclusionQuery(algorithmType: number): Engine;
  127299. /**
  127300. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  127301. * Please note that only one query can be issued at a time
  127302. * @returns a time token used to track the time span
  127303. */
  127304. startTimeQuery(): Nullable<_TimeToken>;
  127305. /**
  127306. * Ends a time query
  127307. * @param token defines the token used to measure the time span
  127308. * @returns the time spent (in ns)
  127309. */
  127310. endTimeQuery(token: _TimeToken): int;
  127311. /** @hidden */
  127312. _currentNonTimestampToken: Nullable<_TimeToken>;
  127313. /** @hidden */
  127314. _createTimeQuery(): WebGLQuery;
  127315. /** @hidden */
  127316. _deleteTimeQuery(query: WebGLQuery): void;
  127317. /** @hidden */
  127318. _getGlAlgorithmType(algorithmType: number): number;
  127319. /** @hidden */
  127320. _getTimeQueryResult(query: WebGLQuery): any;
  127321. /** @hidden */
  127322. _getTimeQueryAvailability(query: WebGLQuery): any;
  127323. }
  127324. interface AbstractMesh {
  127325. /**
  127326. * Backing filed
  127327. * @hidden
  127328. */
  127329. __occlusionDataStorage: _OcclusionDataStorage;
  127330. /**
  127331. * Access property
  127332. * @hidden
  127333. */
  127334. _occlusionDataStorage: _OcclusionDataStorage;
  127335. /**
  127336. * 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.
  127337. * The default value is -1 which means don't break the query and wait till the result
  127338. * @see http://doc.babylonjs.com/features/occlusionquery
  127339. */
  127340. occlusionRetryCount: number;
  127341. /**
  127342. * 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:
  127343. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  127344. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  127345. * * 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.
  127346. * @see http://doc.babylonjs.com/features/occlusionquery
  127347. */
  127348. occlusionType: number;
  127349. /**
  127350. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  127351. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  127352. * * 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.
  127353. * @see http://doc.babylonjs.com/features/occlusionquery
  127354. */
  127355. occlusionQueryAlgorithmType: number;
  127356. /**
  127357. * 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
  127358. * @see http://doc.babylonjs.com/features/occlusionquery
  127359. */
  127360. isOccluded: boolean;
  127361. /**
  127362. * Flag to check the progress status of the query
  127363. * @see http://doc.babylonjs.com/features/occlusionquery
  127364. */
  127365. isOcclusionQueryInProgress: boolean;
  127366. }
  127367. }
  127368. declare module BABYLON {
  127369. /** @hidden */
  127370. export var _forceTransformFeedbackToBundle: boolean;
  127371. interface Engine {
  127372. /**
  127373. * Creates a webGL transform feedback object
  127374. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  127375. * @returns the webGL transform feedback object
  127376. */
  127377. createTransformFeedback(): WebGLTransformFeedback;
  127378. /**
  127379. * Delete a webGL transform feedback object
  127380. * @param value defines the webGL transform feedback object to delete
  127381. */
  127382. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  127383. /**
  127384. * Bind a webGL transform feedback object to the webgl context
  127385. * @param value defines the webGL transform feedback object to bind
  127386. */
  127387. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  127388. /**
  127389. * Begins a transform feedback operation
  127390. * @param usePoints defines if points or triangles must be used
  127391. */
  127392. beginTransformFeedback(usePoints: boolean): void;
  127393. /**
  127394. * Ends a transform feedback operation
  127395. */
  127396. endTransformFeedback(): void;
  127397. /**
  127398. * Specify the varyings to use with transform feedback
  127399. * @param program defines the associated webGL program
  127400. * @param value defines the list of strings representing the varying names
  127401. */
  127402. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  127403. /**
  127404. * Bind a webGL buffer for a transform feedback operation
  127405. * @param value defines the webGL buffer to bind
  127406. */
  127407. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  127408. }
  127409. }
  127410. declare module BABYLON {
  127411. /**
  127412. * Creation options of the multi render target texture.
  127413. */
  127414. export interface IMultiRenderTargetOptions {
  127415. /**
  127416. * Define if the texture needs to create mip maps after render.
  127417. */
  127418. generateMipMaps?: boolean;
  127419. /**
  127420. * Define the types of all the draw buffers we want to create
  127421. */
  127422. types?: number[];
  127423. /**
  127424. * Define the sampling modes of all the draw buffers we want to create
  127425. */
  127426. samplingModes?: number[];
  127427. /**
  127428. * Define if a depth buffer is required
  127429. */
  127430. generateDepthBuffer?: boolean;
  127431. /**
  127432. * Define if a stencil buffer is required
  127433. */
  127434. generateStencilBuffer?: boolean;
  127435. /**
  127436. * Define if a depth texture is required instead of a depth buffer
  127437. */
  127438. generateDepthTexture?: boolean;
  127439. /**
  127440. * Define the number of desired draw buffers
  127441. */
  127442. textureCount?: number;
  127443. /**
  127444. * Define if aspect ratio should be adapted to the texture or stay the scene one
  127445. */
  127446. doNotChangeAspectRatio?: boolean;
  127447. /**
  127448. * Define the default type of the buffers we are creating
  127449. */
  127450. defaultType?: number;
  127451. }
  127452. /**
  127453. * A multi render target, like a render target provides the ability to render to a texture.
  127454. * Unlike the render target, it can render to several draw buffers in one draw.
  127455. * This is specially interesting in deferred rendering or for any effects requiring more than
  127456. * just one color from a single pass.
  127457. */
  127458. export class MultiRenderTarget extends RenderTargetTexture {
  127459. private _internalTextures;
  127460. private _textures;
  127461. private _multiRenderTargetOptions;
  127462. /**
  127463. * Get if draw buffers are currently supported by the used hardware and browser.
  127464. */
  127465. get isSupported(): boolean;
  127466. /**
  127467. * Get the list of textures generated by the multi render target.
  127468. */
  127469. get textures(): Texture[];
  127470. /**
  127471. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  127472. */
  127473. get depthTexture(): Texture;
  127474. /**
  127475. * Set the wrapping mode on U of all the textures we are rendering to.
  127476. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127477. */
  127478. set wrapU(wrap: number);
  127479. /**
  127480. * Set the wrapping mode on V of all the textures we are rendering to.
  127481. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127482. */
  127483. set wrapV(wrap: number);
  127484. /**
  127485. * Instantiate a new multi render target texture.
  127486. * A multi render target, like a render target provides the ability to render to a texture.
  127487. * Unlike the render target, it can render to several draw buffers in one draw.
  127488. * This is specially interesting in deferred rendering or for any effects requiring more than
  127489. * just one color from a single pass.
  127490. * @param name Define the name of the texture
  127491. * @param size Define the size of the buffers to render to
  127492. * @param count Define the number of target we are rendering into
  127493. * @param scene Define the scene the texture belongs to
  127494. * @param options Define the options used to create the multi render target
  127495. */
  127496. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  127497. /** @hidden */
  127498. _rebuild(): void;
  127499. private _createInternalTextures;
  127500. private _createTextures;
  127501. /**
  127502. * Define the number of samples used if MSAA is enabled.
  127503. */
  127504. get samples(): number;
  127505. set samples(value: number);
  127506. /**
  127507. * Resize all the textures in the multi render target.
  127508. * Be carrefull as it will recreate all the data in the new texture.
  127509. * @param size Define the new size
  127510. */
  127511. resize(size: any): void;
  127512. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  127513. /**
  127514. * Dispose the render targets and their associated resources
  127515. */
  127516. dispose(): void;
  127517. /**
  127518. * Release all the underlying texture used as draw buffers.
  127519. */
  127520. releaseInternalTextures(): void;
  127521. }
  127522. }
  127523. declare module BABYLON {
  127524. interface ThinEngine {
  127525. /**
  127526. * Unbind a list of render target textures from the webGL context
  127527. * This is used only when drawBuffer extension or webGL2 are active
  127528. * @param textures defines the render target textures to unbind
  127529. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127530. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127531. */
  127532. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  127533. /**
  127534. * Create a multi render target texture
  127535. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  127536. * @param size defines the size of the texture
  127537. * @param options defines the creation options
  127538. * @returns the cube texture as an InternalTexture
  127539. */
  127540. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  127541. /**
  127542. * Update the sample count for a given multiple render target texture
  127543. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127544. * @param textures defines the textures to update
  127545. * @param samples defines the sample count to set
  127546. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127547. */
  127548. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  127549. }
  127550. }
  127551. declare module BABYLON {
  127552. /**
  127553. * Class used to define an additional view for the engine
  127554. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127555. */
  127556. export class EngineView {
  127557. /** Defines the canvas where to render the view */
  127558. target: HTMLCanvasElement;
  127559. /** Defines an optional camera used to render the view (will use active camera else) */
  127560. camera?: Camera;
  127561. }
  127562. interface Engine {
  127563. /**
  127564. * Gets or sets the HTML element to use for attaching events
  127565. */
  127566. inputElement: Nullable<HTMLElement>;
  127567. /**
  127568. * Gets the current engine view
  127569. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127570. */
  127571. activeView: Nullable<EngineView>;
  127572. /** Gets or sets the list of views */
  127573. views: EngineView[];
  127574. /**
  127575. * Register a new child canvas
  127576. * @param canvas defines the canvas to register
  127577. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  127578. * @returns the associated view
  127579. */
  127580. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  127581. /**
  127582. * Remove a registered child canvas
  127583. * @param canvas defines the canvas to remove
  127584. * @returns the current engine
  127585. */
  127586. unRegisterView(canvas: HTMLCanvasElement): Engine;
  127587. }
  127588. }
  127589. declare module BABYLON {
  127590. interface Engine {
  127591. /** @hidden */
  127592. _excludedCompressedTextures: string[];
  127593. /** @hidden */
  127594. _textureFormatInUse: string;
  127595. /**
  127596. * Gets the list of texture formats supported
  127597. */
  127598. readonly texturesSupported: Array<string>;
  127599. /**
  127600. * Gets the texture format in use
  127601. */
  127602. readonly textureFormatInUse: Nullable<string>;
  127603. /**
  127604. * Set the compressed texture extensions or file names to skip.
  127605. *
  127606. * @param skippedFiles defines the list of those texture files you want to skip
  127607. * Example: [".dds", ".env", "myfile.png"]
  127608. */
  127609. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  127610. /**
  127611. * Set the compressed texture format to use, based on the formats you have, and the formats
  127612. * supported by the hardware / browser.
  127613. *
  127614. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  127615. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  127616. * to API arguments needed to compressed textures. This puts the burden on the container
  127617. * generator to house the arcane code for determining these for current & future formats.
  127618. *
  127619. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  127620. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  127621. *
  127622. * Note: The result of this call is not taken into account when a texture is base64.
  127623. *
  127624. * @param formatsAvailable defines the list of those format families you have created
  127625. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  127626. *
  127627. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  127628. * @returns The extension selected.
  127629. */
  127630. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  127631. }
  127632. }
  127633. declare module BABYLON {
  127634. /**
  127635. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  127636. */
  127637. export interface CubeMapInfo {
  127638. /**
  127639. * The pixel array for the front face.
  127640. * This is stored in format, left to right, up to down format.
  127641. */
  127642. front: Nullable<ArrayBufferView>;
  127643. /**
  127644. * The pixel array for the back face.
  127645. * This is stored in format, left to right, up to down format.
  127646. */
  127647. back: Nullable<ArrayBufferView>;
  127648. /**
  127649. * The pixel array for the left face.
  127650. * This is stored in format, left to right, up to down format.
  127651. */
  127652. left: Nullable<ArrayBufferView>;
  127653. /**
  127654. * The pixel array for the right face.
  127655. * This is stored in format, left to right, up to down format.
  127656. */
  127657. right: Nullable<ArrayBufferView>;
  127658. /**
  127659. * The pixel array for the up face.
  127660. * This is stored in format, left to right, up to down format.
  127661. */
  127662. up: Nullable<ArrayBufferView>;
  127663. /**
  127664. * The pixel array for the down face.
  127665. * This is stored in format, left to right, up to down format.
  127666. */
  127667. down: Nullable<ArrayBufferView>;
  127668. /**
  127669. * The size of the cubemap stored.
  127670. *
  127671. * Each faces will be size * size pixels.
  127672. */
  127673. size: number;
  127674. /**
  127675. * The format of the texture.
  127676. *
  127677. * RGBA, RGB.
  127678. */
  127679. format: number;
  127680. /**
  127681. * The type of the texture data.
  127682. *
  127683. * UNSIGNED_INT, FLOAT.
  127684. */
  127685. type: number;
  127686. /**
  127687. * Specifies whether the texture is in gamma space.
  127688. */
  127689. gammaSpace: boolean;
  127690. }
  127691. /**
  127692. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  127693. */
  127694. export class PanoramaToCubeMapTools {
  127695. private static FACE_LEFT;
  127696. private static FACE_RIGHT;
  127697. private static FACE_FRONT;
  127698. private static FACE_BACK;
  127699. private static FACE_DOWN;
  127700. private static FACE_UP;
  127701. /**
  127702. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  127703. *
  127704. * @param float32Array The source data.
  127705. * @param inputWidth The width of the input panorama.
  127706. * @param inputHeight The height of the input panorama.
  127707. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  127708. * @return The cubemap data
  127709. */
  127710. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  127711. private static CreateCubemapTexture;
  127712. private static CalcProjectionSpherical;
  127713. }
  127714. }
  127715. declare module BABYLON {
  127716. /**
  127717. * Helper class dealing with the extraction of spherical polynomial dataArray
  127718. * from a cube map.
  127719. */
  127720. export class CubeMapToSphericalPolynomialTools {
  127721. private static FileFaces;
  127722. /**
  127723. * Converts a texture to the according Spherical Polynomial data.
  127724. * This extracts the first 3 orders only as they are the only one used in the lighting.
  127725. *
  127726. * @param texture The texture to extract the information from.
  127727. * @return The Spherical Polynomial data.
  127728. */
  127729. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  127730. /**
  127731. * Converts a cubemap to the according Spherical Polynomial data.
  127732. * This extracts the first 3 orders only as they are the only one used in the lighting.
  127733. *
  127734. * @param cubeInfo The Cube map to extract the information from.
  127735. * @return The Spherical Polynomial data.
  127736. */
  127737. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  127738. }
  127739. }
  127740. declare module BABYLON {
  127741. interface BaseTexture {
  127742. /**
  127743. * Get the polynomial representation of the texture data.
  127744. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  127745. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  127746. */
  127747. sphericalPolynomial: Nullable<SphericalPolynomial>;
  127748. }
  127749. }
  127750. declare module BABYLON {
  127751. /** @hidden */
  127752. export var rgbdEncodePixelShader: {
  127753. name: string;
  127754. shader: string;
  127755. };
  127756. }
  127757. declare module BABYLON {
  127758. /** @hidden */
  127759. export var rgbdDecodePixelShader: {
  127760. name: string;
  127761. shader: string;
  127762. };
  127763. }
  127764. declare module BABYLON {
  127765. /**
  127766. * Raw texture data and descriptor sufficient for WebGL texture upload
  127767. */
  127768. export interface EnvironmentTextureInfo {
  127769. /**
  127770. * Version of the environment map
  127771. */
  127772. version: number;
  127773. /**
  127774. * Width of image
  127775. */
  127776. width: number;
  127777. /**
  127778. * Irradiance information stored in the file.
  127779. */
  127780. irradiance: any;
  127781. /**
  127782. * Specular information stored in the file.
  127783. */
  127784. specular: any;
  127785. }
  127786. /**
  127787. * Defines One Image in the file. It requires only the position in the file
  127788. * as well as the length.
  127789. */
  127790. interface BufferImageData {
  127791. /**
  127792. * Length of the image data.
  127793. */
  127794. length: number;
  127795. /**
  127796. * Position of the data from the null terminator delimiting the end of the JSON.
  127797. */
  127798. position: number;
  127799. }
  127800. /**
  127801. * Defines the specular data enclosed in the file.
  127802. * This corresponds to the version 1 of the data.
  127803. */
  127804. export interface EnvironmentTextureSpecularInfoV1 {
  127805. /**
  127806. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  127807. */
  127808. specularDataPosition?: number;
  127809. /**
  127810. * This contains all the images data needed to reconstruct the cubemap.
  127811. */
  127812. mipmaps: Array<BufferImageData>;
  127813. /**
  127814. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  127815. */
  127816. lodGenerationScale: number;
  127817. }
  127818. /**
  127819. * Sets of helpers addressing the serialization and deserialization of environment texture
  127820. * stored in a BabylonJS env file.
  127821. * Those files are usually stored as .env files.
  127822. */
  127823. export class EnvironmentTextureTools {
  127824. /**
  127825. * Magic number identifying the env file.
  127826. */
  127827. private static _MagicBytes;
  127828. /**
  127829. * Gets the environment info from an env file.
  127830. * @param data The array buffer containing the .env bytes.
  127831. * @returns the environment file info (the json header) if successfully parsed.
  127832. */
  127833. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  127834. /**
  127835. * Creates an environment texture from a loaded cube texture.
  127836. * @param texture defines the cube texture to convert in env file
  127837. * @return a promise containing the environment data if succesfull.
  127838. */
  127839. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  127840. /**
  127841. * Creates a JSON representation of the spherical data.
  127842. * @param texture defines the texture containing the polynomials
  127843. * @return the JSON representation of the spherical info
  127844. */
  127845. private static _CreateEnvTextureIrradiance;
  127846. /**
  127847. * Creates the ArrayBufferViews used for initializing environment texture image data.
  127848. * @param data the image data
  127849. * @param info parameters that determine what views will be created for accessing the underlying buffer
  127850. * @return the views described by info providing access to the underlying buffer
  127851. */
  127852. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  127853. /**
  127854. * Uploads the texture info contained in the env file to the GPU.
  127855. * @param texture defines the internal texture to upload to
  127856. * @param data defines the data to load
  127857. * @param info defines the texture info retrieved through the GetEnvInfo method
  127858. * @returns a promise
  127859. */
  127860. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  127861. private static _OnImageReadyAsync;
  127862. /**
  127863. * Uploads the levels of image data to the GPU.
  127864. * @param texture defines the internal texture to upload to
  127865. * @param imageData defines the array buffer views of image data [mipmap][face]
  127866. * @returns a promise
  127867. */
  127868. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  127869. /**
  127870. * Uploads spherical polynomials information to the texture.
  127871. * @param texture defines the texture we are trying to upload the information to
  127872. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  127873. */
  127874. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  127875. /** @hidden */
  127876. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  127877. }
  127878. }
  127879. declare module BABYLON {
  127880. /** @hidden */
  127881. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  127882. private _genericAttributeLocation;
  127883. private _varyingLocationCount;
  127884. private _varyingLocationMap;
  127885. private _replacements;
  127886. private _textureCount;
  127887. private _uniforms;
  127888. lineProcessor(line: string): string;
  127889. attributeProcessor(attribute: string): string;
  127890. varyingProcessor(varying: string, isFragment: boolean): string;
  127891. uniformProcessor(uniform: string): string;
  127892. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  127893. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  127894. }
  127895. }
  127896. declare module BABYLON {
  127897. /**
  127898. * Container for accessors for natively-stored mesh data buffers.
  127899. */
  127900. class NativeDataBuffer extends DataBuffer {
  127901. /**
  127902. * Accessor value used to identify/retrieve a natively-stored index buffer.
  127903. */
  127904. nativeIndexBuffer?: any;
  127905. /**
  127906. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  127907. */
  127908. nativeVertexBuffer?: any;
  127909. }
  127910. /** @hidden */
  127911. class NativeTexture extends InternalTexture {
  127912. getInternalTexture(): InternalTexture;
  127913. getViewCount(): number;
  127914. }
  127915. /** @hidden */
  127916. export class NativeEngine extends Engine {
  127917. private readonly _native;
  127918. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  127919. private readonly INVALID_HANDLE;
  127920. getHardwareScalingLevel(): number;
  127921. constructor();
  127922. dispose(): void;
  127923. /**
  127924. * Can be used to override the current requestAnimationFrame requester.
  127925. * @hidden
  127926. */
  127927. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  127928. /**
  127929. * Override default engine behavior.
  127930. * @param color
  127931. * @param backBuffer
  127932. * @param depth
  127933. * @param stencil
  127934. */
  127935. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  127936. /**
  127937. * Gets host document
  127938. * @returns the host document object
  127939. */
  127940. getHostDocument(): Nullable<Document>;
  127941. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  127942. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  127943. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  127944. recordVertexArrayObject(vertexBuffers: {
  127945. [key: string]: VertexBuffer;
  127946. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  127947. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  127948. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  127949. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127950. /**
  127951. * Draw a list of indexed primitives
  127952. * @param fillMode defines the primitive to use
  127953. * @param indexStart defines the starting index
  127954. * @param indexCount defines the number of index to draw
  127955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127956. */
  127957. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127958. /**
  127959. * Draw a list of unindexed primitives
  127960. * @param fillMode defines the primitive to use
  127961. * @param verticesStart defines the index of first vertex to draw
  127962. * @param verticesCount defines the count of vertices to draw
  127963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127964. */
  127965. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127966. createPipelineContext(): IPipelineContext;
  127967. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  127968. /** @hidden */
  127969. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  127970. /** @hidden */
  127971. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  127972. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  127973. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  127974. protected _setProgram(program: WebGLProgram): void;
  127975. _releaseEffect(effect: Effect): void;
  127976. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  127977. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  127978. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  127979. bindSamplers(effect: Effect): void;
  127980. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  127981. getRenderWidth(useScreen?: boolean): number;
  127982. getRenderHeight(useScreen?: boolean): number;
  127983. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  127984. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127985. /**
  127986. * Set the z offset to apply to current rendering
  127987. * @param value defines the offset to apply
  127988. */
  127989. setZOffset(value: number): void;
  127990. /**
  127991. * Gets the current value of the zOffset
  127992. * @returns the current zOffset state
  127993. */
  127994. getZOffset(): number;
  127995. /**
  127996. * Enable or disable depth buffering
  127997. * @param enable defines the state to set
  127998. */
  127999. setDepthBuffer(enable: boolean): void;
  128000. /**
  128001. * Gets a boolean indicating if depth writing is enabled
  128002. * @returns the current depth writing state
  128003. */
  128004. getDepthWrite(): boolean;
  128005. /**
  128006. * Enable or disable depth writing
  128007. * @param enable defines the state to set
  128008. */
  128009. setDepthWrite(enable: boolean): void;
  128010. /**
  128011. * Enable or disable color writing
  128012. * @param enable defines the state to set
  128013. */
  128014. setColorWrite(enable: boolean): void;
  128015. /**
  128016. * Gets a boolean indicating if color writing is enabled
  128017. * @returns the current color writing state
  128018. */
  128019. getColorWrite(): boolean;
  128020. /**
  128021. * Sets alpha constants used by some alpha blending modes
  128022. * @param r defines the red component
  128023. * @param g defines the green component
  128024. * @param b defines the blue component
  128025. * @param a defines the alpha component
  128026. */
  128027. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128028. /**
  128029. * Sets the current alpha mode
  128030. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128031. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128032. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128033. */
  128034. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128035. /**
  128036. * Gets the current alpha mode
  128037. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128038. * @returns the current alpha mode
  128039. */
  128040. getAlphaMode(): number;
  128041. setInt(uniform: WebGLUniformLocation, int: number): void;
  128042. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128043. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128044. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128045. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128046. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128047. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128048. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128049. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128050. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128051. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128052. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128053. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128054. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128055. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128056. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128057. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128058. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128059. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128060. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128061. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  128062. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  128063. wipeCaches(bruteForce?: boolean): void;
  128064. _createTexture(): WebGLTexture;
  128065. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  128066. /**
  128067. * Usually called from Texture.ts.
  128068. * Passed information to create a WebGLTexture
  128069. * @param url defines a value which contains one of the following:
  128070. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128071. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128072. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128074. * @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)
  128075. * @param scene needed for loading to the correct scene
  128076. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128077. * @param onLoad optional callback to be called upon successful completion
  128078. * @param onError optional callback to be called upon failure
  128079. * @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
  128080. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128081. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128082. * @param forcedExtension defines the extension to use to pick the right loader
  128083. * @param mimeType defines an optional mime type
  128084. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128085. */
  128086. 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;
  128087. /**
  128088. * Creates a cube texture
  128089. * @param rootUrl defines the url where the files to load is located
  128090. * @param scene defines the current scene
  128091. * @param files defines the list of files to load (1 per face)
  128092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  128093. * @param onLoad defines an optional callback raised when the texture is loaded
  128094. * @param onError defines an optional callback raised if there is an issue to load the texture
  128095. * @param format defines the format of the data
  128096. * @param forcedExtension defines the extension to use to pick the right loader
  128097. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  128098. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128099. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128100. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  128101. * @returns the cube texture as an InternalTexture
  128102. */
  128103. 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;
  128104. private _getSamplingFilter;
  128105. private static _GetNativeTextureFormat;
  128106. createRenderTargetTexture(size: number | {
  128107. width: number;
  128108. height: number;
  128109. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  128110. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128111. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128112. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128113. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  128114. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  128115. /**
  128116. * Updates a dynamic vertex buffer.
  128117. * @param vertexBuffer the vertex buffer to update
  128118. * @param data the data used to update the vertex buffer
  128119. * @param byteOffset the byte offset of the data (optional)
  128120. * @param byteLength the byte length of the data (optional)
  128121. */
  128122. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  128123. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  128124. private _updateAnisotropicLevel;
  128125. private _getAddressMode;
  128126. /** @hidden */
  128127. _bindTexture(channel: number, texture: InternalTexture): void;
  128128. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  128129. releaseEffects(): void;
  128130. /** @hidden */
  128131. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128132. /** @hidden */
  128133. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128134. /** @hidden */
  128135. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128136. /** @hidden */
  128137. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128138. }
  128139. }
  128140. declare module BABYLON {
  128141. /**
  128142. * Gather the list of clipboard event types as constants.
  128143. */
  128144. export class ClipboardEventTypes {
  128145. /**
  128146. * The clipboard event is fired when a copy command is active (pressed).
  128147. */
  128148. static readonly COPY: number;
  128149. /**
  128150. * The clipboard event is fired when a cut command is active (pressed).
  128151. */
  128152. static readonly CUT: number;
  128153. /**
  128154. * The clipboard event is fired when a paste command is active (pressed).
  128155. */
  128156. static readonly PASTE: number;
  128157. }
  128158. /**
  128159. * This class is used to store clipboard related info for the onClipboardObservable event.
  128160. */
  128161. export class ClipboardInfo {
  128162. /**
  128163. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128164. */
  128165. type: number;
  128166. /**
  128167. * Defines the related dom event
  128168. */
  128169. event: ClipboardEvent;
  128170. /**
  128171. *Creates an instance of ClipboardInfo.
  128172. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  128173. * @param event Defines the related dom event
  128174. */
  128175. constructor(
  128176. /**
  128177. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128178. */
  128179. type: number,
  128180. /**
  128181. * Defines the related dom event
  128182. */
  128183. event: ClipboardEvent);
  128184. /**
  128185. * Get the clipboard event's type from the keycode.
  128186. * @param keyCode Defines the keyCode for the current keyboard event.
  128187. * @return {number}
  128188. */
  128189. static GetTypeFromCharacter(keyCode: number): number;
  128190. }
  128191. }
  128192. declare module BABYLON {
  128193. /**
  128194. * Google Daydream controller
  128195. */
  128196. export class DaydreamController extends WebVRController {
  128197. /**
  128198. * Base Url for the controller model.
  128199. */
  128200. static MODEL_BASE_URL: string;
  128201. /**
  128202. * File name for the controller model.
  128203. */
  128204. static MODEL_FILENAME: string;
  128205. /**
  128206. * Gamepad Id prefix used to identify Daydream Controller.
  128207. */
  128208. static readonly GAMEPAD_ID_PREFIX: string;
  128209. /**
  128210. * Creates a new DaydreamController from a gamepad
  128211. * @param vrGamepad the gamepad that the controller should be created from
  128212. */
  128213. constructor(vrGamepad: any);
  128214. /**
  128215. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128216. * @param scene scene in which to add meshes
  128217. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128218. */
  128219. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128220. /**
  128221. * Called once for each button that changed state since the last frame
  128222. * @param buttonIdx Which button index changed
  128223. * @param state New state of the button
  128224. * @param changes Which properties on the state changed since last frame
  128225. */
  128226. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128227. }
  128228. }
  128229. declare module BABYLON {
  128230. /**
  128231. * Gear VR Controller
  128232. */
  128233. export class GearVRController extends WebVRController {
  128234. /**
  128235. * Base Url for the controller model.
  128236. */
  128237. static MODEL_BASE_URL: string;
  128238. /**
  128239. * File name for the controller model.
  128240. */
  128241. static MODEL_FILENAME: string;
  128242. /**
  128243. * Gamepad Id prefix used to identify this controller.
  128244. */
  128245. static readonly GAMEPAD_ID_PREFIX: string;
  128246. private readonly _buttonIndexToObservableNameMap;
  128247. /**
  128248. * Creates a new GearVRController from a gamepad
  128249. * @param vrGamepad the gamepad that the controller should be created from
  128250. */
  128251. constructor(vrGamepad: any);
  128252. /**
  128253. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128254. * @param scene scene in which to add meshes
  128255. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128256. */
  128257. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128258. /**
  128259. * Called once for each button that changed state since the last frame
  128260. * @param buttonIdx Which button index changed
  128261. * @param state New state of the button
  128262. * @param changes Which properties on the state changed since last frame
  128263. */
  128264. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128265. }
  128266. }
  128267. declare module BABYLON {
  128268. /**
  128269. * Generic Controller
  128270. */
  128271. export class GenericController extends WebVRController {
  128272. /**
  128273. * Base Url for the controller model.
  128274. */
  128275. static readonly MODEL_BASE_URL: string;
  128276. /**
  128277. * File name for the controller model.
  128278. */
  128279. static readonly MODEL_FILENAME: string;
  128280. /**
  128281. * Creates a new GenericController from a gamepad
  128282. * @param vrGamepad the gamepad that the controller should be created from
  128283. */
  128284. constructor(vrGamepad: any);
  128285. /**
  128286. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128287. * @param scene scene in which to add meshes
  128288. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128289. */
  128290. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128291. /**
  128292. * Called once for each button that changed state since the last frame
  128293. * @param buttonIdx Which button index changed
  128294. * @param state New state of the button
  128295. * @param changes Which properties on the state changed since last frame
  128296. */
  128297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128298. }
  128299. }
  128300. declare module BABYLON {
  128301. /**
  128302. * Oculus Touch Controller
  128303. */
  128304. export class OculusTouchController extends WebVRController {
  128305. /**
  128306. * Base Url for the controller model.
  128307. */
  128308. static MODEL_BASE_URL: string;
  128309. /**
  128310. * File name for the left controller model.
  128311. */
  128312. static MODEL_LEFT_FILENAME: string;
  128313. /**
  128314. * File name for the right controller model.
  128315. */
  128316. static MODEL_RIGHT_FILENAME: string;
  128317. /**
  128318. * Base Url for the Quest controller model.
  128319. */
  128320. static QUEST_MODEL_BASE_URL: string;
  128321. /**
  128322. * @hidden
  128323. * If the controllers are running on a device that needs the updated Quest controller models
  128324. */
  128325. static _IsQuest: boolean;
  128326. /**
  128327. * Fired when the secondary trigger on this controller is modified
  128328. */
  128329. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  128330. /**
  128331. * Fired when the thumb rest on this controller is modified
  128332. */
  128333. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  128334. /**
  128335. * Creates a new OculusTouchController from a gamepad
  128336. * @param vrGamepad the gamepad that the controller should be created from
  128337. */
  128338. constructor(vrGamepad: any);
  128339. /**
  128340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128341. * @param scene scene in which to add meshes
  128342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128343. */
  128344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128345. /**
  128346. * Fired when the A button on this controller is modified
  128347. */
  128348. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128349. /**
  128350. * Fired when the B button on this controller is modified
  128351. */
  128352. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128353. /**
  128354. * Fired when the X button on this controller is modified
  128355. */
  128356. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128357. /**
  128358. * Fired when the Y button on this controller is modified
  128359. */
  128360. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128361. /**
  128362. * Called once for each button that changed state since the last frame
  128363. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  128364. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  128365. * 2) secondary trigger (same)
  128366. * 3) A (right) X (left), touch, pressed = value
  128367. * 4) B / Y
  128368. * 5) thumb rest
  128369. * @param buttonIdx Which button index changed
  128370. * @param state New state of the button
  128371. * @param changes Which properties on the state changed since last frame
  128372. */
  128373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128374. }
  128375. }
  128376. declare module BABYLON {
  128377. /**
  128378. * Vive Controller
  128379. */
  128380. export class ViveController extends WebVRController {
  128381. /**
  128382. * Base Url for the controller model.
  128383. */
  128384. static MODEL_BASE_URL: string;
  128385. /**
  128386. * File name for the controller model.
  128387. */
  128388. static MODEL_FILENAME: string;
  128389. /**
  128390. * Creates a new ViveController from a gamepad
  128391. * @param vrGamepad the gamepad that the controller should be created from
  128392. */
  128393. constructor(vrGamepad: any);
  128394. /**
  128395. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128396. * @param scene scene in which to add meshes
  128397. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128398. */
  128399. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128400. /**
  128401. * Fired when the left button on this controller is modified
  128402. */
  128403. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128404. /**
  128405. * Fired when the right button on this controller is modified
  128406. */
  128407. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128408. /**
  128409. * Fired when the menu button on this controller is modified
  128410. */
  128411. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128412. /**
  128413. * Called once for each button that changed state since the last frame
  128414. * Vive mapping:
  128415. * 0: touchpad
  128416. * 1: trigger
  128417. * 2: left AND right buttons
  128418. * 3: menu button
  128419. * @param buttonIdx Which button index changed
  128420. * @param state New state of the button
  128421. * @param changes Which properties on the state changed since last frame
  128422. */
  128423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128424. }
  128425. }
  128426. declare module BABYLON {
  128427. /**
  128428. * Defines the WindowsMotionController object that the state of the windows motion controller
  128429. */
  128430. export class WindowsMotionController extends WebVRController {
  128431. /**
  128432. * The base url used to load the left and right controller models
  128433. */
  128434. static MODEL_BASE_URL: string;
  128435. /**
  128436. * The name of the left controller model file
  128437. */
  128438. static MODEL_LEFT_FILENAME: string;
  128439. /**
  128440. * The name of the right controller model file
  128441. */
  128442. static MODEL_RIGHT_FILENAME: string;
  128443. /**
  128444. * The controller name prefix for this controller type
  128445. */
  128446. static readonly GAMEPAD_ID_PREFIX: string;
  128447. /**
  128448. * The controller id pattern for this controller type
  128449. */
  128450. private static readonly GAMEPAD_ID_PATTERN;
  128451. private _loadedMeshInfo;
  128452. protected readonly _mapping: {
  128453. buttons: string[];
  128454. buttonMeshNames: {
  128455. trigger: string;
  128456. menu: string;
  128457. grip: string;
  128458. thumbstick: string;
  128459. trackpad: string;
  128460. };
  128461. buttonObservableNames: {
  128462. trigger: string;
  128463. menu: string;
  128464. grip: string;
  128465. thumbstick: string;
  128466. trackpad: string;
  128467. };
  128468. axisMeshNames: string[];
  128469. pointingPoseMeshName: string;
  128470. };
  128471. /**
  128472. * Fired when the trackpad on this controller is clicked
  128473. */
  128474. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128475. /**
  128476. * Fired when the trackpad on this controller is modified
  128477. */
  128478. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128479. /**
  128480. * The current x and y values of this controller's trackpad
  128481. */
  128482. trackpad: StickValues;
  128483. /**
  128484. * Creates a new WindowsMotionController from a gamepad
  128485. * @param vrGamepad the gamepad that the controller should be created from
  128486. */
  128487. constructor(vrGamepad: any);
  128488. /**
  128489. * Fired when the trigger on this controller is modified
  128490. */
  128491. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128492. /**
  128493. * Fired when the menu button on this controller is modified
  128494. */
  128495. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128496. /**
  128497. * Fired when the grip button on this controller is modified
  128498. */
  128499. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128500. /**
  128501. * Fired when the thumbstick button on this controller is modified
  128502. */
  128503. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128504. /**
  128505. * Fired when the touchpad button on this controller is modified
  128506. */
  128507. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128508. /**
  128509. * Fired when the touchpad values on this controller are modified
  128510. */
  128511. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  128512. protected _updateTrackpad(): void;
  128513. /**
  128514. * Called once per frame by the engine.
  128515. */
  128516. update(): void;
  128517. /**
  128518. * Called once for each button that changed state since the last frame
  128519. * @param buttonIdx Which button index changed
  128520. * @param state New state of the button
  128521. * @param changes Which properties on the state changed since last frame
  128522. */
  128523. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128524. /**
  128525. * Moves the buttons on the controller mesh based on their current state
  128526. * @param buttonName the name of the button to move
  128527. * @param buttonValue the value of the button which determines the buttons new position
  128528. */
  128529. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  128530. /**
  128531. * Moves the axis on the controller mesh based on its current state
  128532. * @param axis the index of the axis
  128533. * @param axisValue the value of the axis which determines the meshes new position
  128534. * @hidden
  128535. */
  128536. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  128537. /**
  128538. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128539. * @param scene scene in which to add meshes
  128540. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128541. */
  128542. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  128543. /**
  128544. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  128545. * can be transformed by button presses and axes values, based on this._mapping.
  128546. *
  128547. * @param scene scene in which the meshes exist
  128548. * @param meshes list of meshes that make up the controller model to process
  128549. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  128550. */
  128551. private processModel;
  128552. private createMeshInfo;
  128553. /**
  128554. * Gets the ray of the controller in the direction the controller is pointing
  128555. * @param length the length the resulting ray should be
  128556. * @returns a ray in the direction the controller is pointing
  128557. */
  128558. getForwardRay(length?: number): Ray;
  128559. /**
  128560. * Disposes of the controller
  128561. */
  128562. dispose(): void;
  128563. }
  128564. /**
  128565. * This class represents a new windows motion controller in XR.
  128566. */
  128567. export class XRWindowsMotionController extends WindowsMotionController {
  128568. /**
  128569. * Changing the original WIndowsMotionController mapping to fir the new mapping
  128570. */
  128571. protected readonly _mapping: {
  128572. buttons: string[];
  128573. buttonMeshNames: {
  128574. trigger: string;
  128575. menu: string;
  128576. grip: string;
  128577. thumbstick: string;
  128578. trackpad: string;
  128579. };
  128580. buttonObservableNames: {
  128581. trigger: string;
  128582. menu: string;
  128583. grip: string;
  128584. thumbstick: string;
  128585. trackpad: string;
  128586. };
  128587. axisMeshNames: string[];
  128588. pointingPoseMeshName: string;
  128589. };
  128590. /**
  128591. * Construct a new XR-Based windows motion controller
  128592. *
  128593. * @param gamepadInfo the gamepad object from the browser
  128594. */
  128595. constructor(gamepadInfo: any);
  128596. /**
  128597. * holds the thumbstick values (X,Y)
  128598. */
  128599. thumbstickValues: StickValues;
  128600. /**
  128601. * Fired when the thumbstick on this controller is clicked
  128602. */
  128603. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  128604. /**
  128605. * Fired when the thumbstick on this controller is modified
  128606. */
  128607. onThumbstickValuesChangedObservable: Observable<StickValues>;
  128608. /**
  128609. * Fired when the touchpad button on this controller is modified
  128610. */
  128611. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128612. /**
  128613. * Fired when the touchpad values on this controller are modified
  128614. */
  128615. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128616. /**
  128617. * Fired when the thumbstick button on this controller is modified
  128618. * here to prevent breaking changes
  128619. */
  128620. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128621. /**
  128622. * updating the thumbstick(!) and not the trackpad.
  128623. * This is named this way due to the difference between WebVR and XR and to avoid
  128624. * changing the parent class.
  128625. */
  128626. protected _updateTrackpad(): void;
  128627. /**
  128628. * Disposes the class with joy
  128629. */
  128630. dispose(): void;
  128631. }
  128632. }
  128633. declare module BABYLON {
  128634. /**
  128635. * Class containing static functions to help procedurally build meshes
  128636. */
  128637. export class PolyhedronBuilder {
  128638. /**
  128639. * Creates a polyhedron mesh
  128640. * * 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
  128641. * * The parameter `size` (positive float, default 1) sets the polygon size
  128642. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  128643. * * 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`
  128644. * * 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
  128645. * * 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)`)
  128646. * * 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
  128647. * * 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
  128648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128651. * @param name defines the name of the mesh
  128652. * @param options defines the options used to create the mesh
  128653. * @param scene defines the hosting scene
  128654. * @returns the polyhedron mesh
  128655. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  128656. */
  128657. static CreatePolyhedron(name: string, options: {
  128658. type?: number;
  128659. size?: number;
  128660. sizeX?: number;
  128661. sizeY?: number;
  128662. sizeZ?: number;
  128663. custom?: any;
  128664. faceUV?: Vector4[];
  128665. faceColors?: Color4[];
  128666. flat?: boolean;
  128667. updatable?: boolean;
  128668. sideOrientation?: number;
  128669. frontUVs?: Vector4;
  128670. backUVs?: Vector4;
  128671. }, scene?: Nullable<Scene>): Mesh;
  128672. }
  128673. }
  128674. declare module BABYLON {
  128675. /**
  128676. * Gizmo that enables scaling a mesh along 3 axis
  128677. */
  128678. export class ScaleGizmo extends Gizmo {
  128679. /**
  128680. * Internal gizmo used for interactions on the x axis
  128681. */
  128682. xGizmo: AxisScaleGizmo;
  128683. /**
  128684. * Internal gizmo used for interactions on the y axis
  128685. */
  128686. yGizmo: AxisScaleGizmo;
  128687. /**
  128688. * Internal gizmo used for interactions on the z axis
  128689. */
  128690. zGizmo: AxisScaleGizmo;
  128691. /**
  128692. * Internal gizmo used to scale all axis equally
  128693. */
  128694. uniformScaleGizmo: AxisScaleGizmo;
  128695. private _meshAttached;
  128696. private _updateGizmoRotationToMatchAttachedMesh;
  128697. private _snapDistance;
  128698. private _scaleRatio;
  128699. private _uniformScalingMesh;
  128700. private _octahedron;
  128701. private _sensitivity;
  128702. /** Fires an event when any of it's sub gizmos are dragged */
  128703. onDragStartObservable: Observable<unknown>;
  128704. /** Fires an event when any of it's sub gizmos are released from dragging */
  128705. onDragEndObservable: Observable<unknown>;
  128706. get attachedMesh(): Nullable<AbstractMesh>;
  128707. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128708. /**
  128709. * Creates a ScaleGizmo
  128710. * @param gizmoLayer The utility layer the gizmo will be added to
  128711. */
  128712. constructor(gizmoLayer?: UtilityLayerRenderer);
  128713. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128714. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128715. /**
  128716. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128717. */
  128718. set snapDistance(value: number);
  128719. get snapDistance(): number;
  128720. /**
  128721. * Ratio for the scale of the gizmo (Default: 1)
  128722. */
  128723. set scaleRatio(value: number);
  128724. get scaleRatio(): number;
  128725. /**
  128726. * Sensitivity factor for dragging (Default: 1)
  128727. */
  128728. set sensitivity(value: number);
  128729. get sensitivity(): number;
  128730. /**
  128731. * Disposes of the gizmo
  128732. */
  128733. dispose(): void;
  128734. }
  128735. }
  128736. declare module BABYLON {
  128737. /**
  128738. * Single axis scale gizmo
  128739. */
  128740. export class AxisScaleGizmo extends Gizmo {
  128741. /**
  128742. * Drag behavior responsible for the gizmos dragging interactions
  128743. */
  128744. dragBehavior: PointerDragBehavior;
  128745. private _pointerObserver;
  128746. /**
  128747. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128748. */
  128749. snapDistance: number;
  128750. /**
  128751. * Event that fires each time the gizmo snaps to a new location.
  128752. * * snapDistance is the the change in distance
  128753. */
  128754. onSnapObservable: Observable<{
  128755. snapDistance: number;
  128756. }>;
  128757. /**
  128758. * If the scaling operation should be done on all axis (default: false)
  128759. */
  128760. uniformScaling: boolean;
  128761. /**
  128762. * Custom sensitivity value for the drag strength
  128763. */
  128764. sensitivity: number;
  128765. private _isEnabled;
  128766. private _parent;
  128767. private _arrow;
  128768. private _coloredMaterial;
  128769. private _hoverMaterial;
  128770. /**
  128771. * Creates an AxisScaleGizmo
  128772. * @param gizmoLayer The utility layer the gizmo will be added to
  128773. * @param dragAxis The axis which the gizmo will be able to scale on
  128774. * @param color The color of the gizmo
  128775. */
  128776. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  128777. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  128778. /**
  128779. * If the gizmo is enabled
  128780. */
  128781. set isEnabled(value: boolean);
  128782. get isEnabled(): boolean;
  128783. /**
  128784. * Disposes of the gizmo
  128785. */
  128786. dispose(): void;
  128787. /**
  128788. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128789. * @param mesh The mesh to replace the default mesh of the gizmo
  128790. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  128791. */
  128792. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  128793. }
  128794. }
  128795. declare module BABYLON {
  128796. /**
  128797. * Bounding box gizmo
  128798. */
  128799. export class BoundingBoxGizmo extends Gizmo {
  128800. private _lineBoundingBox;
  128801. private _rotateSpheresParent;
  128802. private _scaleBoxesParent;
  128803. private _boundingDimensions;
  128804. private _renderObserver;
  128805. private _pointerObserver;
  128806. private _scaleDragSpeed;
  128807. private _tmpQuaternion;
  128808. private _tmpVector;
  128809. private _tmpRotationMatrix;
  128810. /**
  128811. * 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)
  128812. */
  128813. ignoreChildren: boolean;
  128814. /**
  128815. * 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)
  128816. */
  128817. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  128818. /**
  128819. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  128820. */
  128821. rotationSphereSize: number;
  128822. /**
  128823. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  128824. */
  128825. scaleBoxSize: number;
  128826. /**
  128827. * 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)
  128828. */
  128829. fixedDragMeshScreenSize: boolean;
  128830. /**
  128831. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  128832. */
  128833. fixedDragMeshScreenSizeDistanceFactor: number;
  128834. /**
  128835. * Fired when a rotation sphere or scale box is dragged
  128836. */
  128837. onDragStartObservable: Observable<{}>;
  128838. /**
  128839. * Fired when a scale box is dragged
  128840. */
  128841. onScaleBoxDragObservable: Observable<{}>;
  128842. /**
  128843. * Fired when a scale box drag is ended
  128844. */
  128845. onScaleBoxDragEndObservable: Observable<{}>;
  128846. /**
  128847. * Fired when a rotation sphere is dragged
  128848. */
  128849. onRotationSphereDragObservable: Observable<{}>;
  128850. /**
  128851. * Fired when a rotation sphere drag is ended
  128852. */
  128853. onRotationSphereDragEndObservable: Observable<{}>;
  128854. /**
  128855. * 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)
  128856. */
  128857. scalePivot: Nullable<Vector3>;
  128858. /**
  128859. * Mesh used as a pivot to rotate the attached mesh
  128860. */
  128861. private _anchorMesh;
  128862. private _existingMeshScale;
  128863. private _dragMesh;
  128864. private pointerDragBehavior;
  128865. private coloredMaterial;
  128866. private hoverColoredMaterial;
  128867. /**
  128868. * Sets the color of the bounding box gizmo
  128869. * @param color the color to set
  128870. */
  128871. setColor(color: Color3): void;
  128872. /**
  128873. * Creates an BoundingBoxGizmo
  128874. * @param gizmoLayer The utility layer the gizmo will be added to
  128875. * @param color The color of the gizmo
  128876. */
  128877. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  128878. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  128879. private _selectNode;
  128880. /**
  128881. * Updates the bounding box information for the Gizmo
  128882. */
  128883. updateBoundingBox(): void;
  128884. private _updateRotationSpheres;
  128885. private _updateScaleBoxes;
  128886. /**
  128887. * Enables rotation on the specified axis and disables rotation on the others
  128888. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  128889. */
  128890. setEnabledRotationAxis(axis: string): void;
  128891. /**
  128892. * Enables/disables scaling
  128893. * @param enable if scaling should be enabled
  128894. * @param homogeneousScaling defines if scaling should only be homogeneous
  128895. */
  128896. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  128897. private _updateDummy;
  128898. /**
  128899. * Enables a pointer drag behavior on the bounding box of the gizmo
  128900. */
  128901. enableDragBehavior(): void;
  128902. /**
  128903. * Disposes of the gizmo
  128904. */
  128905. dispose(): void;
  128906. /**
  128907. * 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)
  128908. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  128909. * @returns the bounding box mesh with the passed in mesh as a child
  128910. */
  128911. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  128912. /**
  128913. * CustomMeshes are not supported by this gizmo
  128914. * @param mesh The mesh to replace the default mesh of the gizmo
  128915. */
  128916. setCustomMesh(mesh: Mesh): void;
  128917. }
  128918. }
  128919. declare module BABYLON {
  128920. /**
  128921. * Single plane rotation gizmo
  128922. */
  128923. export class PlaneRotationGizmo extends Gizmo {
  128924. /**
  128925. * Drag behavior responsible for the gizmos dragging interactions
  128926. */
  128927. dragBehavior: PointerDragBehavior;
  128928. private _pointerObserver;
  128929. /**
  128930. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  128931. */
  128932. snapDistance: number;
  128933. /**
  128934. * Event that fires each time the gizmo snaps to a new location.
  128935. * * snapDistance is the the change in distance
  128936. */
  128937. onSnapObservable: Observable<{
  128938. snapDistance: number;
  128939. }>;
  128940. private _isEnabled;
  128941. private _parent;
  128942. /**
  128943. * Creates a PlaneRotationGizmo
  128944. * @param gizmoLayer The utility layer the gizmo will be added to
  128945. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  128946. * @param color The color of the gizmo
  128947. * @param tessellation Amount of tessellation to be used when creating rotation circles
  128948. * @param useEulerRotation Use and update Euler angle instead of quaternion
  128949. */
  128950. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  128951. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  128952. /**
  128953. * If the gizmo is enabled
  128954. */
  128955. set isEnabled(value: boolean);
  128956. get isEnabled(): boolean;
  128957. /**
  128958. * Disposes of the gizmo
  128959. */
  128960. dispose(): void;
  128961. }
  128962. }
  128963. declare module BABYLON {
  128964. /**
  128965. * Gizmo that enables rotating a mesh along 3 axis
  128966. */
  128967. export class RotationGizmo extends Gizmo {
  128968. /**
  128969. * Internal gizmo used for interactions on the x axis
  128970. */
  128971. xGizmo: PlaneRotationGizmo;
  128972. /**
  128973. * Internal gizmo used for interactions on the y axis
  128974. */
  128975. yGizmo: PlaneRotationGizmo;
  128976. /**
  128977. * Internal gizmo used for interactions on the z axis
  128978. */
  128979. zGizmo: PlaneRotationGizmo;
  128980. /** Fires an event when any of it's sub gizmos are dragged */
  128981. onDragStartObservable: Observable<unknown>;
  128982. /** Fires an event when any of it's sub gizmos are released from dragging */
  128983. onDragEndObservable: Observable<unknown>;
  128984. private _meshAttached;
  128985. get attachedMesh(): Nullable<AbstractMesh>;
  128986. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128987. /**
  128988. * Creates a RotationGizmo
  128989. * @param gizmoLayer The utility layer the gizmo will be added to
  128990. * @param tessellation Amount of tessellation to be used when creating rotation circles
  128991. * @param useEulerRotation Use and update Euler angle instead of quaternion
  128992. */
  128993. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  128994. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128995. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128996. /**
  128997. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128998. */
  128999. set snapDistance(value: number);
  129000. get snapDistance(): number;
  129001. /**
  129002. * Ratio for the scale of the gizmo (Default: 1)
  129003. */
  129004. set scaleRatio(value: number);
  129005. get scaleRatio(): number;
  129006. /**
  129007. * Disposes of the gizmo
  129008. */
  129009. dispose(): void;
  129010. /**
  129011. * CustomMeshes are not supported by this gizmo
  129012. * @param mesh The mesh to replace the default mesh of the gizmo
  129013. */
  129014. setCustomMesh(mesh: Mesh): void;
  129015. }
  129016. }
  129017. declare module BABYLON {
  129018. /**
  129019. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129020. */
  129021. export class GizmoManager implements IDisposable {
  129022. private scene;
  129023. /**
  129024. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129025. */
  129026. gizmos: {
  129027. positionGizmo: Nullable<PositionGizmo>;
  129028. rotationGizmo: Nullable<RotationGizmo>;
  129029. scaleGizmo: Nullable<ScaleGizmo>;
  129030. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129031. };
  129032. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129033. clearGizmoOnEmptyPointerEvent: boolean;
  129034. /** Fires an event when the manager is attached to a mesh */
  129035. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129036. private _gizmosEnabled;
  129037. private _pointerObserver;
  129038. private _attachedMesh;
  129039. private _boundingBoxColor;
  129040. private _defaultUtilityLayer;
  129041. private _defaultKeepDepthUtilityLayer;
  129042. /**
  129043. * When bounding box gizmo is enabled, this can be used to track drag/end events
  129044. */
  129045. boundingBoxDragBehavior: SixDofDragBehavior;
  129046. /**
  129047. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  129048. */
  129049. attachableMeshes: Nullable<Array<AbstractMesh>>;
  129050. /**
  129051. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  129052. */
  129053. usePointerToAttachGizmos: boolean;
  129054. /**
  129055. * Utility layer that the bounding box gizmo belongs to
  129056. */
  129057. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  129058. /**
  129059. * Utility layer that all gizmos besides bounding box belong to
  129060. */
  129061. get utilityLayer(): UtilityLayerRenderer;
  129062. /**
  129063. * Instatiates a gizmo manager
  129064. * @param scene the scene to overlay the gizmos on top of
  129065. */
  129066. constructor(scene: Scene);
  129067. /**
  129068. * Attaches a set of gizmos to the specified mesh
  129069. * @param mesh The mesh the gizmo's should be attached to
  129070. */
  129071. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129072. /**
  129073. * If the position gizmo is enabled
  129074. */
  129075. set positionGizmoEnabled(value: boolean);
  129076. get positionGizmoEnabled(): boolean;
  129077. /**
  129078. * If the rotation gizmo is enabled
  129079. */
  129080. set rotationGizmoEnabled(value: boolean);
  129081. get rotationGizmoEnabled(): boolean;
  129082. /**
  129083. * If the scale gizmo is enabled
  129084. */
  129085. set scaleGizmoEnabled(value: boolean);
  129086. get scaleGizmoEnabled(): boolean;
  129087. /**
  129088. * If the boundingBox gizmo is enabled
  129089. */
  129090. set boundingBoxGizmoEnabled(value: boolean);
  129091. get boundingBoxGizmoEnabled(): boolean;
  129092. /**
  129093. * Disposes of the gizmo manager
  129094. */
  129095. dispose(): void;
  129096. }
  129097. }
  129098. declare module BABYLON {
  129099. /**
  129100. * A directional light is defined by a direction (what a surprise!).
  129101. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  129102. * 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.
  129103. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129104. */
  129105. export class DirectionalLight extends ShadowLight {
  129106. private _shadowFrustumSize;
  129107. /**
  129108. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  129109. */
  129110. get shadowFrustumSize(): number;
  129111. /**
  129112. * Specifies a fix frustum size for the shadow generation.
  129113. */
  129114. set shadowFrustumSize(value: number);
  129115. private _shadowOrthoScale;
  129116. /**
  129117. * Gets the shadow projection scale against the optimal computed one.
  129118. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129119. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129120. */
  129121. get shadowOrthoScale(): number;
  129122. /**
  129123. * Sets the shadow projection scale against the optimal computed one.
  129124. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129125. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129126. */
  129127. set shadowOrthoScale(value: number);
  129128. /**
  129129. * Automatically compute the projection matrix to best fit (including all the casters)
  129130. * on each frame.
  129131. */
  129132. autoUpdateExtends: boolean;
  129133. /**
  129134. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  129135. * on each frame. autoUpdateExtends must be set to true for this to work
  129136. */
  129137. autoCalcShadowZBounds: boolean;
  129138. private _orthoLeft;
  129139. private _orthoRight;
  129140. private _orthoTop;
  129141. private _orthoBottom;
  129142. /**
  129143. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  129144. * The directional light is emitted from everywhere in the given direction.
  129145. * It can cast shadows.
  129146. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129147. * @param name The friendly name of the light
  129148. * @param direction The direction of the light
  129149. * @param scene The scene the light belongs to
  129150. */
  129151. constructor(name: string, direction: Vector3, scene: Scene);
  129152. /**
  129153. * Returns the string "DirectionalLight".
  129154. * @return The class name
  129155. */
  129156. getClassName(): string;
  129157. /**
  129158. * Returns the integer 1.
  129159. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129160. */
  129161. getTypeID(): number;
  129162. /**
  129163. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  129164. * Returns the DirectionalLight Shadow projection matrix.
  129165. */
  129166. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129167. /**
  129168. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  129169. * Returns the DirectionalLight Shadow projection matrix.
  129170. */
  129171. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  129172. /**
  129173. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  129174. * Returns the DirectionalLight Shadow projection matrix.
  129175. */
  129176. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129177. protected _buildUniformLayout(): void;
  129178. /**
  129179. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  129180. * @param effect The effect to update
  129181. * @param lightIndex The index of the light in the effect to update
  129182. * @returns The directional light
  129183. */
  129184. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  129185. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  129186. /**
  129187. * Gets the minZ used for shadow according to both the scene and the light.
  129188. *
  129189. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129190. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129191. * @param activeCamera The camera we are returning the min for
  129192. * @returns the depth min z
  129193. */
  129194. getDepthMinZ(activeCamera: Camera): number;
  129195. /**
  129196. * Gets the maxZ used for shadow according to both the scene and the light.
  129197. *
  129198. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129199. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129200. * @param activeCamera The camera we are returning the max for
  129201. * @returns the depth max z
  129202. */
  129203. getDepthMaxZ(activeCamera: Camera): number;
  129204. /**
  129205. * Prepares the list of defines specific to the light type.
  129206. * @param defines the list of defines
  129207. * @param lightIndex defines the index of the light for the effect
  129208. */
  129209. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129210. }
  129211. }
  129212. declare module BABYLON {
  129213. /**
  129214. * Class containing static functions to help procedurally build meshes
  129215. */
  129216. export class HemisphereBuilder {
  129217. /**
  129218. * Creates a hemisphere mesh
  129219. * @param name defines the name of the mesh
  129220. * @param options defines the options used to create the mesh
  129221. * @param scene defines the hosting scene
  129222. * @returns the hemisphere mesh
  129223. */
  129224. static CreateHemisphere(name: string, options: {
  129225. segments?: number;
  129226. diameter?: number;
  129227. sideOrientation?: number;
  129228. }, scene: any): Mesh;
  129229. }
  129230. }
  129231. declare module BABYLON {
  129232. /**
  129233. * A spot light is defined by a position, a direction, an angle, and an exponent.
  129234. * These values define a cone of light starting from the position, emitting toward the direction.
  129235. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  129236. * and the exponent defines the speed of the decay of the light with distance (reach).
  129237. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129238. */
  129239. export class SpotLight extends ShadowLight {
  129240. private _angle;
  129241. private _innerAngle;
  129242. private _cosHalfAngle;
  129243. private _lightAngleScale;
  129244. private _lightAngleOffset;
  129245. /**
  129246. * Gets the cone angle of the spot light in Radians.
  129247. */
  129248. get angle(): number;
  129249. /**
  129250. * Sets the cone angle of the spot light in Radians.
  129251. */
  129252. set angle(value: number);
  129253. /**
  129254. * Only used in gltf falloff mode, this defines the angle where
  129255. * the directional falloff will start before cutting at angle which could be seen
  129256. * as outer angle.
  129257. */
  129258. get innerAngle(): number;
  129259. /**
  129260. * Only used in gltf falloff mode, this defines the angle where
  129261. * the directional falloff will start before cutting at angle which could be seen
  129262. * as outer angle.
  129263. */
  129264. set innerAngle(value: number);
  129265. private _shadowAngleScale;
  129266. /**
  129267. * Allows scaling the angle of the light for shadow generation only.
  129268. */
  129269. get shadowAngleScale(): number;
  129270. /**
  129271. * Allows scaling the angle of the light for shadow generation only.
  129272. */
  129273. set shadowAngleScale(value: number);
  129274. /**
  129275. * The light decay speed with the distance from the emission spot.
  129276. */
  129277. exponent: number;
  129278. private _projectionTextureMatrix;
  129279. /**
  129280. * Allows reading the projecton texture
  129281. */
  129282. get projectionTextureMatrix(): Matrix;
  129283. protected _projectionTextureLightNear: number;
  129284. /**
  129285. * Gets the near clip of the Spotlight for texture projection.
  129286. */
  129287. get projectionTextureLightNear(): number;
  129288. /**
  129289. * Sets the near clip of the Spotlight for texture projection.
  129290. */
  129291. set projectionTextureLightNear(value: number);
  129292. protected _projectionTextureLightFar: number;
  129293. /**
  129294. * Gets the far clip of the Spotlight for texture projection.
  129295. */
  129296. get projectionTextureLightFar(): number;
  129297. /**
  129298. * Sets the far clip of the Spotlight for texture projection.
  129299. */
  129300. set projectionTextureLightFar(value: number);
  129301. protected _projectionTextureUpDirection: Vector3;
  129302. /**
  129303. * Gets the Up vector of the Spotlight for texture projection.
  129304. */
  129305. get projectionTextureUpDirection(): Vector3;
  129306. /**
  129307. * Sets the Up vector of the Spotlight for texture projection.
  129308. */
  129309. set projectionTextureUpDirection(value: Vector3);
  129310. private _projectionTexture;
  129311. /**
  129312. * Gets the projection texture of the light.
  129313. */
  129314. get projectionTexture(): Nullable<BaseTexture>;
  129315. /**
  129316. * Sets the projection texture of the light.
  129317. */
  129318. set projectionTexture(value: Nullable<BaseTexture>);
  129319. private _projectionTextureViewLightDirty;
  129320. private _projectionTextureProjectionLightDirty;
  129321. private _projectionTextureDirty;
  129322. private _projectionTextureViewTargetVector;
  129323. private _projectionTextureViewLightMatrix;
  129324. private _projectionTextureProjectionLightMatrix;
  129325. private _projectionTextureScalingMatrix;
  129326. /**
  129327. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  129328. * It can cast shadows.
  129329. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129330. * @param name The light friendly name
  129331. * @param position The position of the spot light in the scene
  129332. * @param direction The direction of the light in the scene
  129333. * @param angle The cone angle of the light in Radians
  129334. * @param exponent The light decay speed with the distance from the emission spot
  129335. * @param scene The scene the lights belongs to
  129336. */
  129337. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  129338. /**
  129339. * Returns the string "SpotLight".
  129340. * @returns the class name
  129341. */
  129342. getClassName(): string;
  129343. /**
  129344. * Returns the integer 2.
  129345. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129346. */
  129347. getTypeID(): number;
  129348. /**
  129349. * Overrides the direction setter to recompute the projection texture view light Matrix.
  129350. */
  129351. protected _setDirection(value: Vector3): void;
  129352. /**
  129353. * Overrides the position setter to recompute the projection texture view light Matrix.
  129354. */
  129355. protected _setPosition(value: Vector3): void;
  129356. /**
  129357. * 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.
  129358. * Returns the SpotLight.
  129359. */
  129360. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129361. protected _computeProjectionTextureViewLightMatrix(): void;
  129362. protected _computeProjectionTextureProjectionLightMatrix(): void;
  129363. /**
  129364. * Main function for light texture projection matrix computing.
  129365. */
  129366. protected _computeProjectionTextureMatrix(): void;
  129367. protected _buildUniformLayout(): void;
  129368. private _computeAngleValues;
  129369. /**
  129370. * Sets the passed Effect "effect" with the Light textures.
  129371. * @param effect The effect to update
  129372. * @param lightIndex The index of the light in the effect to update
  129373. * @returns The light
  129374. */
  129375. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  129376. /**
  129377. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  129378. * @param effect The effect to update
  129379. * @param lightIndex The index of the light in the effect to update
  129380. * @returns The spot light
  129381. */
  129382. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  129383. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129384. /**
  129385. * Disposes the light and the associated resources.
  129386. */
  129387. dispose(): void;
  129388. /**
  129389. * Prepares the list of defines specific to the light type.
  129390. * @param defines the list of defines
  129391. * @param lightIndex defines the index of the light for the effect
  129392. */
  129393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129394. }
  129395. }
  129396. declare module BABYLON {
  129397. /**
  129398. * Gizmo that enables viewing a light
  129399. */
  129400. export class LightGizmo extends Gizmo {
  129401. private _lightMesh;
  129402. private _material;
  129403. private _cachedPosition;
  129404. private _cachedForward;
  129405. private _attachedMeshParent;
  129406. /**
  129407. * Creates a LightGizmo
  129408. * @param gizmoLayer The utility layer the gizmo will be added to
  129409. */
  129410. constructor(gizmoLayer?: UtilityLayerRenderer);
  129411. private _light;
  129412. /**
  129413. * The light that the gizmo is attached to
  129414. */
  129415. set light(light: Nullable<Light>);
  129416. get light(): Nullable<Light>;
  129417. /**
  129418. * Gets the material used to render the light gizmo
  129419. */
  129420. get material(): StandardMaterial;
  129421. /**
  129422. * @hidden
  129423. * Updates the gizmo to match the attached mesh's position/rotation
  129424. */
  129425. protected _update(): void;
  129426. private static _Scale;
  129427. /**
  129428. * Creates the lines for a light mesh
  129429. */
  129430. private static _CreateLightLines;
  129431. /**
  129432. * Disposes of the light gizmo
  129433. */
  129434. dispose(): void;
  129435. private static _CreateHemisphericLightMesh;
  129436. private static _CreatePointLightMesh;
  129437. private static _CreateSpotLightMesh;
  129438. private static _CreateDirectionalLightMesh;
  129439. }
  129440. }
  129441. declare module BABYLON {
  129442. /** @hidden */
  129443. export var backgroundFragmentDeclaration: {
  129444. name: string;
  129445. shader: string;
  129446. };
  129447. }
  129448. declare module BABYLON {
  129449. /** @hidden */
  129450. export var backgroundUboDeclaration: {
  129451. name: string;
  129452. shader: string;
  129453. };
  129454. }
  129455. declare module BABYLON {
  129456. /** @hidden */
  129457. export var backgroundPixelShader: {
  129458. name: string;
  129459. shader: string;
  129460. };
  129461. }
  129462. declare module BABYLON {
  129463. /** @hidden */
  129464. export var backgroundVertexDeclaration: {
  129465. name: string;
  129466. shader: string;
  129467. };
  129468. }
  129469. declare module BABYLON {
  129470. /** @hidden */
  129471. export var backgroundVertexShader: {
  129472. name: string;
  129473. shader: string;
  129474. };
  129475. }
  129476. declare module BABYLON {
  129477. /**
  129478. * Background material used to create an efficient environement around your scene.
  129479. */
  129480. export class BackgroundMaterial extends PushMaterial {
  129481. /**
  129482. * Standard reflectance value at parallel view angle.
  129483. */
  129484. static StandardReflectance0: number;
  129485. /**
  129486. * Standard reflectance value at grazing angle.
  129487. */
  129488. static StandardReflectance90: number;
  129489. protected _primaryColor: Color3;
  129490. /**
  129491. * Key light Color (multiply against the environement texture)
  129492. */
  129493. primaryColor: Color3;
  129494. protected __perceptualColor: Nullable<Color3>;
  129495. /**
  129496. * Experimental Internal Use Only.
  129497. *
  129498. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  129499. * This acts as a helper to set the primary color to a more "human friendly" value.
  129500. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  129501. * output color as close as possible from the chosen value.
  129502. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  129503. * part of lighting setup.)
  129504. */
  129505. get _perceptualColor(): Nullable<Color3>;
  129506. set _perceptualColor(value: Nullable<Color3>);
  129507. protected _primaryColorShadowLevel: float;
  129508. /**
  129509. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  129510. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  129511. */
  129512. get primaryColorShadowLevel(): float;
  129513. set primaryColorShadowLevel(value: float);
  129514. protected _primaryColorHighlightLevel: float;
  129515. /**
  129516. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  129517. * The primary color is used at the level chosen to define what the white area would look.
  129518. */
  129519. get primaryColorHighlightLevel(): float;
  129520. set primaryColorHighlightLevel(value: float);
  129521. protected _reflectionTexture: Nullable<BaseTexture>;
  129522. /**
  129523. * Reflection Texture used in the material.
  129524. * Should be author in a specific way for the best result (refer to the documentation).
  129525. */
  129526. reflectionTexture: Nullable<BaseTexture>;
  129527. protected _reflectionBlur: float;
  129528. /**
  129529. * Reflection Texture level of blur.
  129530. *
  129531. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  129532. * texture twice.
  129533. */
  129534. reflectionBlur: float;
  129535. protected _diffuseTexture: Nullable<BaseTexture>;
  129536. /**
  129537. * Diffuse Texture used in the material.
  129538. * Should be author in a specific way for the best result (refer to the documentation).
  129539. */
  129540. diffuseTexture: Nullable<BaseTexture>;
  129541. protected _shadowLights: Nullable<IShadowLight[]>;
  129542. /**
  129543. * Specify the list of lights casting shadow on the material.
  129544. * All scene shadow lights will be included if null.
  129545. */
  129546. shadowLights: Nullable<IShadowLight[]>;
  129547. protected _shadowLevel: float;
  129548. /**
  129549. * Helps adjusting the shadow to a softer level if required.
  129550. * 0 means black shadows and 1 means no shadows.
  129551. */
  129552. shadowLevel: float;
  129553. protected _sceneCenter: Vector3;
  129554. /**
  129555. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  129556. * It is usually zero but might be interesting to modify according to your setup.
  129557. */
  129558. sceneCenter: Vector3;
  129559. protected _opacityFresnel: boolean;
  129560. /**
  129561. * This helps specifying that the material is falling off to the sky box at grazing angle.
  129562. * This helps ensuring a nice transition when the camera goes under the ground.
  129563. */
  129564. opacityFresnel: boolean;
  129565. protected _reflectionFresnel: boolean;
  129566. /**
  129567. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  129568. * This helps adding a mirror texture on the ground.
  129569. */
  129570. reflectionFresnel: boolean;
  129571. protected _reflectionFalloffDistance: number;
  129572. /**
  129573. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  129574. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  129575. */
  129576. reflectionFalloffDistance: number;
  129577. protected _reflectionAmount: number;
  129578. /**
  129579. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  129580. */
  129581. reflectionAmount: number;
  129582. protected _reflectionReflectance0: number;
  129583. /**
  129584. * This specifies the weight of the reflection at grazing angle.
  129585. */
  129586. reflectionReflectance0: number;
  129587. protected _reflectionReflectance90: number;
  129588. /**
  129589. * This specifies the weight of the reflection at a perpendicular point of view.
  129590. */
  129591. reflectionReflectance90: number;
  129592. /**
  129593. * Sets the reflection reflectance fresnel values according to the default standard
  129594. * empirically know to work well :-)
  129595. */
  129596. set reflectionStandardFresnelWeight(value: number);
  129597. protected _useRGBColor: boolean;
  129598. /**
  129599. * Helps to directly use the maps channels instead of their level.
  129600. */
  129601. useRGBColor: boolean;
  129602. protected _enableNoise: boolean;
  129603. /**
  129604. * This helps reducing the banding effect that could occur on the background.
  129605. */
  129606. enableNoise: boolean;
  129607. /**
  129608. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129609. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  129610. * Recommended to be keep at 1.0 except for special cases.
  129611. */
  129612. get fovMultiplier(): number;
  129613. set fovMultiplier(value: number);
  129614. private _fovMultiplier;
  129615. /**
  129616. * Enable the FOV adjustment feature controlled by fovMultiplier.
  129617. */
  129618. useEquirectangularFOV: boolean;
  129619. private _maxSimultaneousLights;
  129620. /**
  129621. * Number of Simultaneous lights allowed on the material.
  129622. */
  129623. maxSimultaneousLights: int;
  129624. /**
  129625. * Default configuration related to image processing available in the Background Material.
  129626. */
  129627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129628. /**
  129629. * Keep track of the image processing observer to allow dispose and replace.
  129630. */
  129631. private _imageProcessingObserver;
  129632. /**
  129633. * Attaches a new image processing configuration to the PBR Material.
  129634. * @param configuration (if null the scene configuration will be use)
  129635. */
  129636. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129637. /**
  129638. * Gets the image processing configuration used either in this material.
  129639. */
  129640. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  129641. /**
  129642. * Sets the Default image processing configuration used either in the this material.
  129643. *
  129644. * If sets to null, the scene one is in use.
  129645. */
  129646. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  129647. /**
  129648. * Gets wether the color curves effect is enabled.
  129649. */
  129650. get cameraColorCurvesEnabled(): boolean;
  129651. /**
  129652. * Sets wether the color curves effect is enabled.
  129653. */
  129654. set cameraColorCurvesEnabled(value: boolean);
  129655. /**
  129656. * Gets wether the color grading effect is enabled.
  129657. */
  129658. get cameraColorGradingEnabled(): boolean;
  129659. /**
  129660. * Gets wether the color grading effect is enabled.
  129661. */
  129662. set cameraColorGradingEnabled(value: boolean);
  129663. /**
  129664. * Gets wether tonemapping is enabled or not.
  129665. */
  129666. get cameraToneMappingEnabled(): boolean;
  129667. /**
  129668. * Sets wether tonemapping is enabled or not
  129669. */
  129670. set cameraToneMappingEnabled(value: boolean);
  129671. /**
  129672. * The camera exposure used on this material.
  129673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  129674. * This corresponds to a photographic exposure.
  129675. */
  129676. get cameraExposure(): float;
  129677. /**
  129678. * The camera exposure used on this material.
  129679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  129680. * This corresponds to a photographic exposure.
  129681. */
  129682. set cameraExposure(value: float);
  129683. /**
  129684. * Gets The camera contrast used on this material.
  129685. */
  129686. get cameraContrast(): float;
  129687. /**
  129688. * Sets The camera contrast used on this material.
  129689. */
  129690. set cameraContrast(value: float);
  129691. /**
  129692. * Gets the Color Grading 2D Lookup Texture.
  129693. */
  129694. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  129695. /**
  129696. * Sets the Color Grading 2D Lookup Texture.
  129697. */
  129698. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  129699. /**
  129700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  129701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  129702. * 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;
  129703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  129704. */
  129705. get cameraColorCurves(): Nullable<ColorCurves>;
  129706. /**
  129707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  129708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  129709. * 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;
  129710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  129711. */
  129712. set cameraColorCurves(value: Nullable<ColorCurves>);
  129713. /**
  129714. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  129715. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  129716. */
  129717. switchToBGR: boolean;
  129718. private _renderTargets;
  129719. private _reflectionControls;
  129720. private _white;
  129721. private _primaryShadowColor;
  129722. private _primaryHighlightColor;
  129723. /**
  129724. * Instantiates a Background Material in the given scene
  129725. * @param name The friendly name of the material
  129726. * @param scene The scene to add the material to
  129727. */
  129728. constructor(name: string, scene: Scene);
  129729. /**
  129730. * Gets a boolean indicating that current material needs to register RTT
  129731. */
  129732. get hasRenderTargetTextures(): boolean;
  129733. /**
  129734. * The entire material has been created in order to prevent overdraw.
  129735. * @returns false
  129736. */
  129737. needAlphaTesting(): boolean;
  129738. /**
  129739. * The entire material has been created in order to prevent overdraw.
  129740. * @returns true if blending is enable
  129741. */
  129742. needAlphaBlending(): boolean;
  129743. /**
  129744. * Checks wether the material is ready to be rendered for a given mesh.
  129745. * @param mesh The mesh to render
  129746. * @param subMesh The submesh to check against
  129747. * @param useInstances Specify wether or not the material is used with instances
  129748. * @returns true if all the dependencies are ready (Textures, Effects...)
  129749. */
  129750. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129751. /**
  129752. * Compute the primary color according to the chosen perceptual color.
  129753. */
  129754. private _computePrimaryColorFromPerceptualColor;
  129755. /**
  129756. * Compute the highlights and shadow colors according to their chosen levels.
  129757. */
  129758. private _computePrimaryColors;
  129759. /**
  129760. * Build the uniform buffer used in the material.
  129761. */
  129762. buildUniformLayout(): void;
  129763. /**
  129764. * Unbind the material.
  129765. */
  129766. unbind(): void;
  129767. /**
  129768. * Bind only the world matrix to the material.
  129769. * @param world The world matrix to bind.
  129770. */
  129771. bindOnlyWorldMatrix(world: Matrix): void;
  129772. /**
  129773. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  129774. * @param world The world matrix to bind.
  129775. * @param subMesh The submesh to bind for.
  129776. */
  129777. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129778. /**
  129779. * Checks to see if a texture is used in the material.
  129780. * @param texture - Base texture to use.
  129781. * @returns - Boolean specifying if a texture is used in the material.
  129782. */
  129783. hasTexture(texture: BaseTexture): boolean;
  129784. /**
  129785. * Dispose the material.
  129786. * @param forceDisposeEffect Force disposal of the associated effect.
  129787. * @param forceDisposeTextures Force disposal of the associated textures.
  129788. */
  129789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  129790. /**
  129791. * Clones the material.
  129792. * @param name The cloned name.
  129793. * @returns The cloned material.
  129794. */
  129795. clone(name: string): BackgroundMaterial;
  129796. /**
  129797. * Serializes the current material to its JSON representation.
  129798. * @returns The JSON representation.
  129799. */
  129800. serialize(): any;
  129801. /**
  129802. * Gets the class name of the material
  129803. * @returns "BackgroundMaterial"
  129804. */
  129805. getClassName(): string;
  129806. /**
  129807. * Parse a JSON input to create back a background material.
  129808. * @param source The JSON data to parse
  129809. * @param scene The scene to create the parsed material in
  129810. * @param rootUrl The root url of the assets the material depends upon
  129811. * @returns the instantiated BackgroundMaterial.
  129812. */
  129813. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  129814. }
  129815. }
  129816. declare module BABYLON {
  129817. /**
  129818. * Represents the different options available during the creation of
  129819. * a Environment helper.
  129820. *
  129821. * This can control the default ground, skybox and image processing setup of your scene.
  129822. */
  129823. export interface IEnvironmentHelperOptions {
  129824. /**
  129825. * Specifies whether or not to create a ground.
  129826. * True by default.
  129827. */
  129828. createGround: boolean;
  129829. /**
  129830. * Specifies the ground size.
  129831. * 15 by default.
  129832. */
  129833. groundSize: number;
  129834. /**
  129835. * The texture used on the ground for the main color.
  129836. * Comes from the BabylonJS CDN by default.
  129837. *
  129838. * Remarks: Can be either a texture or a url.
  129839. */
  129840. groundTexture: string | BaseTexture;
  129841. /**
  129842. * The color mixed in the ground texture by default.
  129843. * BabylonJS clearColor by default.
  129844. */
  129845. groundColor: Color3;
  129846. /**
  129847. * Specifies the ground opacity.
  129848. * 1 by default.
  129849. */
  129850. groundOpacity: number;
  129851. /**
  129852. * Enables the ground to receive shadows.
  129853. * True by default.
  129854. */
  129855. enableGroundShadow: boolean;
  129856. /**
  129857. * Helps preventing the shadow to be fully black on the ground.
  129858. * 0.5 by default.
  129859. */
  129860. groundShadowLevel: number;
  129861. /**
  129862. * Creates a mirror texture attach to the ground.
  129863. * false by default.
  129864. */
  129865. enableGroundMirror: boolean;
  129866. /**
  129867. * Specifies the ground mirror size ratio.
  129868. * 0.3 by default as the default kernel is 64.
  129869. */
  129870. groundMirrorSizeRatio: number;
  129871. /**
  129872. * Specifies the ground mirror blur kernel size.
  129873. * 64 by default.
  129874. */
  129875. groundMirrorBlurKernel: number;
  129876. /**
  129877. * Specifies the ground mirror visibility amount.
  129878. * 1 by default
  129879. */
  129880. groundMirrorAmount: number;
  129881. /**
  129882. * Specifies the ground mirror reflectance weight.
  129883. * This uses the standard weight of the background material to setup the fresnel effect
  129884. * of the mirror.
  129885. * 1 by default.
  129886. */
  129887. groundMirrorFresnelWeight: number;
  129888. /**
  129889. * Specifies the ground mirror Falloff distance.
  129890. * This can helps reducing the size of the reflection.
  129891. * 0 by Default.
  129892. */
  129893. groundMirrorFallOffDistance: number;
  129894. /**
  129895. * Specifies the ground mirror texture type.
  129896. * Unsigned Int by Default.
  129897. */
  129898. groundMirrorTextureType: number;
  129899. /**
  129900. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  129901. * the shown objects.
  129902. */
  129903. groundYBias: number;
  129904. /**
  129905. * Specifies whether or not to create a skybox.
  129906. * True by default.
  129907. */
  129908. createSkybox: boolean;
  129909. /**
  129910. * Specifies the skybox size.
  129911. * 20 by default.
  129912. */
  129913. skyboxSize: number;
  129914. /**
  129915. * The texture used on the skybox for the main color.
  129916. * Comes from the BabylonJS CDN by default.
  129917. *
  129918. * Remarks: Can be either a texture or a url.
  129919. */
  129920. skyboxTexture: string | BaseTexture;
  129921. /**
  129922. * The color mixed in the skybox texture by default.
  129923. * BabylonJS clearColor by default.
  129924. */
  129925. skyboxColor: Color3;
  129926. /**
  129927. * The background rotation around the Y axis of the scene.
  129928. * This helps aligning the key lights of your scene with the background.
  129929. * 0 by default.
  129930. */
  129931. backgroundYRotation: number;
  129932. /**
  129933. * Compute automatically the size of the elements to best fit with the scene.
  129934. */
  129935. sizeAuto: boolean;
  129936. /**
  129937. * Default position of the rootMesh if autoSize is not true.
  129938. */
  129939. rootPosition: Vector3;
  129940. /**
  129941. * Sets up the image processing in the scene.
  129942. * true by default.
  129943. */
  129944. setupImageProcessing: boolean;
  129945. /**
  129946. * The texture used as your environment texture in the scene.
  129947. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  129948. *
  129949. * Remarks: Can be either a texture or a url.
  129950. */
  129951. environmentTexture: string | BaseTexture;
  129952. /**
  129953. * The value of the exposure to apply to the scene.
  129954. * 0.6 by default if setupImageProcessing is true.
  129955. */
  129956. cameraExposure: number;
  129957. /**
  129958. * The value of the contrast to apply to the scene.
  129959. * 1.6 by default if setupImageProcessing is true.
  129960. */
  129961. cameraContrast: number;
  129962. /**
  129963. * Specifies whether or not tonemapping should be enabled in the scene.
  129964. * true by default if setupImageProcessing is true.
  129965. */
  129966. toneMappingEnabled: boolean;
  129967. }
  129968. /**
  129969. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  129970. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  129971. * It also helps with the default setup of your imageProcessing configuration.
  129972. */
  129973. export class EnvironmentHelper {
  129974. /**
  129975. * Default ground texture URL.
  129976. */
  129977. private static _groundTextureCDNUrl;
  129978. /**
  129979. * Default skybox texture URL.
  129980. */
  129981. private static _skyboxTextureCDNUrl;
  129982. /**
  129983. * Default environment texture URL.
  129984. */
  129985. private static _environmentTextureCDNUrl;
  129986. /**
  129987. * Creates the default options for the helper.
  129988. */
  129989. private static _getDefaultOptions;
  129990. private _rootMesh;
  129991. /**
  129992. * Gets the root mesh created by the helper.
  129993. */
  129994. get rootMesh(): Mesh;
  129995. private _skybox;
  129996. /**
  129997. * Gets the skybox created by the helper.
  129998. */
  129999. get skybox(): Nullable<Mesh>;
  130000. private _skyboxTexture;
  130001. /**
  130002. * Gets the skybox texture created by the helper.
  130003. */
  130004. get skyboxTexture(): Nullable<BaseTexture>;
  130005. private _skyboxMaterial;
  130006. /**
  130007. * Gets the skybox material created by the helper.
  130008. */
  130009. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130010. private _ground;
  130011. /**
  130012. * Gets the ground mesh created by the helper.
  130013. */
  130014. get ground(): Nullable<Mesh>;
  130015. private _groundTexture;
  130016. /**
  130017. * Gets the ground texture created by the helper.
  130018. */
  130019. get groundTexture(): Nullable<BaseTexture>;
  130020. private _groundMirror;
  130021. /**
  130022. * Gets the ground mirror created by the helper.
  130023. */
  130024. get groundMirror(): Nullable<MirrorTexture>;
  130025. /**
  130026. * Gets the ground mirror render list to helps pushing the meshes
  130027. * you wish in the ground reflection.
  130028. */
  130029. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130030. private _groundMaterial;
  130031. /**
  130032. * Gets the ground material created by the helper.
  130033. */
  130034. get groundMaterial(): Nullable<BackgroundMaterial>;
  130035. /**
  130036. * Stores the creation options.
  130037. */
  130038. private readonly _scene;
  130039. private _options;
  130040. /**
  130041. * This observable will be notified with any error during the creation of the environment,
  130042. * mainly texture creation errors.
  130043. */
  130044. onErrorObservable: Observable<{
  130045. message?: string;
  130046. exception?: any;
  130047. }>;
  130048. /**
  130049. * constructor
  130050. * @param options Defines the options we want to customize the helper
  130051. * @param scene The scene to add the material to
  130052. */
  130053. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  130054. /**
  130055. * Updates the background according to the new options
  130056. * @param options
  130057. */
  130058. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  130059. /**
  130060. * Sets the primary color of all the available elements.
  130061. * @param color the main color to affect to the ground and the background
  130062. */
  130063. setMainColor(color: Color3): void;
  130064. /**
  130065. * Setup the image processing according to the specified options.
  130066. */
  130067. private _setupImageProcessing;
  130068. /**
  130069. * Setup the environment texture according to the specified options.
  130070. */
  130071. private _setupEnvironmentTexture;
  130072. /**
  130073. * Setup the background according to the specified options.
  130074. */
  130075. private _setupBackground;
  130076. /**
  130077. * Get the scene sizes according to the setup.
  130078. */
  130079. private _getSceneSize;
  130080. /**
  130081. * Setup the ground according to the specified options.
  130082. */
  130083. private _setupGround;
  130084. /**
  130085. * Setup the ground material according to the specified options.
  130086. */
  130087. private _setupGroundMaterial;
  130088. /**
  130089. * Setup the ground diffuse texture according to the specified options.
  130090. */
  130091. private _setupGroundDiffuseTexture;
  130092. /**
  130093. * Setup the ground mirror texture according to the specified options.
  130094. */
  130095. private _setupGroundMirrorTexture;
  130096. /**
  130097. * Setup the ground to receive the mirror texture.
  130098. */
  130099. private _setupMirrorInGroundMaterial;
  130100. /**
  130101. * Setup the skybox according to the specified options.
  130102. */
  130103. private _setupSkybox;
  130104. /**
  130105. * Setup the skybox material according to the specified options.
  130106. */
  130107. private _setupSkyboxMaterial;
  130108. /**
  130109. * Setup the skybox reflection texture according to the specified options.
  130110. */
  130111. private _setupSkyboxReflectionTexture;
  130112. private _errorHandler;
  130113. /**
  130114. * Dispose all the elements created by the Helper.
  130115. */
  130116. dispose(): void;
  130117. }
  130118. }
  130119. declare module BABYLON {
  130120. /**
  130121. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  130122. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  130123. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  130124. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  130125. */
  130126. export class PhotoDome extends TransformNode {
  130127. /**
  130128. * Define the image as a Monoscopic panoramic 360 image.
  130129. */
  130130. static readonly MODE_MONOSCOPIC: number;
  130131. /**
  130132. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130133. */
  130134. static readonly MODE_TOPBOTTOM: number;
  130135. /**
  130136. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130137. */
  130138. static readonly MODE_SIDEBYSIDE: number;
  130139. private _useDirectMapping;
  130140. /**
  130141. * The texture being displayed on the sphere
  130142. */
  130143. protected _photoTexture: Texture;
  130144. /**
  130145. * Gets or sets the texture being displayed on the sphere
  130146. */
  130147. get photoTexture(): Texture;
  130148. set photoTexture(value: Texture);
  130149. /**
  130150. * Observable raised when an error occured while loading the 360 image
  130151. */
  130152. onLoadErrorObservable: Observable<string>;
  130153. /**
  130154. * The skybox material
  130155. */
  130156. protected _material: BackgroundMaterial;
  130157. /**
  130158. * The surface used for the skybox
  130159. */
  130160. protected _mesh: Mesh;
  130161. /**
  130162. * Gets the mesh used for the skybox.
  130163. */
  130164. get mesh(): Mesh;
  130165. /**
  130166. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130167. * Also see the options.resolution property.
  130168. */
  130169. get fovMultiplier(): number;
  130170. set fovMultiplier(value: number);
  130171. private _imageMode;
  130172. /**
  130173. * Gets or set the current video mode for the video. It can be:
  130174. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  130175. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130176. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130177. */
  130178. get imageMode(): number;
  130179. set imageMode(value: number);
  130180. /**
  130181. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  130182. * @param name Element's name, child elements will append suffixes for their own names.
  130183. * @param urlsOfPhoto defines the url of the photo to display
  130184. * @param options defines an object containing optional or exposed sub element properties
  130185. * @param onError defines a callback called when an error occured while loading the texture
  130186. */
  130187. constructor(name: string, urlOfPhoto: string, options: {
  130188. resolution?: number;
  130189. size?: number;
  130190. useDirectMapping?: boolean;
  130191. faceForward?: boolean;
  130192. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  130193. private _onBeforeCameraRenderObserver;
  130194. private _changeImageMode;
  130195. /**
  130196. * Releases resources associated with this node.
  130197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  130198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  130199. */
  130200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  130201. }
  130202. }
  130203. declare module BABYLON {
  130204. /**
  130205. * Class used to host RGBD texture specific utilities
  130206. */
  130207. export class RGBDTextureTools {
  130208. /**
  130209. * Expand the RGBD Texture from RGBD to Half Float if possible.
  130210. * @param texture the texture to expand.
  130211. */
  130212. static ExpandRGBDTexture(texture: Texture): void;
  130213. }
  130214. }
  130215. declare module BABYLON {
  130216. /**
  130217. * Class used to host texture specific utilities
  130218. */
  130219. export class BRDFTextureTools {
  130220. /**
  130221. * Prevents texture cache collision
  130222. */
  130223. private static _instanceNumber;
  130224. /**
  130225. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  130226. * @param scene defines the hosting scene
  130227. * @returns the environment BRDF texture
  130228. */
  130229. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  130230. private static _environmentBRDFBase64Texture;
  130231. }
  130232. }
  130233. declare module BABYLON {
  130234. /**
  130235. * @hidden
  130236. */
  130237. export interface IMaterialClearCoatDefines {
  130238. CLEARCOAT: boolean;
  130239. CLEARCOAT_DEFAULTIOR: boolean;
  130240. CLEARCOAT_TEXTURE: boolean;
  130241. CLEARCOAT_TEXTUREDIRECTUV: number;
  130242. CLEARCOAT_BUMP: boolean;
  130243. CLEARCOAT_BUMPDIRECTUV: number;
  130244. CLEARCOAT_TINT: boolean;
  130245. CLEARCOAT_TINT_TEXTURE: boolean;
  130246. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  130247. /** @hidden */
  130248. _areTexturesDirty: boolean;
  130249. }
  130250. /**
  130251. * Define the code related to the clear coat parameters of the pbr material.
  130252. */
  130253. export class PBRClearCoatConfiguration {
  130254. /**
  130255. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130256. * The default fits with a polyurethane material.
  130257. */
  130258. private static readonly _DefaultIndexOfRefraction;
  130259. private _isEnabled;
  130260. /**
  130261. * Defines if the clear coat is enabled in the material.
  130262. */
  130263. isEnabled: boolean;
  130264. /**
  130265. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  130266. */
  130267. intensity: number;
  130268. /**
  130269. * Defines the clear coat layer roughness.
  130270. */
  130271. roughness: number;
  130272. private _indexOfRefraction;
  130273. /**
  130274. * Defines the index of refraction of the clear coat.
  130275. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130276. * The default fits with a polyurethane material.
  130277. * Changing the default value is more performance intensive.
  130278. */
  130279. indexOfRefraction: number;
  130280. private _texture;
  130281. /**
  130282. * Stores the clear coat values in a texture.
  130283. */
  130284. texture: Nullable<BaseTexture>;
  130285. private _bumpTexture;
  130286. /**
  130287. * Define the clear coat specific bump texture.
  130288. */
  130289. bumpTexture: Nullable<BaseTexture>;
  130290. private _isTintEnabled;
  130291. /**
  130292. * Defines if the clear coat tint is enabled in the material.
  130293. */
  130294. isTintEnabled: boolean;
  130295. /**
  130296. * Defines the clear coat tint of the material.
  130297. * This is only use if tint is enabled
  130298. */
  130299. tintColor: Color3;
  130300. /**
  130301. * Defines the distance at which the tint color should be found in the
  130302. * clear coat media.
  130303. * This is only use if tint is enabled
  130304. */
  130305. tintColorAtDistance: number;
  130306. /**
  130307. * Defines the clear coat layer thickness.
  130308. * This is only use if tint is enabled
  130309. */
  130310. tintThickness: number;
  130311. private _tintTexture;
  130312. /**
  130313. * Stores the clear tint values in a texture.
  130314. * rgb is tint
  130315. * a is a thickness factor
  130316. */
  130317. tintTexture: Nullable<BaseTexture>;
  130318. /** @hidden */
  130319. private _internalMarkAllSubMeshesAsTexturesDirty;
  130320. /** @hidden */
  130321. _markAllSubMeshesAsTexturesDirty(): void;
  130322. /**
  130323. * Instantiate a new istance of clear coat configuration.
  130324. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130325. */
  130326. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130327. /**
  130328. * Gets wehter the submesh is ready to be used or not.
  130329. * @param defines the list of "defines" to update.
  130330. * @param scene defines the scene the material belongs to.
  130331. * @param engine defines the engine the material belongs to.
  130332. * @param disableBumpMap defines wether the material disables bump or not.
  130333. * @returns - boolean indicating that the submesh is ready or not.
  130334. */
  130335. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  130336. /**
  130337. * Checks to see if a texture is used in the material.
  130338. * @param defines the list of "defines" to update.
  130339. * @param scene defines the scene to the material belongs to.
  130340. */
  130341. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  130342. /**
  130343. * Binds the material data.
  130344. * @param uniformBuffer defines the Uniform buffer to fill in.
  130345. * @param scene defines the scene the material belongs to.
  130346. * @param engine defines the engine the material belongs to.
  130347. * @param disableBumpMap defines wether the material disables bump or not.
  130348. * @param isFrozen defines wether the material is frozen or not.
  130349. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  130350. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  130351. */
  130352. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  130353. /**
  130354. * Checks to see if a texture is used in the material.
  130355. * @param texture - Base texture to use.
  130356. * @returns - Boolean specifying if a texture is used in the material.
  130357. */
  130358. hasTexture(texture: BaseTexture): boolean;
  130359. /**
  130360. * Returns an array of the actively used textures.
  130361. * @param activeTextures Array of BaseTextures
  130362. */
  130363. getActiveTextures(activeTextures: BaseTexture[]): void;
  130364. /**
  130365. * Returns the animatable textures.
  130366. * @param animatables Array of animatable textures.
  130367. */
  130368. getAnimatables(animatables: IAnimatable[]): void;
  130369. /**
  130370. * Disposes the resources of the material.
  130371. * @param forceDisposeTextures - Forces the disposal of all textures.
  130372. */
  130373. dispose(forceDisposeTextures?: boolean): void;
  130374. /**
  130375. * Get the current class name of the texture useful for serialization or dynamic coding.
  130376. * @returns "PBRClearCoatConfiguration"
  130377. */
  130378. getClassName(): string;
  130379. /**
  130380. * Add fallbacks to the effect fallbacks list.
  130381. * @param defines defines the Base texture to use.
  130382. * @param fallbacks defines the current fallback list.
  130383. * @param currentRank defines the current fallback rank.
  130384. * @returns the new fallback rank.
  130385. */
  130386. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130387. /**
  130388. * Add the required uniforms to the current list.
  130389. * @param uniforms defines the current uniform list.
  130390. */
  130391. static AddUniforms(uniforms: string[]): void;
  130392. /**
  130393. * Add the required samplers to the current list.
  130394. * @param samplers defines the current sampler list.
  130395. */
  130396. static AddSamplers(samplers: string[]): void;
  130397. /**
  130398. * Add the required uniforms to the current buffer.
  130399. * @param uniformBuffer defines the current uniform buffer.
  130400. */
  130401. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130402. /**
  130403. * Makes a duplicate of the current configuration into another one.
  130404. * @param clearCoatConfiguration define the config where to copy the info
  130405. */
  130406. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  130407. /**
  130408. * Serializes this clear coat configuration.
  130409. * @returns - An object with the serialized config.
  130410. */
  130411. serialize(): any;
  130412. /**
  130413. * Parses a anisotropy Configuration from a serialized object.
  130414. * @param source - Serialized object.
  130415. * @param scene Defines the scene we are parsing for
  130416. * @param rootUrl Defines the rootUrl to load from
  130417. */
  130418. parse(source: any, scene: Scene, rootUrl: string): void;
  130419. }
  130420. }
  130421. declare module BABYLON {
  130422. /**
  130423. * @hidden
  130424. */
  130425. export interface IMaterialAnisotropicDefines {
  130426. ANISOTROPIC: boolean;
  130427. ANISOTROPIC_TEXTURE: boolean;
  130428. ANISOTROPIC_TEXTUREDIRECTUV: number;
  130429. MAINUV1: boolean;
  130430. _areTexturesDirty: boolean;
  130431. _needUVs: boolean;
  130432. }
  130433. /**
  130434. * Define the code related to the anisotropic parameters of the pbr material.
  130435. */
  130436. export class PBRAnisotropicConfiguration {
  130437. private _isEnabled;
  130438. /**
  130439. * Defines if the anisotropy is enabled in the material.
  130440. */
  130441. isEnabled: boolean;
  130442. /**
  130443. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  130444. */
  130445. intensity: number;
  130446. /**
  130447. * Defines if the effect is along the tangents, bitangents or in between.
  130448. * By default, the effect is "strectching" the highlights along the tangents.
  130449. */
  130450. direction: Vector2;
  130451. private _texture;
  130452. /**
  130453. * Stores the anisotropy values in a texture.
  130454. * rg is direction (like normal from -1 to 1)
  130455. * b is a intensity
  130456. */
  130457. texture: Nullable<BaseTexture>;
  130458. /** @hidden */
  130459. private _internalMarkAllSubMeshesAsTexturesDirty;
  130460. /** @hidden */
  130461. _markAllSubMeshesAsTexturesDirty(): void;
  130462. /**
  130463. * Instantiate a new istance of anisotropy configuration.
  130464. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130465. */
  130466. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130467. /**
  130468. * Specifies that the submesh is ready to be used.
  130469. * @param defines the list of "defines" to update.
  130470. * @param scene defines the scene the material belongs to.
  130471. * @returns - boolean indicating that the submesh is ready or not.
  130472. */
  130473. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  130474. /**
  130475. * Checks to see if a texture is used in the material.
  130476. * @param defines the list of "defines" to update.
  130477. * @param mesh the mesh we are preparing the defines for.
  130478. * @param scene defines the scene the material belongs to.
  130479. */
  130480. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  130481. /**
  130482. * Binds the material data.
  130483. * @param uniformBuffer defines the Uniform buffer to fill in.
  130484. * @param scene defines the scene the material belongs to.
  130485. * @param isFrozen defines wether the material is frozen or not.
  130486. */
  130487. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130488. /**
  130489. * Checks to see if a texture is used in the material.
  130490. * @param texture - Base texture to use.
  130491. * @returns - Boolean specifying if a texture is used in the material.
  130492. */
  130493. hasTexture(texture: BaseTexture): boolean;
  130494. /**
  130495. * Returns an array of the actively used textures.
  130496. * @param activeTextures Array of BaseTextures
  130497. */
  130498. getActiveTextures(activeTextures: BaseTexture[]): void;
  130499. /**
  130500. * Returns the animatable textures.
  130501. * @param animatables Array of animatable textures.
  130502. */
  130503. getAnimatables(animatables: IAnimatable[]): void;
  130504. /**
  130505. * Disposes the resources of the material.
  130506. * @param forceDisposeTextures - Forces the disposal of all textures.
  130507. */
  130508. dispose(forceDisposeTextures?: boolean): void;
  130509. /**
  130510. * Get the current class name of the texture useful for serialization or dynamic coding.
  130511. * @returns "PBRAnisotropicConfiguration"
  130512. */
  130513. getClassName(): string;
  130514. /**
  130515. * Add fallbacks to the effect fallbacks list.
  130516. * @param defines defines the Base texture to use.
  130517. * @param fallbacks defines the current fallback list.
  130518. * @param currentRank defines the current fallback rank.
  130519. * @returns the new fallback rank.
  130520. */
  130521. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130522. /**
  130523. * Add the required uniforms to the current list.
  130524. * @param uniforms defines the current uniform list.
  130525. */
  130526. static AddUniforms(uniforms: string[]): void;
  130527. /**
  130528. * Add the required uniforms to the current buffer.
  130529. * @param uniformBuffer defines the current uniform buffer.
  130530. */
  130531. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130532. /**
  130533. * Add the required samplers to the current list.
  130534. * @param samplers defines the current sampler list.
  130535. */
  130536. static AddSamplers(samplers: string[]): void;
  130537. /**
  130538. * Makes a duplicate of the current configuration into another one.
  130539. * @param anisotropicConfiguration define the config where to copy the info
  130540. */
  130541. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  130542. /**
  130543. * Serializes this anisotropy configuration.
  130544. * @returns - An object with the serialized config.
  130545. */
  130546. serialize(): any;
  130547. /**
  130548. * Parses a anisotropy Configuration from a serialized object.
  130549. * @param source - Serialized object.
  130550. * @param scene Defines the scene we are parsing for
  130551. * @param rootUrl Defines the rootUrl to load from
  130552. */
  130553. parse(source: any, scene: Scene, rootUrl: string): void;
  130554. }
  130555. }
  130556. declare module BABYLON {
  130557. /**
  130558. * @hidden
  130559. */
  130560. export interface IMaterialBRDFDefines {
  130561. BRDF_V_HEIGHT_CORRELATED: boolean;
  130562. MS_BRDF_ENERGY_CONSERVATION: boolean;
  130563. SPHERICAL_HARMONICS: boolean;
  130564. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  130565. /** @hidden */
  130566. _areMiscDirty: boolean;
  130567. }
  130568. /**
  130569. * Define the code related to the BRDF parameters of the pbr material.
  130570. */
  130571. export class PBRBRDFConfiguration {
  130572. /**
  130573. * Default value used for the energy conservation.
  130574. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130575. */
  130576. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  130577. /**
  130578. * Default value used for the Smith Visibility Height Correlated mode.
  130579. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130580. */
  130581. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  130582. /**
  130583. * Default value used for the IBL diffuse part.
  130584. * This can help switching back to the polynomials mode globally which is a tiny bit
  130585. * less GPU intensive at the drawback of a lower quality.
  130586. */
  130587. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  130588. /**
  130589. * Default value used for activating energy conservation for the specular workflow.
  130590. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130591. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130592. */
  130593. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  130594. private _useEnergyConservation;
  130595. /**
  130596. * Defines if the material uses energy conservation.
  130597. */
  130598. useEnergyConservation: boolean;
  130599. private _useSmithVisibilityHeightCorrelated;
  130600. /**
  130601. * LEGACY Mode set to false
  130602. * Defines if the material uses height smith correlated visibility term.
  130603. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  130604. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  130605. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  130606. * Not relying on height correlated will also disable energy conservation.
  130607. */
  130608. useSmithVisibilityHeightCorrelated: boolean;
  130609. private _useSphericalHarmonics;
  130610. /**
  130611. * LEGACY Mode set to false
  130612. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  130613. * diffuse part of the IBL.
  130614. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  130615. * to the ground truth.
  130616. */
  130617. useSphericalHarmonics: boolean;
  130618. private _useSpecularGlossinessInputEnergyConservation;
  130619. /**
  130620. * Defines if the material uses energy conservation, when the specular workflow is active.
  130621. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130622. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130623. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  130624. */
  130625. useSpecularGlossinessInputEnergyConservation: boolean;
  130626. /** @hidden */
  130627. private _internalMarkAllSubMeshesAsMiscDirty;
  130628. /** @hidden */
  130629. _markAllSubMeshesAsMiscDirty(): void;
  130630. /**
  130631. * Instantiate a new istance of clear coat configuration.
  130632. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  130633. */
  130634. constructor(markAllSubMeshesAsMiscDirty: () => void);
  130635. /**
  130636. * Checks to see if a texture is used in the material.
  130637. * @param defines the list of "defines" to update.
  130638. */
  130639. prepareDefines(defines: IMaterialBRDFDefines): void;
  130640. /**
  130641. * Get the current class name of the texture useful for serialization or dynamic coding.
  130642. * @returns "PBRClearCoatConfiguration"
  130643. */
  130644. getClassName(): string;
  130645. /**
  130646. * Makes a duplicate of the current configuration into another one.
  130647. * @param brdfConfiguration define the config where to copy the info
  130648. */
  130649. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  130650. /**
  130651. * Serializes this BRDF configuration.
  130652. * @returns - An object with the serialized config.
  130653. */
  130654. serialize(): any;
  130655. /**
  130656. * Parses a anisotropy Configuration from a serialized object.
  130657. * @param source - Serialized object.
  130658. * @param scene Defines the scene we are parsing for
  130659. * @param rootUrl Defines the rootUrl to load from
  130660. */
  130661. parse(source: any, scene: Scene, rootUrl: string): void;
  130662. }
  130663. }
  130664. declare module BABYLON {
  130665. /**
  130666. * @hidden
  130667. */
  130668. export interface IMaterialSheenDefines {
  130669. SHEEN: boolean;
  130670. SHEEN_TEXTURE: boolean;
  130671. SHEEN_TEXTUREDIRECTUV: number;
  130672. SHEEN_LINKWITHALBEDO: boolean;
  130673. SHEEN_ROUGHNESS: boolean;
  130674. SHEEN_ALBEDOSCALING: boolean;
  130675. /** @hidden */
  130676. _areTexturesDirty: boolean;
  130677. }
  130678. /**
  130679. * Define the code related to the Sheen parameters of the pbr material.
  130680. */
  130681. export class PBRSheenConfiguration {
  130682. private _isEnabled;
  130683. /**
  130684. * Defines if the material uses sheen.
  130685. */
  130686. isEnabled: boolean;
  130687. private _linkSheenWithAlbedo;
  130688. /**
  130689. * Defines if the sheen is linked to the sheen color.
  130690. */
  130691. linkSheenWithAlbedo: boolean;
  130692. /**
  130693. * Defines the sheen intensity.
  130694. */
  130695. intensity: number;
  130696. /**
  130697. * Defines the sheen color.
  130698. */
  130699. color: Color3;
  130700. private _texture;
  130701. /**
  130702. * Stores the sheen tint values in a texture.
  130703. * rgb is tint
  130704. * a is a intensity
  130705. */
  130706. texture: Nullable<BaseTexture>;
  130707. private _roughness;
  130708. /**
  130709. * Defines the sheen roughness.
  130710. * It is not taken into account if linkSheenWithAlbedo is true.
  130711. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  130712. */
  130713. roughness: Nullable<number>;
  130714. private _albedoScaling;
  130715. /**
  130716. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  130717. * It allows the strength of the sheen effect to not depend on the base color of the material,
  130718. * making it easier to setup and tweak the effect
  130719. */
  130720. albedoScaling: boolean;
  130721. /** @hidden */
  130722. private _internalMarkAllSubMeshesAsTexturesDirty;
  130723. /** @hidden */
  130724. _markAllSubMeshesAsTexturesDirty(): void;
  130725. /**
  130726. * Instantiate a new istance of clear coat configuration.
  130727. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130728. */
  130729. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130730. /**
  130731. * Specifies that the submesh is ready to be used.
  130732. * @param defines the list of "defines" to update.
  130733. * @param scene defines the scene the material belongs to.
  130734. * @returns - boolean indicating that the submesh is ready or not.
  130735. */
  130736. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  130737. /**
  130738. * Checks to see if a texture is used in the material.
  130739. * @param defines the list of "defines" to update.
  130740. * @param scene defines the scene the material belongs to.
  130741. */
  130742. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  130743. /**
  130744. * Binds the material data.
  130745. * @param uniformBuffer defines the Uniform buffer to fill in.
  130746. * @param scene defines the scene the material belongs to.
  130747. * @param isFrozen defines wether the material is frozen or not.
  130748. */
  130749. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130750. /**
  130751. * Checks to see if a texture is used in the material.
  130752. * @param texture - Base texture to use.
  130753. * @returns - Boolean specifying if a texture is used in the material.
  130754. */
  130755. hasTexture(texture: BaseTexture): boolean;
  130756. /**
  130757. * Returns an array of the actively used textures.
  130758. * @param activeTextures Array of BaseTextures
  130759. */
  130760. getActiveTextures(activeTextures: BaseTexture[]): void;
  130761. /**
  130762. * Returns the animatable textures.
  130763. * @param animatables Array of animatable textures.
  130764. */
  130765. getAnimatables(animatables: IAnimatable[]): void;
  130766. /**
  130767. * Disposes the resources of the material.
  130768. * @param forceDisposeTextures - Forces the disposal of all textures.
  130769. */
  130770. dispose(forceDisposeTextures?: boolean): void;
  130771. /**
  130772. * Get the current class name of the texture useful for serialization or dynamic coding.
  130773. * @returns "PBRSheenConfiguration"
  130774. */
  130775. getClassName(): string;
  130776. /**
  130777. * Add fallbacks to the effect fallbacks list.
  130778. * @param defines defines the Base texture to use.
  130779. * @param fallbacks defines the current fallback list.
  130780. * @param currentRank defines the current fallback rank.
  130781. * @returns the new fallback rank.
  130782. */
  130783. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130784. /**
  130785. * Add the required uniforms to the current list.
  130786. * @param uniforms defines the current uniform list.
  130787. */
  130788. static AddUniforms(uniforms: string[]): void;
  130789. /**
  130790. * Add the required uniforms to the current buffer.
  130791. * @param uniformBuffer defines the current uniform buffer.
  130792. */
  130793. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130794. /**
  130795. * Add the required samplers to the current list.
  130796. * @param samplers defines the current sampler list.
  130797. */
  130798. static AddSamplers(samplers: string[]): void;
  130799. /**
  130800. * Makes a duplicate of the current configuration into another one.
  130801. * @param sheenConfiguration define the config where to copy the info
  130802. */
  130803. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  130804. /**
  130805. * Serializes this BRDF configuration.
  130806. * @returns - An object with the serialized config.
  130807. */
  130808. serialize(): any;
  130809. /**
  130810. * Parses a anisotropy Configuration from a serialized object.
  130811. * @param source - Serialized object.
  130812. * @param scene Defines the scene we are parsing for
  130813. * @param rootUrl Defines the rootUrl to load from
  130814. */
  130815. parse(source: any, scene: Scene, rootUrl: string): void;
  130816. }
  130817. }
  130818. declare module BABYLON {
  130819. /**
  130820. * @hidden
  130821. */
  130822. export interface IMaterialSubSurfaceDefines {
  130823. SUBSURFACE: boolean;
  130824. SS_REFRACTION: boolean;
  130825. SS_TRANSLUCENCY: boolean;
  130826. SS_SCATERRING: boolean;
  130827. SS_THICKNESSANDMASK_TEXTURE: boolean;
  130828. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  130829. SS_REFRACTIONMAP_3D: boolean;
  130830. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  130831. SS_LODINREFRACTIONALPHA: boolean;
  130832. SS_GAMMAREFRACTION: boolean;
  130833. SS_RGBDREFRACTION: boolean;
  130834. SS_LINEARSPECULARREFRACTION: boolean;
  130835. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  130836. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  130837. /** @hidden */
  130838. _areTexturesDirty: boolean;
  130839. }
  130840. /**
  130841. * Define the code related to the sub surface parameters of the pbr material.
  130842. */
  130843. export class PBRSubSurfaceConfiguration {
  130844. private _isRefractionEnabled;
  130845. /**
  130846. * Defines if the refraction is enabled in the material.
  130847. */
  130848. isRefractionEnabled: boolean;
  130849. private _isTranslucencyEnabled;
  130850. /**
  130851. * Defines if the translucency is enabled in the material.
  130852. */
  130853. isTranslucencyEnabled: boolean;
  130854. private _isScatteringEnabled;
  130855. /**
  130856. * Defines the refraction intensity of the material.
  130857. * The refraction when enabled replaces the Diffuse part of the material.
  130858. * The intensity helps transitionning between diffuse and refraction.
  130859. */
  130860. refractionIntensity: number;
  130861. /**
  130862. * Defines the translucency intensity of the material.
  130863. * When translucency has been enabled, this defines how much of the "translucency"
  130864. * is addded to the diffuse part of the material.
  130865. */
  130866. translucencyIntensity: number;
  130867. /**
  130868. * Defines the scattering intensity of the material.
  130869. * When scattering has been enabled, this defines how much of the "scattered light"
  130870. * is addded to the diffuse part of the material.
  130871. */
  130872. scatteringIntensity: number;
  130873. private _thicknessTexture;
  130874. /**
  130875. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  130876. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  130877. * 0 would mean minimumThickness
  130878. * 1 would mean maximumThickness
  130879. * The other channels might be use as a mask to vary the different effects intensity.
  130880. */
  130881. thicknessTexture: Nullable<BaseTexture>;
  130882. private _refractionTexture;
  130883. /**
  130884. * Defines the texture to use for refraction.
  130885. */
  130886. refractionTexture: Nullable<BaseTexture>;
  130887. private _indexOfRefraction;
  130888. /**
  130889. * Index of refraction of the material base layer.
  130890. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  130891. *
  130892. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  130893. *
  130894. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  130895. */
  130896. indexOfRefraction: number;
  130897. private _invertRefractionY;
  130898. /**
  130899. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  130900. */
  130901. invertRefractionY: boolean;
  130902. private _linkRefractionWithTransparency;
  130903. /**
  130904. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  130905. * Materials half opaque for instance using refraction could benefit from this control.
  130906. */
  130907. linkRefractionWithTransparency: boolean;
  130908. /**
  130909. * Defines the minimum thickness stored in the thickness map.
  130910. * If no thickness map is defined, this value will be used to simulate thickness.
  130911. */
  130912. minimumThickness: number;
  130913. /**
  130914. * Defines the maximum thickness stored in the thickness map.
  130915. */
  130916. maximumThickness: number;
  130917. /**
  130918. * Defines the volume tint of the material.
  130919. * This is used for both translucency and scattering.
  130920. */
  130921. tintColor: Color3;
  130922. /**
  130923. * Defines the distance at which the tint color should be found in the media.
  130924. * This is used for refraction only.
  130925. */
  130926. tintColorAtDistance: number;
  130927. /**
  130928. * Defines how far each channel transmit through the media.
  130929. * It is defined as a color to simplify it selection.
  130930. */
  130931. diffusionDistance: Color3;
  130932. private _useMaskFromThicknessTexture;
  130933. /**
  130934. * Stores the intensity of the different subsurface effects in the thickness texture.
  130935. * * the green channel is the translucency intensity.
  130936. * * the blue channel is the scattering intensity.
  130937. * * the alpha channel is the refraction intensity.
  130938. */
  130939. useMaskFromThicknessTexture: boolean;
  130940. /** @hidden */
  130941. private _internalMarkAllSubMeshesAsTexturesDirty;
  130942. /** @hidden */
  130943. _markAllSubMeshesAsTexturesDirty(): void;
  130944. /**
  130945. * Instantiate a new istance of sub surface configuration.
  130946. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130947. */
  130948. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130949. /**
  130950. * Gets wehter the submesh is ready to be used or not.
  130951. * @param defines the list of "defines" to update.
  130952. * @param scene defines the scene the material belongs to.
  130953. * @returns - boolean indicating that the submesh is ready or not.
  130954. */
  130955. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  130956. /**
  130957. * Checks to see if a texture is used in the material.
  130958. * @param defines the list of "defines" to update.
  130959. * @param scene defines the scene to the material belongs to.
  130960. */
  130961. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  130962. /**
  130963. * Binds the material data.
  130964. * @param uniformBuffer defines the Uniform buffer to fill in.
  130965. * @param scene defines the scene the material belongs to.
  130966. * @param engine defines the engine the material belongs to.
  130967. * @param isFrozen defines wether the material is frozen or not.
  130968. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  130969. */
  130970. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  130971. /**
  130972. * Unbinds the material from the mesh.
  130973. * @param activeEffect defines the effect that should be unbound from.
  130974. * @returns true if unbound, otherwise false
  130975. */
  130976. unbind(activeEffect: Effect): boolean;
  130977. /**
  130978. * Returns the texture used for refraction or null if none is used.
  130979. * @param scene defines the scene the material belongs to.
  130980. * @returns - Refraction texture if present. If no refraction texture and refraction
  130981. * is linked with transparency, returns environment texture. Otherwise, returns null.
  130982. */
  130983. private _getRefractionTexture;
  130984. /**
  130985. * Returns true if alpha blending should be disabled.
  130986. */
  130987. get disableAlphaBlending(): boolean;
  130988. /**
  130989. * Fills the list of render target textures.
  130990. * @param renderTargets the list of render targets to update
  130991. */
  130992. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  130993. /**
  130994. * Checks to see if a texture is used in the material.
  130995. * @param texture - Base texture to use.
  130996. * @returns - Boolean specifying if a texture is used in the material.
  130997. */
  130998. hasTexture(texture: BaseTexture): boolean;
  130999. /**
  131000. * Gets a boolean indicating that current material needs to register RTT
  131001. * @returns true if this uses a render target otherwise false.
  131002. */
  131003. hasRenderTargetTextures(): boolean;
  131004. /**
  131005. * Returns an array of the actively used textures.
  131006. * @param activeTextures Array of BaseTextures
  131007. */
  131008. getActiveTextures(activeTextures: BaseTexture[]): void;
  131009. /**
  131010. * Returns the animatable textures.
  131011. * @param animatables Array of animatable textures.
  131012. */
  131013. getAnimatables(animatables: IAnimatable[]): void;
  131014. /**
  131015. * Disposes the resources of the material.
  131016. * @param forceDisposeTextures - Forces the disposal of all textures.
  131017. */
  131018. dispose(forceDisposeTextures?: boolean): void;
  131019. /**
  131020. * Get the current class name of the texture useful for serialization or dynamic coding.
  131021. * @returns "PBRSubSurfaceConfiguration"
  131022. */
  131023. getClassName(): string;
  131024. /**
  131025. * Add fallbacks to the effect fallbacks list.
  131026. * @param defines defines the Base texture to use.
  131027. * @param fallbacks defines the current fallback list.
  131028. * @param currentRank defines the current fallback rank.
  131029. * @returns the new fallback rank.
  131030. */
  131031. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131032. /**
  131033. * Add the required uniforms to the current list.
  131034. * @param uniforms defines the current uniform list.
  131035. */
  131036. static AddUniforms(uniforms: string[]): void;
  131037. /**
  131038. * Add the required samplers to the current list.
  131039. * @param samplers defines the current sampler list.
  131040. */
  131041. static AddSamplers(samplers: string[]): void;
  131042. /**
  131043. * Add the required uniforms to the current buffer.
  131044. * @param uniformBuffer defines the current uniform buffer.
  131045. */
  131046. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131047. /**
  131048. * Makes a duplicate of the current configuration into another one.
  131049. * @param configuration define the config where to copy the info
  131050. */
  131051. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  131052. /**
  131053. * Serializes this Sub Surface configuration.
  131054. * @returns - An object with the serialized config.
  131055. */
  131056. serialize(): any;
  131057. /**
  131058. * Parses a anisotropy Configuration from a serialized object.
  131059. * @param source - Serialized object.
  131060. * @param scene Defines the scene we are parsing for
  131061. * @param rootUrl Defines the rootUrl to load from
  131062. */
  131063. parse(source: any, scene: Scene, rootUrl: string): void;
  131064. }
  131065. }
  131066. declare module BABYLON {
  131067. /** @hidden */
  131068. export var pbrFragmentDeclaration: {
  131069. name: string;
  131070. shader: string;
  131071. };
  131072. }
  131073. declare module BABYLON {
  131074. /** @hidden */
  131075. export var pbrUboDeclaration: {
  131076. name: string;
  131077. shader: string;
  131078. };
  131079. }
  131080. declare module BABYLON {
  131081. /** @hidden */
  131082. export var pbrFragmentExtraDeclaration: {
  131083. name: string;
  131084. shader: string;
  131085. };
  131086. }
  131087. declare module BABYLON {
  131088. /** @hidden */
  131089. export var pbrFragmentSamplersDeclaration: {
  131090. name: string;
  131091. shader: string;
  131092. };
  131093. }
  131094. declare module BABYLON {
  131095. /** @hidden */
  131096. export var importanceSampling: {
  131097. name: string;
  131098. shader: string;
  131099. };
  131100. }
  131101. declare module BABYLON {
  131102. /** @hidden */
  131103. export var pbrHelperFunctions: {
  131104. name: string;
  131105. shader: string;
  131106. };
  131107. }
  131108. declare module BABYLON {
  131109. /** @hidden */
  131110. export var harmonicsFunctions: {
  131111. name: string;
  131112. shader: string;
  131113. };
  131114. }
  131115. declare module BABYLON {
  131116. /** @hidden */
  131117. export var pbrDirectLightingSetupFunctions: {
  131118. name: string;
  131119. shader: string;
  131120. };
  131121. }
  131122. declare module BABYLON {
  131123. /** @hidden */
  131124. export var pbrDirectLightingFalloffFunctions: {
  131125. name: string;
  131126. shader: string;
  131127. };
  131128. }
  131129. declare module BABYLON {
  131130. /** @hidden */
  131131. export var pbrBRDFFunctions: {
  131132. name: string;
  131133. shader: string;
  131134. };
  131135. }
  131136. declare module BABYLON {
  131137. /** @hidden */
  131138. export var hdrFilteringFunctions: {
  131139. name: string;
  131140. shader: string;
  131141. };
  131142. }
  131143. declare module BABYLON {
  131144. /** @hidden */
  131145. export var pbrDirectLightingFunctions: {
  131146. name: string;
  131147. shader: string;
  131148. };
  131149. }
  131150. declare module BABYLON {
  131151. /** @hidden */
  131152. export var pbrIBLFunctions: {
  131153. name: string;
  131154. shader: string;
  131155. };
  131156. }
  131157. declare module BABYLON {
  131158. /** @hidden */
  131159. export var pbrBlockAlbedoOpacity: {
  131160. name: string;
  131161. shader: string;
  131162. };
  131163. }
  131164. declare module BABYLON {
  131165. /** @hidden */
  131166. export var pbrBlockReflectivity: {
  131167. name: string;
  131168. shader: string;
  131169. };
  131170. }
  131171. declare module BABYLON {
  131172. /** @hidden */
  131173. export var pbrBlockAmbientOcclusion: {
  131174. name: string;
  131175. shader: string;
  131176. };
  131177. }
  131178. declare module BABYLON {
  131179. /** @hidden */
  131180. export var pbrBlockAlphaFresnel: {
  131181. name: string;
  131182. shader: string;
  131183. };
  131184. }
  131185. declare module BABYLON {
  131186. /** @hidden */
  131187. export var pbrBlockAnisotropic: {
  131188. name: string;
  131189. shader: string;
  131190. };
  131191. }
  131192. declare module BABYLON {
  131193. /** @hidden */
  131194. export var pbrBlockReflection: {
  131195. name: string;
  131196. shader: string;
  131197. };
  131198. }
  131199. declare module BABYLON {
  131200. /** @hidden */
  131201. export var pbrBlockSheen: {
  131202. name: string;
  131203. shader: string;
  131204. };
  131205. }
  131206. declare module BABYLON {
  131207. /** @hidden */
  131208. export var pbrBlockClearcoat: {
  131209. name: string;
  131210. shader: string;
  131211. };
  131212. }
  131213. declare module BABYLON {
  131214. /** @hidden */
  131215. export var pbrBlockSubSurface: {
  131216. name: string;
  131217. shader: string;
  131218. };
  131219. }
  131220. declare module BABYLON {
  131221. /** @hidden */
  131222. export var pbrBlockNormalGeometric: {
  131223. name: string;
  131224. shader: string;
  131225. };
  131226. }
  131227. declare module BABYLON {
  131228. /** @hidden */
  131229. export var pbrBlockNormalFinal: {
  131230. name: string;
  131231. shader: string;
  131232. };
  131233. }
  131234. declare module BABYLON {
  131235. /** @hidden */
  131236. export var pbrBlockGeometryInfo: {
  131237. name: string;
  131238. shader: string;
  131239. };
  131240. }
  131241. declare module BABYLON {
  131242. /** @hidden */
  131243. export var pbrBlockReflectance0: {
  131244. name: string;
  131245. shader: string;
  131246. };
  131247. }
  131248. declare module BABYLON {
  131249. /** @hidden */
  131250. export var pbrBlockReflectance: {
  131251. name: string;
  131252. shader: string;
  131253. };
  131254. }
  131255. declare module BABYLON {
  131256. /** @hidden */
  131257. export var pbrBlockDirectLighting: {
  131258. name: string;
  131259. shader: string;
  131260. };
  131261. }
  131262. declare module BABYLON {
  131263. /** @hidden */
  131264. export var pbrBlockFinalLitComponents: {
  131265. name: string;
  131266. shader: string;
  131267. };
  131268. }
  131269. declare module BABYLON {
  131270. /** @hidden */
  131271. export var pbrBlockFinalUnlitComponents: {
  131272. name: string;
  131273. shader: string;
  131274. };
  131275. }
  131276. declare module BABYLON {
  131277. /** @hidden */
  131278. export var pbrBlockFinalColorComposition: {
  131279. name: string;
  131280. shader: string;
  131281. };
  131282. }
  131283. declare module BABYLON {
  131284. /** @hidden */
  131285. export var pbrBlockImageProcessing: {
  131286. name: string;
  131287. shader: string;
  131288. };
  131289. }
  131290. declare module BABYLON {
  131291. /** @hidden */
  131292. export var pbrDebug: {
  131293. name: string;
  131294. shader: string;
  131295. };
  131296. }
  131297. declare module BABYLON {
  131298. /** @hidden */
  131299. export var pbrPixelShader: {
  131300. name: string;
  131301. shader: string;
  131302. };
  131303. }
  131304. declare module BABYLON {
  131305. /** @hidden */
  131306. export var pbrVertexDeclaration: {
  131307. name: string;
  131308. shader: string;
  131309. };
  131310. }
  131311. declare module BABYLON {
  131312. /** @hidden */
  131313. export var pbrVertexShader: {
  131314. name: string;
  131315. shader: string;
  131316. };
  131317. }
  131318. declare module BABYLON {
  131319. /**
  131320. * Manages the defines for the PBR Material.
  131321. * @hidden
  131322. */
  131323. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  131324. PBR: boolean;
  131325. NUM_SAMPLES: string;
  131326. REALTIME_FILTERING: boolean;
  131327. MAINUV1: boolean;
  131328. MAINUV2: boolean;
  131329. UV1: boolean;
  131330. UV2: boolean;
  131331. ALBEDO: boolean;
  131332. GAMMAALBEDO: boolean;
  131333. ALBEDODIRECTUV: number;
  131334. VERTEXCOLOR: boolean;
  131335. AMBIENT: boolean;
  131336. AMBIENTDIRECTUV: number;
  131337. AMBIENTINGRAYSCALE: boolean;
  131338. OPACITY: boolean;
  131339. VERTEXALPHA: boolean;
  131340. OPACITYDIRECTUV: number;
  131341. OPACITYRGB: boolean;
  131342. ALPHATEST: boolean;
  131343. DEPTHPREPASS: boolean;
  131344. ALPHABLEND: boolean;
  131345. ALPHAFROMALBEDO: boolean;
  131346. ALPHATESTVALUE: string;
  131347. SPECULAROVERALPHA: boolean;
  131348. RADIANCEOVERALPHA: boolean;
  131349. ALPHAFRESNEL: boolean;
  131350. LINEARALPHAFRESNEL: boolean;
  131351. PREMULTIPLYALPHA: boolean;
  131352. EMISSIVE: boolean;
  131353. EMISSIVEDIRECTUV: number;
  131354. REFLECTIVITY: boolean;
  131355. REFLECTIVITYDIRECTUV: number;
  131356. SPECULARTERM: boolean;
  131357. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  131358. MICROSURFACEAUTOMATIC: boolean;
  131359. LODBASEDMICROSFURACE: boolean;
  131360. MICROSURFACEMAP: boolean;
  131361. MICROSURFACEMAPDIRECTUV: number;
  131362. METALLICWORKFLOW: boolean;
  131363. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  131364. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  131365. METALLNESSSTOREINMETALMAPBLUE: boolean;
  131366. AOSTOREINMETALMAPRED: boolean;
  131367. METALLIC_REFLECTANCE: boolean;
  131368. METALLIC_REFLECTANCEDIRECTUV: number;
  131369. ENVIRONMENTBRDF: boolean;
  131370. ENVIRONMENTBRDF_RGBD: boolean;
  131371. NORMAL: boolean;
  131372. TANGENT: boolean;
  131373. BUMP: boolean;
  131374. BUMPDIRECTUV: number;
  131375. OBJECTSPACE_NORMALMAP: boolean;
  131376. PARALLAX: boolean;
  131377. PARALLAXOCCLUSION: boolean;
  131378. NORMALXYSCALE: boolean;
  131379. LIGHTMAP: boolean;
  131380. LIGHTMAPDIRECTUV: number;
  131381. USELIGHTMAPASSHADOWMAP: boolean;
  131382. GAMMALIGHTMAP: boolean;
  131383. RGBDLIGHTMAP: boolean;
  131384. REFLECTION: boolean;
  131385. REFLECTIONMAP_3D: boolean;
  131386. REFLECTIONMAP_SPHERICAL: boolean;
  131387. REFLECTIONMAP_PLANAR: boolean;
  131388. REFLECTIONMAP_CUBIC: boolean;
  131389. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  131390. REFLECTIONMAP_PROJECTION: boolean;
  131391. REFLECTIONMAP_SKYBOX: boolean;
  131392. REFLECTIONMAP_EXPLICIT: boolean;
  131393. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  131394. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  131395. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  131396. INVERTCUBICMAP: boolean;
  131397. USESPHERICALFROMREFLECTIONMAP: boolean;
  131398. USEIRRADIANCEMAP: boolean;
  131399. SPHERICAL_HARMONICS: boolean;
  131400. USESPHERICALINVERTEX: boolean;
  131401. REFLECTIONMAP_OPPOSITEZ: boolean;
  131402. LODINREFLECTIONALPHA: boolean;
  131403. GAMMAREFLECTION: boolean;
  131404. RGBDREFLECTION: boolean;
  131405. LINEARSPECULARREFLECTION: boolean;
  131406. RADIANCEOCCLUSION: boolean;
  131407. HORIZONOCCLUSION: boolean;
  131408. INSTANCES: boolean;
  131409. NUM_BONE_INFLUENCERS: number;
  131410. BonesPerMesh: number;
  131411. BONETEXTURE: boolean;
  131412. NONUNIFORMSCALING: boolean;
  131413. MORPHTARGETS: boolean;
  131414. MORPHTARGETS_NORMAL: boolean;
  131415. MORPHTARGETS_TANGENT: boolean;
  131416. MORPHTARGETS_UV: boolean;
  131417. NUM_MORPH_INFLUENCERS: number;
  131418. IMAGEPROCESSING: boolean;
  131419. VIGNETTE: boolean;
  131420. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131421. VIGNETTEBLENDMODEOPAQUE: boolean;
  131422. TONEMAPPING: boolean;
  131423. TONEMAPPING_ACES: boolean;
  131424. CONTRAST: boolean;
  131425. COLORCURVES: boolean;
  131426. COLORGRADING: boolean;
  131427. COLORGRADING3D: boolean;
  131428. SAMPLER3DGREENDEPTH: boolean;
  131429. SAMPLER3DBGRMAP: boolean;
  131430. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131431. EXPOSURE: boolean;
  131432. MULTIVIEW: boolean;
  131433. USEPHYSICALLIGHTFALLOFF: boolean;
  131434. USEGLTFLIGHTFALLOFF: boolean;
  131435. TWOSIDEDLIGHTING: boolean;
  131436. SHADOWFLOAT: boolean;
  131437. CLIPPLANE: boolean;
  131438. CLIPPLANE2: boolean;
  131439. CLIPPLANE3: boolean;
  131440. CLIPPLANE4: boolean;
  131441. CLIPPLANE5: boolean;
  131442. CLIPPLANE6: boolean;
  131443. POINTSIZE: boolean;
  131444. FOG: boolean;
  131445. LOGARITHMICDEPTH: boolean;
  131446. FORCENORMALFORWARD: boolean;
  131447. SPECULARAA: boolean;
  131448. CLEARCOAT: boolean;
  131449. CLEARCOAT_DEFAULTIOR: boolean;
  131450. CLEARCOAT_TEXTURE: boolean;
  131451. CLEARCOAT_TEXTUREDIRECTUV: number;
  131452. CLEARCOAT_BUMP: boolean;
  131453. CLEARCOAT_BUMPDIRECTUV: number;
  131454. CLEARCOAT_TINT: boolean;
  131455. CLEARCOAT_TINT_TEXTURE: boolean;
  131456. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131457. ANISOTROPIC: boolean;
  131458. ANISOTROPIC_TEXTURE: boolean;
  131459. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131460. BRDF_V_HEIGHT_CORRELATED: boolean;
  131461. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131462. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131463. SHEEN: boolean;
  131464. SHEEN_TEXTURE: boolean;
  131465. SHEEN_TEXTUREDIRECTUV: number;
  131466. SHEEN_LINKWITHALBEDO: boolean;
  131467. SHEEN_ROUGHNESS: boolean;
  131468. SHEEN_ALBEDOSCALING: boolean;
  131469. SUBSURFACE: boolean;
  131470. SS_REFRACTION: boolean;
  131471. SS_TRANSLUCENCY: boolean;
  131472. SS_SCATERRING: boolean;
  131473. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131474. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131475. SS_REFRACTIONMAP_3D: boolean;
  131476. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131477. SS_LODINREFRACTIONALPHA: boolean;
  131478. SS_GAMMAREFRACTION: boolean;
  131479. SS_RGBDREFRACTION: boolean;
  131480. SS_LINEARSPECULARREFRACTION: boolean;
  131481. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131482. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131483. UNLIT: boolean;
  131484. DEBUGMODE: number;
  131485. /**
  131486. * Initializes the PBR Material defines.
  131487. */
  131488. constructor();
  131489. /**
  131490. * Resets the PBR Material defines.
  131491. */
  131492. reset(): void;
  131493. }
  131494. /**
  131495. * The Physically based material base class of BJS.
  131496. *
  131497. * This offers the main features of a standard PBR material.
  131498. * For more information, please refer to the documentation :
  131499. * https://doc.babylonjs.com/how_to/physically_based_rendering
  131500. */
  131501. export abstract class PBRBaseMaterial extends PushMaterial {
  131502. /**
  131503. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  131504. */
  131505. static readonly PBRMATERIAL_OPAQUE: number;
  131506. /**
  131507. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  131508. */
  131509. static readonly PBRMATERIAL_ALPHATEST: number;
  131510. /**
  131511. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131512. */
  131513. static readonly PBRMATERIAL_ALPHABLEND: number;
  131514. /**
  131515. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131516. * They are also discarded below the alpha cutoff threshold to improve performances.
  131517. */
  131518. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  131519. /**
  131520. * Defines the default value of how much AO map is occluding the analytical lights
  131521. * (point spot...).
  131522. */
  131523. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  131524. /**
  131525. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  131526. */
  131527. static readonly LIGHTFALLOFF_PHYSICAL: number;
  131528. /**
  131529. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  131530. * to enhance interoperability with other engines.
  131531. */
  131532. static readonly LIGHTFALLOFF_GLTF: number;
  131533. /**
  131534. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  131535. * to enhance interoperability with other materials.
  131536. */
  131537. static readonly LIGHTFALLOFF_STANDARD: number;
  131538. /**
  131539. * Intensity of the direct lights e.g. the four lights available in your scene.
  131540. * This impacts both the direct diffuse and specular highlights.
  131541. */
  131542. protected _directIntensity: number;
  131543. /**
  131544. * Intensity of the emissive part of the material.
  131545. * This helps controlling the emissive effect without modifying the emissive color.
  131546. */
  131547. protected _emissiveIntensity: number;
  131548. /**
  131549. * Intensity of the environment e.g. how much the environment will light the object
  131550. * either through harmonics for rough material or through the refelction for shiny ones.
  131551. */
  131552. protected _environmentIntensity: number;
  131553. /**
  131554. * This is a special control allowing the reduction of the specular highlights coming from the
  131555. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  131556. */
  131557. protected _specularIntensity: number;
  131558. /**
  131559. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  131560. */
  131561. private _lightingInfos;
  131562. /**
  131563. * Debug Control allowing disabling the bump map on this material.
  131564. */
  131565. protected _disableBumpMap: boolean;
  131566. /**
  131567. * AKA Diffuse Texture in standard nomenclature.
  131568. */
  131569. protected _albedoTexture: Nullable<BaseTexture>;
  131570. /**
  131571. * AKA Occlusion Texture in other nomenclature.
  131572. */
  131573. protected _ambientTexture: Nullable<BaseTexture>;
  131574. /**
  131575. * AKA Occlusion Texture Intensity in other nomenclature.
  131576. */
  131577. protected _ambientTextureStrength: number;
  131578. /**
  131579. * Defines how much the AO map is occluding the analytical lights (point spot...).
  131580. * 1 means it completely occludes it
  131581. * 0 mean it has no impact
  131582. */
  131583. protected _ambientTextureImpactOnAnalyticalLights: number;
  131584. /**
  131585. * Stores the alpha values in a texture.
  131586. */
  131587. protected _opacityTexture: Nullable<BaseTexture>;
  131588. /**
  131589. * Stores the reflection values in a texture.
  131590. */
  131591. protected _reflectionTexture: Nullable<BaseTexture>;
  131592. /**
  131593. * Stores the emissive values in a texture.
  131594. */
  131595. protected _emissiveTexture: Nullable<BaseTexture>;
  131596. /**
  131597. * AKA Specular texture in other nomenclature.
  131598. */
  131599. protected _reflectivityTexture: Nullable<BaseTexture>;
  131600. /**
  131601. * Used to switch from specular/glossiness to metallic/roughness workflow.
  131602. */
  131603. protected _metallicTexture: Nullable<BaseTexture>;
  131604. /**
  131605. * Specifies the metallic scalar of the metallic/roughness workflow.
  131606. * Can also be used to scale the metalness values of the metallic texture.
  131607. */
  131608. protected _metallic: Nullable<number>;
  131609. /**
  131610. * Specifies the roughness scalar of the metallic/roughness workflow.
  131611. * Can also be used to scale the roughness values of the metallic texture.
  131612. */
  131613. protected _roughness: Nullable<number>;
  131614. /**
  131615. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  131616. * By default the indexOfrefraction is used to compute F0;
  131617. *
  131618. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  131619. *
  131620. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  131621. * F90 = metallicReflectanceColor;
  131622. */
  131623. protected _metallicF0Factor: number;
  131624. /**
  131625. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  131626. * By default the F90 is always 1;
  131627. *
  131628. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  131629. *
  131630. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  131631. * F90 = metallicReflectanceColor;
  131632. */
  131633. protected _metallicReflectanceColor: Color3;
  131634. /**
  131635. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  131636. * This is multiply against the scalar values defined in the material.
  131637. */
  131638. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  131639. /**
  131640. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  131641. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  131642. */
  131643. protected _microSurfaceTexture: Nullable<BaseTexture>;
  131644. /**
  131645. * Stores surface normal data used to displace a mesh in a texture.
  131646. */
  131647. protected _bumpTexture: Nullable<BaseTexture>;
  131648. /**
  131649. * Stores the pre-calculated light information of a mesh in a texture.
  131650. */
  131651. protected _lightmapTexture: Nullable<BaseTexture>;
  131652. /**
  131653. * The color of a material in ambient lighting.
  131654. */
  131655. protected _ambientColor: Color3;
  131656. /**
  131657. * AKA Diffuse Color in other nomenclature.
  131658. */
  131659. protected _albedoColor: Color3;
  131660. /**
  131661. * AKA Specular Color in other nomenclature.
  131662. */
  131663. protected _reflectivityColor: Color3;
  131664. /**
  131665. * The color applied when light is reflected from a material.
  131666. */
  131667. protected _reflectionColor: Color3;
  131668. /**
  131669. * The color applied when light is emitted from a material.
  131670. */
  131671. protected _emissiveColor: Color3;
  131672. /**
  131673. * AKA Glossiness in other nomenclature.
  131674. */
  131675. protected _microSurface: number;
  131676. /**
  131677. * Specifies that the material will use the light map as a show map.
  131678. */
  131679. protected _useLightmapAsShadowmap: boolean;
  131680. /**
  131681. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  131682. * makes the reflect vector face the model (under horizon).
  131683. */
  131684. protected _useHorizonOcclusion: boolean;
  131685. /**
  131686. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  131687. * too much the area relying on ambient texture to define their ambient occlusion.
  131688. */
  131689. protected _useRadianceOcclusion: boolean;
  131690. /**
  131691. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  131692. */
  131693. protected _useAlphaFromAlbedoTexture: boolean;
  131694. /**
  131695. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  131696. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  131697. */
  131698. protected _useSpecularOverAlpha: boolean;
  131699. /**
  131700. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  131701. */
  131702. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  131703. /**
  131704. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  131705. */
  131706. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  131707. /**
  131708. * Specifies if the metallic texture contains the roughness information in its green channel.
  131709. */
  131710. protected _useRoughnessFromMetallicTextureGreen: boolean;
  131711. /**
  131712. * Specifies if the metallic texture contains the metallness information in its blue channel.
  131713. */
  131714. protected _useMetallnessFromMetallicTextureBlue: boolean;
  131715. /**
  131716. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  131717. */
  131718. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  131719. /**
  131720. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  131721. */
  131722. protected _useAmbientInGrayScale: boolean;
  131723. /**
  131724. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  131725. * The material will try to infer what glossiness each pixel should be.
  131726. */
  131727. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  131728. /**
  131729. * Defines the falloff type used in this material.
  131730. * It by default is Physical.
  131731. */
  131732. protected _lightFalloff: number;
  131733. /**
  131734. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  131735. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  131736. */
  131737. protected _useRadianceOverAlpha: boolean;
  131738. /**
  131739. * Allows using an object space normal map (instead of tangent space).
  131740. */
  131741. protected _useObjectSpaceNormalMap: boolean;
  131742. /**
  131743. * Allows using the bump map in parallax mode.
  131744. */
  131745. protected _useParallax: boolean;
  131746. /**
  131747. * Allows using the bump map in parallax occlusion mode.
  131748. */
  131749. protected _useParallaxOcclusion: boolean;
  131750. /**
  131751. * Controls the scale bias of the parallax mode.
  131752. */
  131753. protected _parallaxScaleBias: number;
  131754. /**
  131755. * If sets to true, disables all the lights affecting the material.
  131756. */
  131757. protected _disableLighting: boolean;
  131758. /**
  131759. * Number of Simultaneous lights allowed on the material.
  131760. */
  131761. protected _maxSimultaneousLights: number;
  131762. /**
  131763. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131764. */
  131765. protected _invertNormalMapX: boolean;
  131766. /**
  131767. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131768. */
  131769. protected _invertNormalMapY: boolean;
  131770. /**
  131771. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  131772. */
  131773. protected _twoSidedLighting: boolean;
  131774. /**
  131775. * Defines the alpha limits in alpha test mode.
  131776. */
  131777. protected _alphaCutOff: number;
  131778. /**
  131779. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  131780. */
  131781. protected _forceAlphaTest: boolean;
  131782. /**
  131783. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  131784. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  131785. */
  131786. protected _useAlphaFresnel: boolean;
  131787. /**
  131788. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  131789. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  131790. */
  131791. protected _useLinearAlphaFresnel: boolean;
  131792. /**
  131793. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  131794. * from cos thetav and roughness:
  131795. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  131796. */
  131797. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  131798. /**
  131799. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  131800. */
  131801. protected _forceIrradianceInFragment: boolean;
  131802. /**
  131803. * Force normal to face away from face.
  131804. */
  131805. protected _forceNormalForward: boolean;
  131806. /**
  131807. * Enables specular anti aliasing in the PBR shader.
  131808. * It will both interacts on the Geometry for analytical and IBL lighting.
  131809. * It also prefilter the roughness map based on the bump values.
  131810. */
  131811. protected _enableSpecularAntiAliasing: boolean;
  131812. /**
  131813. * Default configuration related to image processing available in the PBR Material.
  131814. */
  131815. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131816. /**
  131817. * Keep track of the image processing observer to allow dispose and replace.
  131818. */
  131819. private _imageProcessingObserver;
  131820. /**
  131821. * Attaches a new image processing configuration to the PBR Material.
  131822. * @param configuration
  131823. */
  131824. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131825. /**
  131826. * Stores the available render targets.
  131827. */
  131828. private _renderTargets;
  131829. /**
  131830. * Sets the global ambient color for the material used in lighting calculations.
  131831. */
  131832. private _globalAmbientColor;
  131833. /**
  131834. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  131835. */
  131836. private _useLogarithmicDepth;
  131837. /**
  131838. * If set to true, no lighting calculations will be applied.
  131839. */
  131840. private _unlit;
  131841. private _debugMode;
  131842. /**
  131843. * @hidden
  131844. * This is reserved for the inspector.
  131845. * Defines the material debug mode.
  131846. * It helps seeing only some components of the material while troubleshooting.
  131847. */
  131848. debugMode: number;
  131849. /**
  131850. * @hidden
  131851. * This is reserved for the inspector.
  131852. * Specify from where on screen the debug mode should start.
  131853. * The value goes from -1 (full screen) to 1 (not visible)
  131854. * It helps with side by side comparison against the final render
  131855. * This defaults to -1
  131856. */
  131857. private debugLimit;
  131858. /**
  131859. * @hidden
  131860. * This is reserved for the inspector.
  131861. * As the default viewing range might not be enough (if the ambient is really small for instance)
  131862. * You can use the factor to better multiply the final value.
  131863. */
  131864. private debugFactor;
  131865. /**
  131866. * Defines the clear coat layer parameters for the material.
  131867. */
  131868. readonly clearCoat: PBRClearCoatConfiguration;
  131869. /**
  131870. * Defines the anisotropic parameters for the material.
  131871. */
  131872. readonly anisotropy: PBRAnisotropicConfiguration;
  131873. /**
  131874. * Defines the BRDF parameters for the material.
  131875. */
  131876. readonly brdf: PBRBRDFConfiguration;
  131877. /**
  131878. * Defines the Sheen parameters for the material.
  131879. */
  131880. readonly sheen: PBRSheenConfiguration;
  131881. /**
  131882. * Defines the SubSurface parameters for the material.
  131883. */
  131884. readonly subSurface: PBRSubSurfaceConfiguration;
  131885. protected _rebuildInParallel: boolean;
  131886. /**
  131887. * Instantiates a new PBRMaterial instance.
  131888. *
  131889. * @param name The material name
  131890. * @param scene The scene the material will be use in.
  131891. */
  131892. constructor(name: string, scene: Scene);
  131893. /**
  131894. * Gets a boolean indicating that current material needs to register RTT
  131895. */
  131896. get hasRenderTargetTextures(): boolean;
  131897. /**
  131898. * Gets the name of the material class.
  131899. */
  131900. getClassName(): string;
  131901. /**
  131902. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  131903. */
  131904. get useLogarithmicDepth(): boolean;
  131905. /**
  131906. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  131907. */
  131908. set useLogarithmicDepth(value: boolean);
  131909. /**
  131910. * Returns true if alpha blending should be disabled.
  131911. */
  131912. protected get _disableAlphaBlending(): boolean;
  131913. /**
  131914. * Specifies whether or not this material should be rendered in alpha blend mode.
  131915. */
  131916. needAlphaBlending(): boolean;
  131917. /**
  131918. * Specifies whether or not this material should be rendered in alpha test mode.
  131919. */
  131920. needAlphaTesting(): boolean;
  131921. /**
  131922. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  131923. */
  131924. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  131925. /**
  131926. * Gets the texture used for the alpha test.
  131927. */
  131928. getAlphaTestTexture(): Nullable<BaseTexture>;
  131929. /**
  131930. * Specifies that the submesh is ready to be used.
  131931. * @param mesh - BJS mesh.
  131932. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  131933. * @param useInstances - Specifies that instances should be used.
  131934. * @returns - boolean indicating that the submesh is ready or not.
  131935. */
  131936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131937. /**
  131938. * Specifies if the material uses metallic roughness workflow.
  131939. * @returns boolean specifiying if the material uses metallic roughness workflow.
  131940. */
  131941. isMetallicWorkflow(): boolean;
  131942. private _prepareEffect;
  131943. private _prepareDefines;
  131944. /**
  131945. * Force shader compilation
  131946. */
  131947. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  131948. /**
  131949. * Initializes the uniform buffer layout for the shader.
  131950. */
  131951. buildUniformLayout(): void;
  131952. /**
  131953. * Unbinds the material from the mesh
  131954. */
  131955. unbind(): void;
  131956. /**
  131957. * Binds the submesh data.
  131958. * @param world - The world matrix.
  131959. * @param mesh - The BJS mesh.
  131960. * @param subMesh - A submesh of the BJS mesh.
  131961. */
  131962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131963. /**
  131964. * Returns the animatable textures.
  131965. * @returns - Array of animatable textures.
  131966. */
  131967. getAnimatables(): IAnimatable[];
  131968. /**
  131969. * Returns the texture used for reflections.
  131970. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  131971. */
  131972. private _getReflectionTexture;
  131973. /**
  131974. * Returns an array of the actively used textures.
  131975. * @returns - Array of BaseTextures
  131976. */
  131977. getActiveTextures(): BaseTexture[];
  131978. /**
  131979. * Checks to see if a texture is used in the material.
  131980. * @param texture - Base texture to use.
  131981. * @returns - Boolean specifying if a texture is used in the material.
  131982. */
  131983. hasTexture(texture: BaseTexture): boolean;
  131984. /**
  131985. * Disposes the resources of the material.
  131986. * @param forceDisposeEffect - Forces the disposal of effects.
  131987. * @param forceDisposeTextures - Forces the disposal of all textures.
  131988. */
  131989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131990. }
  131991. }
  131992. declare module BABYLON {
  131993. /**
  131994. * The Physically based material of BJS.
  131995. *
  131996. * This offers the main features of a standard PBR material.
  131997. * For more information, please refer to the documentation :
  131998. * https://doc.babylonjs.com/how_to/physically_based_rendering
  131999. */
  132000. export class PBRMaterial extends PBRBaseMaterial {
  132001. /**
  132002. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132003. */
  132004. static readonly PBRMATERIAL_OPAQUE: number;
  132005. /**
  132006. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132007. */
  132008. static readonly PBRMATERIAL_ALPHATEST: number;
  132009. /**
  132010. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132011. */
  132012. static readonly PBRMATERIAL_ALPHABLEND: number;
  132013. /**
  132014. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132015. * They are also discarded below the alpha cutoff threshold to improve performances.
  132016. */
  132017. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132018. /**
  132019. * Defines the default value of how much AO map is occluding the analytical lights
  132020. * (point spot...).
  132021. */
  132022. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132023. /**
  132024. * Intensity of the direct lights e.g. the four lights available in your scene.
  132025. * This impacts both the direct diffuse and specular highlights.
  132026. */
  132027. directIntensity: number;
  132028. /**
  132029. * Intensity of the emissive part of the material.
  132030. * This helps controlling the emissive effect without modifying the emissive color.
  132031. */
  132032. emissiveIntensity: number;
  132033. /**
  132034. * Intensity of the environment e.g. how much the environment will light the object
  132035. * either through harmonics for rough material or through the refelction for shiny ones.
  132036. */
  132037. environmentIntensity: number;
  132038. /**
  132039. * This is a special control allowing the reduction of the specular highlights coming from the
  132040. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132041. */
  132042. specularIntensity: number;
  132043. /**
  132044. * Debug Control allowing disabling the bump map on this material.
  132045. */
  132046. disableBumpMap: boolean;
  132047. /**
  132048. * AKA Diffuse Texture in standard nomenclature.
  132049. */
  132050. albedoTexture: BaseTexture;
  132051. /**
  132052. * AKA Occlusion Texture in other nomenclature.
  132053. */
  132054. ambientTexture: BaseTexture;
  132055. /**
  132056. * AKA Occlusion Texture Intensity in other nomenclature.
  132057. */
  132058. ambientTextureStrength: number;
  132059. /**
  132060. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132061. * 1 means it completely occludes it
  132062. * 0 mean it has no impact
  132063. */
  132064. ambientTextureImpactOnAnalyticalLights: number;
  132065. /**
  132066. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  132067. */
  132068. opacityTexture: BaseTexture;
  132069. /**
  132070. * Stores the reflection values in a texture.
  132071. */
  132072. reflectionTexture: Nullable<BaseTexture>;
  132073. /**
  132074. * Stores the emissive values in a texture.
  132075. */
  132076. emissiveTexture: BaseTexture;
  132077. /**
  132078. * AKA Specular texture in other nomenclature.
  132079. */
  132080. reflectivityTexture: BaseTexture;
  132081. /**
  132082. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132083. */
  132084. metallicTexture: BaseTexture;
  132085. /**
  132086. * Specifies the metallic scalar of the metallic/roughness workflow.
  132087. * Can also be used to scale the metalness values of the metallic texture.
  132088. */
  132089. metallic: Nullable<number>;
  132090. /**
  132091. * Specifies the roughness scalar of the metallic/roughness workflow.
  132092. * Can also be used to scale the roughness values of the metallic texture.
  132093. */
  132094. roughness: Nullable<number>;
  132095. /**
  132096. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132097. * By default the indexOfrefraction is used to compute F0;
  132098. *
  132099. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132100. *
  132101. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132102. * F90 = metallicReflectanceColor;
  132103. */
  132104. metallicF0Factor: number;
  132105. /**
  132106. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132107. * By default the F90 is always 1;
  132108. *
  132109. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132110. *
  132111. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132112. * F90 = metallicReflectanceColor;
  132113. */
  132114. metallicReflectanceColor: Color3;
  132115. /**
  132116. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132117. * This is multiply against the scalar values defined in the material.
  132118. */
  132119. metallicReflectanceTexture: Nullable<BaseTexture>;
  132120. /**
  132121. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132122. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132123. */
  132124. microSurfaceTexture: BaseTexture;
  132125. /**
  132126. * Stores surface normal data used to displace a mesh in a texture.
  132127. */
  132128. bumpTexture: BaseTexture;
  132129. /**
  132130. * Stores the pre-calculated light information of a mesh in a texture.
  132131. */
  132132. lightmapTexture: BaseTexture;
  132133. /**
  132134. * Stores the refracted light information in a texture.
  132135. */
  132136. get refractionTexture(): Nullable<BaseTexture>;
  132137. set refractionTexture(value: Nullable<BaseTexture>);
  132138. /**
  132139. * The color of a material in ambient lighting.
  132140. */
  132141. ambientColor: Color3;
  132142. /**
  132143. * AKA Diffuse Color in other nomenclature.
  132144. */
  132145. albedoColor: Color3;
  132146. /**
  132147. * AKA Specular Color in other nomenclature.
  132148. */
  132149. reflectivityColor: Color3;
  132150. /**
  132151. * The color reflected from the material.
  132152. */
  132153. reflectionColor: Color3;
  132154. /**
  132155. * The color emitted from the material.
  132156. */
  132157. emissiveColor: Color3;
  132158. /**
  132159. * AKA Glossiness in other nomenclature.
  132160. */
  132161. microSurface: number;
  132162. /**
  132163. * Index of refraction of the material base layer.
  132164. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132165. *
  132166. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132167. *
  132168. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132169. */
  132170. get indexOfRefraction(): number;
  132171. set indexOfRefraction(value: number);
  132172. /**
  132173. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132174. */
  132175. get invertRefractionY(): boolean;
  132176. set invertRefractionY(value: boolean);
  132177. /**
  132178. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132179. * Materials half opaque for instance using refraction could benefit from this control.
  132180. */
  132181. get linkRefractionWithTransparency(): boolean;
  132182. set linkRefractionWithTransparency(value: boolean);
  132183. /**
  132184. * If true, the light map contains occlusion information instead of lighting info.
  132185. */
  132186. useLightmapAsShadowmap: boolean;
  132187. /**
  132188. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132189. */
  132190. useAlphaFromAlbedoTexture: boolean;
  132191. /**
  132192. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132193. */
  132194. forceAlphaTest: boolean;
  132195. /**
  132196. * Defines the alpha limits in alpha test mode.
  132197. */
  132198. alphaCutOff: number;
  132199. /**
  132200. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  132201. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132202. */
  132203. useSpecularOverAlpha: boolean;
  132204. /**
  132205. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132206. */
  132207. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132208. /**
  132209. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132210. */
  132211. useRoughnessFromMetallicTextureAlpha: boolean;
  132212. /**
  132213. * Specifies if the metallic texture contains the roughness information in its green channel.
  132214. */
  132215. useRoughnessFromMetallicTextureGreen: boolean;
  132216. /**
  132217. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132218. */
  132219. useMetallnessFromMetallicTextureBlue: boolean;
  132220. /**
  132221. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132222. */
  132223. useAmbientOcclusionFromMetallicTextureRed: boolean;
  132224. /**
  132225. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132226. */
  132227. useAmbientInGrayScale: boolean;
  132228. /**
  132229. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132230. * The material will try to infer what glossiness each pixel should be.
  132231. */
  132232. useAutoMicroSurfaceFromReflectivityMap: boolean;
  132233. /**
  132234. * BJS is using an harcoded light falloff based on a manually sets up range.
  132235. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132236. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132237. */
  132238. get usePhysicalLightFalloff(): boolean;
  132239. /**
  132240. * BJS is using an harcoded light falloff based on a manually sets up range.
  132241. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132242. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132243. */
  132244. set usePhysicalLightFalloff(value: boolean);
  132245. /**
  132246. * In order to support the falloff compatibility with gltf, a special mode has been added
  132247. * to reproduce the gltf light falloff.
  132248. */
  132249. get useGLTFLightFalloff(): boolean;
  132250. /**
  132251. * In order to support the falloff compatibility with gltf, a special mode has been added
  132252. * to reproduce the gltf light falloff.
  132253. */
  132254. set useGLTFLightFalloff(value: boolean);
  132255. /**
  132256. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132257. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132258. */
  132259. useRadianceOverAlpha: boolean;
  132260. /**
  132261. * Allows using an object space normal map (instead of tangent space).
  132262. */
  132263. useObjectSpaceNormalMap: boolean;
  132264. /**
  132265. * Allows using the bump map in parallax mode.
  132266. */
  132267. useParallax: boolean;
  132268. /**
  132269. * Allows using the bump map in parallax occlusion mode.
  132270. */
  132271. useParallaxOcclusion: boolean;
  132272. /**
  132273. * Controls the scale bias of the parallax mode.
  132274. */
  132275. parallaxScaleBias: number;
  132276. /**
  132277. * If sets to true, disables all the lights affecting the material.
  132278. */
  132279. disableLighting: boolean;
  132280. /**
  132281. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132282. */
  132283. forceIrradianceInFragment: boolean;
  132284. /**
  132285. * Number of Simultaneous lights allowed on the material.
  132286. */
  132287. maxSimultaneousLights: number;
  132288. /**
  132289. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132290. */
  132291. invertNormalMapX: boolean;
  132292. /**
  132293. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132294. */
  132295. invertNormalMapY: boolean;
  132296. /**
  132297. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132298. */
  132299. twoSidedLighting: boolean;
  132300. /**
  132301. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132302. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132303. */
  132304. useAlphaFresnel: boolean;
  132305. /**
  132306. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132307. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132308. */
  132309. useLinearAlphaFresnel: boolean;
  132310. /**
  132311. * Let user defines the brdf lookup texture used for IBL.
  132312. * A default 8bit version is embedded but you could point at :
  132313. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  132314. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  132315. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  132316. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  132317. */
  132318. environmentBRDFTexture: Nullable<BaseTexture>;
  132319. /**
  132320. * Force normal to face away from face.
  132321. */
  132322. forceNormalForward: boolean;
  132323. /**
  132324. * Enables specular anti aliasing in the PBR shader.
  132325. * It will both interacts on the Geometry for analytical and IBL lighting.
  132326. * It also prefilter the roughness map based on the bump values.
  132327. */
  132328. enableSpecularAntiAliasing: boolean;
  132329. /**
  132330. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132331. * makes the reflect vector face the model (under horizon).
  132332. */
  132333. useHorizonOcclusion: boolean;
  132334. /**
  132335. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132336. * too much the area relying on ambient texture to define their ambient occlusion.
  132337. */
  132338. useRadianceOcclusion: boolean;
  132339. /**
  132340. * If set to true, no lighting calculations will be applied.
  132341. */
  132342. unlit: boolean;
  132343. /**
  132344. * Gets the image processing configuration used either in this material.
  132345. */
  132346. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132347. /**
  132348. * Sets the Default image processing configuration used either in the this material.
  132349. *
  132350. * If sets to null, the scene one is in use.
  132351. */
  132352. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132353. /**
  132354. * Gets wether the color curves effect is enabled.
  132355. */
  132356. get cameraColorCurvesEnabled(): boolean;
  132357. /**
  132358. * Sets wether the color curves effect is enabled.
  132359. */
  132360. set cameraColorCurvesEnabled(value: boolean);
  132361. /**
  132362. * Gets wether the color grading effect is enabled.
  132363. */
  132364. get cameraColorGradingEnabled(): boolean;
  132365. /**
  132366. * Gets wether the color grading effect is enabled.
  132367. */
  132368. set cameraColorGradingEnabled(value: boolean);
  132369. /**
  132370. * Gets wether tonemapping is enabled or not.
  132371. */
  132372. get cameraToneMappingEnabled(): boolean;
  132373. /**
  132374. * Sets wether tonemapping is enabled or not
  132375. */
  132376. set cameraToneMappingEnabled(value: boolean);
  132377. /**
  132378. * The camera exposure used on this material.
  132379. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132380. * This corresponds to a photographic exposure.
  132381. */
  132382. get cameraExposure(): number;
  132383. /**
  132384. * The camera exposure used on this material.
  132385. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132386. * This corresponds to a photographic exposure.
  132387. */
  132388. set cameraExposure(value: number);
  132389. /**
  132390. * Gets The camera contrast used on this material.
  132391. */
  132392. get cameraContrast(): number;
  132393. /**
  132394. * Sets The camera contrast used on this material.
  132395. */
  132396. set cameraContrast(value: number);
  132397. /**
  132398. * Gets the Color Grading 2D Lookup Texture.
  132399. */
  132400. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132401. /**
  132402. * Sets the Color Grading 2D Lookup Texture.
  132403. */
  132404. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132405. /**
  132406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132408. * 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;
  132409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132410. */
  132411. get cameraColorCurves(): Nullable<ColorCurves>;
  132412. /**
  132413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132415. * 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;
  132416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132417. */
  132418. set cameraColorCurves(value: Nullable<ColorCurves>);
  132419. /**
  132420. * Instantiates a new PBRMaterial instance.
  132421. *
  132422. * @param name The material name
  132423. * @param scene The scene the material will be use in.
  132424. */
  132425. constructor(name: string, scene: Scene);
  132426. /**
  132427. * Returns the name of this material class.
  132428. */
  132429. getClassName(): string;
  132430. /**
  132431. * Makes a duplicate of the current material.
  132432. * @param name - name to use for the new material.
  132433. */
  132434. clone(name: string): PBRMaterial;
  132435. /**
  132436. * Serializes this PBR Material.
  132437. * @returns - An object with the serialized material.
  132438. */
  132439. serialize(): any;
  132440. /**
  132441. * Parses a PBR Material from a serialized object.
  132442. * @param source - Serialized object.
  132443. * @param scene - BJS scene instance.
  132444. * @param rootUrl - url for the scene object
  132445. * @returns - PBRMaterial
  132446. */
  132447. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  132448. }
  132449. }
  132450. declare module BABYLON {
  132451. /**
  132452. * Direct draw surface info
  132453. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  132454. */
  132455. export interface DDSInfo {
  132456. /**
  132457. * Width of the texture
  132458. */
  132459. width: number;
  132460. /**
  132461. * Width of the texture
  132462. */
  132463. height: number;
  132464. /**
  132465. * Number of Mipmaps for the texture
  132466. * @see https://en.wikipedia.org/wiki/Mipmap
  132467. */
  132468. mipmapCount: number;
  132469. /**
  132470. * If the textures format is a known fourCC format
  132471. * @see https://www.fourcc.org/
  132472. */
  132473. isFourCC: boolean;
  132474. /**
  132475. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  132476. */
  132477. isRGB: boolean;
  132478. /**
  132479. * If the texture is a lumincance format
  132480. */
  132481. isLuminance: boolean;
  132482. /**
  132483. * If this is a cube texture
  132484. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  132485. */
  132486. isCube: boolean;
  132487. /**
  132488. * If the texture is a compressed format eg. FOURCC_DXT1
  132489. */
  132490. isCompressed: boolean;
  132491. /**
  132492. * The dxgiFormat of the texture
  132493. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  132494. */
  132495. dxgiFormat: number;
  132496. /**
  132497. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  132498. */
  132499. textureType: number;
  132500. /**
  132501. * Sphericle polynomial created for the dds texture
  132502. */
  132503. sphericalPolynomial?: SphericalPolynomial;
  132504. }
  132505. /**
  132506. * Class used to provide DDS decompression tools
  132507. */
  132508. export class DDSTools {
  132509. /**
  132510. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  132511. */
  132512. static StoreLODInAlphaChannel: boolean;
  132513. /**
  132514. * Gets DDS information from an array buffer
  132515. * @param data defines the array buffer view to read data from
  132516. * @returns the DDS information
  132517. */
  132518. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  132519. private static _FloatView;
  132520. private static _Int32View;
  132521. private static _ToHalfFloat;
  132522. private static _FromHalfFloat;
  132523. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  132524. private static _GetHalfFloatRGBAArrayBuffer;
  132525. private static _GetFloatRGBAArrayBuffer;
  132526. private static _GetFloatAsUIntRGBAArrayBuffer;
  132527. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  132528. private static _GetRGBAArrayBuffer;
  132529. private static _ExtractLongWordOrder;
  132530. private static _GetRGBArrayBuffer;
  132531. private static _GetLuminanceArrayBuffer;
  132532. /**
  132533. * Uploads DDS Levels to a Babylon Texture
  132534. * @hidden
  132535. */
  132536. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  132537. }
  132538. interface ThinEngine {
  132539. /**
  132540. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  132541. * @param rootUrl defines the url where the file to load is located
  132542. * @param scene defines the current scene
  132543. * @param lodScale defines scale to apply to the mip map selection
  132544. * @param lodOffset defines offset to apply to the mip map selection
  132545. * @param onLoad defines an optional callback raised when the texture is loaded
  132546. * @param onError defines an optional callback raised if there is an issue to load the texture
  132547. * @param format defines the format of the data
  132548. * @param forcedExtension defines the extension to use to pick the right loader
  132549. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  132550. * @returns the cube texture as an InternalTexture
  132551. */
  132552. 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;
  132553. }
  132554. }
  132555. declare module BABYLON {
  132556. /**
  132557. * Implementation of the DDS Texture Loader.
  132558. * @hidden
  132559. */
  132560. export class _DDSTextureLoader implements IInternalTextureLoader {
  132561. /**
  132562. * Defines wether the loader supports cascade loading the different faces.
  132563. */
  132564. readonly supportCascades: boolean;
  132565. /**
  132566. * This returns if the loader support the current file information.
  132567. * @param extension defines the file extension of the file being loaded
  132568. * @returns true if the loader can load the specified file
  132569. */
  132570. canLoad(extension: string): boolean;
  132571. /**
  132572. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132573. * @param data contains the texture data
  132574. * @param texture defines the BabylonJS internal texture
  132575. * @param createPolynomials will be true if polynomials have been requested
  132576. * @param onLoad defines the callback to trigger once the texture is ready
  132577. * @param onError defines the callback to trigger in case of error
  132578. */
  132579. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132580. /**
  132581. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132582. * @param data contains the texture data
  132583. * @param texture defines the BabylonJS internal texture
  132584. * @param callback defines the method to call once ready to upload
  132585. */
  132586. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132587. }
  132588. }
  132589. declare module BABYLON {
  132590. /**
  132591. * Implementation of the ENV Texture Loader.
  132592. * @hidden
  132593. */
  132594. export class _ENVTextureLoader implements IInternalTextureLoader {
  132595. /**
  132596. * Defines wether the loader supports cascade loading the different faces.
  132597. */
  132598. readonly supportCascades: boolean;
  132599. /**
  132600. * This returns if the loader support the current file information.
  132601. * @param extension defines the file extension of the file being loaded
  132602. * @returns true if the loader can load the specified file
  132603. */
  132604. canLoad(extension: string): boolean;
  132605. /**
  132606. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132607. * @param data contains the texture data
  132608. * @param texture defines the BabylonJS internal texture
  132609. * @param createPolynomials will be true if polynomials have been requested
  132610. * @param onLoad defines the callback to trigger once the texture is ready
  132611. * @param onError defines the callback to trigger in case of error
  132612. */
  132613. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132614. /**
  132615. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132616. * @param data contains the texture data
  132617. * @param texture defines the BabylonJS internal texture
  132618. * @param callback defines the method to call once ready to upload
  132619. */
  132620. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132621. }
  132622. }
  132623. declare module BABYLON {
  132624. /**
  132625. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132626. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132627. */
  132628. export class KhronosTextureContainer {
  132629. /** contents of the KTX container file */
  132630. data: ArrayBufferView;
  132631. private static HEADER_LEN;
  132632. private static COMPRESSED_2D;
  132633. private static COMPRESSED_3D;
  132634. private static TEX_2D;
  132635. private static TEX_3D;
  132636. /**
  132637. * Gets the openGL type
  132638. */
  132639. glType: number;
  132640. /**
  132641. * Gets the openGL type size
  132642. */
  132643. glTypeSize: number;
  132644. /**
  132645. * Gets the openGL format
  132646. */
  132647. glFormat: number;
  132648. /**
  132649. * Gets the openGL internal format
  132650. */
  132651. glInternalFormat: number;
  132652. /**
  132653. * Gets the base internal format
  132654. */
  132655. glBaseInternalFormat: number;
  132656. /**
  132657. * Gets image width in pixel
  132658. */
  132659. pixelWidth: number;
  132660. /**
  132661. * Gets image height in pixel
  132662. */
  132663. pixelHeight: number;
  132664. /**
  132665. * Gets image depth in pixels
  132666. */
  132667. pixelDepth: number;
  132668. /**
  132669. * Gets the number of array elements
  132670. */
  132671. numberOfArrayElements: number;
  132672. /**
  132673. * Gets the number of faces
  132674. */
  132675. numberOfFaces: number;
  132676. /**
  132677. * Gets the number of mipmap levels
  132678. */
  132679. numberOfMipmapLevels: number;
  132680. /**
  132681. * Gets the bytes of key value data
  132682. */
  132683. bytesOfKeyValueData: number;
  132684. /**
  132685. * Gets the load type
  132686. */
  132687. loadType: number;
  132688. /**
  132689. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  132690. */
  132691. isInvalid: boolean;
  132692. /**
  132693. * Creates a new KhronosTextureContainer
  132694. * @param data contents of the KTX container file
  132695. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  132696. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  132697. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  132698. */
  132699. constructor(
  132700. /** contents of the KTX container file */
  132701. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  132702. /**
  132703. * Uploads KTX content to a Babylon Texture.
  132704. * It is assumed that the texture has already been created & is currently bound
  132705. * @hidden
  132706. */
  132707. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  132708. private _upload2DCompressedLevels;
  132709. /**
  132710. * Checks if the given data starts with a KTX file identifier.
  132711. * @param data the data to check
  132712. * @returns true if the data is a KTX file or false otherwise
  132713. */
  132714. static IsValid(data: ArrayBufferView): boolean;
  132715. }
  132716. }
  132717. declare module BABYLON {
  132718. /**
  132719. * Class for loading KTX2 files
  132720. * !!! Experimental Extension Subject to Changes !!!
  132721. * @hidden
  132722. */
  132723. export class KhronosTextureContainer2 {
  132724. private static _ModulePromise;
  132725. private static _TranscodeFormat;
  132726. constructor(engine: ThinEngine);
  132727. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  132728. private _determineTranscodeFormat;
  132729. /**
  132730. * Checks if the given data starts with a KTX2 file identifier.
  132731. * @param data the data to check
  132732. * @returns true if the data is a KTX2 file or false otherwise
  132733. */
  132734. static IsValid(data: ArrayBufferView): boolean;
  132735. }
  132736. }
  132737. declare module BABYLON {
  132738. /**
  132739. * Implementation of the KTX Texture Loader.
  132740. * @hidden
  132741. */
  132742. export class _KTXTextureLoader implements IInternalTextureLoader {
  132743. /**
  132744. * Defines wether the loader supports cascade loading the different faces.
  132745. */
  132746. readonly supportCascades: boolean;
  132747. /**
  132748. * This returns if the loader support the current file information.
  132749. * @param extension defines the file extension of the file being loaded
  132750. * @returns true if the loader can load the specified file
  132751. */
  132752. canLoad(extension: string): boolean;
  132753. /**
  132754. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132755. * @param data contains the texture data
  132756. * @param texture defines the BabylonJS internal texture
  132757. * @param createPolynomials will be true if polynomials have been requested
  132758. * @param onLoad defines the callback to trigger once the texture is ready
  132759. * @param onError defines the callback to trigger in case of error
  132760. */
  132761. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132762. /**
  132763. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132764. * @param data contains the texture data
  132765. * @param texture defines the BabylonJS internal texture
  132766. * @param callback defines the method to call once ready to upload
  132767. */
  132768. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  132769. }
  132770. }
  132771. declare module BABYLON {
  132772. /** @hidden */
  132773. export var _forceSceneHelpersToBundle: boolean;
  132774. interface Scene {
  132775. /**
  132776. * Creates a default light for the scene.
  132777. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  132778. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  132779. */
  132780. createDefaultLight(replace?: boolean): void;
  132781. /**
  132782. * Creates a default camera for the scene.
  132783. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  132784. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  132785. * @param replace has default false, when true replaces the active camera in the scene
  132786. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  132787. */
  132788. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  132789. /**
  132790. * Creates a default camera and a default light.
  132791. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  132792. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  132793. * @param replace has the default false, when true replaces the active camera/light in the scene
  132794. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  132795. */
  132796. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  132797. /**
  132798. * Creates a new sky box
  132799. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  132800. * @param environmentTexture defines the texture to use as environment texture
  132801. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  132802. * @param scale defines the overall scale of the skybox
  132803. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  132804. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  132805. * @returns a new mesh holding the sky box
  132806. */
  132807. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  132808. /**
  132809. * Creates a new environment
  132810. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  132811. * @param options defines the options you can use to configure the environment
  132812. * @returns the new EnvironmentHelper
  132813. */
  132814. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  132815. /**
  132816. * Creates a new VREXperienceHelper
  132817. * @see http://doc.babylonjs.com/how_to/webvr_helper
  132818. * @param webVROptions defines the options used to create the new VREXperienceHelper
  132819. * @returns a new VREXperienceHelper
  132820. */
  132821. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  132822. /**
  132823. * Creates a new WebXRDefaultExperience
  132824. * @see http://doc.babylonjs.com/how_to/webxr
  132825. * @param options experience options
  132826. * @returns a promise for a new WebXRDefaultExperience
  132827. */
  132828. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  132829. }
  132830. }
  132831. declare module BABYLON {
  132832. /**
  132833. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  132834. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  132835. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  132836. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132837. */
  132838. export class VideoDome extends TransformNode {
  132839. /**
  132840. * Define the video source as a Monoscopic panoramic 360 video.
  132841. */
  132842. static readonly MODE_MONOSCOPIC: number;
  132843. /**
  132844. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  132845. */
  132846. static readonly MODE_TOPBOTTOM: number;
  132847. /**
  132848. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  132849. */
  132850. static readonly MODE_SIDEBYSIDE: number;
  132851. private _halfDome;
  132852. private _useDirectMapping;
  132853. /**
  132854. * The video texture being displayed on the sphere
  132855. */
  132856. protected _videoTexture: VideoTexture;
  132857. /**
  132858. * Gets the video texture being displayed on the sphere
  132859. */
  132860. get videoTexture(): VideoTexture;
  132861. /**
  132862. * The skybox material
  132863. */
  132864. protected _material: BackgroundMaterial;
  132865. /**
  132866. * The surface used for the skybox
  132867. */
  132868. protected _mesh: Mesh;
  132869. /**
  132870. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  132871. */
  132872. private _halfDomeMask;
  132873. /**
  132874. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132875. * Also see the options.resolution property.
  132876. */
  132877. get fovMultiplier(): number;
  132878. set fovMultiplier(value: number);
  132879. private _videoMode;
  132880. /**
  132881. * Gets or set the current video mode for the video. It can be:
  132882. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  132883. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  132884. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  132885. */
  132886. get videoMode(): number;
  132887. set videoMode(value: number);
  132888. /**
  132889. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  132890. *
  132891. */
  132892. get halfDome(): boolean;
  132893. /**
  132894. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  132895. */
  132896. set halfDome(enabled: boolean);
  132897. /**
  132898. * Oberserver used in Stereoscopic VR Mode.
  132899. */
  132900. private _onBeforeCameraRenderObserver;
  132901. /**
  132902. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  132903. * @param name Element's name, child elements will append suffixes for their own names.
  132904. * @param urlsOrVideo defines the url(s) or the video element to use
  132905. * @param options An object containing optional or exposed sub element properties
  132906. */
  132907. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  132908. resolution?: number;
  132909. clickToPlay?: boolean;
  132910. autoPlay?: boolean;
  132911. loop?: boolean;
  132912. size?: number;
  132913. poster?: string;
  132914. faceForward?: boolean;
  132915. useDirectMapping?: boolean;
  132916. halfDomeMode?: boolean;
  132917. }, scene: Scene);
  132918. private _changeVideoMode;
  132919. /**
  132920. * Releases resources associated with this node.
  132921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132923. */
  132924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132925. }
  132926. }
  132927. declare module BABYLON {
  132928. /**
  132929. * This class can be used to get instrumentation data from a Babylon engine
  132930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  132931. */
  132932. export class EngineInstrumentation implements IDisposable {
  132933. /**
  132934. * Define the instrumented engine.
  132935. */
  132936. engine: Engine;
  132937. private _captureGPUFrameTime;
  132938. private _gpuFrameTimeToken;
  132939. private _gpuFrameTime;
  132940. private _captureShaderCompilationTime;
  132941. private _shaderCompilationTime;
  132942. private _onBeginFrameObserver;
  132943. private _onEndFrameObserver;
  132944. private _onBeforeShaderCompilationObserver;
  132945. private _onAfterShaderCompilationObserver;
  132946. /**
  132947. * Gets the perf counter used for GPU frame time
  132948. */
  132949. get gpuFrameTimeCounter(): PerfCounter;
  132950. /**
  132951. * Gets the GPU frame time capture status
  132952. */
  132953. get captureGPUFrameTime(): boolean;
  132954. /**
  132955. * Enable or disable the GPU frame time capture
  132956. */
  132957. set captureGPUFrameTime(value: boolean);
  132958. /**
  132959. * Gets the perf counter used for shader compilation time
  132960. */
  132961. get shaderCompilationTimeCounter(): PerfCounter;
  132962. /**
  132963. * Gets the shader compilation time capture status
  132964. */
  132965. get captureShaderCompilationTime(): boolean;
  132966. /**
  132967. * Enable or disable the shader compilation time capture
  132968. */
  132969. set captureShaderCompilationTime(value: boolean);
  132970. /**
  132971. * Instantiates a new engine instrumentation.
  132972. * This class can be used to get instrumentation data from a Babylon engine
  132973. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  132974. * @param engine Defines the engine to instrument
  132975. */
  132976. constructor(
  132977. /**
  132978. * Define the instrumented engine.
  132979. */
  132980. engine: Engine);
  132981. /**
  132982. * Dispose and release associated resources.
  132983. */
  132984. dispose(): void;
  132985. }
  132986. }
  132987. declare module BABYLON {
  132988. /**
  132989. * This class can be used to get instrumentation data from a Babylon engine
  132990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  132991. */
  132992. export class SceneInstrumentation implements IDisposable {
  132993. /**
  132994. * Defines the scene to instrument
  132995. */
  132996. scene: Scene;
  132997. private _captureActiveMeshesEvaluationTime;
  132998. private _activeMeshesEvaluationTime;
  132999. private _captureRenderTargetsRenderTime;
  133000. private _renderTargetsRenderTime;
  133001. private _captureFrameTime;
  133002. private _frameTime;
  133003. private _captureRenderTime;
  133004. private _renderTime;
  133005. private _captureInterFrameTime;
  133006. private _interFrameTime;
  133007. private _captureParticlesRenderTime;
  133008. private _particlesRenderTime;
  133009. private _captureSpritesRenderTime;
  133010. private _spritesRenderTime;
  133011. private _capturePhysicsTime;
  133012. private _physicsTime;
  133013. private _captureAnimationsTime;
  133014. private _animationsTime;
  133015. private _captureCameraRenderTime;
  133016. private _cameraRenderTime;
  133017. private _onBeforeActiveMeshesEvaluationObserver;
  133018. private _onAfterActiveMeshesEvaluationObserver;
  133019. private _onBeforeRenderTargetsRenderObserver;
  133020. private _onAfterRenderTargetsRenderObserver;
  133021. private _onAfterRenderObserver;
  133022. private _onBeforeDrawPhaseObserver;
  133023. private _onAfterDrawPhaseObserver;
  133024. private _onBeforeAnimationsObserver;
  133025. private _onBeforeParticlesRenderingObserver;
  133026. private _onAfterParticlesRenderingObserver;
  133027. private _onBeforeSpritesRenderingObserver;
  133028. private _onAfterSpritesRenderingObserver;
  133029. private _onBeforePhysicsObserver;
  133030. private _onAfterPhysicsObserver;
  133031. private _onAfterAnimationsObserver;
  133032. private _onBeforeCameraRenderObserver;
  133033. private _onAfterCameraRenderObserver;
  133034. /**
  133035. * Gets the perf counter used for active meshes evaluation time
  133036. */
  133037. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  133038. /**
  133039. * Gets the active meshes evaluation time capture status
  133040. */
  133041. get captureActiveMeshesEvaluationTime(): boolean;
  133042. /**
  133043. * Enable or disable the active meshes evaluation time capture
  133044. */
  133045. set captureActiveMeshesEvaluationTime(value: boolean);
  133046. /**
  133047. * Gets the perf counter used for render targets render time
  133048. */
  133049. get renderTargetsRenderTimeCounter(): PerfCounter;
  133050. /**
  133051. * Gets the render targets render time capture status
  133052. */
  133053. get captureRenderTargetsRenderTime(): boolean;
  133054. /**
  133055. * Enable or disable the render targets render time capture
  133056. */
  133057. set captureRenderTargetsRenderTime(value: boolean);
  133058. /**
  133059. * Gets the perf counter used for particles render time
  133060. */
  133061. get particlesRenderTimeCounter(): PerfCounter;
  133062. /**
  133063. * Gets the particles render time capture status
  133064. */
  133065. get captureParticlesRenderTime(): boolean;
  133066. /**
  133067. * Enable or disable the particles render time capture
  133068. */
  133069. set captureParticlesRenderTime(value: boolean);
  133070. /**
  133071. * Gets the perf counter used for sprites render time
  133072. */
  133073. get spritesRenderTimeCounter(): PerfCounter;
  133074. /**
  133075. * Gets the sprites render time capture status
  133076. */
  133077. get captureSpritesRenderTime(): boolean;
  133078. /**
  133079. * Enable or disable the sprites render time capture
  133080. */
  133081. set captureSpritesRenderTime(value: boolean);
  133082. /**
  133083. * Gets the perf counter used for physics time
  133084. */
  133085. get physicsTimeCounter(): PerfCounter;
  133086. /**
  133087. * Gets the physics time capture status
  133088. */
  133089. get capturePhysicsTime(): boolean;
  133090. /**
  133091. * Enable or disable the physics time capture
  133092. */
  133093. set capturePhysicsTime(value: boolean);
  133094. /**
  133095. * Gets the perf counter used for animations time
  133096. */
  133097. get animationsTimeCounter(): PerfCounter;
  133098. /**
  133099. * Gets the animations time capture status
  133100. */
  133101. get captureAnimationsTime(): boolean;
  133102. /**
  133103. * Enable or disable the animations time capture
  133104. */
  133105. set captureAnimationsTime(value: boolean);
  133106. /**
  133107. * Gets the perf counter used for frame time capture
  133108. */
  133109. get frameTimeCounter(): PerfCounter;
  133110. /**
  133111. * Gets the frame time capture status
  133112. */
  133113. get captureFrameTime(): boolean;
  133114. /**
  133115. * Enable or disable the frame time capture
  133116. */
  133117. set captureFrameTime(value: boolean);
  133118. /**
  133119. * Gets the perf counter used for inter-frames time capture
  133120. */
  133121. get interFrameTimeCounter(): PerfCounter;
  133122. /**
  133123. * Gets the inter-frames time capture status
  133124. */
  133125. get captureInterFrameTime(): boolean;
  133126. /**
  133127. * Enable or disable the inter-frames time capture
  133128. */
  133129. set captureInterFrameTime(value: boolean);
  133130. /**
  133131. * Gets the perf counter used for render time capture
  133132. */
  133133. get renderTimeCounter(): PerfCounter;
  133134. /**
  133135. * Gets the render time capture status
  133136. */
  133137. get captureRenderTime(): boolean;
  133138. /**
  133139. * Enable or disable the render time capture
  133140. */
  133141. set captureRenderTime(value: boolean);
  133142. /**
  133143. * Gets the perf counter used for camera render time capture
  133144. */
  133145. get cameraRenderTimeCounter(): PerfCounter;
  133146. /**
  133147. * Gets the camera render time capture status
  133148. */
  133149. get captureCameraRenderTime(): boolean;
  133150. /**
  133151. * Enable or disable the camera render time capture
  133152. */
  133153. set captureCameraRenderTime(value: boolean);
  133154. /**
  133155. * Gets the perf counter used for draw calls
  133156. */
  133157. get drawCallsCounter(): PerfCounter;
  133158. /**
  133159. * Instantiates a new scene instrumentation.
  133160. * This class can be used to get instrumentation data from a Babylon engine
  133161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133162. * @param scene Defines the scene to instrument
  133163. */
  133164. constructor(
  133165. /**
  133166. * Defines the scene to instrument
  133167. */
  133168. scene: Scene);
  133169. /**
  133170. * Dispose and release associated resources.
  133171. */
  133172. dispose(): void;
  133173. }
  133174. }
  133175. declare module BABYLON {
  133176. /** @hidden */
  133177. export var glowMapGenerationPixelShader: {
  133178. name: string;
  133179. shader: string;
  133180. };
  133181. }
  133182. declare module BABYLON {
  133183. /** @hidden */
  133184. export var glowMapGenerationVertexShader: {
  133185. name: string;
  133186. shader: string;
  133187. };
  133188. }
  133189. declare module BABYLON {
  133190. /**
  133191. * Effect layer options. This helps customizing the behaviour
  133192. * of the effect layer.
  133193. */
  133194. export interface IEffectLayerOptions {
  133195. /**
  133196. * Multiplication factor apply to the canvas size to compute the render target size
  133197. * used to generated the objects (the smaller the faster).
  133198. */
  133199. mainTextureRatio: number;
  133200. /**
  133201. * Enforces a fixed size texture to ensure effect stability across devices.
  133202. */
  133203. mainTextureFixedSize?: number;
  133204. /**
  133205. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  133206. */
  133207. alphaBlendingMode: number;
  133208. /**
  133209. * The camera attached to the layer.
  133210. */
  133211. camera: Nullable<Camera>;
  133212. /**
  133213. * The rendering group to draw the layer in.
  133214. */
  133215. renderingGroupId: number;
  133216. }
  133217. /**
  133218. * The effect layer Helps adding post process effect blended with the main pass.
  133219. *
  133220. * This can be for instance use to generate glow or higlight effects on the scene.
  133221. *
  133222. * The effect layer class can not be used directly and is intented to inherited from to be
  133223. * customized per effects.
  133224. */
  133225. export abstract class EffectLayer {
  133226. private _vertexBuffers;
  133227. private _indexBuffer;
  133228. private _cachedDefines;
  133229. private _effectLayerMapGenerationEffect;
  133230. private _effectLayerOptions;
  133231. private _mergeEffect;
  133232. protected _scene: Scene;
  133233. protected _engine: Engine;
  133234. protected _maxSize: number;
  133235. protected _mainTextureDesiredSize: ISize;
  133236. protected _mainTexture: RenderTargetTexture;
  133237. protected _shouldRender: boolean;
  133238. protected _postProcesses: PostProcess[];
  133239. protected _textures: BaseTexture[];
  133240. protected _emissiveTextureAndColor: {
  133241. texture: Nullable<BaseTexture>;
  133242. color: Color4;
  133243. };
  133244. /**
  133245. * The name of the layer
  133246. */
  133247. name: string;
  133248. /**
  133249. * The clear color of the texture used to generate the glow map.
  133250. */
  133251. neutralColor: Color4;
  133252. /**
  133253. * Specifies whether the highlight layer is enabled or not.
  133254. */
  133255. isEnabled: boolean;
  133256. /**
  133257. * Gets the camera attached to the layer.
  133258. */
  133259. get camera(): Nullable<Camera>;
  133260. /**
  133261. * Gets the rendering group id the layer should render in.
  133262. */
  133263. get renderingGroupId(): number;
  133264. set renderingGroupId(renderingGroupId: number);
  133265. /**
  133266. * An event triggered when the effect layer has been disposed.
  133267. */
  133268. onDisposeObservable: Observable<EffectLayer>;
  133269. /**
  133270. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  133271. */
  133272. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  133273. /**
  133274. * An event triggered when the generated texture is being merged in the scene.
  133275. */
  133276. onBeforeComposeObservable: Observable<EffectLayer>;
  133277. /**
  133278. * An event triggered when the mesh is rendered into the effect render target.
  133279. */
  133280. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  133281. /**
  133282. * An event triggered after the mesh has been rendered into the effect render target.
  133283. */
  133284. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  133285. /**
  133286. * An event triggered when the generated texture has been merged in the scene.
  133287. */
  133288. onAfterComposeObservable: Observable<EffectLayer>;
  133289. /**
  133290. * An event triggered when the efffect layer changes its size.
  133291. */
  133292. onSizeChangedObservable: Observable<EffectLayer>;
  133293. /** @hidden */
  133294. static _SceneComponentInitialization: (scene: Scene) => void;
  133295. /**
  133296. * Instantiates a new effect Layer and references it in the scene.
  133297. * @param name The name of the layer
  133298. * @param scene The scene to use the layer in
  133299. */
  133300. constructor(
  133301. /** The Friendly of the effect in the scene */
  133302. name: string, scene: Scene);
  133303. /**
  133304. * Get the effect name of the layer.
  133305. * @return The effect name
  133306. */
  133307. abstract getEffectName(): string;
  133308. /**
  133309. * Checks for the readiness of the element composing the layer.
  133310. * @param subMesh the mesh to check for
  133311. * @param useInstances specify whether or not to use instances to render the mesh
  133312. * @return true if ready otherwise, false
  133313. */
  133314. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133315. /**
  133316. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133317. * @returns true if the effect requires stencil during the main canvas render pass.
  133318. */
  133319. abstract needStencil(): boolean;
  133320. /**
  133321. * Create the merge effect. This is the shader use to blit the information back
  133322. * to the main canvas at the end of the scene rendering.
  133323. * @returns The effect containing the shader used to merge the effect on the main canvas
  133324. */
  133325. protected abstract _createMergeEffect(): Effect;
  133326. /**
  133327. * Creates the render target textures and post processes used in the effect layer.
  133328. */
  133329. protected abstract _createTextureAndPostProcesses(): void;
  133330. /**
  133331. * Implementation specific of rendering the generating effect on the main canvas.
  133332. * @param effect The effect used to render through
  133333. */
  133334. protected abstract _internalRender(effect: Effect): void;
  133335. /**
  133336. * Sets the required values for both the emissive texture and and the main color.
  133337. */
  133338. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133339. /**
  133340. * Free any resources and references associated to a mesh.
  133341. * Internal use
  133342. * @param mesh The mesh to free.
  133343. */
  133344. abstract _disposeMesh(mesh: Mesh): void;
  133345. /**
  133346. * Serializes this layer (Glow or Highlight for example)
  133347. * @returns a serialized layer object
  133348. */
  133349. abstract serialize?(): any;
  133350. /**
  133351. * Initializes the effect layer with the required options.
  133352. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  133353. */
  133354. protected _init(options: Partial<IEffectLayerOptions>): void;
  133355. /**
  133356. * Generates the index buffer of the full screen quad blending to the main canvas.
  133357. */
  133358. private _generateIndexBuffer;
  133359. /**
  133360. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  133361. */
  133362. private _generateVertexBuffer;
  133363. /**
  133364. * Sets the main texture desired size which is the closest power of two
  133365. * of the engine canvas size.
  133366. */
  133367. private _setMainTextureSize;
  133368. /**
  133369. * Creates the main texture for the effect layer.
  133370. */
  133371. protected _createMainTexture(): void;
  133372. /**
  133373. * Adds specific effects defines.
  133374. * @param defines The defines to add specifics to.
  133375. */
  133376. protected _addCustomEffectDefines(defines: string[]): void;
  133377. /**
  133378. * Checks for the readiness of the element composing the layer.
  133379. * @param subMesh the mesh to check for
  133380. * @param useInstances specify whether or not to use instances to render the mesh
  133381. * @param emissiveTexture the associated emissive texture used to generate the glow
  133382. * @return true if ready otherwise, false
  133383. */
  133384. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  133385. /**
  133386. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  133387. */
  133388. render(): void;
  133389. /**
  133390. * Determine if a given mesh will be used in the current effect.
  133391. * @param mesh mesh to test
  133392. * @returns true if the mesh will be used
  133393. */
  133394. hasMesh(mesh: AbstractMesh): boolean;
  133395. /**
  133396. * Returns true if the layer contains information to display, otherwise false.
  133397. * @returns true if the glow layer should be rendered
  133398. */
  133399. shouldRender(): boolean;
  133400. /**
  133401. * Returns true if the mesh should render, otherwise false.
  133402. * @param mesh The mesh to render
  133403. * @returns true if it should render otherwise false
  133404. */
  133405. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  133406. /**
  133407. * Returns true if the mesh can be rendered, otherwise false.
  133408. * @param mesh The mesh to render
  133409. * @param material The material used on the mesh
  133410. * @returns true if it can be rendered otherwise false
  133411. */
  133412. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133413. /**
  133414. * Returns true if the mesh should render, otherwise false.
  133415. * @param mesh The mesh to render
  133416. * @returns true if it should render otherwise false
  133417. */
  133418. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  133419. /**
  133420. * Renders the submesh passed in parameter to the generation map.
  133421. */
  133422. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  133423. /**
  133424. * Defines whether the current material of the mesh should be use to render the effect.
  133425. * @param mesh defines the current mesh to render
  133426. */
  133427. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133428. /**
  133429. * Rebuild the required buffers.
  133430. * @hidden Internal use only.
  133431. */
  133432. _rebuild(): void;
  133433. /**
  133434. * Dispose only the render target textures and post process.
  133435. */
  133436. private _disposeTextureAndPostProcesses;
  133437. /**
  133438. * Dispose the highlight layer and free resources.
  133439. */
  133440. dispose(): void;
  133441. /**
  133442. * Gets the class name of the effect layer
  133443. * @returns the string with the class name of the effect layer
  133444. */
  133445. getClassName(): string;
  133446. /**
  133447. * Creates an effect layer from parsed effect layer data
  133448. * @param parsedEffectLayer defines effect layer data
  133449. * @param scene defines the current scene
  133450. * @param rootUrl defines the root URL containing the effect layer information
  133451. * @returns a parsed effect Layer
  133452. */
  133453. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  133454. }
  133455. }
  133456. declare module BABYLON {
  133457. interface AbstractScene {
  133458. /**
  133459. * The list of effect layers (highlights/glow) added to the scene
  133460. * @see http://doc.babylonjs.com/how_to/highlight_layer
  133461. * @see http://doc.babylonjs.com/how_to/glow_layer
  133462. */
  133463. effectLayers: Array<EffectLayer>;
  133464. /**
  133465. * Removes the given effect layer from this scene.
  133466. * @param toRemove defines the effect layer to remove
  133467. * @returns the index of the removed effect layer
  133468. */
  133469. removeEffectLayer(toRemove: EffectLayer): number;
  133470. /**
  133471. * Adds the given effect layer to this scene
  133472. * @param newEffectLayer defines the effect layer to add
  133473. */
  133474. addEffectLayer(newEffectLayer: EffectLayer): void;
  133475. }
  133476. /**
  133477. * Defines the layer scene component responsible to manage any effect layers
  133478. * in a given scene.
  133479. */
  133480. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  133481. /**
  133482. * The component name helpfull to identify the component in the list of scene components.
  133483. */
  133484. readonly name: string;
  133485. /**
  133486. * The scene the component belongs to.
  133487. */
  133488. scene: Scene;
  133489. private _engine;
  133490. private _renderEffects;
  133491. private _needStencil;
  133492. private _previousStencilState;
  133493. /**
  133494. * Creates a new instance of the component for the given scene
  133495. * @param scene Defines the scene to register the component in
  133496. */
  133497. constructor(scene: Scene);
  133498. /**
  133499. * Registers the component in a given scene
  133500. */
  133501. register(): void;
  133502. /**
  133503. * Rebuilds the elements related to this component in case of
  133504. * context lost for instance.
  133505. */
  133506. rebuild(): void;
  133507. /**
  133508. * Serializes the component data to the specified json object
  133509. * @param serializationObject The object to serialize to
  133510. */
  133511. serialize(serializationObject: any): void;
  133512. /**
  133513. * Adds all the elements from the container to the scene
  133514. * @param container the container holding the elements
  133515. */
  133516. addFromContainer(container: AbstractScene): void;
  133517. /**
  133518. * Removes all the elements in the container from the scene
  133519. * @param container contains the elements to remove
  133520. * @param dispose if the removed element should be disposed (default: false)
  133521. */
  133522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133523. /**
  133524. * Disposes the component and the associated ressources.
  133525. */
  133526. dispose(): void;
  133527. private _isReadyForMesh;
  133528. private _renderMainTexture;
  133529. private _setStencil;
  133530. private _setStencilBack;
  133531. private _draw;
  133532. private _drawCamera;
  133533. private _drawRenderingGroup;
  133534. }
  133535. }
  133536. declare module BABYLON {
  133537. /** @hidden */
  133538. export var glowMapMergePixelShader: {
  133539. name: string;
  133540. shader: string;
  133541. };
  133542. }
  133543. declare module BABYLON {
  133544. /** @hidden */
  133545. export var glowMapMergeVertexShader: {
  133546. name: string;
  133547. shader: string;
  133548. };
  133549. }
  133550. declare module BABYLON {
  133551. interface AbstractScene {
  133552. /**
  133553. * Return a the first highlight layer of the scene with a given name.
  133554. * @param name The name of the highlight layer to look for.
  133555. * @return The highlight layer if found otherwise null.
  133556. */
  133557. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  133558. }
  133559. /**
  133560. * Glow layer options. This helps customizing the behaviour
  133561. * of the glow layer.
  133562. */
  133563. export interface IGlowLayerOptions {
  133564. /**
  133565. * Multiplication factor apply to the canvas size to compute the render target size
  133566. * used to generated the glowing objects (the smaller the faster).
  133567. */
  133568. mainTextureRatio: number;
  133569. /**
  133570. * Enforces a fixed size texture to ensure resize independant blur.
  133571. */
  133572. mainTextureFixedSize?: number;
  133573. /**
  133574. * How big is the kernel of the blur texture.
  133575. */
  133576. blurKernelSize: number;
  133577. /**
  133578. * The camera attached to the layer.
  133579. */
  133580. camera: Nullable<Camera>;
  133581. /**
  133582. * Enable MSAA by chosing the number of samples.
  133583. */
  133584. mainTextureSamples?: number;
  133585. /**
  133586. * The rendering group to draw the layer in.
  133587. */
  133588. renderingGroupId: number;
  133589. }
  133590. /**
  133591. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  133592. *
  133593. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  133594. *
  133595. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  133596. */
  133597. export class GlowLayer extends EffectLayer {
  133598. /**
  133599. * Effect Name of the layer.
  133600. */
  133601. static readonly EffectName: string;
  133602. /**
  133603. * The default blur kernel size used for the glow.
  133604. */
  133605. static DefaultBlurKernelSize: number;
  133606. /**
  133607. * The default texture size ratio used for the glow.
  133608. */
  133609. static DefaultTextureRatio: number;
  133610. /**
  133611. * Sets the kernel size of the blur.
  133612. */
  133613. set blurKernelSize(value: number);
  133614. /**
  133615. * Gets the kernel size of the blur.
  133616. */
  133617. get blurKernelSize(): number;
  133618. /**
  133619. * Sets the glow intensity.
  133620. */
  133621. set intensity(value: number);
  133622. /**
  133623. * Gets the glow intensity.
  133624. */
  133625. get intensity(): number;
  133626. private _options;
  133627. private _intensity;
  133628. private _horizontalBlurPostprocess1;
  133629. private _verticalBlurPostprocess1;
  133630. private _horizontalBlurPostprocess2;
  133631. private _verticalBlurPostprocess2;
  133632. private _blurTexture1;
  133633. private _blurTexture2;
  133634. private _postProcesses1;
  133635. private _postProcesses2;
  133636. private _includedOnlyMeshes;
  133637. private _excludedMeshes;
  133638. private _meshesUsingTheirOwnMaterials;
  133639. /**
  133640. * Callback used to let the user override the color selection on a per mesh basis
  133641. */
  133642. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  133643. /**
  133644. * Callback used to let the user override the texture selection on a per mesh basis
  133645. */
  133646. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  133647. /**
  133648. * Instantiates a new glow Layer and references it to the scene.
  133649. * @param name The name of the layer
  133650. * @param scene The scene to use the layer in
  133651. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  133652. */
  133653. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  133654. /**
  133655. * Get the effect name of the layer.
  133656. * @return The effect name
  133657. */
  133658. getEffectName(): string;
  133659. /**
  133660. * Create the merge effect. This is the shader use to blit the information back
  133661. * to the main canvas at the end of the scene rendering.
  133662. */
  133663. protected _createMergeEffect(): Effect;
  133664. /**
  133665. * Creates the render target textures and post processes used in the glow layer.
  133666. */
  133667. protected _createTextureAndPostProcesses(): void;
  133668. /**
  133669. * Checks for the readiness of the element composing the layer.
  133670. * @param subMesh the mesh to check for
  133671. * @param useInstances specify wether or not to use instances to render the mesh
  133672. * @param emissiveTexture the associated emissive texture used to generate the glow
  133673. * @return true if ready otherwise, false
  133674. */
  133675. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133676. /**
  133677. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133678. */
  133679. needStencil(): boolean;
  133680. /**
  133681. * Returns true if the mesh can be rendered, otherwise false.
  133682. * @param mesh The mesh to render
  133683. * @param material The material used on the mesh
  133684. * @returns true if it can be rendered otherwise false
  133685. */
  133686. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133687. /**
  133688. * Implementation specific of rendering the generating effect on the main canvas.
  133689. * @param effect The effect used to render through
  133690. */
  133691. protected _internalRender(effect: Effect): void;
  133692. /**
  133693. * Sets the required values for both the emissive texture and and the main color.
  133694. */
  133695. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133696. /**
  133697. * Returns true if the mesh should render, otherwise false.
  133698. * @param mesh The mesh to render
  133699. * @returns true if it should render otherwise false
  133700. */
  133701. protected _shouldRenderMesh(mesh: Mesh): boolean;
  133702. /**
  133703. * Adds specific effects defines.
  133704. * @param defines The defines to add specifics to.
  133705. */
  133706. protected _addCustomEffectDefines(defines: string[]): void;
  133707. /**
  133708. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  133709. * @param mesh The mesh to exclude from the glow layer
  133710. */
  133711. addExcludedMesh(mesh: Mesh): void;
  133712. /**
  133713. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  133714. * @param mesh The mesh to remove
  133715. */
  133716. removeExcludedMesh(mesh: Mesh): void;
  133717. /**
  133718. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  133719. * @param mesh The mesh to include in the glow layer
  133720. */
  133721. addIncludedOnlyMesh(mesh: Mesh): void;
  133722. /**
  133723. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  133724. * @param mesh The mesh to remove
  133725. */
  133726. removeIncludedOnlyMesh(mesh: Mesh): void;
  133727. /**
  133728. * Determine if a given mesh will be used in the glow layer
  133729. * @param mesh The mesh to test
  133730. * @returns true if the mesh will be highlighted by the current glow layer
  133731. */
  133732. hasMesh(mesh: AbstractMesh): boolean;
  133733. /**
  133734. * Defines whether the current material of the mesh should be use to render the effect.
  133735. * @param mesh defines the current mesh to render
  133736. */
  133737. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133738. /**
  133739. * Add a mesh to be rendered through its own material and not with emissive only.
  133740. * @param mesh The mesh for which we need to use its material
  133741. */
  133742. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  133743. /**
  133744. * Remove a mesh from being rendered through its own material and not with emissive only.
  133745. * @param mesh The mesh for which we need to not use its material
  133746. */
  133747. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  133748. /**
  133749. * Free any resources and references associated to a mesh.
  133750. * Internal use
  133751. * @param mesh The mesh to free.
  133752. * @hidden
  133753. */
  133754. _disposeMesh(mesh: Mesh): void;
  133755. /**
  133756. * Gets the class name of the effect layer
  133757. * @returns the string with the class name of the effect layer
  133758. */
  133759. getClassName(): string;
  133760. /**
  133761. * Serializes this glow layer
  133762. * @returns a serialized glow layer object
  133763. */
  133764. serialize(): any;
  133765. /**
  133766. * Creates a Glow Layer from parsed glow layer data
  133767. * @param parsedGlowLayer defines glow layer data
  133768. * @param scene defines the current scene
  133769. * @param rootUrl defines the root URL containing the glow layer information
  133770. * @returns a parsed Glow Layer
  133771. */
  133772. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  133773. }
  133774. }
  133775. declare module BABYLON {
  133776. /** @hidden */
  133777. export var glowBlurPostProcessPixelShader: {
  133778. name: string;
  133779. shader: string;
  133780. };
  133781. }
  133782. declare module BABYLON {
  133783. interface AbstractScene {
  133784. /**
  133785. * Return a the first highlight layer of the scene with a given name.
  133786. * @param name The name of the highlight layer to look for.
  133787. * @return The highlight layer if found otherwise null.
  133788. */
  133789. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  133790. }
  133791. /**
  133792. * Highlight layer options. This helps customizing the behaviour
  133793. * of the highlight layer.
  133794. */
  133795. export interface IHighlightLayerOptions {
  133796. /**
  133797. * Multiplication factor apply to the canvas size to compute the render target size
  133798. * used to generated the glowing objects (the smaller the faster).
  133799. */
  133800. mainTextureRatio: number;
  133801. /**
  133802. * Enforces a fixed size texture to ensure resize independant blur.
  133803. */
  133804. mainTextureFixedSize?: number;
  133805. /**
  133806. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  133807. * of the picture to blur (the smaller the faster).
  133808. */
  133809. blurTextureSizeRatio: number;
  133810. /**
  133811. * How big in texel of the blur texture is the vertical blur.
  133812. */
  133813. blurVerticalSize: number;
  133814. /**
  133815. * How big in texel of the blur texture is the horizontal blur.
  133816. */
  133817. blurHorizontalSize: number;
  133818. /**
  133819. * Alpha blending mode used to apply the blur. Default is combine.
  133820. */
  133821. alphaBlendingMode: number;
  133822. /**
  133823. * The camera attached to the layer.
  133824. */
  133825. camera: Nullable<Camera>;
  133826. /**
  133827. * Should we display highlight as a solid stroke?
  133828. */
  133829. isStroke?: boolean;
  133830. /**
  133831. * The rendering group to draw the layer in.
  133832. */
  133833. renderingGroupId: number;
  133834. }
  133835. /**
  133836. * The highlight layer Helps adding a glow effect around a mesh.
  133837. *
  133838. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  133839. * glowy meshes to your scene.
  133840. *
  133841. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  133842. */
  133843. export class HighlightLayer extends EffectLayer {
  133844. name: string;
  133845. /**
  133846. * Effect Name of the highlight layer.
  133847. */
  133848. static readonly EffectName: string;
  133849. /**
  133850. * The neutral color used during the preparation of the glow effect.
  133851. * This is black by default as the blend operation is a blend operation.
  133852. */
  133853. static NeutralColor: Color4;
  133854. /**
  133855. * Stencil value used for glowing meshes.
  133856. */
  133857. static GlowingMeshStencilReference: number;
  133858. /**
  133859. * Stencil value used for the other meshes in the scene.
  133860. */
  133861. static NormalMeshStencilReference: number;
  133862. /**
  133863. * Specifies whether or not the inner glow is ACTIVE in the layer.
  133864. */
  133865. innerGlow: boolean;
  133866. /**
  133867. * Specifies whether or not the outer glow is ACTIVE in the layer.
  133868. */
  133869. outerGlow: boolean;
  133870. /**
  133871. * Specifies the horizontal size of the blur.
  133872. */
  133873. set blurHorizontalSize(value: number);
  133874. /**
  133875. * Specifies the vertical size of the blur.
  133876. */
  133877. set blurVerticalSize(value: number);
  133878. /**
  133879. * Gets the horizontal size of the blur.
  133880. */
  133881. get blurHorizontalSize(): number;
  133882. /**
  133883. * Gets the vertical size of the blur.
  133884. */
  133885. get blurVerticalSize(): number;
  133886. /**
  133887. * An event triggered when the highlight layer is being blurred.
  133888. */
  133889. onBeforeBlurObservable: Observable<HighlightLayer>;
  133890. /**
  133891. * An event triggered when the highlight layer has been blurred.
  133892. */
  133893. onAfterBlurObservable: Observable<HighlightLayer>;
  133894. private _instanceGlowingMeshStencilReference;
  133895. private _options;
  133896. private _downSamplePostprocess;
  133897. private _horizontalBlurPostprocess;
  133898. private _verticalBlurPostprocess;
  133899. private _blurTexture;
  133900. private _meshes;
  133901. private _excludedMeshes;
  133902. /**
  133903. * Instantiates a new highlight Layer and references it to the scene..
  133904. * @param name The name of the layer
  133905. * @param scene The scene to use the layer in
  133906. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  133907. */
  133908. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  133909. /**
  133910. * Get the effect name of the layer.
  133911. * @return The effect name
  133912. */
  133913. getEffectName(): string;
  133914. /**
  133915. * Create the merge effect. This is the shader use to blit the information back
  133916. * to the main canvas at the end of the scene rendering.
  133917. */
  133918. protected _createMergeEffect(): Effect;
  133919. /**
  133920. * Creates the render target textures and post processes used in the highlight layer.
  133921. */
  133922. protected _createTextureAndPostProcesses(): void;
  133923. /**
  133924. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  133925. */
  133926. needStencil(): boolean;
  133927. /**
  133928. * Checks for the readiness of the element composing the layer.
  133929. * @param subMesh the mesh to check for
  133930. * @param useInstances specify wether or not to use instances to render the mesh
  133931. * @param emissiveTexture the associated emissive texture used to generate the glow
  133932. * @return true if ready otherwise, false
  133933. */
  133934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133935. /**
  133936. * Implementation specific of rendering the generating effect on the main canvas.
  133937. * @param effect The effect used to render through
  133938. */
  133939. protected _internalRender(effect: Effect): void;
  133940. /**
  133941. * Returns true if the layer contains information to display, otherwise false.
  133942. */
  133943. shouldRender(): boolean;
  133944. /**
  133945. * Returns true if the mesh should render, otherwise false.
  133946. * @param mesh The mesh to render
  133947. * @returns true if it should render otherwise false
  133948. */
  133949. protected _shouldRenderMesh(mesh: Mesh): boolean;
  133950. /**
  133951. * Adds specific effects defines.
  133952. * @param defines The defines to add specifics to.
  133953. */
  133954. protected _addCustomEffectDefines(defines: string[]): void;
  133955. /**
  133956. * Sets the required values for both the emissive texture and and the main color.
  133957. */
  133958. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133959. /**
  133960. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  133961. * @param mesh The mesh to exclude from the highlight layer
  133962. */
  133963. addExcludedMesh(mesh: Mesh): void;
  133964. /**
  133965. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  133966. * @param mesh The mesh to highlight
  133967. */
  133968. removeExcludedMesh(mesh: Mesh): void;
  133969. /**
  133970. * Determine if a given mesh will be highlighted by the current HighlightLayer
  133971. * @param mesh mesh to test
  133972. * @returns true if the mesh will be highlighted by the current HighlightLayer
  133973. */
  133974. hasMesh(mesh: AbstractMesh): boolean;
  133975. /**
  133976. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  133977. * @param mesh The mesh to highlight
  133978. * @param color The color of the highlight
  133979. * @param glowEmissiveOnly Extract the glow from the emissive texture
  133980. */
  133981. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  133982. /**
  133983. * Remove a mesh from the highlight layer in order to make it stop glowing.
  133984. * @param mesh The mesh to highlight
  133985. */
  133986. removeMesh(mesh: Mesh): void;
  133987. /**
  133988. * Remove all the meshes currently referenced in the highlight layer
  133989. */
  133990. removeAllMeshes(): void;
  133991. /**
  133992. * Force the stencil to the normal expected value for none glowing parts
  133993. */
  133994. private _defaultStencilReference;
  133995. /**
  133996. * Free any resources and references associated to a mesh.
  133997. * Internal use
  133998. * @param mesh The mesh to free.
  133999. * @hidden
  134000. */
  134001. _disposeMesh(mesh: Mesh): void;
  134002. /**
  134003. * Dispose the highlight layer and free resources.
  134004. */
  134005. dispose(): void;
  134006. /**
  134007. * Gets the class name of the effect layer
  134008. * @returns the string with the class name of the effect layer
  134009. */
  134010. getClassName(): string;
  134011. /**
  134012. * Serializes this Highlight layer
  134013. * @returns a serialized Highlight layer object
  134014. */
  134015. serialize(): any;
  134016. /**
  134017. * Creates a Highlight layer from parsed Highlight layer data
  134018. * @param parsedHightlightLayer defines the Highlight layer data
  134019. * @param scene defines the current scene
  134020. * @param rootUrl defines the root URL containing the Highlight layer information
  134021. * @returns a parsed Highlight layer
  134022. */
  134023. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  134024. }
  134025. }
  134026. declare module BABYLON {
  134027. interface AbstractScene {
  134028. /**
  134029. * The list of layers (background and foreground) of the scene
  134030. */
  134031. layers: Array<Layer>;
  134032. }
  134033. /**
  134034. * Defines the layer scene component responsible to manage any layers
  134035. * in a given scene.
  134036. */
  134037. export class LayerSceneComponent implements ISceneComponent {
  134038. /**
  134039. * The component name helpfull to identify the component in the list of scene components.
  134040. */
  134041. readonly name: string;
  134042. /**
  134043. * The scene the component belongs to.
  134044. */
  134045. scene: Scene;
  134046. private _engine;
  134047. /**
  134048. * Creates a new instance of the component for the given scene
  134049. * @param scene Defines the scene to register the component in
  134050. */
  134051. constructor(scene: Scene);
  134052. /**
  134053. * Registers the component in a given scene
  134054. */
  134055. register(): void;
  134056. /**
  134057. * Rebuilds the elements related to this component in case of
  134058. * context lost for instance.
  134059. */
  134060. rebuild(): void;
  134061. /**
  134062. * Disposes the component and the associated ressources.
  134063. */
  134064. dispose(): void;
  134065. private _draw;
  134066. private _drawCameraPredicate;
  134067. private _drawCameraBackground;
  134068. private _drawCameraForeground;
  134069. private _drawRenderTargetPredicate;
  134070. private _drawRenderTargetBackground;
  134071. private _drawRenderTargetForeground;
  134072. /**
  134073. * Adds all the elements from the container to the scene
  134074. * @param container the container holding the elements
  134075. */
  134076. addFromContainer(container: AbstractScene): void;
  134077. /**
  134078. * Removes all the elements in the container from the scene
  134079. * @param container contains the elements to remove
  134080. * @param dispose if the removed element should be disposed (default: false)
  134081. */
  134082. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134083. }
  134084. }
  134085. declare module BABYLON {
  134086. /** @hidden */
  134087. export var layerPixelShader: {
  134088. name: string;
  134089. shader: string;
  134090. };
  134091. }
  134092. declare module BABYLON {
  134093. /** @hidden */
  134094. export var layerVertexShader: {
  134095. name: string;
  134096. shader: string;
  134097. };
  134098. }
  134099. declare module BABYLON {
  134100. /**
  134101. * This represents a full screen 2d layer.
  134102. * This can be useful to display a picture in the background of your scene for instance.
  134103. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134104. */
  134105. export class Layer {
  134106. /**
  134107. * Define the name of the layer.
  134108. */
  134109. name: string;
  134110. /**
  134111. * Define the texture the layer should display.
  134112. */
  134113. texture: Nullable<Texture>;
  134114. /**
  134115. * Is the layer in background or foreground.
  134116. */
  134117. isBackground: boolean;
  134118. /**
  134119. * Define the color of the layer (instead of texture).
  134120. */
  134121. color: Color4;
  134122. /**
  134123. * Define the scale of the layer in order to zoom in out of the texture.
  134124. */
  134125. scale: Vector2;
  134126. /**
  134127. * Define an offset for the layer in order to shift the texture.
  134128. */
  134129. offset: Vector2;
  134130. /**
  134131. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  134132. */
  134133. alphaBlendingMode: number;
  134134. /**
  134135. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  134136. * Alpha test will not mix with the background color in case of transparency.
  134137. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  134138. */
  134139. alphaTest: boolean;
  134140. /**
  134141. * Define a mask to restrict the layer to only some of the scene cameras.
  134142. */
  134143. layerMask: number;
  134144. /**
  134145. * Define the list of render target the layer is visible into.
  134146. */
  134147. renderTargetTextures: RenderTargetTexture[];
  134148. /**
  134149. * Define if the layer is only used in renderTarget or if it also
  134150. * renders in the main frame buffer of the canvas.
  134151. */
  134152. renderOnlyInRenderTargetTextures: boolean;
  134153. private _scene;
  134154. private _vertexBuffers;
  134155. private _indexBuffer;
  134156. private _effect;
  134157. private _previousDefines;
  134158. /**
  134159. * An event triggered when the layer is disposed.
  134160. */
  134161. onDisposeObservable: Observable<Layer>;
  134162. private _onDisposeObserver;
  134163. /**
  134164. * Back compatibility with callback before the onDisposeObservable existed.
  134165. * The set callback will be triggered when the layer has been disposed.
  134166. */
  134167. set onDispose(callback: () => void);
  134168. /**
  134169. * An event triggered before rendering the scene
  134170. */
  134171. onBeforeRenderObservable: Observable<Layer>;
  134172. private _onBeforeRenderObserver;
  134173. /**
  134174. * Back compatibility with callback before the onBeforeRenderObservable existed.
  134175. * The set callback will be triggered just before rendering the layer.
  134176. */
  134177. set onBeforeRender(callback: () => void);
  134178. /**
  134179. * An event triggered after rendering the scene
  134180. */
  134181. onAfterRenderObservable: Observable<Layer>;
  134182. private _onAfterRenderObserver;
  134183. /**
  134184. * Back compatibility with callback before the onAfterRenderObservable existed.
  134185. * The set callback will be triggered just after rendering the layer.
  134186. */
  134187. set onAfterRender(callback: () => void);
  134188. /**
  134189. * Instantiates a new layer.
  134190. * This represents a full screen 2d layer.
  134191. * This can be useful to display a picture in the background of your scene for instance.
  134192. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134193. * @param name Define the name of the layer in the scene
  134194. * @param imgUrl Define the url of the texture to display in the layer
  134195. * @param scene Define the scene the layer belongs to
  134196. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  134197. * @param color Defines a color for the layer
  134198. */
  134199. constructor(
  134200. /**
  134201. * Define the name of the layer.
  134202. */
  134203. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  134204. private _createIndexBuffer;
  134205. /** @hidden */
  134206. _rebuild(): void;
  134207. /**
  134208. * Renders the layer in the scene.
  134209. */
  134210. render(): void;
  134211. /**
  134212. * Disposes and releases the associated ressources.
  134213. */
  134214. dispose(): void;
  134215. }
  134216. }
  134217. declare module BABYLON {
  134218. /** @hidden */
  134219. export var lensFlarePixelShader: {
  134220. name: string;
  134221. shader: string;
  134222. };
  134223. }
  134224. declare module BABYLON {
  134225. /** @hidden */
  134226. export var lensFlareVertexShader: {
  134227. name: string;
  134228. shader: string;
  134229. };
  134230. }
  134231. declare module BABYLON {
  134232. /**
  134233. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134234. * It is usually composed of several `lensFlare`.
  134235. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134236. */
  134237. export class LensFlareSystem {
  134238. /**
  134239. * Define the name of the lens flare system
  134240. */
  134241. name: string;
  134242. /**
  134243. * List of lens flares used in this system.
  134244. */
  134245. lensFlares: LensFlare[];
  134246. /**
  134247. * Define a limit from the border the lens flare can be visible.
  134248. */
  134249. borderLimit: number;
  134250. /**
  134251. * Define a viewport border we do not want to see the lens flare in.
  134252. */
  134253. viewportBorder: number;
  134254. /**
  134255. * Define a predicate which could limit the list of meshes able to occlude the effect.
  134256. */
  134257. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134258. /**
  134259. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  134260. */
  134261. layerMask: number;
  134262. /**
  134263. * Define the id of the lens flare system in the scene.
  134264. * (equal to name by default)
  134265. */
  134266. id: string;
  134267. private _scene;
  134268. private _emitter;
  134269. private _vertexBuffers;
  134270. private _indexBuffer;
  134271. private _effect;
  134272. private _positionX;
  134273. private _positionY;
  134274. private _isEnabled;
  134275. /** @hidden */
  134276. static _SceneComponentInitialization: (scene: Scene) => void;
  134277. /**
  134278. * Instantiates a lens flare system.
  134279. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134280. * It is usually composed of several `lensFlare`.
  134281. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134282. * @param name Define the name of the lens flare system in the scene
  134283. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  134284. * @param scene Define the scene the lens flare system belongs to
  134285. */
  134286. constructor(
  134287. /**
  134288. * Define the name of the lens flare system
  134289. */
  134290. name: string, emitter: any, scene: Scene);
  134291. /**
  134292. * Define if the lens flare system is enabled.
  134293. */
  134294. get isEnabled(): boolean;
  134295. set isEnabled(value: boolean);
  134296. /**
  134297. * Get the scene the effects belongs to.
  134298. * @returns the scene holding the lens flare system
  134299. */
  134300. getScene(): Scene;
  134301. /**
  134302. * Get the emitter of the lens flare system.
  134303. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134304. * @returns the emitter of the lens flare system
  134305. */
  134306. getEmitter(): any;
  134307. /**
  134308. * Set the emitter of the lens flare system.
  134309. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134310. * @param newEmitter Define the new emitter of the system
  134311. */
  134312. setEmitter(newEmitter: any): void;
  134313. /**
  134314. * Get the lens flare system emitter position.
  134315. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  134316. * @returns the position
  134317. */
  134318. getEmitterPosition(): Vector3;
  134319. /**
  134320. * @hidden
  134321. */
  134322. computeEffectivePosition(globalViewport: Viewport): boolean;
  134323. /** @hidden */
  134324. _isVisible(): boolean;
  134325. /**
  134326. * @hidden
  134327. */
  134328. render(): boolean;
  134329. /**
  134330. * Dispose and release the lens flare with its associated resources.
  134331. */
  134332. dispose(): void;
  134333. /**
  134334. * Parse a lens flare system from a JSON repressentation
  134335. * @param parsedLensFlareSystem Define the JSON to parse
  134336. * @param scene Define the scene the parsed system should be instantiated in
  134337. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  134338. * @returns the parsed system
  134339. */
  134340. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  134341. /**
  134342. * Serialize the current Lens Flare System into a JSON representation.
  134343. * @returns the serialized JSON
  134344. */
  134345. serialize(): any;
  134346. }
  134347. }
  134348. declare module BABYLON {
  134349. /**
  134350. * This represents one of the lens effect in a `lensFlareSystem`.
  134351. * It controls one of the indiviual texture used in the effect.
  134352. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134353. */
  134354. export class LensFlare {
  134355. /**
  134356. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134357. */
  134358. size: number;
  134359. /**
  134360. * 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.
  134361. */
  134362. position: number;
  134363. /**
  134364. * Define the lens color.
  134365. */
  134366. color: Color3;
  134367. /**
  134368. * Define the lens texture.
  134369. */
  134370. texture: Nullable<Texture>;
  134371. /**
  134372. * Define the alpha mode to render this particular lens.
  134373. */
  134374. alphaMode: number;
  134375. private _system;
  134376. /**
  134377. * Creates a new Lens Flare.
  134378. * This represents one of the lens effect in a `lensFlareSystem`.
  134379. * It controls one of the indiviual texture used in the effect.
  134380. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134381. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  134382. * @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.
  134383. * @param color Define the lens color
  134384. * @param imgUrl Define the lens texture url
  134385. * @param system Define the `lensFlareSystem` this flare is part of
  134386. * @returns The newly created Lens Flare
  134387. */
  134388. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  134389. /**
  134390. * Instantiates a new Lens Flare.
  134391. * This represents one of the lens effect in a `lensFlareSystem`.
  134392. * It controls one of the indiviual texture used in the effect.
  134393. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134394. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  134395. * @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.
  134396. * @param color Define the lens color
  134397. * @param imgUrl Define the lens texture url
  134398. * @param system Define the `lensFlareSystem` this flare is part of
  134399. */
  134400. constructor(
  134401. /**
  134402. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134403. */
  134404. size: number,
  134405. /**
  134406. * 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.
  134407. */
  134408. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  134409. /**
  134410. * Dispose and release the lens flare with its associated resources.
  134411. */
  134412. dispose(): void;
  134413. }
  134414. }
  134415. declare module BABYLON {
  134416. interface AbstractScene {
  134417. /**
  134418. * The list of lens flare system added to the scene
  134419. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134420. */
  134421. lensFlareSystems: Array<LensFlareSystem>;
  134422. /**
  134423. * Removes the given lens flare system from this scene.
  134424. * @param toRemove The lens flare system to remove
  134425. * @returns The index of the removed lens flare system
  134426. */
  134427. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  134428. /**
  134429. * Adds the given lens flare system to this scene
  134430. * @param newLensFlareSystem The lens flare system to add
  134431. */
  134432. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  134433. /**
  134434. * Gets a lens flare system using its name
  134435. * @param name defines the name to look for
  134436. * @returns the lens flare system or null if not found
  134437. */
  134438. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  134439. /**
  134440. * Gets a lens flare system using its id
  134441. * @param id defines the id to look for
  134442. * @returns the lens flare system or null if not found
  134443. */
  134444. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  134445. }
  134446. /**
  134447. * Defines the lens flare scene component responsible to manage any lens flares
  134448. * in a given scene.
  134449. */
  134450. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  134451. /**
  134452. * The component name helpfull to identify the component in the list of scene components.
  134453. */
  134454. readonly name: string;
  134455. /**
  134456. * The scene the component belongs to.
  134457. */
  134458. scene: Scene;
  134459. /**
  134460. * Creates a new instance of the component for the given scene
  134461. * @param scene Defines the scene to register the component in
  134462. */
  134463. constructor(scene: Scene);
  134464. /**
  134465. * Registers the component in a given scene
  134466. */
  134467. register(): void;
  134468. /**
  134469. * Rebuilds the elements related to this component in case of
  134470. * context lost for instance.
  134471. */
  134472. rebuild(): void;
  134473. /**
  134474. * Adds all the elements from the container to the scene
  134475. * @param container the container holding the elements
  134476. */
  134477. addFromContainer(container: AbstractScene): void;
  134478. /**
  134479. * Removes all the elements in the container from the scene
  134480. * @param container contains the elements to remove
  134481. * @param dispose if the removed element should be disposed (default: false)
  134482. */
  134483. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134484. /**
  134485. * Serializes the component data to the specified json object
  134486. * @param serializationObject The object to serialize to
  134487. */
  134488. serialize(serializationObject: any): void;
  134489. /**
  134490. * Disposes the component and the associated ressources.
  134491. */
  134492. dispose(): void;
  134493. private _draw;
  134494. }
  134495. }
  134496. declare module BABYLON {
  134497. /** @hidden */
  134498. export var depthPixelShader: {
  134499. name: string;
  134500. shader: string;
  134501. };
  134502. }
  134503. declare module BABYLON {
  134504. /** @hidden */
  134505. export var depthVertexShader: {
  134506. name: string;
  134507. shader: string;
  134508. };
  134509. }
  134510. declare module BABYLON {
  134511. /**
  134512. * This represents a depth renderer in Babylon.
  134513. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  134514. */
  134515. export class DepthRenderer {
  134516. private _scene;
  134517. private _depthMap;
  134518. private _effect;
  134519. private readonly _storeNonLinearDepth;
  134520. private readonly _clearColor;
  134521. /** Get if the depth renderer is using packed depth or not */
  134522. readonly isPacked: boolean;
  134523. private _cachedDefines;
  134524. private _camera;
  134525. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  134526. enabled: boolean;
  134527. /**
  134528. * Specifiess that the depth renderer will only be used within
  134529. * the camera it is created for.
  134530. * This can help forcing its rendering during the camera processing.
  134531. */
  134532. useOnlyInActiveCamera: boolean;
  134533. /** @hidden */
  134534. static _SceneComponentInitialization: (scene: Scene) => void;
  134535. /**
  134536. * Instantiates a depth renderer
  134537. * @param scene The scene the renderer belongs to
  134538. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  134539. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  134540. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134541. */
  134542. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  134543. /**
  134544. * Creates the depth rendering effect and checks if the effect is ready.
  134545. * @param subMesh The submesh to be used to render the depth map of
  134546. * @param useInstances If multiple world instances should be used
  134547. * @returns if the depth renderer is ready to render the depth map
  134548. */
  134549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134550. /**
  134551. * Gets the texture which the depth map will be written to.
  134552. * @returns The depth map texture
  134553. */
  134554. getDepthMap(): RenderTargetTexture;
  134555. /**
  134556. * Disposes of the depth renderer.
  134557. */
  134558. dispose(): void;
  134559. }
  134560. }
  134561. declare module BABYLON {
  134562. /** @hidden */
  134563. export var minmaxReduxPixelShader: {
  134564. name: string;
  134565. shader: string;
  134566. };
  134567. }
  134568. declare module BABYLON {
  134569. /**
  134570. * This class computes a min/max reduction from a texture: it means it computes the minimum
  134571. * and maximum values from all values of the texture.
  134572. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  134573. * The source values are read from the red channel of the texture.
  134574. */
  134575. export class MinMaxReducer {
  134576. /**
  134577. * Observable triggered when the computation has been performed
  134578. */
  134579. onAfterReductionPerformed: Observable<{
  134580. min: number;
  134581. max: number;
  134582. }>;
  134583. protected _camera: Camera;
  134584. protected _sourceTexture: Nullable<RenderTargetTexture>;
  134585. protected _reductionSteps: Nullable<Array<PostProcess>>;
  134586. protected _postProcessManager: PostProcessManager;
  134587. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  134588. protected _forceFullscreenViewport: boolean;
  134589. /**
  134590. * Creates a min/max reducer
  134591. * @param camera The camera to use for the post processes
  134592. */
  134593. constructor(camera: Camera);
  134594. /**
  134595. * Gets the texture used to read the values from.
  134596. */
  134597. get sourceTexture(): Nullable<RenderTargetTexture>;
  134598. /**
  134599. * Sets the source texture to read the values from.
  134600. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  134601. * because in such textures '1' value must not be taken into account to compute the maximum
  134602. * as this value is used to clear the texture.
  134603. * Note that the computation is not activated by calling this function, you must call activate() for that!
  134604. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  134605. * @param depthRedux Indicates if the texture is a depth texture or not
  134606. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  134607. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  134608. */
  134609. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  134610. /**
  134611. * Defines the refresh rate of the computation.
  134612. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  134613. */
  134614. get refreshRate(): number;
  134615. set refreshRate(value: number);
  134616. protected _activated: boolean;
  134617. /**
  134618. * Gets the activation status of the reducer
  134619. */
  134620. get activated(): boolean;
  134621. /**
  134622. * Activates the reduction computation.
  134623. * When activated, the observers registered in onAfterReductionPerformed are
  134624. * called after the compuation is performed
  134625. */
  134626. activate(): void;
  134627. /**
  134628. * Deactivates the reduction computation.
  134629. */
  134630. deactivate(): void;
  134631. /**
  134632. * Disposes the min/max reducer
  134633. * @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.
  134634. */
  134635. dispose(disposeAll?: boolean): void;
  134636. }
  134637. }
  134638. declare module BABYLON {
  134639. /**
  134640. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  134641. */
  134642. export class DepthReducer extends MinMaxReducer {
  134643. private _depthRenderer;
  134644. private _depthRendererId;
  134645. /**
  134646. * Gets the depth renderer used for the computation.
  134647. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  134648. */
  134649. get depthRenderer(): Nullable<DepthRenderer>;
  134650. /**
  134651. * Creates a depth reducer
  134652. * @param camera The camera used to render the depth texture
  134653. */
  134654. constructor(camera: Camera);
  134655. /**
  134656. * Sets the depth renderer to use to generate the depth map
  134657. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  134658. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  134659. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  134660. */
  134661. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  134662. /** @hidden */
  134663. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  134664. /**
  134665. * Activates the reduction computation.
  134666. * When activated, the observers registered in onAfterReductionPerformed are
  134667. * called after the compuation is performed
  134668. */
  134669. activate(): void;
  134670. /**
  134671. * Deactivates the reduction computation.
  134672. */
  134673. deactivate(): void;
  134674. /**
  134675. * Disposes the depth reducer
  134676. * @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.
  134677. */
  134678. dispose(disposeAll?: boolean): void;
  134679. }
  134680. }
  134681. declare module BABYLON {
  134682. /**
  134683. * A CSM implementation allowing casting shadows on large scenes.
  134684. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  134685. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  134686. */
  134687. export class CascadedShadowGenerator extends ShadowGenerator {
  134688. private static readonly frustumCornersNDCSpace;
  134689. /**
  134690. * Name of the CSM class
  134691. */
  134692. static CLASSNAME: string;
  134693. /**
  134694. * Defines the default number of cascades used by the CSM.
  134695. */
  134696. static readonly DEFAULT_CASCADES_COUNT: number;
  134697. /**
  134698. * Defines the minimum number of cascades used by the CSM.
  134699. */
  134700. static readonly MIN_CASCADES_COUNT: number;
  134701. /**
  134702. * Defines the maximum number of cascades used by the CSM.
  134703. */
  134704. static readonly MAX_CASCADES_COUNT: number;
  134705. protected _validateFilter(filter: number): number;
  134706. /**
  134707. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  134708. */
  134709. penumbraDarkness: number;
  134710. private _numCascades;
  134711. /**
  134712. * Gets or set the number of cascades used by the CSM.
  134713. */
  134714. get numCascades(): number;
  134715. set numCascades(value: number);
  134716. /**
  134717. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  134718. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  134719. */
  134720. stabilizeCascades: boolean;
  134721. private _freezeShadowCastersBoundingInfo;
  134722. private _freezeShadowCastersBoundingInfoObservable;
  134723. /**
  134724. * Enables or disables the shadow casters bounding info computation.
  134725. * If your shadow casters don't move, you can disable this feature.
  134726. * If it is enabled, the bounding box computation is done every frame.
  134727. */
  134728. get freezeShadowCastersBoundingInfo(): boolean;
  134729. set freezeShadowCastersBoundingInfo(freeze: boolean);
  134730. private _scbiMin;
  134731. private _scbiMax;
  134732. protected _computeShadowCastersBoundingInfo(): void;
  134733. protected _shadowCastersBoundingInfo: BoundingInfo;
  134734. /**
  134735. * Gets or sets the shadow casters bounding info.
  134736. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  134737. * so that the system won't overwrite the bounds you provide
  134738. */
  134739. get shadowCastersBoundingInfo(): BoundingInfo;
  134740. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  134741. protected _breaksAreDirty: boolean;
  134742. protected _minDistance: number;
  134743. protected _maxDistance: number;
  134744. /**
  134745. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  134746. *
  134747. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  134748. * If you don't know these values, simply leave them to their defaults and don't call this function.
  134749. * @param min minimal distance for the breaks (default to 0.)
  134750. * @param max maximal distance for the breaks (default to 1.)
  134751. */
  134752. setMinMaxDistance(min: number, max: number): void;
  134753. /** Gets the minimal distance used in the cascade break computation */
  134754. get minDistance(): number;
  134755. /** Gets the maximal distance used in the cascade break computation */
  134756. get maxDistance(): number;
  134757. /**
  134758. * Gets the class name of that object
  134759. * @returns "CascadedShadowGenerator"
  134760. */
  134761. getClassName(): string;
  134762. private _cascadeMinExtents;
  134763. private _cascadeMaxExtents;
  134764. /**
  134765. * Gets a cascade minimum extents
  134766. * @param cascadeIndex index of the cascade
  134767. * @returns the minimum cascade extents
  134768. */
  134769. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  134770. /**
  134771. * Gets a cascade maximum extents
  134772. * @param cascadeIndex index of the cascade
  134773. * @returns the maximum cascade extents
  134774. */
  134775. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  134776. private _cascades;
  134777. private _currentLayer;
  134778. private _viewSpaceFrustumsZ;
  134779. private _viewMatrices;
  134780. private _projectionMatrices;
  134781. private _transformMatrices;
  134782. private _transformMatricesAsArray;
  134783. private _frustumLengths;
  134784. private _lightSizeUVCorrection;
  134785. private _depthCorrection;
  134786. private _frustumCornersWorldSpace;
  134787. private _frustumCenter;
  134788. private _shadowCameraPos;
  134789. private _shadowMaxZ;
  134790. /**
  134791. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  134792. * It defaults to camera.maxZ
  134793. */
  134794. get shadowMaxZ(): number;
  134795. /**
  134796. * Sets the shadow max z distance.
  134797. */
  134798. set shadowMaxZ(value: number);
  134799. protected _debug: boolean;
  134800. /**
  134801. * Gets or sets the debug flag.
  134802. * When enabled, the cascades are materialized by different colors on the screen.
  134803. */
  134804. get debug(): boolean;
  134805. set debug(dbg: boolean);
  134806. private _depthClamp;
  134807. /**
  134808. * Gets or sets the depth clamping value.
  134809. *
  134810. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  134811. * to account for the shadow casters far away.
  134812. *
  134813. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  134814. */
  134815. get depthClamp(): boolean;
  134816. set depthClamp(value: boolean);
  134817. private _cascadeBlendPercentage;
  134818. /**
  134819. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  134820. * It defaults to 0.1 (10% blending).
  134821. */
  134822. get cascadeBlendPercentage(): number;
  134823. set cascadeBlendPercentage(value: number);
  134824. private _lambda;
  134825. /**
  134826. * Gets or set the lambda parameter.
  134827. * This parameter is used to split the camera frustum and create the cascades.
  134828. * 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.
  134829. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  134830. */
  134831. get lambda(): number;
  134832. set lambda(value: number);
  134833. /**
  134834. * Gets the view matrix corresponding to a given cascade
  134835. * @param cascadeNum cascade to retrieve the view matrix from
  134836. * @returns the cascade view matrix
  134837. */
  134838. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  134839. /**
  134840. * Gets the projection matrix corresponding to a given cascade
  134841. * @param cascadeNum cascade to retrieve the projection matrix from
  134842. * @returns the cascade projection matrix
  134843. */
  134844. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  134845. /**
  134846. * Gets the transformation matrix corresponding to a given cascade
  134847. * @param cascadeNum cascade to retrieve the transformation matrix from
  134848. * @returns the cascade transformation matrix
  134849. */
  134850. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  134851. private _depthRenderer;
  134852. /**
  134853. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  134854. *
  134855. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  134856. *
  134857. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  134858. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  134859. * @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
  134860. */
  134861. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  134862. private _depthReducer;
  134863. private _autoCalcDepthBounds;
  134864. /**
  134865. * Gets or sets the autoCalcDepthBounds property.
  134866. *
  134867. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  134868. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  134869. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  134870. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  134871. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  134872. */
  134873. get autoCalcDepthBounds(): boolean;
  134874. set autoCalcDepthBounds(value: boolean);
  134875. /**
  134876. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  134877. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  134878. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  134879. * for setting the refresh rate on the renderer yourself!
  134880. */
  134881. get autoCalcDepthBoundsRefreshRate(): number;
  134882. set autoCalcDepthBoundsRefreshRate(value: number);
  134883. /**
  134884. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  134885. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  134886. * you change the camera near/far planes!
  134887. */
  134888. splitFrustum(): void;
  134889. private _splitFrustum;
  134890. private _computeMatrices;
  134891. private _computeFrustumInWorldSpace;
  134892. private _computeCascadeFrustum;
  134893. /**
  134894. * Support test.
  134895. */
  134896. static get IsSupported(): boolean;
  134897. /** @hidden */
  134898. static _SceneComponentInitialization: (scene: Scene) => void;
  134899. /**
  134900. * Creates a Cascaded Shadow Generator object.
  134901. * A ShadowGenerator is the required tool to use the shadows.
  134902. * Each directional light casting shadows needs to use its own ShadowGenerator.
  134903. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  134904. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  134905. * @param light The directional light object generating the shadows.
  134906. * @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.
  134907. */
  134908. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  134909. protected _initializeGenerator(): void;
  134910. protected _createTargetRenderTexture(): void;
  134911. protected _initializeShadowMap(): void;
  134912. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  134913. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  134914. /**
  134915. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  134916. * @param defines Defines of the material we want to update
  134917. * @param lightIndex Index of the light in the enabled light list of the material
  134918. */
  134919. prepareDefines(defines: any, lightIndex: number): void;
  134920. /**
  134921. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  134922. * defined in the generator but impacting the effect).
  134923. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  134924. * @param effect The effect we are binfing the information for
  134925. */
  134926. bindShadowLight(lightIndex: string, effect: Effect): void;
  134927. /**
  134928. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  134929. * (eq to view projection * shadow projection matrices)
  134930. * @returns The transform matrix used to create the shadow map
  134931. */
  134932. getTransformMatrix(): Matrix;
  134933. /**
  134934. * Disposes the ShadowGenerator.
  134935. * Returns nothing.
  134936. */
  134937. dispose(): void;
  134938. /**
  134939. * Serializes the shadow generator setup to a json object.
  134940. * @returns The serialized JSON object
  134941. */
  134942. serialize(): any;
  134943. /**
  134944. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  134945. * @param parsedShadowGenerator The JSON object to parse
  134946. * @param scene The scene to create the shadow map for
  134947. * @returns The parsed shadow generator
  134948. */
  134949. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  134950. }
  134951. }
  134952. declare module BABYLON {
  134953. /**
  134954. * Defines the shadow generator component responsible to manage any shadow generators
  134955. * in a given scene.
  134956. */
  134957. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  134958. /**
  134959. * The component name helpfull to identify the component in the list of scene components.
  134960. */
  134961. readonly name: string;
  134962. /**
  134963. * The scene the component belongs to.
  134964. */
  134965. scene: Scene;
  134966. /**
  134967. * Creates a new instance of the component for the given scene
  134968. * @param scene Defines the scene to register the component in
  134969. */
  134970. constructor(scene: Scene);
  134971. /**
  134972. * Registers the component in a given scene
  134973. */
  134974. register(): void;
  134975. /**
  134976. * Rebuilds the elements related to this component in case of
  134977. * context lost for instance.
  134978. */
  134979. rebuild(): void;
  134980. /**
  134981. * Serializes the component data to the specified json object
  134982. * @param serializationObject The object to serialize to
  134983. */
  134984. serialize(serializationObject: any): void;
  134985. /**
  134986. * Adds all the elements from the container to the scene
  134987. * @param container the container holding the elements
  134988. */
  134989. addFromContainer(container: AbstractScene): void;
  134990. /**
  134991. * Removes all the elements in the container from the scene
  134992. * @param container contains the elements to remove
  134993. * @param dispose if the removed element should be disposed (default: false)
  134994. */
  134995. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134996. /**
  134997. * Rebuilds the elements related to this component in case of
  134998. * context lost for instance.
  134999. */
  135000. dispose(): void;
  135001. private _gatherRenderTargets;
  135002. }
  135003. }
  135004. declare module BABYLON {
  135005. /**
  135006. * A point light is a light defined by an unique point in world space.
  135007. * The light is emitted in every direction from this point.
  135008. * A good example of a point light is a standard light bulb.
  135009. * Documentation: https://doc.babylonjs.com/babylon101/lights
  135010. */
  135011. export class PointLight extends ShadowLight {
  135012. private _shadowAngle;
  135013. /**
  135014. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135015. * This specifies what angle the shadow will use to be created.
  135016. *
  135017. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135018. */
  135019. get shadowAngle(): number;
  135020. /**
  135021. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135022. * This specifies what angle the shadow will use to be created.
  135023. *
  135024. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135025. */
  135026. set shadowAngle(value: number);
  135027. /**
  135028. * Gets the direction if it has been set.
  135029. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135030. */
  135031. get direction(): Vector3;
  135032. /**
  135033. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135034. */
  135035. set direction(value: Vector3);
  135036. /**
  135037. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  135038. * A PointLight emits the light in every direction.
  135039. * It can cast shadows.
  135040. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  135041. * ```javascript
  135042. * var pointLight = new PointLight("pl", camera.position, scene);
  135043. * ```
  135044. * Documentation : https://doc.babylonjs.com/babylon101/lights
  135045. * @param name The light friendly name
  135046. * @param position The position of the point light in the scene
  135047. * @param scene The scene the lights belongs to
  135048. */
  135049. constructor(name: string, position: Vector3, scene: Scene);
  135050. /**
  135051. * Returns the string "PointLight"
  135052. * @returns the class name
  135053. */
  135054. getClassName(): string;
  135055. /**
  135056. * Returns the integer 0.
  135057. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135058. */
  135059. getTypeID(): number;
  135060. /**
  135061. * Specifies wether or not the shadowmap should be a cube texture.
  135062. * @returns true if the shadowmap needs to be a cube texture.
  135063. */
  135064. needCube(): boolean;
  135065. /**
  135066. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  135067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  135068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  135069. */
  135070. getShadowDirection(faceIndex?: number): Vector3;
  135071. /**
  135072. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  135073. * - fov = PI / 2
  135074. * - aspect ratio : 1.0
  135075. * - z-near and far equal to the active camera minZ and maxZ.
  135076. * Returns the PointLight.
  135077. */
  135078. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135079. protected _buildUniformLayout(): void;
  135080. /**
  135081. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  135082. * @param effect The effect to update
  135083. * @param lightIndex The index of the light in the effect to update
  135084. * @returns The point light
  135085. */
  135086. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  135087. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135088. /**
  135089. * Prepares the list of defines specific to the light type.
  135090. * @param defines the list of defines
  135091. * @param lightIndex defines the index of the light for the effect
  135092. */
  135093. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135094. }
  135095. }
  135096. declare module BABYLON {
  135097. /**
  135098. * Header information of HDR texture files.
  135099. */
  135100. export interface HDRInfo {
  135101. /**
  135102. * The height of the texture in pixels.
  135103. */
  135104. height: number;
  135105. /**
  135106. * The width of the texture in pixels.
  135107. */
  135108. width: number;
  135109. /**
  135110. * The index of the beginning of the data in the binary file.
  135111. */
  135112. dataPosition: number;
  135113. }
  135114. /**
  135115. * This groups tools to convert HDR texture to native colors array.
  135116. */
  135117. export class HDRTools {
  135118. private static Ldexp;
  135119. private static Rgbe2float;
  135120. private static readStringLine;
  135121. /**
  135122. * Reads header information from an RGBE texture stored in a native array.
  135123. * More information on this format are available here:
  135124. * https://en.wikipedia.org/wiki/RGBE_image_format
  135125. *
  135126. * @param uint8array The binary file stored in native array.
  135127. * @return The header information.
  135128. */
  135129. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  135130. /**
  135131. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  135132. * This RGBE texture needs to store the information as a panorama.
  135133. *
  135134. * More information on this format are available here:
  135135. * https://en.wikipedia.org/wiki/RGBE_image_format
  135136. *
  135137. * @param buffer The binary file stored in an array buffer.
  135138. * @param size The expected size of the extracted cubemap.
  135139. * @return The Cube Map information.
  135140. */
  135141. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  135142. /**
  135143. * Returns the pixels data extracted from an RGBE texture.
  135144. * This pixels will be stored left to right up to down in the R G B order in one array.
  135145. *
  135146. * More information on this format are available here:
  135147. * https://en.wikipedia.org/wiki/RGBE_image_format
  135148. *
  135149. * @param uint8array The binary file stored in an array buffer.
  135150. * @param hdrInfo The header information of the file.
  135151. * @return The pixels data in RGB right to left up to down order.
  135152. */
  135153. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  135154. private static RGBE_ReadPixels_RLE;
  135155. }
  135156. }
  135157. declare module BABYLON {
  135158. /**
  135159. * Effect Render Options
  135160. */
  135161. export interface IEffectRendererOptions {
  135162. /**
  135163. * Defines the vertices positions.
  135164. */
  135165. positions?: number[];
  135166. /**
  135167. * Defines the indices.
  135168. */
  135169. indices?: number[];
  135170. }
  135171. /**
  135172. * Helper class to render one or more effects.
  135173. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135174. */
  135175. export class EffectRenderer {
  135176. private engine;
  135177. private static _DefaultOptions;
  135178. private _vertexBuffers;
  135179. private _indexBuffer;
  135180. private _fullscreenViewport;
  135181. /**
  135182. * Creates an effect renderer
  135183. * @param engine the engine to use for rendering
  135184. * @param options defines the options of the effect renderer
  135185. */
  135186. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135187. /**
  135188. * Sets the current viewport in normalized coordinates 0-1
  135189. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135190. */
  135191. setViewport(viewport?: Viewport): void;
  135192. /**
  135193. * Binds the embedded attributes buffer to the effect.
  135194. * @param effect Defines the effect to bind the attributes for
  135195. */
  135196. bindBuffers(effect: Effect): void;
  135197. /**
  135198. * Sets the current effect wrapper to use during draw.
  135199. * The effect needs to be ready before calling this api.
  135200. * This also sets the default full screen position attribute.
  135201. * @param effectWrapper Defines the effect to draw with
  135202. */
  135203. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135204. /**
  135205. * Restores engine states
  135206. */
  135207. restoreStates(): void;
  135208. /**
  135209. * Draws a full screen quad.
  135210. */
  135211. draw(): void;
  135212. private isRenderTargetTexture;
  135213. /**
  135214. * renders one or more effects to a specified texture
  135215. * @param effectWrapper the effect to renderer
  135216. * @param outputTexture texture to draw to, if null it will render to the screen.
  135217. */
  135218. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135219. /**
  135220. * Disposes of the effect renderer
  135221. */
  135222. dispose(): void;
  135223. }
  135224. /**
  135225. * Options to create an EffectWrapper
  135226. */
  135227. interface EffectWrapperCreationOptions {
  135228. /**
  135229. * Engine to use to create the effect
  135230. */
  135231. engine: ThinEngine;
  135232. /**
  135233. * Fragment shader for the effect
  135234. */
  135235. fragmentShader: string;
  135236. /**
  135237. * Use the shader store instead of direct source code
  135238. */
  135239. useShaderStore?: boolean;
  135240. /**
  135241. * Vertex shader for the effect
  135242. */
  135243. vertexShader?: string;
  135244. /**
  135245. * Attributes to use in the shader
  135246. */
  135247. attributeNames?: Array<string>;
  135248. /**
  135249. * Uniforms to use in the shader
  135250. */
  135251. uniformNames?: Array<string>;
  135252. /**
  135253. * Texture sampler names to use in the shader
  135254. */
  135255. samplerNames?: Array<string>;
  135256. /**
  135257. * Defines to use in the shader
  135258. */
  135259. defines?: Array<string>;
  135260. /**
  135261. * Callback when effect is compiled
  135262. */
  135263. onCompiled?: Nullable<(effect: Effect) => void>;
  135264. /**
  135265. * The friendly name of the effect displayed in Spector.
  135266. */
  135267. name?: string;
  135268. }
  135269. /**
  135270. * Wraps an effect to be used for rendering
  135271. */
  135272. export class EffectWrapper {
  135273. /**
  135274. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135275. */
  135276. onApplyObservable: Observable<{}>;
  135277. /**
  135278. * The underlying effect
  135279. */
  135280. effect: Effect;
  135281. /**
  135282. * Creates an effect to be renderer
  135283. * @param creationOptions options to create the effect
  135284. */
  135285. constructor(creationOptions: EffectWrapperCreationOptions);
  135286. /**
  135287. * Disposes of the effect wrapper
  135288. */
  135289. dispose(): void;
  135290. }
  135291. }
  135292. declare module BABYLON {
  135293. /** @hidden */
  135294. export var hdrFilteringVertexShader: {
  135295. name: string;
  135296. shader: string;
  135297. };
  135298. }
  135299. declare module BABYLON {
  135300. /** @hidden */
  135301. export var hdrFilteringPixelShader: {
  135302. name: string;
  135303. shader: string;
  135304. };
  135305. }
  135306. declare module BABYLON {
  135307. /**
  135308. * Options for texture filtering
  135309. */
  135310. interface IHDRFilteringOptions {
  135311. /**
  135312. * Scales pixel intensity for the input HDR map.
  135313. */
  135314. hdrScale?: number;
  135315. /**
  135316. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  135317. */
  135318. quality?: number;
  135319. }
  135320. /**
  135321. * Filters HDR maps to get correct renderings of PBR reflections
  135322. */
  135323. export class HDRFiltering {
  135324. private _engine;
  135325. private _effectRenderer;
  135326. private _effectWrapper;
  135327. private _lodGenerationOffset;
  135328. private _lodGenerationScale;
  135329. /**
  135330. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  135331. * you care about baking speed.
  135332. */
  135333. quality: number;
  135334. /**
  135335. * Scales pixel intensity for the input HDR map.
  135336. */
  135337. hdrScale: number;
  135338. /**
  135339. * Instantiates HDR filter for reflection maps
  135340. *
  135341. * @param engine Thin engine
  135342. * @param options Options
  135343. */
  135344. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  135345. private _createRenderTarget;
  135346. private _prefilterInternal;
  135347. private _createEffect;
  135348. /**
  135349. * Get a value indicating if the filter is ready to be used
  135350. * @param texture Texture to filter
  135351. * @returns true if the filter is ready
  135352. */
  135353. isReady(texture: BaseTexture): boolean;
  135354. /**
  135355. * Prefilters a cube texture to have mipmap levels representing roughness values.
  135356. * Prefiltering will be invoked at the end of next rendering pass.
  135357. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  135358. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  135359. * @param texture Texture to filter
  135360. * @param onFinished Callback when filtering is done
  135361. * @return Promise called when prefiltering is done
  135362. */
  135363. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown>;
  135364. }
  135365. }
  135366. declare module BABYLON {
  135367. /**
  135368. * This represents a texture coming from an HDR input.
  135369. *
  135370. * The only supported format is currently panorama picture stored in RGBE format.
  135371. * Example of such files can be found on HDRLib: http://hdrlib.com/
  135372. */
  135373. export class HDRCubeTexture extends BaseTexture {
  135374. private static _facesMapping;
  135375. private _generateHarmonics;
  135376. private _noMipmap;
  135377. private _prefilterOnLoad;
  135378. private _textureMatrix;
  135379. private _size;
  135380. private _onLoad;
  135381. private _onError;
  135382. /**
  135383. * The texture URL.
  135384. */
  135385. url: string;
  135386. /**
  135387. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  135388. */
  135389. coordinatesMode: number;
  135390. protected _isBlocking: boolean;
  135391. /**
  135392. * Sets wether or not the texture is blocking during loading.
  135393. */
  135394. set isBlocking(value: boolean);
  135395. /**
  135396. * Gets wether or not the texture is blocking during loading.
  135397. */
  135398. get isBlocking(): boolean;
  135399. protected _rotationY: number;
  135400. /**
  135401. * Sets texture matrix rotation angle around Y axis in radians.
  135402. */
  135403. set rotationY(value: number);
  135404. /**
  135405. * Gets texture matrix rotation angle around Y axis radians.
  135406. */
  135407. get rotationY(): number;
  135408. /**
  135409. * Gets or sets the center of the bounding box associated with the cube texture
  135410. * It must define where the camera used to render the texture was set
  135411. */
  135412. boundingBoxPosition: Vector3;
  135413. private _boundingBoxSize;
  135414. /**
  135415. * Gets or sets the size of the bounding box associated with the cube texture
  135416. * When defined, the cubemap will switch to local mode
  135417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  135418. * @example https://www.babylonjs-playground.com/#RNASML
  135419. */
  135420. set boundingBoxSize(value: Vector3);
  135421. get boundingBoxSize(): Vector3;
  135422. /**
  135423. * Instantiates an HDRTexture from the following parameters.
  135424. *
  135425. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  135426. * @param sceneOrEngine The scene or engine the texture will be used in
  135427. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  135428. * @param noMipmap Forces to not generate the mipmap if true
  135429. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  135430. * @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)
  135431. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  135432. */
  135433. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  135434. /**
  135435. * Get the current class name of the texture useful for serialization or dynamic coding.
  135436. * @returns "HDRCubeTexture"
  135437. */
  135438. getClassName(): string;
  135439. /**
  135440. * Occurs when the file is raw .hdr file.
  135441. */
  135442. private loadTexture;
  135443. clone(): HDRCubeTexture;
  135444. delayLoad(): void;
  135445. /**
  135446. * Get the texture reflection matrix used to rotate/transform the reflection.
  135447. * @returns the reflection matrix
  135448. */
  135449. getReflectionTextureMatrix(): Matrix;
  135450. /**
  135451. * Set the texture reflection matrix used to rotate/transform the reflection.
  135452. * @param value Define the reflection matrix to set
  135453. */
  135454. setReflectionTextureMatrix(value: Matrix): void;
  135455. /**
  135456. * Parses a JSON representation of an HDR Texture in order to create the texture
  135457. * @param parsedTexture Define the JSON representation
  135458. * @param scene Define the scene the texture should be created in
  135459. * @param rootUrl Define the root url in case we need to load relative dependencies
  135460. * @returns the newly created texture after parsing
  135461. */
  135462. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  135463. serialize(): any;
  135464. }
  135465. }
  135466. declare module BABYLON {
  135467. /**
  135468. * Class used to control physics engine
  135469. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135470. */
  135471. export class PhysicsEngine implements IPhysicsEngine {
  135472. private _physicsPlugin;
  135473. /**
  135474. * Global value used to control the smallest number supported by the simulation
  135475. */
  135476. static Epsilon: number;
  135477. private _impostors;
  135478. private _joints;
  135479. private _subTimeStep;
  135480. /**
  135481. * Gets the gravity vector used by the simulation
  135482. */
  135483. gravity: Vector3;
  135484. /**
  135485. * Factory used to create the default physics plugin.
  135486. * @returns The default physics plugin
  135487. */
  135488. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  135489. /**
  135490. * Creates a new Physics Engine
  135491. * @param gravity defines the gravity vector used by the simulation
  135492. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  135493. */
  135494. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  135495. /**
  135496. * Sets the gravity vector used by the simulation
  135497. * @param gravity defines the gravity vector to use
  135498. */
  135499. setGravity(gravity: Vector3): void;
  135500. /**
  135501. * Set the time step of the physics engine.
  135502. * Default is 1/60.
  135503. * To slow it down, enter 1/600 for example.
  135504. * To speed it up, 1/30
  135505. * @param newTimeStep defines the new timestep to apply to this world.
  135506. */
  135507. setTimeStep(newTimeStep?: number): void;
  135508. /**
  135509. * Get the time step of the physics engine.
  135510. * @returns the current time step
  135511. */
  135512. getTimeStep(): number;
  135513. /**
  135514. * Set the sub time step of the physics engine.
  135515. * Default is 0 meaning there is no sub steps
  135516. * To increase physics resolution precision, set a small value (like 1 ms)
  135517. * @param subTimeStep defines the new sub timestep used for physics resolution.
  135518. */
  135519. setSubTimeStep(subTimeStep?: number): void;
  135520. /**
  135521. * Get the sub time step of the physics engine.
  135522. * @returns the current sub time step
  135523. */
  135524. getSubTimeStep(): number;
  135525. /**
  135526. * Release all resources
  135527. */
  135528. dispose(): void;
  135529. /**
  135530. * Gets the name of the current physics plugin
  135531. * @returns the name of the plugin
  135532. */
  135533. getPhysicsPluginName(): string;
  135534. /**
  135535. * Adding a new impostor for the impostor tracking.
  135536. * This will be done by the impostor itself.
  135537. * @param impostor the impostor to add
  135538. */
  135539. addImpostor(impostor: PhysicsImpostor): void;
  135540. /**
  135541. * Remove an impostor from the engine.
  135542. * This impostor and its mesh will not longer be updated by the physics engine.
  135543. * @param impostor the impostor to remove
  135544. */
  135545. removeImpostor(impostor: PhysicsImpostor): void;
  135546. /**
  135547. * Add a joint to the physics engine
  135548. * @param mainImpostor defines the main impostor to which the joint is added.
  135549. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  135550. * @param joint defines the joint that will connect both impostors.
  135551. */
  135552. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135553. /**
  135554. * Removes a joint from the simulation
  135555. * @param mainImpostor defines the impostor used with the joint
  135556. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  135557. * @param joint defines the joint to remove
  135558. */
  135559. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135560. /**
  135561. * Called by the scene. No need to call it.
  135562. * @param delta defines the timespam between frames
  135563. */
  135564. _step(delta: number): void;
  135565. /**
  135566. * Gets the current plugin used to run the simulation
  135567. * @returns current plugin
  135568. */
  135569. getPhysicsPlugin(): IPhysicsEnginePlugin;
  135570. /**
  135571. * Gets the list of physic impostors
  135572. * @returns an array of PhysicsImpostor
  135573. */
  135574. getImpostors(): Array<PhysicsImpostor>;
  135575. /**
  135576. * Gets the impostor for a physics enabled object
  135577. * @param object defines the object impersonated by the impostor
  135578. * @returns the PhysicsImpostor or null if not found
  135579. */
  135580. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  135581. /**
  135582. * Gets the impostor for a physics body object
  135583. * @param body defines physics body used by the impostor
  135584. * @returns the PhysicsImpostor or null if not found
  135585. */
  135586. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  135587. /**
  135588. * Does a raycast in the physics world
  135589. * @param from when should the ray start?
  135590. * @param to when should the ray end?
  135591. * @returns PhysicsRaycastResult
  135592. */
  135593. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135594. }
  135595. }
  135596. declare module BABYLON {
  135597. /** @hidden */
  135598. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  135599. private _useDeltaForWorldStep;
  135600. world: any;
  135601. name: string;
  135602. private _physicsMaterials;
  135603. private _fixedTimeStep;
  135604. private _cannonRaycastResult;
  135605. private _raycastResult;
  135606. private _physicsBodysToRemoveAfterStep;
  135607. BJSCANNON: any;
  135608. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  135609. setGravity(gravity: Vector3): void;
  135610. setTimeStep(timeStep: number): void;
  135611. getTimeStep(): number;
  135612. executeStep(delta: number): void;
  135613. private _removeMarkedPhysicsBodiesFromWorld;
  135614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135617. private _processChildMeshes;
  135618. removePhysicsBody(impostor: PhysicsImpostor): void;
  135619. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135621. private _addMaterial;
  135622. private _checkWithEpsilon;
  135623. private _createShape;
  135624. private _createHeightmap;
  135625. private _minus90X;
  135626. private _plus90X;
  135627. private _tmpPosition;
  135628. private _tmpDeltaPosition;
  135629. private _tmpUnityRotation;
  135630. private _updatePhysicsBodyTransformation;
  135631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  135632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  135633. isSupported(): boolean;
  135634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135635. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135636. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135637. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135638. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  135639. getBodyMass(impostor: PhysicsImpostor): number;
  135640. getBodyFriction(impostor: PhysicsImpostor): number;
  135641. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  135642. getBodyRestitution(impostor: PhysicsImpostor): number;
  135643. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  135644. sleepBody(impostor: PhysicsImpostor): void;
  135645. wakeUpBody(impostor: PhysicsImpostor): void;
  135646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  135647. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  135648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  135649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  135650. getRadius(impostor: PhysicsImpostor): number;
  135651. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  135652. dispose(): void;
  135653. private _extendNamespace;
  135654. /**
  135655. * Does a raycast in the physics world
  135656. * @param from when should the ray start?
  135657. * @param to when should the ray end?
  135658. * @returns PhysicsRaycastResult
  135659. */
  135660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135661. }
  135662. }
  135663. declare module BABYLON {
  135664. /** @hidden */
  135665. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  135666. private _useDeltaForWorldStep;
  135667. world: any;
  135668. name: string;
  135669. BJSOIMO: any;
  135670. private _raycastResult;
  135671. private _fixedTimeStep;
  135672. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  135673. setGravity(gravity: Vector3): void;
  135674. setTimeStep(timeStep: number): void;
  135675. getTimeStep(): number;
  135676. private _tmpImpostorsArray;
  135677. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  135678. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135679. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135680. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135681. private _tmpPositionVector;
  135682. removePhysicsBody(impostor: PhysicsImpostor): void;
  135683. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135684. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135685. isSupported(): boolean;
  135686. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  135687. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  135688. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135689. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135690. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135691. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135692. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  135693. getBodyMass(impostor: PhysicsImpostor): number;
  135694. getBodyFriction(impostor: PhysicsImpostor): number;
  135695. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  135696. getBodyRestitution(impostor: PhysicsImpostor): number;
  135697. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  135698. sleepBody(impostor: PhysicsImpostor): void;
  135699. wakeUpBody(impostor: PhysicsImpostor): void;
  135700. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  135701. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  135702. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  135703. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  135704. getRadius(impostor: PhysicsImpostor): number;
  135705. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  135706. dispose(): void;
  135707. /**
  135708. * Does a raycast in the physics world
  135709. * @param from when should the ray start?
  135710. * @param to when should the ray end?
  135711. * @returns PhysicsRaycastResult
  135712. */
  135713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135714. }
  135715. }
  135716. declare module BABYLON {
  135717. /**
  135718. * Class containing static functions to help procedurally build meshes
  135719. */
  135720. export class RibbonBuilder {
  135721. /**
  135722. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135723. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135724. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135725. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135726. * * 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
  135727. * * 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
  135728. * * 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
  135729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135732. * * 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
  135733. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135734. * * 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
  135735. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135737. * @param name defines the name of the mesh
  135738. * @param options defines the options used to create the mesh
  135739. * @param scene defines the hosting scene
  135740. * @returns the ribbon mesh
  135741. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135742. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135743. */
  135744. static CreateRibbon(name: string, options: {
  135745. pathArray: Vector3[][];
  135746. closeArray?: boolean;
  135747. closePath?: boolean;
  135748. offset?: number;
  135749. updatable?: boolean;
  135750. sideOrientation?: number;
  135751. frontUVs?: Vector4;
  135752. backUVs?: Vector4;
  135753. instance?: Mesh;
  135754. invertUV?: boolean;
  135755. uvs?: Vector2[];
  135756. colors?: Color4[];
  135757. }, scene?: Nullable<Scene>): Mesh;
  135758. }
  135759. }
  135760. declare module BABYLON {
  135761. /**
  135762. * Class containing static functions to help procedurally build meshes
  135763. */
  135764. export class ShapeBuilder {
  135765. /**
  135766. * 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.
  135767. * * 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.
  135768. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135769. * * 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.
  135770. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135771. * * 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
  135772. * * 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
  135773. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135776. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135778. * @param name defines the name of the mesh
  135779. * @param options defines the options used to create the mesh
  135780. * @param scene defines the hosting scene
  135781. * @returns the extruded shape mesh
  135782. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135784. */
  135785. static ExtrudeShape(name: string, options: {
  135786. shape: Vector3[];
  135787. path: Vector3[];
  135788. scale?: number;
  135789. rotation?: number;
  135790. cap?: number;
  135791. updatable?: boolean;
  135792. sideOrientation?: number;
  135793. frontUVs?: Vector4;
  135794. backUVs?: Vector4;
  135795. instance?: Mesh;
  135796. invertUV?: boolean;
  135797. }, scene?: Nullable<Scene>): Mesh;
  135798. /**
  135799. * Creates an custom extruded shape mesh.
  135800. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135801. * * 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.
  135802. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135803. * * 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
  135804. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135805. * * 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
  135806. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135807. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135808. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135809. * * 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
  135810. * * 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
  135811. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135816. * @param name defines the name of the mesh
  135817. * @param options defines the options used to create the mesh
  135818. * @param scene defines the hosting scene
  135819. * @returns the custom extruded shape mesh
  135820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135821. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135823. */
  135824. static ExtrudeShapeCustom(name: string, options: {
  135825. shape: Vector3[];
  135826. path: Vector3[];
  135827. scaleFunction?: any;
  135828. rotationFunction?: any;
  135829. ribbonCloseArray?: boolean;
  135830. ribbonClosePath?: boolean;
  135831. cap?: number;
  135832. updatable?: boolean;
  135833. sideOrientation?: number;
  135834. frontUVs?: Vector4;
  135835. backUVs?: Vector4;
  135836. instance?: Mesh;
  135837. invertUV?: boolean;
  135838. }, scene?: Nullable<Scene>): Mesh;
  135839. private static _ExtrudeShapeGeneric;
  135840. }
  135841. }
  135842. declare module BABYLON {
  135843. /**
  135844. * AmmoJS Physics plugin
  135845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  135846. * @see https://github.com/kripken/ammo.js/
  135847. */
  135848. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  135849. private _useDeltaForWorldStep;
  135850. /**
  135851. * Reference to the Ammo library
  135852. */
  135853. bjsAMMO: any;
  135854. /**
  135855. * Created ammoJS world which physics bodies are added to
  135856. */
  135857. world: any;
  135858. /**
  135859. * Name of the plugin
  135860. */
  135861. name: string;
  135862. private _timeStep;
  135863. private _fixedTimeStep;
  135864. private _maxSteps;
  135865. private _tmpQuaternion;
  135866. private _tmpAmmoTransform;
  135867. private _tmpAmmoQuaternion;
  135868. private _tmpAmmoConcreteContactResultCallback;
  135869. private _collisionConfiguration;
  135870. private _dispatcher;
  135871. private _overlappingPairCache;
  135872. private _solver;
  135873. private _softBodySolver;
  135874. private _tmpAmmoVectorA;
  135875. private _tmpAmmoVectorB;
  135876. private _tmpAmmoVectorC;
  135877. private _tmpAmmoVectorD;
  135878. private _tmpContactCallbackResult;
  135879. private _tmpAmmoVectorRCA;
  135880. private _tmpAmmoVectorRCB;
  135881. private _raycastResult;
  135882. private static readonly DISABLE_COLLISION_FLAG;
  135883. private static readonly KINEMATIC_FLAG;
  135884. private static readonly DISABLE_DEACTIVATION_FLAG;
  135885. /**
  135886. * Initializes the ammoJS plugin
  135887. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  135888. * @param ammoInjection can be used to inject your own ammo reference
  135889. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  135890. */
  135891. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  135892. /**
  135893. * Sets the gravity of the physics world (m/(s^2))
  135894. * @param gravity Gravity to set
  135895. */
  135896. setGravity(gravity: Vector3): void;
  135897. /**
  135898. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  135899. * @param timeStep timestep to use in seconds
  135900. */
  135901. setTimeStep(timeStep: number): void;
  135902. /**
  135903. * 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)
  135904. * @param fixedTimeStep fixedTimeStep to use in seconds
  135905. */
  135906. setFixedTimeStep(fixedTimeStep: number): void;
  135907. /**
  135908. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  135909. * @param maxSteps the maximum number of steps by the physics engine per frame
  135910. */
  135911. setMaxSteps(maxSteps: number): void;
  135912. /**
  135913. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  135914. * @returns the current timestep in seconds
  135915. */
  135916. getTimeStep(): number;
  135917. /**
  135918. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  135919. */
  135920. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  135921. private _isImpostorInContact;
  135922. private _isImpostorPairInContact;
  135923. private _stepSimulation;
  135924. /**
  135925. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  135926. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  135927. * After the step the babylon meshes are set to the position of the physics imposters
  135928. * @param delta amount of time to step forward
  135929. * @param impostors array of imposters to update before/after the step
  135930. */
  135931. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  135932. /**
  135933. * Update babylon mesh to match physics world object
  135934. * @param impostor imposter to match
  135935. */
  135936. private _afterSoftStep;
  135937. /**
  135938. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  135939. * @param impostor imposter to match
  135940. */
  135941. private _ropeStep;
  135942. /**
  135943. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  135944. * @param impostor imposter to match
  135945. */
  135946. private _softbodyOrClothStep;
  135947. private _tmpMatrix;
  135948. /**
  135949. * Applies an impulse on the imposter
  135950. * @param impostor imposter to apply impulse to
  135951. * @param force amount of force to be applied to the imposter
  135952. * @param contactPoint the location to apply the impulse on the imposter
  135953. */
  135954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135955. /**
  135956. * Applies a force on the imposter
  135957. * @param impostor imposter to apply force
  135958. * @param force amount of force to be applied to the imposter
  135959. * @param contactPoint the location to apply the force on the imposter
  135960. */
  135961. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135962. /**
  135963. * Creates a physics body using the plugin
  135964. * @param impostor the imposter to create the physics body on
  135965. */
  135966. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135967. /**
  135968. * Removes the physics body from the imposter and disposes of the body's memory
  135969. * @param impostor imposter to remove the physics body from
  135970. */
  135971. removePhysicsBody(impostor: PhysicsImpostor): void;
  135972. /**
  135973. * Generates a joint
  135974. * @param impostorJoint the imposter joint to create the joint with
  135975. */
  135976. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135977. /**
  135978. * Removes a joint
  135979. * @param impostorJoint the imposter joint to remove the joint from
  135980. */
  135981. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135982. private _addMeshVerts;
  135983. /**
  135984. * Initialise the soft body vertices to match its object's (mesh) vertices
  135985. * Softbody vertices (nodes) are in world space and to match this
  135986. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  135987. * @param impostor to create the softbody for
  135988. */
  135989. private _softVertexData;
  135990. /**
  135991. * Create an impostor's soft body
  135992. * @param impostor to create the softbody for
  135993. */
  135994. private _createSoftbody;
  135995. /**
  135996. * Create cloth for an impostor
  135997. * @param impostor to create the softbody for
  135998. */
  135999. private _createCloth;
  136000. /**
  136001. * Create rope for an impostor
  136002. * @param impostor to create the softbody for
  136003. */
  136004. private _createRope;
  136005. /**
  136006. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  136007. * @param impostor to create the custom physics shape for
  136008. */
  136009. private _createCustom;
  136010. private _addHullVerts;
  136011. private _createShape;
  136012. /**
  136013. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  136014. * @param impostor imposter containing the physics body and babylon object
  136015. */
  136016. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136017. /**
  136018. * Sets the babylon object's position/rotation from the physics body's position/rotation
  136019. * @param impostor imposter containing the physics body and babylon object
  136020. * @param newPosition new position
  136021. * @param newRotation new rotation
  136022. */
  136023. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136024. /**
  136025. * If this plugin is supported
  136026. * @returns true if its supported
  136027. */
  136028. isSupported(): boolean;
  136029. /**
  136030. * Sets the linear velocity of the physics body
  136031. * @param impostor imposter to set the velocity on
  136032. * @param velocity velocity to set
  136033. */
  136034. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136035. /**
  136036. * Sets the angular velocity of the physics body
  136037. * @param impostor imposter to set the velocity on
  136038. * @param velocity velocity to set
  136039. */
  136040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136041. /**
  136042. * gets the linear velocity
  136043. * @param impostor imposter to get linear velocity from
  136044. * @returns linear velocity
  136045. */
  136046. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136047. /**
  136048. * gets the angular velocity
  136049. * @param impostor imposter to get angular velocity from
  136050. * @returns angular velocity
  136051. */
  136052. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136053. /**
  136054. * Sets the mass of physics body
  136055. * @param impostor imposter to set the mass on
  136056. * @param mass mass to set
  136057. */
  136058. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136059. /**
  136060. * Gets the mass of the physics body
  136061. * @param impostor imposter to get the mass from
  136062. * @returns mass
  136063. */
  136064. getBodyMass(impostor: PhysicsImpostor): number;
  136065. /**
  136066. * Gets friction of the impostor
  136067. * @param impostor impostor to get friction from
  136068. * @returns friction value
  136069. */
  136070. getBodyFriction(impostor: PhysicsImpostor): number;
  136071. /**
  136072. * Sets friction of the impostor
  136073. * @param impostor impostor to set friction on
  136074. * @param friction friction value
  136075. */
  136076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136077. /**
  136078. * Gets restitution of the impostor
  136079. * @param impostor impostor to get restitution from
  136080. * @returns restitution value
  136081. */
  136082. getBodyRestitution(impostor: PhysicsImpostor): number;
  136083. /**
  136084. * Sets resitution of the impostor
  136085. * @param impostor impostor to set resitution on
  136086. * @param restitution resitution value
  136087. */
  136088. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136089. /**
  136090. * Gets pressure inside the impostor
  136091. * @param impostor impostor to get pressure from
  136092. * @returns pressure value
  136093. */
  136094. getBodyPressure(impostor: PhysicsImpostor): number;
  136095. /**
  136096. * Sets pressure inside a soft body impostor
  136097. * Cloth and rope must remain 0 pressure
  136098. * @param impostor impostor to set pressure on
  136099. * @param pressure pressure value
  136100. */
  136101. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  136102. /**
  136103. * Gets stiffness of the impostor
  136104. * @param impostor impostor to get stiffness from
  136105. * @returns pressure value
  136106. */
  136107. getBodyStiffness(impostor: PhysicsImpostor): number;
  136108. /**
  136109. * Sets stiffness of the impostor
  136110. * @param impostor impostor to set stiffness on
  136111. * @param stiffness stiffness value from 0 to 1
  136112. */
  136113. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  136114. /**
  136115. * Gets velocityIterations of the impostor
  136116. * @param impostor impostor to get velocity iterations from
  136117. * @returns velocityIterations value
  136118. */
  136119. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  136120. /**
  136121. * Sets velocityIterations of the impostor
  136122. * @param impostor impostor to set velocity iterations on
  136123. * @param velocityIterations velocityIterations value
  136124. */
  136125. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  136126. /**
  136127. * Gets positionIterations of the impostor
  136128. * @param impostor impostor to get position iterations from
  136129. * @returns positionIterations value
  136130. */
  136131. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  136132. /**
  136133. * Sets positionIterations of the impostor
  136134. * @param impostor impostor to set position on
  136135. * @param positionIterations positionIterations value
  136136. */
  136137. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  136138. /**
  136139. * Append an anchor to a cloth object
  136140. * @param impostor is the cloth impostor to add anchor to
  136141. * @param otherImpostor is the rigid impostor to anchor to
  136142. * @param width ratio across width from 0 to 1
  136143. * @param height ratio up height from 0 to 1
  136144. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  136145. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136146. */
  136147. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136148. /**
  136149. * Append an hook to a rope object
  136150. * @param impostor is the rope impostor to add hook to
  136151. * @param otherImpostor is the rigid impostor to hook to
  136152. * @param length ratio along the rope from 0 to 1
  136153. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  136154. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136155. */
  136156. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136157. /**
  136158. * Sleeps the physics body and stops it from being active
  136159. * @param impostor impostor to sleep
  136160. */
  136161. sleepBody(impostor: PhysicsImpostor): void;
  136162. /**
  136163. * Activates the physics body
  136164. * @param impostor impostor to activate
  136165. */
  136166. wakeUpBody(impostor: PhysicsImpostor): void;
  136167. /**
  136168. * Updates the distance parameters of the joint
  136169. * @param joint joint to update
  136170. * @param maxDistance maximum distance of the joint
  136171. * @param minDistance minimum distance of the joint
  136172. */
  136173. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136174. /**
  136175. * Sets a motor on the joint
  136176. * @param joint joint to set motor on
  136177. * @param speed speed of the motor
  136178. * @param maxForce maximum force of the motor
  136179. * @param motorIndex index of the motor
  136180. */
  136181. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136182. /**
  136183. * Sets the motors limit
  136184. * @param joint joint to set limit on
  136185. * @param upperLimit upper limit
  136186. * @param lowerLimit lower limit
  136187. */
  136188. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136189. /**
  136190. * Syncs the position and rotation of a mesh with the impostor
  136191. * @param mesh mesh to sync
  136192. * @param impostor impostor to update the mesh with
  136193. */
  136194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136195. /**
  136196. * Gets the radius of the impostor
  136197. * @param impostor impostor to get radius from
  136198. * @returns the radius
  136199. */
  136200. getRadius(impostor: PhysicsImpostor): number;
  136201. /**
  136202. * Gets the box size of the impostor
  136203. * @param impostor impostor to get box size from
  136204. * @param result the resulting box size
  136205. */
  136206. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136207. /**
  136208. * Disposes of the impostor
  136209. */
  136210. dispose(): void;
  136211. /**
  136212. * Does a raycast in the physics world
  136213. * @param from when should the ray start?
  136214. * @param to when should the ray end?
  136215. * @returns PhysicsRaycastResult
  136216. */
  136217. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136218. }
  136219. }
  136220. declare module BABYLON {
  136221. interface AbstractScene {
  136222. /**
  136223. * The list of reflection probes added to the scene
  136224. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136225. */
  136226. reflectionProbes: Array<ReflectionProbe>;
  136227. /**
  136228. * Removes the given reflection probe from this scene.
  136229. * @param toRemove The reflection probe to remove
  136230. * @returns The index of the removed reflection probe
  136231. */
  136232. removeReflectionProbe(toRemove: ReflectionProbe): number;
  136233. /**
  136234. * Adds the given reflection probe to this scene.
  136235. * @param newReflectionProbe The reflection probe to add
  136236. */
  136237. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  136238. }
  136239. /**
  136240. * Class used to generate realtime reflection / refraction cube textures
  136241. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136242. */
  136243. export class ReflectionProbe {
  136244. /** defines the name of the probe */
  136245. name: string;
  136246. private _scene;
  136247. private _renderTargetTexture;
  136248. private _projectionMatrix;
  136249. private _viewMatrix;
  136250. private _target;
  136251. private _add;
  136252. private _attachedMesh;
  136253. private _invertYAxis;
  136254. /** Gets or sets probe position (center of the cube map) */
  136255. position: Vector3;
  136256. /**
  136257. * Creates a new reflection probe
  136258. * @param name defines the name of the probe
  136259. * @param size defines the texture resolution (for each face)
  136260. * @param scene defines the hosting scene
  136261. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  136262. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  136263. */
  136264. constructor(
  136265. /** defines the name of the probe */
  136266. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  136267. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  136268. get samples(): number;
  136269. set samples(value: number);
  136270. /** Gets or sets the refresh rate to use (on every frame by default) */
  136271. get refreshRate(): number;
  136272. set refreshRate(value: number);
  136273. /**
  136274. * Gets the hosting scene
  136275. * @returns a Scene
  136276. */
  136277. getScene(): Scene;
  136278. /** Gets the internal CubeTexture used to render to */
  136279. get cubeTexture(): RenderTargetTexture;
  136280. /** Gets the list of meshes to render */
  136281. get renderList(): Nullable<AbstractMesh[]>;
  136282. /**
  136283. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  136284. * @param mesh defines the mesh to attach to
  136285. */
  136286. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136287. /**
  136288. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  136289. * @param renderingGroupId The rendering group id corresponding to its index
  136290. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136291. */
  136292. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  136293. /**
  136294. * Clean all associated resources
  136295. */
  136296. dispose(): void;
  136297. /**
  136298. * Converts the reflection probe information to a readable string for debug purpose.
  136299. * @param fullDetails Supports for multiple levels of logging within scene loading
  136300. * @returns the human readable reflection probe info
  136301. */
  136302. toString(fullDetails?: boolean): string;
  136303. /**
  136304. * Get the class name of the relfection probe.
  136305. * @returns "ReflectionProbe"
  136306. */
  136307. getClassName(): string;
  136308. /**
  136309. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  136310. * @returns The JSON representation of the texture
  136311. */
  136312. serialize(): any;
  136313. /**
  136314. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  136315. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  136316. * @param scene Define the scene the parsed reflection probe should be instantiated in
  136317. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  136318. * @returns The parsed reflection probe if successful
  136319. */
  136320. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  136321. }
  136322. }
  136323. declare module BABYLON {
  136324. /** @hidden */
  136325. export var _BabylonLoaderRegistered: boolean;
  136326. /**
  136327. * Helps setting up some configuration for the babylon file loader.
  136328. */
  136329. export class BabylonFileLoaderConfiguration {
  136330. /**
  136331. * The loader does not allow injecting custom physix engine into the plugins.
  136332. * Unfortunately in ES6, we need to manually inject them into the plugin.
  136333. * So you could set this variable to your engine import to make it work.
  136334. */
  136335. static LoaderInjectedPhysicsEngine: any;
  136336. }
  136337. }
  136338. declare module BABYLON {
  136339. /**
  136340. * The Physically based simple base material of BJS.
  136341. *
  136342. * This enables better naming and convention enforcements on top of the pbrMaterial.
  136343. * It is used as the base class for both the specGloss and metalRough conventions.
  136344. */
  136345. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  136346. /**
  136347. * Number of Simultaneous lights allowed on the material.
  136348. */
  136349. maxSimultaneousLights: number;
  136350. /**
  136351. * If sets to true, disables all the lights affecting the material.
  136352. */
  136353. disableLighting: boolean;
  136354. /**
  136355. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  136356. */
  136357. environmentTexture: BaseTexture;
  136358. /**
  136359. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136360. */
  136361. invertNormalMapX: boolean;
  136362. /**
  136363. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136364. */
  136365. invertNormalMapY: boolean;
  136366. /**
  136367. * Normal map used in the model.
  136368. */
  136369. normalTexture: BaseTexture;
  136370. /**
  136371. * Emissivie color used to self-illuminate the model.
  136372. */
  136373. emissiveColor: Color3;
  136374. /**
  136375. * Emissivie texture used to self-illuminate the model.
  136376. */
  136377. emissiveTexture: BaseTexture;
  136378. /**
  136379. * Occlusion Channel Strenght.
  136380. */
  136381. occlusionStrength: number;
  136382. /**
  136383. * Occlusion Texture of the material (adding extra occlusion effects).
  136384. */
  136385. occlusionTexture: BaseTexture;
  136386. /**
  136387. * Defines the alpha limits in alpha test mode.
  136388. */
  136389. alphaCutOff: number;
  136390. /**
  136391. * Gets the current double sided mode.
  136392. */
  136393. get doubleSided(): boolean;
  136394. /**
  136395. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136396. */
  136397. set doubleSided(value: boolean);
  136398. /**
  136399. * Stores the pre-calculated light information of a mesh in a texture.
  136400. */
  136401. lightmapTexture: BaseTexture;
  136402. /**
  136403. * If true, the light map contains occlusion information instead of lighting info.
  136404. */
  136405. useLightmapAsShadowmap: boolean;
  136406. /**
  136407. * Instantiates a new PBRMaterial instance.
  136408. *
  136409. * @param name The material name
  136410. * @param scene The scene the material will be use in.
  136411. */
  136412. constructor(name: string, scene: Scene);
  136413. getClassName(): string;
  136414. }
  136415. }
  136416. declare module BABYLON {
  136417. /**
  136418. * The PBR material of BJS following the metal roughness convention.
  136419. *
  136420. * This fits to the PBR convention in the GLTF definition:
  136421. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  136422. */
  136423. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  136424. /**
  136425. * The base color has two different interpretations depending on the value of metalness.
  136426. * When the material is a metal, the base color is the specific measured reflectance value
  136427. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  136428. * of the material.
  136429. */
  136430. baseColor: Color3;
  136431. /**
  136432. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  136433. * well as opacity information in the alpha channel.
  136434. */
  136435. baseTexture: BaseTexture;
  136436. /**
  136437. * Specifies the metallic scalar value of the material.
  136438. * Can also be used to scale the metalness values of the metallic texture.
  136439. */
  136440. metallic: number;
  136441. /**
  136442. * Specifies the roughness scalar value of the material.
  136443. * Can also be used to scale the roughness values of the metallic texture.
  136444. */
  136445. roughness: number;
  136446. /**
  136447. * Texture containing both the metallic value in the B channel and the
  136448. * roughness value in the G channel to keep better precision.
  136449. */
  136450. metallicRoughnessTexture: BaseTexture;
  136451. /**
  136452. * Instantiates a new PBRMetalRoughnessMaterial instance.
  136453. *
  136454. * @param name The material name
  136455. * @param scene The scene the material will be use in.
  136456. */
  136457. constructor(name: string, scene: Scene);
  136458. /**
  136459. * Return the currrent class name of the material.
  136460. */
  136461. getClassName(): string;
  136462. /**
  136463. * Makes a duplicate of the current material.
  136464. * @param name - name to use for the new material.
  136465. */
  136466. clone(name: string): PBRMetallicRoughnessMaterial;
  136467. /**
  136468. * Serialize the material to a parsable JSON object.
  136469. */
  136470. serialize(): any;
  136471. /**
  136472. * Parses a JSON object correponding to the serialize function.
  136473. */
  136474. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  136475. }
  136476. }
  136477. declare module BABYLON {
  136478. /**
  136479. * The PBR material of BJS following the specular glossiness convention.
  136480. *
  136481. * This fits to the PBR convention in the GLTF definition:
  136482. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  136483. */
  136484. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  136485. /**
  136486. * Specifies the diffuse color of the material.
  136487. */
  136488. diffuseColor: Color3;
  136489. /**
  136490. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  136491. * channel.
  136492. */
  136493. diffuseTexture: BaseTexture;
  136494. /**
  136495. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  136496. */
  136497. specularColor: Color3;
  136498. /**
  136499. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  136500. */
  136501. glossiness: number;
  136502. /**
  136503. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  136504. */
  136505. specularGlossinessTexture: BaseTexture;
  136506. /**
  136507. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  136508. *
  136509. * @param name The material name
  136510. * @param scene The scene the material will be use in.
  136511. */
  136512. constructor(name: string, scene: Scene);
  136513. /**
  136514. * Return the currrent class name of the material.
  136515. */
  136516. getClassName(): string;
  136517. /**
  136518. * Makes a duplicate of the current material.
  136519. * @param name - name to use for the new material.
  136520. */
  136521. clone(name: string): PBRSpecularGlossinessMaterial;
  136522. /**
  136523. * Serialize the material to a parsable JSON object.
  136524. */
  136525. serialize(): any;
  136526. /**
  136527. * Parses a JSON object correponding to the serialize function.
  136528. */
  136529. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  136530. }
  136531. }
  136532. declare module BABYLON {
  136533. /**
  136534. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  136535. * It can help converting any input color in a desired output one. This can then be used to create effects
  136536. * from sepia, black and white to sixties or futuristic rendering...
  136537. *
  136538. * The only supported format is currently 3dl.
  136539. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  136540. */
  136541. export class ColorGradingTexture extends BaseTexture {
  136542. /**
  136543. * The texture URL.
  136544. */
  136545. url: string;
  136546. /**
  136547. * Empty line regex stored for GC.
  136548. */
  136549. private static _noneEmptyLineRegex;
  136550. private _textureMatrix;
  136551. private _onLoad;
  136552. /**
  136553. * Instantiates a ColorGradingTexture from the following parameters.
  136554. *
  136555. * @param url The location of the color gradind data (currently only supporting 3dl)
  136556. * @param sceneOrEngine The scene or engine the texture will be used in
  136557. * @param onLoad defines a callback triggered when the texture has been loaded
  136558. */
  136559. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  136560. /**
  136561. * Fires the onload event from the constructor if requested.
  136562. */
  136563. private _triggerOnLoad;
  136564. /**
  136565. * Returns the texture matrix used in most of the material.
  136566. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  136567. */
  136568. getTextureMatrix(): Matrix;
  136569. /**
  136570. * Occurs when the file being loaded is a .3dl LUT file.
  136571. */
  136572. private load3dlTexture;
  136573. /**
  136574. * Starts the loading process of the texture.
  136575. */
  136576. private loadTexture;
  136577. /**
  136578. * Clones the color gradind texture.
  136579. */
  136580. clone(): ColorGradingTexture;
  136581. /**
  136582. * Called during delayed load for textures.
  136583. */
  136584. delayLoad(): void;
  136585. /**
  136586. * Parses a color grading texture serialized by Babylon.
  136587. * @param parsedTexture The texture information being parsedTexture
  136588. * @param scene The scene to load the texture in
  136589. * @param rootUrl The root url of the data assets to load
  136590. * @return A color gradind texture
  136591. */
  136592. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  136593. /**
  136594. * Serializes the LUT texture to json format.
  136595. */
  136596. serialize(): any;
  136597. }
  136598. }
  136599. declare module BABYLON {
  136600. /**
  136601. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  136602. */
  136603. export class EquiRectangularCubeTexture extends BaseTexture {
  136604. /** The six faces of the cube. */
  136605. private static _FacesMapping;
  136606. private _noMipmap;
  136607. private _onLoad;
  136608. private _onError;
  136609. /** The size of the cubemap. */
  136610. private _size;
  136611. /** The buffer of the image. */
  136612. private _buffer;
  136613. /** The width of the input image. */
  136614. private _width;
  136615. /** The height of the input image. */
  136616. private _height;
  136617. /** The URL to the image. */
  136618. url: string;
  136619. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  136620. coordinatesMode: number;
  136621. /**
  136622. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  136623. * @param url The location of the image
  136624. * @param scene The scene the texture will be used in
  136625. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136626. * @param noMipmap Forces to not generate the mipmap if true
  136627. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136628. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136629. * @param onLoad — defines a callback called when texture is loaded
  136630. * @param onError — defines a callback called if there is an error
  136631. */
  136632. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  136633. /**
  136634. * Load the image data, by putting the image on a canvas and extracting its buffer.
  136635. */
  136636. private loadImage;
  136637. /**
  136638. * Convert the image buffer into a cubemap and create a CubeTexture.
  136639. */
  136640. private loadTexture;
  136641. /**
  136642. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  136643. * @param buffer The ArrayBuffer that should be converted.
  136644. * @returns The buffer as Float32Array.
  136645. */
  136646. private getFloat32ArrayFromArrayBuffer;
  136647. /**
  136648. * Get the current class name of the texture useful for serialization or dynamic coding.
  136649. * @returns "EquiRectangularCubeTexture"
  136650. */
  136651. getClassName(): string;
  136652. /**
  136653. * Create a clone of the current EquiRectangularCubeTexture and return it.
  136654. * @returns A clone of the current EquiRectangularCubeTexture.
  136655. */
  136656. clone(): EquiRectangularCubeTexture;
  136657. }
  136658. }
  136659. declare module BABYLON {
  136660. /**
  136661. * Defines the options related to the creation of an HtmlElementTexture
  136662. */
  136663. export interface IHtmlElementTextureOptions {
  136664. /**
  136665. * Defines wether mip maps should be created or not.
  136666. */
  136667. generateMipMaps?: boolean;
  136668. /**
  136669. * Defines the sampling mode of the texture.
  136670. */
  136671. samplingMode?: number;
  136672. /**
  136673. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  136674. */
  136675. engine: Nullable<ThinEngine>;
  136676. /**
  136677. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  136678. */
  136679. scene: Nullable<Scene>;
  136680. }
  136681. /**
  136682. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  136683. * To be as efficient as possible depending on your constraints nothing aside the first upload
  136684. * is automatically managed.
  136685. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  136686. * in your application.
  136687. *
  136688. * As the update is not automatic, you need to call them manually.
  136689. */
  136690. export class HtmlElementTexture extends BaseTexture {
  136691. /**
  136692. * The texture URL.
  136693. */
  136694. element: HTMLVideoElement | HTMLCanvasElement;
  136695. private static readonly DefaultOptions;
  136696. private _textureMatrix;
  136697. private _isVideo;
  136698. private _generateMipMaps;
  136699. private _samplingMode;
  136700. /**
  136701. * Instantiates a HtmlElementTexture from the following parameters.
  136702. *
  136703. * @param name Defines the name of the texture
  136704. * @param element Defines the video or canvas the texture is filled with
  136705. * @param options Defines the other none mandatory texture creation options
  136706. */
  136707. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  136708. private _createInternalTexture;
  136709. /**
  136710. * Returns the texture matrix used in most of the material.
  136711. */
  136712. getTextureMatrix(): Matrix;
  136713. /**
  136714. * Updates the content of the texture.
  136715. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  136716. */
  136717. update(invertY?: Nullable<boolean>): void;
  136718. }
  136719. }
  136720. declare module BABYLON {
  136721. /**
  136722. * Based on jsTGALoader - Javascript loader for TGA file
  136723. * By Vincent Thibault
  136724. * @see http://blog.robrowser.com/javascript-tga-loader.html
  136725. */
  136726. export class TGATools {
  136727. private static _TYPE_INDEXED;
  136728. private static _TYPE_RGB;
  136729. private static _TYPE_GREY;
  136730. private static _TYPE_RLE_INDEXED;
  136731. private static _TYPE_RLE_RGB;
  136732. private static _TYPE_RLE_GREY;
  136733. private static _ORIGIN_MASK;
  136734. private static _ORIGIN_SHIFT;
  136735. private static _ORIGIN_BL;
  136736. private static _ORIGIN_BR;
  136737. private static _ORIGIN_UL;
  136738. private static _ORIGIN_UR;
  136739. /**
  136740. * Gets the header of a TGA file
  136741. * @param data defines the TGA data
  136742. * @returns the header
  136743. */
  136744. static GetTGAHeader(data: Uint8Array): any;
  136745. /**
  136746. * Uploads TGA content to a Babylon Texture
  136747. * @hidden
  136748. */
  136749. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  136750. /** @hidden */
  136751. 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;
  136752. /** @hidden */
  136753. 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;
  136754. /** @hidden */
  136755. 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;
  136756. /** @hidden */
  136757. 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;
  136758. /** @hidden */
  136759. 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;
  136760. /** @hidden */
  136761. 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;
  136762. }
  136763. }
  136764. declare module BABYLON {
  136765. /**
  136766. * Implementation of the TGA Texture Loader.
  136767. * @hidden
  136768. */
  136769. export class _TGATextureLoader implements IInternalTextureLoader {
  136770. /**
  136771. * Defines wether the loader supports cascade loading the different faces.
  136772. */
  136773. readonly supportCascades: boolean;
  136774. /**
  136775. * This returns if the loader support the current file information.
  136776. * @param extension defines the file extension of the file being loaded
  136777. * @returns true if the loader can load the specified file
  136778. */
  136779. canLoad(extension: string): boolean;
  136780. /**
  136781. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136782. * @param data contains the texture data
  136783. * @param texture defines the BabylonJS internal texture
  136784. * @param createPolynomials will be true if polynomials have been requested
  136785. * @param onLoad defines the callback to trigger once the texture is ready
  136786. * @param onError defines the callback to trigger in case of error
  136787. */
  136788. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136789. /**
  136790. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136791. * @param data contains the texture data
  136792. * @param texture defines the BabylonJS internal texture
  136793. * @param callback defines the method to call once ready to upload
  136794. */
  136795. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136796. }
  136797. }
  136798. declare module BABYLON {
  136799. /**
  136800. * Info about the .basis files
  136801. */
  136802. class BasisFileInfo {
  136803. /**
  136804. * If the file has alpha
  136805. */
  136806. hasAlpha: boolean;
  136807. /**
  136808. * Info about each image of the basis file
  136809. */
  136810. images: Array<{
  136811. levels: Array<{
  136812. width: number;
  136813. height: number;
  136814. transcodedPixels: ArrayBufferView;
  136815. }>;
  136816. }>;
  136817. }
  136818. /**
  136819. * Result of transcoding a basis file
  136820. */
  136821. class TranscodeResult {
  136822. /**
  136823. * Info about the .basis file
  136824. */
  136825. fileInfo: BasisFileInfo;
  136826. /**
  136827. * Format to use when loading the file
  136828. */
  136829. format: number;
  136830. }
  136831. /**
  136832. * Configuration options for the Basis transcoder
  136833. */
  136834. export class BasisTranscodeConfiguration {
  136835. /**
  136836. * Supported compression formats used to determine the supported output format of the transcoder
  136837. */
  136838. supportedCompressionFormats?: {
  136839. /**
  136840. * etc1 compression format
  136841. */
  136842. etc1?: boolean;
  136843. /**
  136844. * s3tc compression format
  136845. */
  136846. s3tc?: boolean;
  136847. /**
  136848. * pvrtc compression format
  136849. */
  136850. pvrtc?: boolean;
  136851. /**
  136852. * etc2 compression format
  136853. */
  136854. etc2?: boolean;
  136855. };
  136856. /**
  136857. * If mipmap levels should be loaded for transcoded images (Default: true)
  136858. */
  136859. loadMipmapLevels?: boolean;
  136860. /**
  136861. * Index of a single image to load (Default: all images)
  136862. */
  136863. loadSingleImage?: number;
  136864. }
  136865. /**
  136866. * Used to load .Basis files
  136867. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  136868. */
  136869. export class BasisTools {
  136870. private static _IgnoreSupportedFormats;
  136871. /**
  136872. * URL to use when loading the basis transcoder
  136873. */
  136874. static JSModuleURL: string;
  136875. /**
  136876. * URL to use when loading the wasm module for the transcoder
  136877. */
  136878. static WasmModuleURL: string;
  136879. /**
  136880. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  136881. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  136882. * @returns internal format corresponding to the Basis format
  136883. */
  136884. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  136885. private static _WorkerPromise;
  136886. private static _Worker;
  136887. private static _actionId;
  136888. private static _CreateWorkerAsync;
  136889. /**
  136890. * Transcodes a loaded image file to compressed pixel data
  136891. * @param data image data to transcode
  136892. * @param config configuration options for the transcoding
  136893. * @returns a promise resulting in the transcoded image
  136894. */
  136895. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  136896. /**
  136897. * Loads a texture from the transcode result
  136898. * @param texture texture load to
  136899. * @param transcodeResult the result of transcoding the basis file to load from
  136900. */
  136901. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  136902. }
  136903. }
  136904. declare module BABYLON {
  136905. /**
  136906. * Loader for .basis file format
  136907. */
  136908. export class _BasisTextureLoader implements IInternalTextureLoader {
  136909. /**
  136910. * Defines whether the loader supports cascade loading the different faces.
  136911. */
  136912. readonly supportCascades: boolean;
  136913. /**
  136914. * This returns if the loader support the current file information.
  136915. * @param extension defines the file extension of the file being loaded
  136916. * @returns true if the loader can load the specified file
  136917. */
  136918. canLoad(extension: string): boolean;
  136919. /**
  136920. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136921. * @param data contains the texture data
  136922. * @param texture defines the BabylonJS internal texture
  136923. * @param createPolynomials will be true if polynomials have been requested
  136924. * @param onLoad defines the callback to trigger once the texture is ready
  136925. * @param onError defines the callback to trigger in case of error
  136926. */
  136927. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136928. /**
  136929. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136930. * @param data contains the texture data
  136931. * @param texture defines the BabylonJS internal texture
  136932. * @param callback defines the method to call once ready to upload
  136933. */
  136934. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136935. }
  136936. }
  136937. declare module BABYLON {
  136938. /**
  136939. * Defines the basic options interface of a TexturePacker Frame
  136940. */
  136941. export interface ITexturePackerFrame {
  136942. /**
  136943. * The frame ID
  136944. */
  136945. id: number;
  136946. /**
  136947. * The frames Scale
  136948. */
  136949. scale: Vector2;
  136950. /**
  136951. * The Frames offset
  136952. */
  136953. offset: Vector2;
  136954. }
  136955. /**
  136956. * This is a support class for frame Data on texture packer sets.
  136957. */
  136958. export class TexturePackerFrame implements ITexturePackerFrame {
  136959. /**
  136960. * The frame ID
  136961. */
  136962. id: number;
  136963. /**
  136964. * The frames Scale
  136965. */
  136966. scale: Vector2;
  136967. /**
  136968. * The Frames offset
  136969. */
  136970. offset: Vector2;
  136971. /**
  136972. * Initializes a texture package frame.
  136973. * @param id The numerical frame identifier
  136974. * @param scale Scalar Vector2 for UV frame
  136975. * @param offset Vector2 for the frame position in UV units.
  136976. * @returns TexturePackerFrame
  136977. */
  136978. constructor(id: number, scale: Vector2, offset: Vector2);
  136979. }
  136980. }
  136981. declare module BABYLON {
  136982. /**
  136983. * Defines the basic options interface of a TexturePacker
  136984. */
  136985. export interface ITexturePackerOptions {
  136986. /**
  136987. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  136988. */
  136989. map?: string[];
  136990. /**
  136991. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  136992. */
  136993. uvsIn?: string;
  136994. /**
  136995. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  136996. */
  136997. uvsOut?: string;
  136998. /**
  136999. * number representing the layout style. Defaults to LAYOUT_STRIP
  137000. */
  137001. layout?: number;
  137002. /**
  137003. * number of columns if using custom column count layout(2). This defaults to 4.
  137004. */
  137005. colnum?: number;
  137006. /**
  137007. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  137008. */
  137009. updateInputMeshes?: boolean;
  137010. /**
  137011. * boolean flag to dispose all the source textures. Defaults to true.
  137012. */
  137013. disposeSources?: boolean;
  137014. /**
  137015. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  137016. */
  137017. fillBlanks?: boolean;
  137018. /**
  137019. * string value representing the context fill style color. Defaults to 'black'.
  137020. */
  137021. customFillColor?: string;
  137022. /**
  137023. * Width and Height Value of each Frame in the TexturePacker Sets
  137024. */
  137025. frameSize?: number;
  137026. /**
  137027. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  137028. */
  137029. paddingRatio?: number;
  137030. /**
  137031. * Number that declares the fill method for the padding gutter.
  137032. */
  137033. paddingMode?: number;
  137034. /**
  137035. * If in SUBUV_COLOR padding mode what color to use.
  137036. */
  137037. paddingColor?: Color3 | Color4;
  137038. }
  137039. /**
  137040. * Defines the basic interface of a TexturePacker JSON File
  137041. */
  137042. export interface ITexturePackerJSON {
  137043. /**
  137044. * The frame ID
  137045. */
  137046. name: string;
  137047. /**
  137048. * The base64 channel data
  137049. */
  137050. sets: any;
  137051. /**
  137052. * The options of the Packer
  137053. */
  137054. options: ITexturePackerOptions;
  137055. /**
  137056. * The frame data of the Packer
  137057. */
  137058. frames: Array<number>;
  137059. }
  137060. /**
  137061. * This is a support class that generates a series of packed texture sets.
  137062. * @see https://doc.babylonjs.com/babylon101/materials
  137063. */
  137064. export class TexturePacker {
  137065. /** Packer Layout Constant 0 */
  137066. static readonly LAYOUT_STRIP: number;
  137067. /** Packer Layout Constant 1 */
  137068. static readonly LAYOUT_POWER2: number;
  137069. /** Packer Layout Constant 2 */
  137070. static readonly LAYOUT_COLNUM: number;
  137071. /** Packer Layout Constant 0 */
  137072. static readonly SUBUV_WRAP: number;
  137073. /** Packer Layout Constant 1 */
  137074. static readonly SUBUV_EXTEND: number;
  137075. /** Packer Layout Constant 2 */
  137076. static readonly SUBUV_COLOR: number;
  137077. /** The Name of the Texture Package */
  137078. name: string;
  137079. /** The scene scope of the TexturePacker */
  137080. scene: Scene;
  137081. /** The Meshes to target */
  137082. meshes: AbstractMesh[];
  137083. /** Arguments passed with the Constructor */
  137084. options: ITexturePackerOptions;
  137085. /** The promise that is started upon initialization */
  137086. promise: Nullable<Promise<TexturePacker | string>>;
  137087. /** The Container object for the channel sets that are generated */
  137088. sets: object;
  137089. /** The Container array for the frames that are generated */
  137090. frames: TexturePackerFrame[];
  137091. /** The expected number of textures the system is parsing. */
  137092. private _expecting;
  137093. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  137094. private _paddingValue;
  137095. /**
  137096. * Initializes a texture package series from an array of meshes or a single mesh.
  137097. * @param name The name of the package
  137098. * @param meshes The target meshes to compose the package from
  137099. * @param options The arguments that texture packer should follow while building.
  137100. * @param scene The scene which the textures are scoped to.
  137101. * @returns TexturePacker
  137102. */
  137103. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  137104. /**
  137105. * Starts the package process
  137106. * @param resolve The promises resolution function
  137107. * @returns TexturePacker
  137108. */
  137109. private _createFrames;
  137110. /**
  137111. * Calculates the Size of the Channel Sets
  137112. * @returns Vector2
  137113. */
  137114. private _calculateSize;
  137115. /**
  137116. * Calculates the UV data for the frames.
  137117. * @param baseSize the base frameSize
  137118. * @param padding the base frame padding
  137119. * @param dtSize size of the Dynamic Texture for that channel
  137120. * @param dtUnits is 1/dtSize
  137121. * @param update flag to update the input meshes
  137122. */
  137123. private _calculateMeshUVFrames;
  137124. /**
  137125. * Calculates the frames Offset.
  137126. * @param index of the frame
  137127. * @returns Vector2
  137128. */
  137129. private _getFrameOffset;
  137130. /**
  137131. * Updates a Mesh to the frame data
  137132. * @param mesh that is the target
  137133. * @param frameID or the frame index
  137134. */
  137135. private _updateMeshUV;
  137136. /**
  137137. * Updates a Meshes materials to use the texture packer channels
  137138. * @param m is the mesh to target
  137139. * @param force all channels on the packer to be set.
  137140. */
  137141. private _updateTextureReferences;
  137142. /**
  137143. * Public method to set a Mesh to a frame
  137144. * @param m that is the target
  137145. * @param frameID or the frame index
  137146. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  137147. */
  137148. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  137149. /**
  137150. * Starts the async promise to compile the texture packer.
  137151. * @returns Promise<void>
  137152. */
  137153. processAsync(): Promise<void>;
  137154. /**
  137155. * Disposes all textures associated with this packer
  137156. */
  137157. dispose(): void;
  137158. /**
  137159. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  137160. * @param imageType is the image type to use.
  137161. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  137162. */
  137163. download(imageType?: string, quality?: number): void;
  137164. /**
  137165. * Public method to load a texturePacker JSON file.
  137166. * @param data of the JSON file in string format.
  137167. */
  137168. updateFromJSON(data: string): void;
  137169. }
  137170. }
  137171. declare module BABYLON {
  137172. /**
  137173. * 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.
  137174. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137175. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137176. */
  137177. export class CustomProceduralTexture extends ProceduralTexture {
  137178. private _animate;
  137179. private _time;
  137180. private _config;
  137181. private _texturePath;
  137182. /**
  137183. * Instantiates a new Custom Procedural Texture.
  137184. * 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.
  137185. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137186. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137187. * @param name Define the name of the texture
  137188. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  137189. * @param size Define the size of the texture to create
  137190. * @param scene Define the scene the texture belongs to
  137191. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  137192. * @param generateMipMaps Define if the texture should creates mip maps or not
  137193. */
  137194. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137195. private _loadJson;
  137196. /**
  137197. * Is the texture ready to be used ? (rendered at least once)
  137198. * @returns true if ready, otherwise, false.
  137199. */
  137200. isReady(): boolean;
  137201. /**
  137202. * Render the texture to its associated render target.
  137203. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  137204. */
  137205. render(useCameraPostProcess?: boolean): void;
  137206. /**
  137207. * Update the list of dependant textures samplers in the shader.
  137208. */
  137209. updateTextures(): void;
  137210. /**
  137211. * Update the uniform values of the procedural texture in the shader.
  137212. */
  137213. updateShaderUniforms(): void;
  137214. /**
  137215. * Define if the texture animates or not.
  137216. */
  137217. get animate(): boolean;
  137218. set animate(value: boolean);
  137219. }
  137220. }
  137221. declare module BABYLON {
  137222. /** @hidden */
  137223. export var noisePixelShader: {
  137224. name: string;
  137225. shader: string;
  137226. };
  137227. }
  137228. declare module BABYLON {
  137229. /**
  137230. * Class used to generate noise procedural textures
  137231. */
  137232. export class NoiseProceduralTexture extends ProceduralTexture {
  137233. private _time;
  137234. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  137235. brightness: number;
  137236. /** Defines the number of octaves to process */
  137237. octaves: number;
  137238. /** Defines the level of persistence (0.8 by default) */
  137239. persistence: number;
  137240. /** Gets or sets animation speed factor (default is 1) */
  137241. animationSpeedFactor: number;
  137242. /**
  137243. * Creates a new NoiseProceduralTexture
  137244. * @param name defines the name fo the texture
  137245. * @param size defines the size of the texture (default is 256)
  137246. * @param scene defines the hosting scene
  137247. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  137248. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  137249. */
  137250. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137251. private _updateShaderUniforms;
  137252. protected _getDefines(): string;
  137253. /** Generate the current state of the procedural texture */
  137254. render(useCameraPostProcess?: boolean): void;
  137255. /**
  137256. * Serializes this noise procedural texture
  137257. * @returns a serialized noise procedural texture object
  137258. */
  137259. serialize(): any;
  137260. /**
  137261. * Clone the texture.
  137262. * @returns the cloned texture
  137263. */
  137264. clone(): NoiseProceduralTexture;
  137265. /**
  137266. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  137267. * @param parsedTexture defines parsed texture data
  137268. * @param scene defines the current scene
  137269. * @param rootUrl defines the root URL containing noise procedural texture information
  137270. * @returns a parsed NoiseProceduralTexture
  137271. */
  137272. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  137273. }
  137274. }
  137275. declare module BABYLON {
  137276. /**
  137277. * Raw cube texture where the raw buffers are passed in
  137278. */
  137279. export class RawCubeTexture extends CubeTexture {
  137280. /**
  137281. * Creates a cube texture where the raw buffers are passed in.
  137282. * @param scene defines the scene the texture is attached to
  137283. * @param data defines the array of data to use to create each face
  137284. * @param size defines the size of the textures
  137285. * @param format defines the format of the data
  137286. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  137287. * @param generateMipMaps defines if the engine should generate the mip levels
  137288. * @param invertY defines if data must be stored with Y axis inverted
  137289. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  137290. * @param compression defines the compression used (null by default)
  137291. */
  137292. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  137293. /**
  137294. * Updates the raw cube texture.
  137295. * @param data defines the data to store
  137296. * @param format defines the data format
  137297. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  137298. * @param invertY defines if data must be stored with Y axis inverted
  137299. * @param compression defines the compression used (null by default)
  137300. * @param level defines which level of the texture to update
  137301. */
  137302. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  137303. /**
  137304. * Updates a raw cube texture with RGBD encoded data.
  137305. * @param data defines the array of data [mipmap][face] to use to create each face
  137306. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  137307. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137308. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137309. * @returns a promsie that resolves when the operation is complete
  137310. */
  137311. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  137312. /**
  137313. * Clones the raw cube texture.
  137314. * @return a new cube texture
  137315. */
  137316. clone(): CubeTexture;
  137317. /** @hidden */
  137318. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137319. }
  137320. }
  137321. declare module BABYLON {
  137322. /**
  137323. * Class used to store 2D array textures containing user data
  137324. */
  137325. export class RawTexture2DArray extends Texture {
  137326. /** Gets or sets the texture format to use */
  137327. format: number;
  137328. /**
  137329. * Create a new RawTexture2DArray
  137330. * @param data defines the data of the texture
  137331. * @param width defines the width of the texture
  137332. * @param height defines the height of the texture
  137333. * @param depth defines the number of layers of the texture
  137334. * @param format defines the texture format to use
  137335. * @param scene defines the hosting scene
  137336. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137337. * @param invertY defines if texture must be stored with Y axis inverted
  137338. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137339. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137340. */
  137341. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137342. /** Gets or sets the texture format to use */
  137343. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137344. /**
  137345. * Update the texture with new data
  137346. * @param data defines the data to store in the texture
  137347. */
  137348. update(data: ArrayBufferView): void;
  137349. }
  137350. }
  137351. declare module BABYLON {
  137352. /**
  137353. * Class used to store 3D textures containing user data
  137354. */
  137355. export class RawTexture3D extends Texture {
  137356. /** Gets or sets the texture format to use */
  137357. format: number;
  137358. /**
  137359. * Create a new RawTexture3D
  137360. * @param data defines the data of the texture
  137361. * @param width defines the width of the texture
  137362. * @param height defines the height of the texture
  137363. * @param depth defines the depth of the texture
  137364. * @param format defines the texture format to use
  137365. * @param scene defines the hosting scene
  137366. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137367. * @param invertY defines if texture must be stored with Y axis inverted
  137368. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137369. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137370. */
  137371. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137372. /** Gets or sets the texture format to use */
  137373. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137374. /**
  137375. * Update the texture with new data
  137376. * @param data defines the data to store in the texture
  137377. */
  137378. update(data: ArrayBufferView): void;
  137379. }
  137380. }
  137381. declare module BABYLON {
  137382. /**
  137383. * Creates a refraction texture used by refraction channel of the standard material.
  137384. * It is like a mirror but to see through a material.
  137385. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137386. */
  137387. export class RefractionTexture extends RenderTargetTexture {
  137388. /**
  137389. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  137390. * 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.
  137391. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137392. */
  137393. refractionPlane: Plane;
  137394. /**
  137395. * Define how deep under the surface we should see.
  137396. */
  137397. depth: number;
  137398. /**
  137399. * Creates a refraction texture used by refraction channel of the standard material.
  137400. * It is like a mirror but to see through a material.
  137401. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137402. * @param name Define the texture name
  137403. * @param size Define the size of the underlying texture
  137404. * @param scene Define the scene the refraction belongs to
  137405. * @param generateMipMaps Define if we need to generate mips level for the refraction
  137406. */
  137407. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  137408. /**
  137409. * Clone the refraction texture.
  137410. * @returns the cloned texture
  137411. */
  137412. clone(): RefractionTexture;
  137413. /**
  137414. * Serialize the texture to a JSON representation you could use in Parse later on
  137415. * @returns the serialized JSON representation
  137416. */
  137417. serialize(): any;
  137418. }
  137419. }
  137420. declare module BABYLON {
  137421. /**
  137422. * Block used to add support for vertex skinning (bones)
  137423. */
  137424. export class BonesBlock extends NodeMaterialBlock {
  137425. /**
  137426. * Creates a new BonesBlock
  137427. * @param name defines the block name
  137428. */
  137429. constructor(name: string);
  137430. /**
  137431. * Initialize the block and prepare the context for build
  137432. * @param state defines the state that will be used for the build
  137433. */
  137434. initialize(state: NodeMaterialBuildState): void;
  137435. /**
  137436. * Gets the current class name
  137437. * @returns the class name
  137438. */
  137439. getClassName(): string;
  137440. /**
  137441. * Gets the matrix indices input component
  137442. */
  137443. get matricesIndices(): NodeMaterialConnectionPoint;
  137444. /**
  137445. * Gets the matrix weights input component
  137446. */
  137447. get matricesWeights(): NodeMaterialConnectionPoint;
  137448. /**
  137449. * Gets the extra matrix indices input component
  137450. */
  137451. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  137452. /**
  137453. * Gets the extra matrix weights input component
  137454. */
  137455. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  137456. /**
  137457. * Gets the world input component
  137458. */
  137459. get world(): NodeMaterialConnectionPoint;
  137460. /**
  137461. * Gets the output component
  137462. */
  137463. get output(): NodeMaterialConnectionPoint;
  137464. autoConfigure(material: NodeMaterial): void;
  137465. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  137466. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137468. protected _buildBlock(state: NodeMaterialBuildState): this;
  137469. }
  137470. }
  137471. declare module BABYLON {
  137472. /**
  137473. * Block used to add support for instances
  137474. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  137475. */
  137476. export class InstancesBlock extends NodeMaterialBlock {
  137477. /**
  137478. * Creates a new InstancesBlock
  137479. * @param name defines the block name
  137480. */
  137481. constructor(name: string);
  137482. /**
  137483. * Gets the current class name
  137484. * @returns the class name
  137485. */
  137486. getClassName(): string;
  137487. /**
  137488. * Gets the first world row input component
  137489. */
  137490. get world0(): NodeMaterialConnectionPoint;
  137491. /**
  137492. * Gets the second world row input component
  137493. */
  137494. get world1(): NodeMaterialConnectionPoint;
  137495. /**
  137496. * Gets the third world row input component
  137497. */
  137498. get world2(): NodeMaterialConnectionPoint;
  137499. /**
  137500. * Gets the forth world row input component
  137501. */
  137502. get world3(): NodeMaterialConnectionPoint;
  137503. /**
  137504. * Gets the world input component
  137505. */
  137506. get world(): NodeMaterialConnectionPoint;
  137507. /**
  137508. * Gets the output component
  137509. */
  137510. get output(): NodeMaterialConnectionPoint;
  137511. /**
  137512. * Gets the isntanceID component
  137513. */
  137514. get instanceID(): NodeMaterialConnectionPoint;
  137515. autoConfigure(material: NodeMaterial): void;
  137516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  137517. protected _buildBlock(state: NodeMaterialBuildState): this;
  137518. }
  137519. }
  137520. declare module BABYLON {
  137521. /**
  137522. * Block used to add morph targets support to vertex shader
  137523. */
  137524. export class MorphTargetsBlock extends NodeMaterialBlock {
  137525. private _repeatableContentAnchor;
  137526. /**
  137527. * Create a new MorphTargetsBlock
  137528. * @param name defines the block name
  137529. */
  137530. constructor(name: string);
  137531. /**
  137532. * Gets the current class name
  137533. * @returns the class name
  137534. */
  137535. getClassName(): string;
  137536. /**
  137537. * Gets the position input component
  137538. */
  137539. get position(): NodeMaterialConnectionPoint;
  137540. /**
  137541. * Gets the normal input component
  137542. */
  137543. get normal(): NodeMaterialConnectionPoint;
  137544. /**
  137545. * Gets the tangent input component
  137546. */
  137547. get tangent(): NodeMaterialConnectionPoint;
  137548. /**
  137549. * Gets the tangent input component
  137550. */
  137551. get uv(): NodeMaterialConnectionPoint;
  137552. /**
  137553. * Gets the position output component
  137554. */
  137555. get positionOutput(): NodeMaterialConnectionPoint;
  137556. /**
  137557. * Gets the normal output component
  137558. */
  137559. get normalOutput(): NodeMaterialConnectionPoint;
  137560. /**
  137561. * Gets the tangent output component
  137562. */
  137563. get tangentOutput(): NodeMaterialConnectionPoint;
  137564. /**
  137565. * Gets the tangent output component
  137566. */
  137567. get uvOutput(): NodeMaterialConnectionPoint;
  137568. initialize(state: NodeMaterialBuildState): void;
  137569. autoConfigure(material: NodeMaterial): void;
  137570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137571. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137572. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  137573. protected _buildBlock(state: NodeMaterialBuildState): this;
  137574. }
  137575. }
  137576. declare module BABYLON {
  137577. /**
  137578. * Block used to get data information from a light
  137579. */
  137580. export class LightInformationBlock extends NodeMaterialBlock {
  137581. private _lightDataUniformName;
  137582. private _lightColorUniformName;
  137583. private _lightTypeDefineName;
  137584. /**
  137585. * Gets or sets the light associated with this block
  137586. */
  137587. light: Nullable<Light>;
  137588. /**
  137589. * Creates a new LightInformationBlock
  137590. * @param name defines the block name
  137591. */
  137592. constructor(name: string);
  137593. /**
  137594. * Gets the current class name
  137595. * @returns the class name
  137596. */
  137597. getClassName(): string;
  137598. /**
  137599. * Gets the world position input component
  137600. */
  137601. get worldPosition(): NodeMaterialConnectionPoint;
  137602. /**
  137603. * Gets the direction output component
  137604. */
  137605. get direction(): NodeMaterialConnectionPoint;
  137606. /**
  137607. * Gets the direction output component
  137608. */
  137609. get color(): NodeMaterialConnectionPoint;
  137610. /**
  137611. * Gets the direction output component
  137612. */
  137613. get intensity(): NodeMaterialConnectionPoint;
  137614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137616. protected _buildBlock(state: NodeMaterialBuildState): this;
  137617. serialize(): any;
  137618. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137619. }
  137620. }
  137621. declare module BABYLON {
  137622. /**
  137623. * Block used to add image processing support to fragment shader
  137624. */
  137625. export class ImageProcessingBlock extends NodeMaterialBlock {
  137626. /**
  137627. * Create a new ImageProcessingBlock
  137628. * @param name defines the block name
  137629. */
  137630. constructor(name: string);
  137631. /**
  137632. * Gets the current class name
  137633. * @returns the class name
  137634. */
  137635. getClassName(): string;
  137636. /**
  137637. * Gets the color input component
  137638. */
  137639. get color(): NodeMaterialConnectionPoint;
  137640. /**
  137641. * Gets the output component
  137642. */
  137643. get output(): NodeMaterialConnectionPoint;
  137644. /**
  137645. * Initialize the block and prepare the context for build
  137646. * @param state defines the state that will be used for the build
  137647. */
  137648. initialize(state: NodeMaterialBuildState): void;
  137649. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  137650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137651. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137652. protected _buildBlock(state: NodeMaterialBuildState): this;
  137653. }
  137654. }
  137655. declare module BABYLON {
  137656. /**
  137657. * Block used to pertub normals based on a normal map
  137658. */
  137659. export class PerturbNormalBlock extends NodeMaterialBlock {
  137660. private _tangentSpaceParameterName;
  137661. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  137662. invertX: boolean;
  137663. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  137664. invertY: boolean;
  137665. /**
  137666. * Create a new PerturbNormalBlock
  137667. * @param name defines the block name
  137668. */
  137669. constructor(name: string);
  137670. /**
  137671. * Gets the current class name
  137672. * @returns the class name
  137673. */
  137674. getClassName(): string;
  137675. /**
  137676. * Gets the world position input component
  137677. */
  137678. get worldPosition(): NodeMaterialConnectionPoint;
  137679. /**
  137680. * Gets the world normal input component
  137681. */
  137682. get worldNormal(): NodeMaterialConnectionPoint;
  137683. /**
  137684. * Gets the world tangent input component
  137685. */
  137686. get worldTangent(): NodeMaterialConnectionPoint;
  137687. /**
  137688. * Gets the uv input component
  137689. */
  137690. get uv(): NodeMaterialConnectionPoint;
  137691. /**
  137692. * Gets the normal map color input component
  137693. */
  137694. get normalMapColor(): NodeMaterialConnectionPoint;
  137695. /**
  137696. * Gets the strength input component
  137697. */
  137698. get strength(): NodeMaterialConnectionPoint;
  137699. /**
  137700. * Gets the output component
  137701. */
  137702. get output(): NodeMaterialConnectionPoint;
  137703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137705. autoConfigure(material: NodeMaterial): void;
  137706. protected _buildBlock(state: NodeMaterialBuildState): this;
  137707. protected _dumpPropertiesCode(): string;
  137708. serialize(): any;
  137709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137710. }
  137711. }
  137712. declare module BABYLON {
  137713. /**
  137714. * Block used to discard a pixel if a value is smaller than a cutoff
  137715. */
  137716. export class DiscardBlock extends NodeMaterialBlock {
  137717. /**
  137718. * Create a new DiscardBlock
  137719. * @param name defines the block name
  137720. */
  137721. constructor(name: string);
  137722. /**
  137723. * Gets the current class name
  137724. * @returns the class name
  137725. */
  137726. getClassName(): string;
  137727. /**
  137728. * Gets the color input component
  137729. */
  137730. get value(): NodeMaterialConnectionPoint;
  137731. /**
  137732. * Gets the cutoff input component
  137733. */
  137734. get cutoff(): NodeMaterialConnectionPoint;
  137735. protected _buildBlock(state: NodeMaterialBuildState): this;
  137736. }
  137737. }
  137738. declare module BABYLON {
  137739. /**
  137740. * Block used to test if the fragment shader is front facing
  137741. */
  137742. export class FrontFacingBlock extends NodeMaterialBlock {
  137743. /**
  137744. * Creates a new FrontFacingBlock
  137745. * @param name defines the block name
  137746. */
  137747. constructor(name: string);
  137748. /**
  137749. * Gets the current class name
  137750. * @returns the class name
  137751. */
  137752. getClassName(): string;
  137753. /**
  137754. * Gets the output component
  137755. */
  137756. get output(): NodeMaterialConnectionPoint;
  137757. protected _buildBlock(state: NodeMaterialBuildState): this;
  137758. }
  137759. }
  137760. declare module BABYLON {
  137761. /**
  137762. * Block used to get the derivative value on x and y of a given input
  137763. */
  137764. export class DerivativeBlock extends NodeMaterialBlock {
  137765. /**
  137766. * Create a new DerivativeBlock
  137767. * @param name defines the block name
  137768. */
  137769. constructor(name: string);
  137770. /**
  137771. * Gets the current class name
  137772. * @returns the class name
  137773. */
  137774. getClassName(): string;
  137775. /**
  137776. * Gets the input component
  137777. */
  137778. get input(): NodeMaterialConnectionPoint;
  137779. /**
  137780. * Gets the derivative output on x
  137781. */
  137782. get dx(): NodeMaterialConnectionPoint;
  137783. /**
  137784. * Gets the derivative output on y
  137785. */
  137786. get dy(): NodeMaterialConnectionPoint;
  137787. protected _buildBlock(state: NodeMaterialBuildState): this;
  137788. }
  137789. }
  137790. declare module BABYLON {
  137791. /**
  137792. * Block used to add support for scene fog
  137793. */
  137794. export class FogBlock extends NodeMaterialBlock {
  137795. private _fogDistanceName;
  137796. private _fogParameters;
  137797. /**
  137798. * Create a new FogBlock
  137799. * @param name defines the block name
  137800. */
  137801. constructor(name: string);
  137802. /**
  137803. * Gets the current class name
  137804. * @returns the class name
  137805. */
  137806. getClassName(): string;
  137807. /**
  137808. * Gets the world position input component
  137809. */
  137810. get worldPosition(): NodeMaterialConnectionPoint;
  137811. /**
  137812. * Gets the view input component
  137813. */
  137814. get view(): NodeMaterialConnectionPoint;
  137815. /**
  137816. * Gets the color input component
  137817. */
  137818. get input(): NodeMaterialConnectionPoint;
  137819. /**
  137820. * Gets the fog color input component
  137821. */
  137822. get fogColor(): NodeMaterialConnectionPoint;
  137823. /**
  137824. * Gets the output component
  137825. */
  137826. get output(): NodeMaterialConnectionPoint;
  137827. autoConfigure(material: NodeMaterial): void;
  137828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137829. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137830. protected _buildBlock(state: NodeMaterialBuildState): this;
  137831. }
  137832. }
  137833. declare module BABYLON {
  137834. /**
  137835. * Block used to add light in the fragment shader
  137836. */
  137837. export class LightBlock extends NodeMaterialBlock {
  137838. private _lightId;
  137839. /**
  137840. * Gets or sets the light associated with this block
  137841. */
  137842. light: Nullable<Light>;
  137843. /**
  137844. * Create a new LightBlock
  137845. * @param name defines the block name
  137846. */
  137847. constructor(name: string);
  137848. /**
  137849. * Gets the current class name
  137850. * @returns the class name
  137851. */
  137852. getClassName(): string;
  137853. /**
  137854. * Gets the world position input component
  137855. */
  137856. get worldPosition(): NodeMaterialConnectionPoint;
  137857. /**
  137858. * Gets the world normal input component
  137859. */
  137860. get worldNormal(): NodeMaterialConnectionPoint;
  137861. /**
  137862. * Gets the camera (or eye) position component
  137863. */
  137864. get cameraPosition(): NodeMaterialConnectionPoint;
  137865. /**
  137866. * Gets the glossiness component
  137867. */
  137868. get glossiness(): NodeMaterialConnectionPoint;
  137869. /**
  137870. * Gets the glossinness power component
  137871. */
  137872. get glossPower(): NodeMaterialConnectionPoint;
  137873. /**
  137874. * Gets the diffuse color component
  137875. */
  137876. get diffuseColor(): NodeMaterialConnectionPoint;
  137877. /**
  137878. * Gets the specular color component
  137879. */
  137880. get specularColor(): NodeMaterialConnectionPoint;
  137881. /**
  137882. * Gets the diffuse output component
  137883. */
  137884. get diffuseOutput(): NodeMaterialConnectionPoint;
  137885. /**
  137886. * Gets the specular output component
  137887. */
  137888. get specularOutput(): NodeMaterialConnectionPoint;
  137889. /**
  137890. * Gets the shadow output component
  137891. */
  137892. get shadow(): NodeMaterialConnectionPoint;
  137893. autoConfigure(material: NodeMaterial): void;
  137894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137895. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  137896. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137897. private _injectVertexCode;
  137898. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  137899. serialize(): any;
  137900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137901. }
  137902. }
  137903. declare module BABYLON {
  137904. /**
  137905. * Block used to read a reflection texture from a sampler
  137906. */
  137907. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  137908. /**
  137909. * Create a new ReflectionTextureBlock
  137910. * @param name defines the block name
  137911. */
  137912. constructor(name: string);
  137913. /**
  137914. * Gets the current class name
  137915. * @returns the class name
  137916. */
  137917. getClassName(): string;
  137918. /**
  137919. * Gets the world position input component
  137920. */
  137921. get position(): NodeMaterialConnectionPoint;
  137922. /**
  137923. * Gets the world position input component
  137924. */
  137925. get worldPosition(): NodeMaterialConnectionPoint;
  137926. /**
  137927. * Gets the world normal input component
  137928. */
  137929. get worldNormal(): NodeMaterialConnectionPoint;
  137930. /**
  137931. * Gets the world input component
  137932. */
  137933. get world(): NodeMaterialConnectionPoint;
  137934. /**
  137935. * Gets the camera (or eye) position component
  137936. */
  137937. get cameraPosition(): NodeMaterialConnectionPoint;
  137938. /**
  137939. * Gets the view input component
  137940. */
  137941. get view(): NodeMaterialConnectionPoint;
  137942. /**
  137943. * Gets the rgb output component
  137944. */
  137945. get rgb(): NodeMaterialConnectionPoint;
  137946. /**
  137947. * Gets the r output component
  137948. */
  137949. get r(): NodeMaterialConnectionPoint;
  137950. /**
  137951. * Gets the g output component
  137952. */
  137953. get g(): NodeMaterialConnectionPoint;
  137954. /**
  137955. * Gets the b output component
  137956. */
  137957. get b(): NodeMaterialConnectionPoint;
  137958. autoConfigure(material: NodeMaterial): void;
  137959. protected _buildBlock(state: NodeMaterialBuildState): this;
  137960. }
  137961. }
  137962. declare module BABYLON {
  137963. /**
  137964. * Block used to add 2 vectors
  137965. */
  137966. export class AddBlock extends NodeMaterialBlock {
  137967. /**
  137968. * Creates a new AddBlock
  137969. * @param name defines the block name
  137970. */
  137971. constructor(name: string);
  137972. /**
  137973. * Gets the current class name
  137974. * @returns the class name
  137975. */
  137976. getClassName(): string;
  137977. /**
  137978. * Gets the left operand input component
  137979. */
  137980. get left(): NodeMaterialConnectionPoint;
  137981. /**
  137982. * Gets the right operand input component
  137983. */
  137984. get right(): NodeMaterialConnectionPoint;
  137985. /**
  137986. * Gets the output component
  137987. */
  137988. get output(): NodeMaterialConnectionPoint;
  137989. protected _buildBlock(state: NodeMaterialBuildState): this;
  137990. }
  137991. }
  137992. declare module BABYLON {
  137993. /**
  137994. * Block used to scale a vector by a float
  137995. */
  137996. export class ScaleBlock extends NodeMaterialBlock {
  137997. /**
  137998. * Creates a new ScaleBlock
  137999. * @param name defines the block name
  138000. */
  138001. constructor(name: string);
  138002. /**
  138003. * Gets the current class name
  138004. * @returns the class name
  138005. */
  138006. getClassName(): string;
  138007. /**
  138008. * Gets the input component
  138009. */
  138010. get input(): NodeMaterialConnectionPoint;
  138011. /**
  138012. * Gets the factor input component
  138013. */
  138014. get factor(): NodeMaterialConnectionPoint;
  138015. /**
  138016. * Gets the output component
  138017. */
  138018. get output(): NodeMaterialConnectionPoint;
  138019. protected _buildBlock(state: NodeMaterialBuildState): this;
  138020. }
  138021. }
  138022. declare module BABYLON {
  138023. /**
  138024. * Block used to clamp a float
  138025. */
  138026. export class ClampBlock extends NodeMaterialBlock {
  138027. /** Gets or sets the minimum range */
  138028. minimum: number;
  138029. /** Gets or sets the maximum range */
  138030. maximum: number;
  138031. /**
  138032. * Creates a new ClampBlock
  138033. * @param name defines the block name
  138034. */
  138035. constructor(name: string);
  138036. /**
  138037. * Gets the current class name
  138038. * @returns the class name
  138039. */
  138040. getClassName(): string;
  138041. /**
  138042. * Gets the value input component
  138043. */
  138044. get value(): NodeMaterialConnectionPoint;
  138045. /**
  138046. * Gets the output component
  138047. */
  138048. get output(): NodeMaterialConnectionPoint;
  138049. protected _buildBlock(state: NodeMaterialBuildState): this;
  138050. protected _dumpPropertiesCode(): string;
  138051. serialize(): any;
  138052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138053. }
  138054. }
  138055. declare module BABYLON {
  138056. /**
  138057. * Block used to apply a cross product between 2 vectors
  138058. */
  138059. export class CrossBlock extends NodeMaterialBlock {
  138060. /**
  138061. * Creates a new CrossBlock
  138062. * @param name defines the block name
  138063. */
  138064. constructor(name: string);
  138065. /**
  138066. * Gets the current class name
  138067. * @returns the class name
  138068. */
  138069. getClassName(): string;
  138070. /**
  138071. * Gets the left operand input component
  138072. */
  138073. get left(): NodeMaterialConnectionPoint;
  138074. /**
  138075. * Gets the right operand input component
  138076. */
  138077. get right(): NodeMaterialConnectionPoint;
  138078. /**
  138079. * Gets the output component
  138080. */
  138081. get output(): NodeMaterialConnectionPoint;
  138082. protected _buildBlock(state: NodeMaterialBuildState): this;
  138083. }
  138084. }
  138085. declare module BABYLON {
  138086. /**
  138087. * Block used to apply a dot product between 2 vectors
  138088. */
  138089. export class DotBlock extends NodeMaterialBlock {
  138090. /**
  138091. * Creates a new DotBlock
  138092. * @param name defines the block name
  138093. */
  138094. constructor(name: string);
  138095. /**
  138096. * Gets the current class name
  138097. * @returns the class name
  138098. */
  138099. getClassName(): string;
  138100. /**
  138101. * Gets the left operand input component
  138102. */
  138103. get left(): NodeMaterialConnectionPoint;
  138104. /**
  138105. * Gets the right operand input component
  138106. */
  138107. get right(): NodeMaterialConnectionPoint;
  138108. /**
  138109. * Gets the output component
  138110. */
  138111. get output(): NodeMaterialConnectionPoint;
  138112. protected _buildBlock(state: NodeMaterialBuildState): this;
  138113. }
  138114. }
  138115. declare module BABYLON {
  138116. /**
  138117. * Block used to normalize a vector
  138118. */
  138119. export class NormalizeBlock extends NodeMaterialBlock {
  138120. /**
  138121. * Creates a new NormalizeBlock
  138122. * @param name defines the block name
  138123. */
  138124. constructor(name: string);
  138125. /**
  138126. * Gets the current class name
  138127. * @returns the class name
  138128. */
  138129. getClassName(): string;
  138130. /**
  138131. * Gets the input component
  138132. */
  138133. get input(): NodeMaterialConnectionPoint;
  138134. /**
  138135. * Gets the output component
  138136. */
  138137. get output(): NodeMaterialConnectionPoint;
  138138. protected _buildBlock(state: NodeMaterialBuildState): this;
  138139. }
  138140. }
  138141. declare module BABYLON {
  138142. /**
  138143. * Operations supported by the Trigonometry block
  138144. */
  138145. export enum TrigonometryBlockOperations {
  138146. /** Cos */
  138147. Cos = 0,
  138148. /** Sin */
  138149. Sin = 1,
  138150. /** Abs */
  138151. Abs = 2,
  138152. /** Exp */
  138153. Exp = 3,
  138154. /** Exp2 */
  138155. Exp2 = 4,
  138156. /** Round */
  138157. Round = 5,
  138158. /** Floor */
  138159. Floor = 6,
  138160. /** Ceiling */
  138161. Ceiling = 7,
  138162. /** Square root */
  138163. Sqrt = 8,
  138164. /** Log */
  138165. Log = 9,
  138166. /** Tangent */
  138167. Tan = 10,
  138168. /** Arc tangent */
  138169. ArcTan = 11,
  138170. /** Arc cosinus */
  138171. ArcCos = 12,
  138172. /** Arc sinus */
  138173. ArcSin = 13,
  138174. /** Fraction */
  138175. Fract = 14,
  138176. /** Sign */
  138177. Sign = 15,
  138178. /** To radians (from degrees) */
  138179. Radians = 16,
  138180. /** To degrees (from radians) */
  138181. Degrees = 17
  138182. }
  138183. /**
  138184. * Block used to apply trigonometry operation to floats
  138185. */
  138186. export class TrigonometryBlock extends NodeMaterialBlock {
  138187. /**
  138188. * Gets or sets the operation applied by the block
  138189. */
  138190. operation: TrigonometryBlockOperations;
  138191. /**
  138192. * Creates a new TrigonometryBlock
  138193. * @param name defines the block name
  138194. */
  138195. constructor(name: string);
  138196. /**
  138197. * Gets the current class name
  138198. * @returns the class name
  138199. */
  138200. getClassName(): string;
  138201. /**
  138202. * Gets the input component
  138203. */
  138204. get input(): NodeMaterialConnectionPoint;
  138205. /**
  138206. * Gets the output component
  138207. */
  138208. get output(): NodeMaterialConnectionPoint;
  138209. protected _buildBlock(state: NodeMaterialBuildState): this;
  138210. serialize(): any;
  138211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138212. protected _dumpPropertiesCode(): string;
  138213. }
  138214. }
  138215. declare module BABYLON {
  138216. /**
  138217. * Block used to create a Color3/4 out of individual inputs (one for each component)
  138218. */
  138219. export class ColorMergerBlock extends NodeMaterialBlock {
  138220. /**
  138221. * Create a new ColorMergerBlock
  138222. * @param name defines the block name
  138223. */
  138224. constructor(name: string);
  138225. /**
  138226. * Gets the current class name
  138227. * @returns the class name
  138228. */
  138229. getClassName(): string;
  138230. /**
  138231. * Gets the rgb component (input)
  138232. */
  138233. get rgbIn(): NodeMaterialConnectionPoint;
  138234. /**
  138235. * Gets the r component (input)
  138236. */
  138237. get r(): NodeMaterialConnectionPoint;
  138238. /**
  138239. * Gets the g component (input)
  138240. */
  138241. get g(): NodeMaterialConnectionPoint;
  138242. /**
  138243. * Gets the b component (input)
  138244. */
  138245. get b(): NodeMaterialConnectionPoint;
  138246. /**
  138247. * Gets the a component (input)
  138248. */
  138249. get a(): NodeMaterialConnectionPoint;
  138250. /**
  138251. * Gets the rgba component (output)
  138252. */
  138253. get rgba(): NodeMaterialConnectionPoint;
  138254. /**
  138255. * Gets the rgb component (output)
  138256. */
  138257. get rgbOut(): NodeMaterialConnectionPoint;
  138258. /**
  138259. * Gets the rgb component (output)
  138260. * @deprecated Please use rgbOut instead.
  138261. */
  138262. get rgb(): NodeMaterialConnectionPoint;
  138263. protected _buildBlock(state: NodeMaterialBuildState): this;
  138264. }
  138265. }
  138266. declare module BABYLON {
  138267. /**
  138268. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  138269. */
  138270. export class VectorSplitterBlock extends NodeMaterialBlock {
  138271. /**
  138272. * Create a new VectorSplitterBlock
  138273. * @param name defines the block name
  138274. */
  138275. constructor(name: string);
  138276. /**
  138277. * Gets the current class name
  138278. * @returns the class name
  138279. */
  138280. getClassName(): string;
  138281. /**
  138282. * Gets the xyzw component (input)
  138283. */
  138284. get xyzw(): NodeMaterialConnectionPoint;
  138285. /**
  138286. * Gets the xyz component (input)
  138287. */
  138288. get xyzIn(): NodeMaterialConnectionPoint;
  138289. /**
  138290. * Gets the xy component (input)
  138291. */
  138292. get xyIn(): NodeMaterialConnectionPoint;
  138293. /**
  138294. * Gets the xyz component (output)
  138295. */
  138296. get xyzOut(): NodeMaterialConnectionPoint;
  138297. /**
  138298. * Gets the xy component (output)
  138299. */
  138300. get xyOut(): NodeMaterialConnectionPoint;
  138301. /**
  138302. * Gets the x component (output)
  138303. */
  138304. get x(): NodeMaterialConnectionPoint;
  138305. /**
  138306. * Gets the y component (output)
  138307. */
  138308. get y(): NodeMaterialConnectionPoint;
  138309. /**
  138310. * Gets the z component (output)
  138311. */
  138312. get z(): NodeMaterialConnectionPoint;
  138313. /**
  138314. * Gets the w component (output)
  138315. */
  138316. get w(): NodeMaterialConnectionPoint;
  138317. protected _inputRename(name: string): string;
  138318. protected _outputRename(name: string): string;
  138319. protected _buildBlock(state: NodeMaterialBuildState): this;
  138320. }
  138321. }
  138322. declare module BABYLON {
  138323. /**
  138324. * Block used to lerp between 2 values
  138325. */
  138326. export class LerpBlock extends NodeMaterialBlock {
  138327. /**
  138328. * Creates a new LerpBlock
  138329. * @param name defines the block name
  138330. */
  138331. constructor(name: string);
  138332. /**
  138333. * Gets the current class name
  138334. * @returns the class name
  138335. */
  138336. getClassName(): string;
  138337. /**
  138338. * Gets the left operand input component
  138339. */
  138340. get left(): NodeMaterialConnectionPoint;
  138341. /**
  138342. * Gets the right operand input component
  138343. */
  138344. get right(): NodeMaterialConnectionPoint;
  138345. /**
  138346. * Gets the gradient operand input component
  138347. */
  138348. get gradient(): NodeMaterialConnectionPoint;
  138349. /**
  138350. * Gets the output component
  138351. */
  138352. get output(): NodeMaterialConnectionPoint;
  138353. protected _buildBlock(state: NodeMaterialBuildState): this;
  138354. }
  138355. }
  138356. declare module BABYLON {
  138357. /**
  138358. * Block used to divide 2 vectors
  138359. */
  138360. export class DivideBlock extends NodeMaterialBlock {
  138361. /**
  138362. * Creates a new DivideBlock
  138363. * @param name defines the block name
  138364. */
  138365. constructor(name: string);
  138366. /**
  138367. * Gets the current class name
  138368. * @returns the class name
  138369. */
  138370. getClassName(): string;
  138371. /**
  138372. * Gets the left operand input component
  138373. */
  138374. get left(): NodeMaterialConnectionPoint;
  138375. /**
  138376. * Gets the right operand input component
  138377. */
  138378. get right(): NodeMaterialConnectionPoint;
  138379. /**
  138380. * Gets the output component
  138381. */
  138382. get output(): NodeMaterialConnectionPoint;
  138383. protected _buildBlock(state: NodeMaterialBuildState): this;
  138384. }
  138385. }
  138386. declare module BABYLON {
  138387. /**
  138388. * Block used to subtract 2 vectors
  138389. */
  138390. export class SubtractBlock extends NodeMaterialBlock {
  138391. /**
  138392. * Creates a new SubtractBlock
  138393. * @param name defines the block name
  138394. */
  138395. constructor(name: string);
  138396. /**
  138397. * Gets the current class name
  138398. * @returns the class name
  138399. */
  138400. getClassName(): string;
  138401. /**
  138402. * Gets the left operand input component
  138403. */
  138404. get left(): NodeMaterialConnectionPoint;
  138405. /**
  138406. * Gets the right operand input component
  138407. */
  138408. get right(): NodeMaterialConnectionPoint;
  138409. /**
  138410. * Gets the output component
  138411. */
  138412. get output(): NodeMaterialConnectionPoint;
  138413. protected _buildBlock(state: NodeMaterialBuildState): this;
  138414. }
  138415. }
  138416. declare module BABYLON {
  138417. /**
  138418. * Block used to step a value
  138419. */
  138420. export class StepBlock extends NodeMaterialBlock {
  138421. /**
  138422. * Creates a new StepBlock
  138423. * @param name defines the block name
  138424. */
  138425. constructor(name: string);
  138426. /**
  138427. * Gets the current class name
  138428. * @returns the class name
  138429. */
  138430. getClassName(): string;
  138431. /**
  138432. * Gets the value operand input component
  138433. */
  138434. get value(): NodeMaterialConnectionPoint;
  138435. /**
  138436. * Gets the edge operand input component
  138437. */
  138438. get edge(): NodeMaterialConnectionPoint;
  138439. /**
  138440. * Gets the output component
  138441. */
  138442. get output(): NodeMaterialConnectionPoint;
  138443. protected _buildBlock(state: NodeMaterialBuildState): this;
  138444. }
  138445. }
  138446. declare module BABYLON {
  138447. /**
  138448. * Block used to get the opposite (1 - x) of a value
  138449. */
  138450. export class OneMinusBlock extends NodeMaterialBlock {
  138451. /**
  138452. * Creates a new OneMinusBlock
  138453. * @param name defines the block name
  138454. */
  138455. constructor(name: string);
  138456. /**
  138457. * Gets the current class name
  138458. * @returns the class name
  138459. */
  138460. getClassName(): string;
  138461. /**
  138462. * Gets the input component
  138463. */
  138464. get input(): NodeMaterialConnectionPoint;
  138465. /**
  138466. * Gets the output component
  138467. */
  138468. get output(): NodeMaterialConnectionPoint;
  138469. protected _buildBlock(state: NodeMaterialBuildState): this;
  138470. }
  138471. }
  138472. declare module BABYLON {
  138473. /**
  138474. * Block used to get the view direction
  138475. */
  138476. export class ViewDirectionBlock extends NodeMaterialBlock {
  138477. /**
  138478. * Creates a new ViewDirectionBlock
  138479. * @param name defines the block name
  138480. */
  138481. constructor(name: string);
  138482. /**
  138483. * Gets the current class name
  138484. * @returns the class name
  138485. */
  138486. getClassName(): string;
  138487. /**
  138488. * Gets the world position component
  138489. */
  138490. get worldPosition(): NodeMaterialConnectionPoint;
  138491. /**
  138492. * Gets the camera position component
  138493. */
  138494. get cameraPosition(): NodeMaterialConnectionPoint;
  138495. /**
  138496. * Gets the output component
  138497. */
  138498. get output(): NodeMaterialConnectionPoint;
  138499. autoConfigure(material: NodeMaterial): void;
  138500. protected _buildBlock(state: NodeMaterialBuildState): this;
  138501. }
  138502. }
  138503. declare module BABYLON {
  138504. /**
  138505. * Block used to compute fresnel value
  138506. */
  138507. export class FresnelBlock extends NodeMaterialBlock {
  138508. /**
  138509. * Create a new FresnelBlock
  138510. * @param name defines the block name
  138511. */
  138512. constructor(name: string);
  138513. /**
  138514. * Gets the current class name
  138515. * @returns the class name
  138516. */
  138517. getClassName(): string;
  138518. /**
  138519. * Gets the world normal input component
  138520. */
  138521. get worldNormal(): NodeMaterialConnectionPoint;
  138522. /**
  138523. * Gets the view direction input component
  138524. */
  138525. get viewDirection(): NodeMaterialConnectionPoint;
  138526. /**
  138527. * Gets the bias input component
  138528. */
  138529. get bias(): NodeMaterialConnectionPoint;
  138530. /**
  138531. * Gets the camera (or eye) position component
  138532. */
  138533. get power(): NodeMaterialConnectionPoint;
  138534. /**
  138535. * Gets the fresnel output component
  138536. */
  138537. get fresnel(): NodeMaterialConnectionPoint;
  138538. autoConfigure(material: NodeMaterial): void;
  138539. protected _buildBlock(state: NodeMaterialBuildState): this;
  138540. }
  138541. }
  138542. declare module BABYLON {
  138543. /**
  138544. * Block used to get the max of 2 values
  138545. */
  138546. export class MaxBlock extends NodeMaterialBlock {
  138547. /**
  138548. * Creates a new MaxBlock
  138549. * @param name defines the block name
  138550. */
  138551. constructor(name: string);
  138552. /**
  138553. * Gets the current class name
  138554. * @returns the class name
  138555. */
  138556. getClassName(): string;
  138557. /**
  138558. * Gets the left operand input component
  138559. */
  138560. get left(): NodeMaterialConnectionPoint;
  138561. /**
  138562. * Gets the right operand input component
  138563. */
  138564. get right(): NodeMaterialConnectionPoint;
  138565. /**
  138566. * Gets the output component
  138567. */
  138568. get output(): NodeMaterialConnectionPoint;
  138569. protected _buildBlock(state: NodeMaterialBuildState): this;
  138570. }
  138571. }
  138572. declare module BABYLON {
  138573. /**
  138574. * Block used to get the min of 2 values
  138575. */
  138576. export class MinBlock extends NodeMaterialBlock {
  138577. /**
  138578. * Creates a new MinBlock
  138579. * @param name defines the block name
  138580. */
  138581. constructor(name: string);
  138582. /**
  138583. * Gets the current class name
  138584. * @returns the class name
  138585. */
  138586. getClassName(): string;
  138587. /**
  138588. * Gets the left operand input component
  138589. */
  138590. get left(): NodeMaterialConnectionPoint;
  138591. /**
  138592. * Gets the right operand input component
  138593. */
  138594. get right(): NodeMaterialConnectionPoint;
  138595. /**
  138596. * Gets the output component
  138597. */
  138598. get output(): NodeMaterialConnectionPoint;
  138599. protected _buildBlock(state: NodeMaterialBuildState): this;
  138600. }
  138601. }
  138602. declare module BABYLON {
  138603. /**
  138604. * Block used to get the distance between 2 values
  138605. */
  138606. export class DistanceBlock extends NodeMaterialBlock {
  138607. /**
  138608. * Creates a new DistanceBlock
  138609. * @param name defines the block name
  138610. */
  138611. constructor(name: string);
  138612. /**
  138613. * Gets the current class name
  138614. * @returns the class name
  138615. */
  138616. getClassName(): string;
  138617. /**
  138618. * Gets the left operand input component
  138619. */
  138620. get left(): NodeMaterialConnectionPoint;
  138621. /**
  138622. * Gets the right operand input component
  138623. */
  138624. get right(): NodeMaterialConnectionPoint;
  138625. /**
  138626. * Gets the output component
  138627. */
  138628. get output(): NodeMaterialConnectionPoint;
  138629. protected _buildBlock(state: NodeMaterialBuildState): this;
  138630. }
  138631. }
  138632. declare module BABYLON {
  138633. /**
  138634. * Block used to get the length of a vector
  138635. */
  138636. export class LengthBlock extends NodeMaterialBlock {
  138637. /**
  138638. * Creates a new LengthBlock
  138639. * @param name defines the block name
  138640. */
  138641. constructor(name: string);
  138642. /**
  138643. * Gets the current class name
  138644. * @returns the class name
  138645. */
  138646. getClassName(): string;
  138647. /**
  138648. * Gets the value input component
  138649. */
  138650. get value(): NodeMaterialConnectionPoint;
  138651. /**
  138652. * Gets the output component
  138653. */
  138654. get output(): NodeMaterialConnectionPoint;
  138655. protected _buildBlock(state: NodeMaterialBuildState): this;
  138656. }
  138657. }
  138658. declare module BABYLON {
  138659. /**
  138660. * Block used to get negative version of a value (i.e. x * -1)
  138661. */
  138662. export class NegateBlock extends NodeMaterialBlock {
  138663. /**
  138664. * Creates a new NegateBlock
  138665. * @param name defines the block name
  138666. */
  138667. constructor(name: string);
  138668. /**
  138669. * Gets the current class name
  138670. * @returns the class name
  138671. */
  138672. getClassName(): string;
  138673. /**
  138674. * Gets the value input component
  138675. */
  138676. get value(): NodeMaterialConnectionPoint;
  138677. /**
  138678. * Gets the output component
  138679. */
  138680. get output(): NodeMaterialConnectionPoint;
  138681. protected _buildBlock(state: NodeMaterialBuildState): this;
  138682. }
  138683. }
  138684. declare module BABYLON {
  138685. /**
  138686. * Block used to get the value of the first parameter raised to the power of the second
  138687. */
  138688. export class PowBlock extends NodeMaterialBlock {
  138689. /**
  138690. * Creates a new PowBlock
  138691. * @param name defines the block name
  138692. */
  138693. constructor(name: string);
  138694. /**
  138695. * Gets the current class name
  138696. * @returns the class name
  138697. */
  138698. getClassName(): string;
  138699. /**
  138700. * Gets the value operand input component
  138701. */
  138702. get value(): NodeMaterialConnectionPoint;
  138703. /**
  138704. * Gets the power operand input component
  138705. */
  138706. get power(): NodeMaterialConnectionPoint;
  138707. /**
  138708. * Gets the output component
  138709. */
  138710. get output(): NodeMaterialConnectionPoint;
  138711. protected _buildBlock(state: NodeMaterialBuildState): this;
  138712. }
  138713. }
  138714. declare module BABYLON {
  138715. /**
  138716. * Block used to get a random number
  138717. */
  138718. export class RandomNumberBlock extends NodeMaterialBlock {
  138719. /**
  138720. * Creates a new RandomNumberBlock
  138721. * @param name defines the block name
  138722. */
  138723. constructor(name: string);
  138724. /**
  138725. * Gets the current class name
  138726. * @returns the class name
  138727. */
  138728. getClassName(): string;
  138729. /**
  138730. * Gets the seed input component
  138731. */
  138732. get seed(): NodeMaterialConnectionPoint;
  138733. /**
  138734. * Gets the output component
  138735. */
  138736. get output(): NodeMaterialConnectionPoint;
  138737. protected _buildBlock(state: NodeMaterialBuildState): this;
  138738. }
  138739. }
  138740. declare module BABYLON {
  138741. /**
  138742. * Block used to compute arc tangent of 2 values
  138743. */
  138744. export class ArcTan2Block extends NodeMaterialBlock {
  138745. /**
  138746. * Creates a new ArcTan2Block
  138747. * @param name defines the block name
  138748. */
  138749. constructor(name: string);
  138750. /**
  138751. * Gets the current class name
  138752. * @returns the class name
  138753. */
  138754. getClassName(): string;
  138755. /**
  138756. * Gets the x operand input component
  138757. */
  138758. get x(): NodeMaterialConnectionPoint;
  138759. /**
  138760. * Gets the y operand input component
  138761. */
  138762. get y(): NodeMaterialConnectionPoint;
  138763. /**
  138764. * Gets the output component
  138765. */
  138766. get output(): NodeMaterialConnectionPoint;
  138767. protected _buildBlock(state: NodeMaterialBuildState): this;
  138768. }
  138769. }
  138770. declare module BABYLON {
  138771. /**
  138772. * Block used to smooth step a value
  138773. */
  138774. export class SmoothStepBlock extends NodeMaterialBlock {
  138775. /**
  138776. * Creates a new SmoothStepBlock
  138777. * @param name defines the block name
  138778. */
  138779. constructor(name: string);
  138780. /**
  138781. * Gets the current class name
  138782. * @returns the class name
  138783. */
  138784. getClassName(): string;
  138785. /**
  138786. * Gets the value operand input component
  138787. */
  138788. get value(): NodeMaterialConnectionPoint;
  138789. /**
  138790. * Gets the first edge operand input component
  138791. */
  138792. get edge0(): NodeMaterialConnectionPoint;
  138793. /**
  138794. * Gets the second edge operand input component
  138795. */
  138796. get edge1(): NodeMaterialConnectionPoint;
  138797. /**
  138798. * Gets the output component
  138799. */
  138800. get output(): NodeMaterialConnectionPoint;
  138801. protected _buildBlock(state: NodeMaterialBuildState): this;
  138802. }
  138803. }
  138804. declare module BABYLON {
  138805. /**
  138806. * Block used to get the reciprocal (1 / x) of a value
  138807. */
  138808. export class ReciprocalBlock extends NodeMaterialBlock {
  138809. /**
  138810. * Creates a new ReciprocalBlock
  138811. * @param name defines the block name
  138812. */
  138813. constructor(name: string);
  138814. /**
  138815. * Gets the current class name
  138816. * @returns the class name
  138817. */
  138818. getClassName(): string;
  138819. /**
  138820. * Gets the input component
  138821. */
  138822. get input(): NodeMaterialConnectionPoint;
  138823. /**
  138824. * Gets the output component
  138825. */
  138826. get output(): NodeMaterialConnectionPoint;
  138827. protected _buildBlock(state: NodeMaterialBuildState): this;
  138828. }
  138829. }
  138830. declare module BABYLON {
  138831. /**
  138832. * Block used to replace a color by another one
  138833. */
  138834. export class ReplaceColorBlock extends NodeMaterialBlock {
  138835. /**
  138836. * Creates a new ReplaceColorBlock
  138837. * @param name defines the block name
  138838. */
  138839. constructor(name: string);
  138840. /**
  138841. * Gets the current class name
  138842. * @returns the class name
  138843. */
  138844. getClassName(): string;
  138845. /**
  138846. * Gets the value input component
  138847. */
  138848. get value(): NodeMaterialConnectionPoint;
  138849. /**
  138850. * Gets the reference input component
  138851. */
  138852. get reference(): NodeMaterialConnectionPoint;
  138853. /**
  138854. * Gets the distance input component
  138855. */
  138856. get distance(): NodeMaterialConnectionPoint;
  138857. /**
  138858. * Gets the replacement input component
  138859. */
  138860. get replacement(): NodeMaterialConnectionPoint;
  138861. /**
  138862. * Gets the output component
  138863. */
  138864. get output(): NodeMaterialConnectionPoint;
  138865. protected _buildBlock(state: NodeMaterialBuildState): this;
  138866. }
  138867. }
  138868. declare module BABYLON {
  138869. /**
  138870. * Block used to posterize a value
  138871. * @see https://en.wikipedia.org/wiki/Posterization
  138872. */
  138873. export class PosterizeBlock extends NodeMaterialBlock {
  138874. /**
  138875. * Creates a new PosterizeBlock
  138876. * @param name defines the block name
  138877. */
  138878. constructor(name: string);
  138879. /**
  138880. * Gets the current class name
  138881. * @returns the class name
  138882. */
  138883. getClassName(): string;
  138884. /**
  138885. * Gets the value input component
  138886. */
  138887. get value(): NodeMaterialConnectionPoint;
  138888. /**
  138889. * Gets the steps input component
  138890. */
  138891. get steps(): NodeMaterialConnectionPoint;
  138892. /**
  138893. * Gets the output component
  138894. */
  138895. get output(): NodeMaterialConnectionPoint;
  138896. protected _buildBlock(state: NodeMaterialBuildState): this;
  138897. }
  138898. }
  138899. declare module BABYLON {
  138900. /**
  138901. * Operations supported by the Wave block
  138902. */
  138903. export enum WaveBlockKind {
  138904. /** SawTooth */
  138905. SawTooth = 0,
  138906. /** Square */
  138907. Square = 1,
  138908. /** Triangle */
  138909. Triangle = 2
  138910. }
  138911. /**
  138912. * Block used to apply wave operation to floats
  138913. */
  138914. export class WaveBlock extends NodeMaterialBlock {
  138915. /**
  138916. * Gets or sets the kibnd of wave to be applied by the block
  138917. */
  138918. kind: WaveBlockKind;
  138919. /**
  138920. * Creates a new WaveBlock
  138921. * @param name defines the block name
  138922. */
  138923. constructor(name: string);
  138924. /**
  138925. * Gets the current class name
  138926. * @returns the class name
  138927. */
  138928. getClassName(): string;
  138929. /**
  138930. * Gets the input component
  138931. */
  138932. get input(): NodeMaterialConnectionPoint;
  138933. /**
  138934. * Gets the output component
  138935. */
  138936. get output(): NodeMaterialConnectionPoint;
  138937. protected _buildBlock(state: NodeMaterialBuildState): this;
  138938. serialize(): any;
  138939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138940. }
  138941. }
  138942. declare module BABYLON {
  138943. /**
  138944. * Class used to store a color step for the GradientBlock
  138945. */
  138946. export class GradientBlockColorStep {
  138947. /**
  138948. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  138949. */
  138950. step: number;
  138951. /**
  138952. * Gets or sets the color associated with this step
  138953. */
  138954. color: Color3;
  138955. /**
  138956. * Creates a new GradientBlockColorStep
  138957. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  138958. * @param color defines the color associated with this step
  138959. */
  138960. constructor(
  138961. /**
  138962. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  138963. */
  138964. step: number,
  138965. /**
  138966. * Gets or sets the color associated with this step
  138967. */
  138968. color: Color3);
  138969. }
  138970. /**
  138971. * Block used to return a color from a gradient based on an input value between 0 and 1
  138972. */
  138973. export class GradientBlock extends NodeMaterialBlock {
  138974. /**
  138975. * Gets or sets the list of color steps
  138976. */
  138977. colorSteps: GradientBlockColorStep[];
  138978. /**
  138979. * Creates a new GradientBlock
  138980. * @param name defines the block name
  138981. */
  138982. constructor(name: string);
  138983. /**
  138984. * Gets the current class name
  138985. * @returns the class name
  138986. */
  138987. getClassName(): string;
  138988. /**
  138989. * Gets the gradient input component
  138990. */
  138991. get gradient(): NodeMaterialConnectionPoint;
  138992. /**
  138993. * Gets the output component
  138994. */
  138995. get output(): NodeMaterialConnectionPoint;
  138996. private _writeColorConstant;
  138997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138998. serialize(): any;
  138999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139000. protected _dumpPropertiesCode(): string;
  139001. }
  139002. }
  139003. declare module BABYLON {
  139004. /**
  139005. * Block used to normalize lerp between 2 values
  139006. */
  139007. export class NLerpBlock extends NodeMaterialBlock {
  139008. /**
  139009. * Creates a new NLerpBlock
  139010. * @param name defines the block name
  139011. */
  139012. constructor(name: string);
  139013. /**
  139014. * Gets the current class name
  139015. * @returns the class name
  139016. */
  139017. getClassName(): string;
  139018. /**
  139019. * Gets the left operand input component
  139020. */
  139021. get left(): NodeMaterialConnectionPoint;
  139022. /**
  139023. * Gets the right operand input component
  139024. */
  139025. get right(): NodeMaterialConnectionPoint;
  139026. /**
  139027. * Gets the gradient operand input component
  139028. */
  139029. get gradient(): NodeMaterialConnectionPoint;
  139030. /**
  139031. * Gets the output component
  139032. */
  139033. get output(): NodeMaterialConnectionPoint;
  139034. protected _buildBlock(state: NodeMaterialBuildState): this;
  139035. }
  139036. }
  139037. declare module BABYLON {
  139038. /**
  139039. * block used to Generate a Worley Noise 3D Noise Pattern
  139040. */
  139041. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  139042. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139043. manhattanDistance: boolean;
  139044. /**
  139045. * Creates a new WorleyNoise3DBlock
  139046. * @param name defines the block name
  139047. */
  139048. constructor(name: string);
  139049. /**
  139050. * Gets the current class name
  139051. * @returns the class name
  139052. */
  139053. getClassName(): string;
  139054. /**
  139055. * Gets the seed input component
  139056. */
  139057. get seed(): NodeMaterialConnectionPoint;
  139058. /**
  139059. * Gets the jitter input component
  139060. */
  139061. get jitter(): NodeMaterialConnectionPoint;
  139062. /**
  139063. * Gets the output component
  139064. */
  139065. get output(): NodeMaterialConnectionPoint;
  139066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139067. /**
  139068. * Exposes the properties to the UI?
  139069. */
  139070. protected _dumpPropertiesCode(): string;
  139071. /**
  139072. * Exposes the properties to the Seralize?
  139073. */
  139074. serialize(): any;
  139075. /**
  139076. * Exposes the properties to the deseralize?
  139077. */
  139078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139079. }
  139080. }
  139081. declare module BABYLON {
  139082. /**
  139083. * block used to Generate a Simplex Perlin 3d Noise Pattern
  139084. */
  139085. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  139086. /**
  139087. * Creates a new SimplexPerlin3DBlock
  139088. * @param name defines the block name
  139089. */
  139090. constructor(name: string);
  139091. /**
  139092. * Gets the current class name
  139093. * @returns the class name
  139094. */
  139095. getClassName(): string;
  139096. /**
  139097. * Gets the seed operand input component
  139098. */
  139099. get seed(): NodeMaterialConnectionPoint;
  139100. /**
  139101. * Gets the output component
  139102. */
  139103. get output(): NodeMaterialConnectionPoint;
  139104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139105. }
  139106. }
  139107. declare module BABYLON {
  139108. /**
  139109. * Block used to blend normals
  139110. */
  139111. export class NormalBlendBlock extends NodeMaterialBlock {
  139112. /**
  139113. * Creates a new NormalBlendBlock
  139114. * @param name defines the block name
  139115. */
  139116. constructor(name: string);
  139117. /**
  139118. * Gets the current class name
  139119. * @returns the class name
  139120. */
  139121. getClassName(): string;
  139122. /**
  139123. * Gets the first input component
  139124. */
  139125. get normalMap0(): NodeMaterialConnectionPoint;
  139126. /**
  139127. * Gets the second input component
  139128. */
  139129. get normalMap1(): NodeMaterialConnectionPoint;
  139130. /**
  139131. * Gets the output component
  139132. */
  139133. get output(): NodeMaterialConnectionPoint;
  139134. protected _buildBlock(state: NodeMaterialBuildState): this;
  139135. }
  139136. }
  139137. declare module BABYLON {
  139138. /**
  139139. * Block used to rotate a 2d vector by a given angle
  139140. */
  139141. export class Rotate2dBlock extends NodeMaterialBlock {
  139142. /**
  139143. * Creates a new Rotate2dBlock
  139144. * @param name defines the block name
  139145. */
  139146. constructor(name: string);
  139147. /**
  139148. * Gets the current class name
  139149. * @returns the class name
  139150. */
  139151. getClassName(): string;
  139152. /**
  139153. * Gets the input vector
  139154. */
  139155. get input(): NodeMaterialConnectionPoint;
  139156. /**
  139157. * Gets the input angle
  139158. */
  139159. get angle(): NodeMaterialConnectionPoint;
  139160. /**
  139161. * Gets the output component
  139162. */
  139163. get output(): NodeMaterialConnectionPoint;
  139164. autoConfigure(material: NodeMaterial): void;
  139165. protected _buildBlock(state: NodeMaterialBuildState): this;
  139166. }
  139167. }
  139168. declare module BABYLON {
  139169. /**
  139170. * Block used to get the reflected vector from a direction and a normal
  139171. */
  139172. export class ReflectBlock extends NodeMaterialBlock {
  139173. /**
  139174. * Creates a new ReflectBlock
  139175. * @param name defines the block name
  139176. */
  139177. constructor(name: string);
  139178. /**
  139179. * Gets the current class name
  139180. * @returns the class name
  139181. */
  139182. getClassName(): string;
  139183. /**
  139184. * Gets the incident component
  139185. */
  139186. get incident(): NodeMaterialConnectionPoint;
  139187. /**
  139188. * Gets the normal component
  139189. */
  139190. get normal(): NodeMaterialConnectionPoint;
  139191. /**
  139192. * Gets the output component
  139193. */
  139194. get output(): NodeMaterialConnectionPoint;
  139195. protected _buildBlock(state: NodeMaterialBuildState): this;
  139196. }
  139197. }
  139198. declare module BABYLON {
  139199. /**
  139200. * Block used to get the refracted vector from a direction and a normal
  139201. */
  139202. export class RefractBlock extends NodeMaterialBlock {
  139203. /**
  139204. * Creates a new RefractBlock
  139205. * @param name defines the block name
  139206. */
  139207. constructor(name: string);
  139208. /**
  139209. * Gets the current class name
  139210. * @returns the class name
  139211. */
  139212. getClassName(): string;
  139213. /**
  139214. * Gets the incident component
  139215. */
  139216. get incident(): NodeMaterialConnectionPoint;
  139217. /**
  139218. * Gets the normal component
  139219. */
  139220. get normal(): NodeMaterialConnectionPoint;
  139221. /**
  139222. * Gets the index of refraction component
  139223. */
  139224. get ior(): NodeMaterialConnectionPoint;
  139225. /**
  139226. * Gets the output component
  139227. */
  139228. get output(): NodeMaterialConnectionPoint;
  139229. protected _buildBlock(state: NodeMaterialBuildState): this;
  139230. }
  139231. }
  139232. declare module BABYLON {
  139233. /**
  139234. * Block used to desaturate a color
  139235. */
  139236. export class DesaturateBlock extends NodeMaterialBlock {
  139237. /**
  139238. * Creates a new DesaturateBlock
  139239. * @param name defines the block name
  139240. */
  139241. constructor(name: string);
  139242. /**
  139243. * Gets the current class name
  139244. * @returns the class name
  139245. */
  139246. getClassName(): string;
  139247. /**
  139248. * Gets the color operand input component
  139249. */
  139250. get color(): NodeMaterialConnectionPoint;
  139251. /**
  139252. * Gets the level operand input component
  139253. */
  139254. get level(): NodeMaterialConnectionPoint;
  139255. /**
  139256. * Gets the output component
  139257. */
  139258. get output(): NodeMaterialConnectionPoint;
  139259. protected _buildBlock(state: NodeMaterialBuildState): this;
  139260. }
  139261. }
  139262. declare module BABYLON {
  139263. /**
  139264. * Block used to implement the ambient occlusion module of the PBR material
  139265. */
  139266. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  139267. /**
  139268. * Create a new AmbientOcclusionBlock
  139269. * @param name defines the block name
  139270. */
  139271. constructor(name: string);
  139272. /**
  139273. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  139274. */
  139275. useAmbientInGrayScale: boolean;
  139276. /**
  139277. * Initialize the block and prepare the context for build
  139278. * @param state defines the state that will be used for the build
  139279. */
  139280. initialize(state: NodeMaterialBuildState): void;
  139281. /**
  139282. * Gets the current class name
  139283. * @returns the class name
  139284. */
  139285. getClassName(): string;
  139286. /**
  139287. * Gets the texture input component
  139288. */
  139289. get texture(): NodeMaterialConnectionPoint;
  139290. /**
  139291. * Gets the texture intensity component
  139292. */
  139293. get intensity(): NodeMaterialConnectionPoint;
  139294. /**
  139295. * Gets the direct light intensity input component
  139296. */
  139297. get directLightIntensity(): NodeMaterialConnectionPoint;
  139298. /**
  139299. * Gets the ambient occlusion object output component
  139300. */
  139301. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139302. /**
  139303. * Gets the main code of the block (fragment side)
  139304. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  139305. * @returns the shader code
  139306. */
  139307. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  139308. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139309. protected _buildBlock(state: NodeMaterialBuildState): this;
  139310. protected _dumpPropertiesCode(): string;
  139311. serialize(): any;
  139312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139313. }
  139314. }
  139315. declare module BABYLON {
  139316. /**
  139317. * Block used to implement the reflection module of the PBR material
  139318. */
  139319. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  139320. /** @hidden */
  139321. _defineLODReflectionAlpha: string;
  139322. /** @hidden */
  139323. _defineLinearSpecularReflection: string;
  139324. private _vEnvironmentIrradianceName;
  139325. /** @hidden */
  139326. _vReflectionMicrosurfaceInfosName: string;
  139327. /** @hidden */
  139328. _vReflectionInfosName: string;
  139329. private _scene;
  139330. /**
  139331. * The three properties below are set by the main PBR block prior to calling methods of this class.
  139332. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139333. * It's less burden on the user side in the editor part.
  139334. */
  139335. /** @hidden */
  139336. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139337. /** @hidden */
  139338. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139339. /** @hidden */
  139340. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  139341. /**
  139342. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  139343. * diffuse part of the IBL.
  139344. */
  139345. useSphericalHarmonics: boolean;
  139346. /**
  139347. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  139348. */
  139349. forceIrradianceInFragment: boolean;
  139350. /**
  139351. * Create a new ReflectionBlock
  139352. * @param name defines the block name
  139353. */
  139354. constructor(name: string);
  139355. /**
  139356. * Gets the current class name
  139357. * @returns the class name
  139358. */
  139359. getClassName(): string;
  139360. /**
  139361. * Gets the position input component
  139362. */
  139363. get position(): NodeMaterialConnectionPoint;
  139364. /**
  139365. * Gets the world position input component
  139366. */
  139367. get worldPosition(): NodeMaterialConnectionPoint;
  139368. /**
  139369. * Gets the world normal input component
  139370. */
  139371. get worldNormal(): NodeMaterialConnectionPoint;
  139372. /**
  139373. * Gets the world input component
  139374. */
  139375. get world(): NodeMaterialConnectionPoint;
  139376. /**
  139377. * Gets the camera (or eye) position component
  139378. */
  139379. get cameraPosition(): NodeMaterialConnectionPoint;
  139380. /**
  139381. * Gets the view input component
  139382. */
  139383. get view(): NodeMaterialConnectionPoint;
  139384. /**
  139385. * Gets the color input component
  139386. */
  139387. get color(): NodeMaterialConnectionPoint;
  139388. /**
  139389. * Gets the reflection object output component
  139390. */
  139391. get reflection(): NodeMaterialConnectionPoint;
  139392. /**
  139393. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  139394. */
  139395. get hasTexture(): boolean;
  139396. /**
  139397. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  139398. */
  139399. get reflectionColor(): string;
  139400. protected _getTexture(): Nullable<BaseTexture>;
  139401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139403. /**
  139404. * Gets the code to inject in the vertex shader
  139405. * @param state current state of the node material building
  139406. * @returns the shader code
  139407. */
  139408. handleVertexSide(state: NodeMaterialBuildState): string;
  139409. /**
  139410. * Gets the main code of the block (fragment side)
  139411. * @param state current state of the node material building
  139412. * @param normalVarName name of the existing variable corresponding to the normal
  139413. * @returns the shader code
  139414. */
  139415. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  139416. protected _buildBlock(state: NodeMaterialBuildState): this;
  139417. protected _dumpPropertiesCode(): string;
  139418. serialize(): any;
  139419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139420. }
  139421. }
  139422. declare module BABYLON {
  139423. /**
  139424. * Block used to implement the sheen module of the PBR material
  139425. */
  139426. export class SheenBlock extends NodeMaterialBlock {
  139427. /**
  139428. * Create a new SheenBlock
  139429. * @param name defines the block name
  139430. */
  139431. constructor(name: string);
  139432. /**
  139433. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  139434. * It allows the strength of the sheen effect to not depend on the base color of the material,
  139435. * making it easier to setup and tweak the effect
  139436. */
  139437. albedoScaling: boolean;
  139438. /**
  139439. * Defines if the sheen is linked to the sheen color.
  139440. */
  139441. linkSheenWithAlbedo: boolean;
  139442. /**
  139443. * Initialize the block and prepare the context for build
  139444. * @param state defines the state that will be used for the build
  139445. */
  139446. initialize(state: NodeMaterialBuildState): void;
  139447. /**
  139448. * Gets the current class name
  139449. * @returns the class name
  139450. */
  139451. getClassName(): string;
  139452. /**
  139453. * Gets the intensity input component
  139454. */
  139455. get intensity(): NodeMaterialConnectionPoint;
  139456. /**
  139457. * Gets the color input component
  139458. */
  139459. get color(): NodeMaterialConnectionPoint;
  139460. /**
  139461. * Gets the roughness input component
  139462. */
  139463. get roughness(): NodeMaterialConnectionPoint;
  139464. /**
  139465. * Gets the texture input component
  139466. */
  139467. get texture(): NodeMaterialConnectionPoint;
  139468. /**
  139469. * Gets the sheen object output component
  139470. */
  139471. get sheen(): NodeMaterialConnectionPoint;
  139472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139473. /**
  139474. * Gets the main code of the block (fragment side)
  139475. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139476. * @returns the shader code
  139477. */
  139478. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  139479. protected _buildBlock(state: NodeMaterialBuildState): this;
  139480. protected _dumpPropertiesCode(): string;
  139481. serialize(): any;
  139482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139483. }
  139484. }
  139485. declare module BABYLON {
  139486. /**
  139487. * Block used to implement the reflectivity module of the PBR material
  139488. */
  139489. export class ReflectivityBlock extends NodeMaterialBlock {
  139490. /**
  139491. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  139492. */
  139493. useAmbientOcclusionFromMetallicTextureRed: boolean;
  139494. /**
  139495. * Specifies if the metallic texture contains the metallness information in its blue channel.
  139496. */
  139497. useMetallnessFromMetallicTextureBlue: boolean;
  139498. /**
  139499. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  139500. */
  139501. useRoughnessFromMetallicTextureAlpha: boolean;
  139502. /**
  139503. * Specifies if the metallic texture contains the roughness information in its green channel.
  139504. */
  139505. useRoughnessFromMetallicTextureGreen: boolean;
  139506. /**
  139507. * Create a new ReflectivityBlock
  139508. * @param name defines the block name
  139509. */
  139510. constructor(name: string);
  139511. /**
  139512. * Initialize the block and prepare the context for build
  139513. * @param state defines the state that will be used for the build
  139514. */
  139515. initialize(state: NodeMaterialBuildState): void;
  139516. /**
  139517. * Gets the current class name
  139518. * @returns the class name
  139519. */
  139520. getClassName(): string;
  139521. /**
  139522. * Gets the metallic input component
  139523. */
  139524. get metallic(): NodeMaterialConnectionPoint;
  139525. /**
  139526. * Gets the roughness input component
  139527. */
  139528. get roughness(): NodeMaterialConnectionPoint;
  139529. /**
  139530. * Gets the texture input component
  139531. */
  139532. get texture(): NodeMaterialConnectionPoint;
  139533. /**
  139534. * Gets the reflectivity object output component
  139535. */
  139536. get reflectivity(): NodeMaterialConnectionPoint;
  139537. /**
  139538. * Gets the main code of the block (fragment side)
  139539. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  139540. * @returns the shader code
  139541. */
  139542. getCode(aoIntensityVarName: string): string;
  139543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139544. protected _buildBlock(state: NodeMaterialBuildState): this;
  139545. protected _dumpPropertiesCode(): string;
  139546. serialize(): any;
  139547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139548. }
  139549. }
  139550. declare module BABYLON {
  139551. /**
  139552. * Block used to implement the anisotropy module of the PBR material
  139553. */
  139554. export class AnisotropyBlock extends NodeMaterialBlock {
  139555. /**
  139556. * The two properties below are set by the main PBR block prior to calling methods of this class.
  139557. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139558. * It's less burden on the user side in the editor part.
  139559. */
  139560. /** @hidden */
  139561. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139562. /** @hidden */
  139563. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139564. /**
  139565. * Create a new AnisotropyBlock
  139566. * @param name defines the block name
  139567. */
  139568. constructor(name: string);
  139569. /**
  139570. * Initialize the block and prepare the context for build
  139571. * @param state defines the state that will be used for the build
  139572. */
  139573. initialize(state: NodeMaterialBuildState): void;
  139574. /**
  139575. * Gets the current class name
  139576. * @returns the class name
  139577. */
  139578. getClassName(): string;
  139579. /**
  139580. * Gets the intensity input component
  139581. */
  139582. get intensity(): NodeMaterialConnectionPoint;
  139583. /**
  139584. * Gets the direction input component
  139585. */
  139586. get direction(): NodeMaterialConnectionPoint;
  139587. /**
  139588. * Gets the texture input component
  139589. */
  139590. get texture(): NodeMaterialConnectionPoint;
  139591. /**
  139592. * Gets the uv input component
  139593. */
  139594. get uv(): NodeMaterialConnectionPoint;
  139595. /**
  139596. * Gets the worldTangent input component
  139597. */
  139598. get worldTangent(): NodeMaterialConnectionPoint;
  139599. /**
  139600. * Gets the anisotropy object output component
  139601. */
  139602. get anisotropy(): NodeMaterialConnectionPoint;
  139603. private _generateTBNSpace;
  139604. /**
  139605. * Gets the main code of the block (fragment side)
  139606. * @param state current state of the node material building
  139607. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  139608. * @returns the shader code
  139609. */
  139610. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  139611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139612. protected _buildBlock(state: NodeMaterialBuildState): this;
  139613. }
  139614. }
  139615. declare module BABYLON {
  139616. /**
  139617. * Block used to implement the clear coat module of the PBR material
  139618. */
  139619. export class ClearCoatBlock extends NodeMaterialBlock {
  139620. private _scene;
  139621. /**
  139622. * Create a new ClearCoatBlock
  139623. * @param name defines the block name
  139624. */
  139625. constructor(name: string);
  139626. /**
  139627. * Initialize the block and prepare the context for build
  139628. * @param state defines the state that will be used for the build
  139629. */
  139630. initialize(state: NodeMaterialBuildState): void;
  139631. /**
  139632. * Gets the current class name
  139633. * @returns the class name
  139634. */
  139635. getClassName(): string;
  139636. /**
  139637. * Gets the intensity input component
  139638. */
  139639. get intensity(): NodeMaterialConnectionPoint;
  139640. /**
  139641. * Gets the roughness input component
  139642. */
  139643. get roughness(): NodeMaterialConnectionPoint;
  139644. /**
  139645. * Gets the ior input component
  139646. */
  139647. get ior(): NodeMaterialConnectionPoint;
  139648. /**
  139649. * Gets the texture input component
  139650. */
  139651. get texture(): NodeMaterialConnectionPoint;
  139652. /**
  139653. * Gets the bump texture input component
  139654. */
  139655. get bumpTexture(): NodeMaterialConnectionPoint;
  139656. /**
  139657. * Gets the uv input component
  139658. */
  139659. get uv(): NodeMaterialConnectionPoint;
  139660. /**
  139661. * Gets the tint color input component
  139662. */
  139663. get tintColor(): NodeMaterialConnectionPoint;
  139664. /**
  139665. * Gets the tint "at distance" input component
  139666. */
  139667. get tintAtDistance(): NodeMaterialConnectionPoint;
  139668. /**
  139669. * Gets the tint thickness input component
  139670. */
  139671. get tintThickness(): NodeMaterialConnectionPoint;
  139672. /**
  139673. * Gets the tint texture input component
  139674. */
  139675. get tintTexture(): NodeMaterialConnectionPoint;
  139676. /**
  139677. * Gets the world tangent input component
  139678. */
  139679. get worldTangent(): NodeMaterialConnectionPoint;
  139680. /**
  139681. * Gets the clear coat object output component
  139682. */
  139683. get clearcoat(): NodeMaterialConnectionPoint;
  139684. autoConfigure(material: NodeMaterial): void;
  139685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139687. private _generateTBNSpace;
  139688. /**
  139689. * Gets the main code of the block (fragment side)
  139690. * @param state current state of the node material building
  139691. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  139692. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139693. * @param worldPosVarName name of the variable holding the world position
  139694. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  139695. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  139696. * @param worldNormalVarName name of the variable holding the world normal
  139697. * @returns the shader code
  139698. */
  139699. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  139700. protected _buildBlock(state: NodeMaterialBuildState): this;
  139701. }
  139702. }
  139703. declare module BABYLON {
  139704. /**
  139705. * Block used to implement the sub surface module of the PBR material
  139706. */
  139707. export class SubSurfaceBlock extends NodeMaterialBlock {
  139708. /**
  139709. * Create a new SubSurfaceBlock
  139710. * @param name defines the block name
  139711. */
  139712. constructor(name: string);
  139713. /**
  139714. * Stores the intensity of the different subsurface effects in the thickness texture.
  139715. * * the green channel is the translucency intensity.
  139716. * * the blue channel is the scattering intensity.
  139717. * * the alpha channel is the refraction intensity.
  139718. */
  139719. useMaskFromThicknessTexture: boolean;
  139720. /**
  139721. * Initialize the block and prepare the context for build
  139722. * @param state defines the state that will be used for the build
  139723. */
  139724. initialize(state: NodeMaterialBuildState): void;
  139725. /**
  139726. * Gets the current class name
  139727. * @returns the class name
  139728. */
  139729. getClassName(): string;
  139730. /**
  139731. * Gets the min thickness input component
  139732. */
  139733. get minThickness(): NodeMaterialConnectionPoint;
  139734. /**
  139735. * Gets the max thickness input component
  139736. */
  139737. get maxThickness(): NodeMaterialConnectionPoint;
  139738. /**
  139739. * Gets the thickness texture component
  139740. */
  139741. get thicknessTexture(): NodeMaterialConnectionPoint;
  139742. /**
  139743. * Gets the tint color input component
  139744. */
  139745. get tintColor(): NodeMaterialConnectionPoint;
  139746. /**
  139747. * Gets the translucency intensity input component
  139748. */
  139749. get translucencyIntensity(): NodeMaterialConnectionPoint;
  139750. /**
  139751. * Gets the translucency diffusion distance input component
  139752. */
  139753. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  139754. /**
  139755. * Gets the refraction object parameters
  139756. */
  139757. get refraction(): NodeMaterialConnectionPoint;
  139758. /**
  139759. * Gets the sub surface object output component
  139760. */
  139761. get subsurface(): NodeMaterialConnectionPoint;
  139762. autoConfigure(material: NodeMaterial): void;
  139763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139764. /**
  139765. * Gets the main code of the block (fragment side)
  139766. * @param state current state of the node material building
  139767. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  139768. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139769. * @param worldPosVarName name of the variable holding the world position
  139770. * @returns the shader code
  139771. */
  139772. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  139773. protected _buildBlock(state: NodeMaterialBuildState): this;
  139774. }
  139775. }
  139776. declare module BABYLON {
  139777. /**
  139778. * Block used to implement the PBR metallic/roughness model
  139779. */
  139780. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  139781. /**
  139782. * Gets or sets the light associated with this block
  139783. */
  139784. light: Nullable<Light>;
  139785. private _lightId;
  139786. private _scene;
  139787. private _environmentBRDFTexture;
  139788. private _environmentBrdfSamplerName;
  139789. private _vNormalWName;
  139790. private _invertNormalName;
  139791. /**
  139792. * Create a new ReflectionBlock
  139793. * @param name defines the block name
  139794. */
  139795. constructor(name: string);
  139796. /**
  139797. * Intensity of the direct lights e.g. the four lights available in your scene.
  139798. * This impacts both the direct diffuse and specular highlights.
  139799. */
  139800. directIntensity: number;
  139801. /**
  139802. * Intensity of the environment e.g. how much the environment will light the object
  139803. * either through harmonics for rough material or through the refelction for shiny ones.
  139804. */
  139805. environmentIntensity: number;
  139806. /**
  139807. * This is a special control allowing the reduction of the specular highlights coming from the
  139808. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  139809. */
  139810. specularIntensity: number;
  139811. /**
  139812. * Defines the falloff type used in this material.
  139813. * It by default is Physical.
  139814. */
  139815. lightFalloff: number;
  139816. /**
  139817. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  139818. */
  139819. useAlphaFromAlbedoTexture: boolean;
  139820. /**
  139821. * Specifies that alpha test should be used
  139822. */
  139823. useAlphaTest: boolean;
  139824. /**
  139825. * Defines the alpha limits in alpha test mode.
  139826. */
  139827. alphaTestCutoff: number;
  139828. /**
  139829. * Specifies that alpha blending should be used
  139830. */
  139831. useAlphaBlending: boolean;
  139832. /**
  139833. * Defines if the alpha value should be determined via the rgb values.
  139834. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  139835. */
  139836. opacityRGB: boolean;
  139837. /**
  139838. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  139839. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  139840. */
  139841. useRadianceOverAlpha: boolean;
  139842. /**
  139843. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  139844. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  139845. */
  139846. useSpecularOverAlpha: boolean;
  139847. /**
  139848. * Enables specular anti aliasing in the PBR shader.
  139849. * It will both interacts on the Geometry for analytical and IBL lighting.
  139850. * It also prefilter the roughness map based on the bump values.
  139851. */
  139852. enableSpecularAntiAliasing: boolean;
  139853. /**
  139854. * Defines if the material uses energy conservation.
  139855. */
  139856. useEnergyConservation: boolean;
  139857. /**
  139858. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  139859. * too much the area relying on ambient texture to define their ambient occlusion.
  139860. */
  139861. useRadianceOcclusion: boolean;
  139862. /**
  139863. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  139864. * makes the reflect vector face the model (under horizon).
  139865. */
  139866. useHorizonOcclusion: boolean;
  139867. /**
  139868. * If set to true, no lighting calculations will be applied.
  139869. */
  139870. unlit: boolean;
  139871. /**
  139872. * Force normal to face away from face.
  139873. */
  139874. forceNormalForward: boolean;
  139875. /**
  139876. * Defines the material debug mode.
  139877. * It helps seeing only some components of the material while troubleshooting.
  139878. */
  139879. debugMode: number;
  139880. /**
  139881. * Specify from where on screen the debug mode should start.
  139882. * The value goes from -1 (full screen) to 1 (not visible)
  139883. * It helps with side by side comparison against the final render
  139884. * This defaults to 0
  139885. */
  139886. debugLimit: number;
  139887. /**
  139888. * As the default viewing range might not be enough (if the ambient is really small for instance)
  139889. * You can use the factor to better multiply the final value.
  139890. */
  139891. debugFactor: number;
  139892. /**
  139893. * Initialize the block and prepare the context for build
  139894. * @param state defines the state that will be used for the build
  139895. */
  139896. initialize(state: NodeMaterialBuildState): void;
  139897. /**
  139898. * Gets the current class name
  139899. * @returns the class name
  139900. */
  139901. getClassName(): string;
  139902. /**
  139903. * Gets the world position input component
  139904. */
  139905. get worldPosition(): NodeMaterialConnectionPoint;
  139906. /**
  139907. * Gets the world normal input component
  139908. */
  139909. get worldNormal(): NodeMaterialConnectionPoint;
  139910. /**
  139911. * Gets the perturbed normal input component
  139912. */
  139913. get perturbedNormal(): NodeMaterialConnectionPoint;
  139914. /**
  139915. * Gets the camera position input component
  139916. */
  139917. get cameraPosition(): NodeMaterialConnectionPoint;
  139918. /**
  139919. * Gets the base color input component
  139920. */
  139921. get baseColor(): NodeMaterialConnectionPoint;
  139922. /**
  139923. * Gets the base texture input component
  139924. */
  139925. get baseTexture(): NodeMaterialConnectionPoint;
  139926. /**
  139927. * Gets the opacity texture input component
  139928. */
  139929. get opacityTexture(): NodeMaterialConnectionPoint;
  139930. /**
  139931. * Gets the ambient color input component
  139932. */
  139933. get ambientColor(): NodeMaterialConnectionPoint;
  139934. /**
  139935. * Gets the reflectivity object parameters
  139936. */
  139937. get reflectivity(): NodeMaterialConnectionPoint;
  139938. /**
  139939. * Gets the ambient occlusion object parameters
  139940. */
  139941. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139942. /**
  139943. * Gets the reflection object parameters
  139944. */
  139945. get reflection(): NodeMaterialConnectionPoint;
  139946. /**
  139947. * Gets the sheen object parameters
  139948. */
  139949. get sheen(): NodeMaterialConnectionPoint;
  139950. /**
  139951. * Gets the clear coat object parameters
  139952. */
  139953. get clearcoat(): NodeMaterialConnectionPoint;
  139954. /**
  139955. * Gets the sub surface object parameters
  139956. */
  139957. get subsurface(): NodeMaterialConnectionPoint;
  139958. /**
  139959. * Gets the anisotropy object parameters
  139960. */
  139961. get anisotropy(): NodeMaterialConnectionPoint;
  139962. /**
  139963. * Gets the ambient output component
  139964. */
  139965. get ambient(): NodeMaterialConnectionPoint;
  139966. /**
  139967. * Gets the diffuse output component
  139968. */
  139969. get diffuse(): NodeMaterialConnectionPoint;
  139970. /**
  139971. * Gets the specular output component
  139972. */
  139973. get specular(): NodeMaterialConnectionPoint;
  139974. /**
  139975. * Gets the sheen output component
  139976. */
  139977. get sheenDir(): NodeMaterialConnectionPoint;
  139978. /**
  139979. * Gets the clear coat output component
  139980. */
  139981. get clearcoatDir(): NodeMaterialConnectionPoint;
  139982. /**
  139983. * Gets the indirect diffuse output component
  139984. */
  139985. get diffuseIndirect(): NodeMaterialConnectionPoint;
  139986. /**
  139987. * Gets the indirect specular output component
  139988. */
  139989. get specularIndirect(): NodeMaterialConnectionPoint;
  139990. /**
  139991. * Gets the indirect sheen output component
  139992. */
  139993. get sheenIndirect(): NodeMaterialConnectionPoint;
  139994. /**
  139995. * Gets the indirect clear coat output component
  139996. */
  139997. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  139998. /**
  139999. * Gets the refraction output component
  140000. */
  140001. get refraction(): NodeMaterialConnectionPoint;
  140002. /**
  140003. * Gets the global lighting output component
  140004. */
  140005. get lighting(): NodeMaterialConnectionPoint;
  140006. /**
  140007. * Gets the shadow output component
  140008. */
  140009. get shadow(): NodeMaterialConnectionPoint;
  140010. /**
  140011. * Gets the alpha output component
  140012. */
  140013. get alpha(): NodeMaterialConnectionPoint;
  140014. autoConfigure(material: NodeMaterial): void;
  140015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140016. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140018. private _injectVertexCode;
  140019. /**
  140020. * Gets the code corresponding to the albedo/opacity module
  140021. * @returns the shader code
  140022. */
  140023. getAlbedoOpacityCode(): string;
  140024. protected _buildBlock(state: NodeMaterialBuildState): this;
  140025. protected _dumpPropertiesCode(): string;
  140026. serialize(): any;
  140027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140028. }
  140029. }
  140030. declare module BABYLON {
  140031. /**
  140032. * Block used to compute value of one parameter modulo another
  140033. */
  140034. export class ModBlock extends NodeMaterialBlock {
  140035. /**
  140036. * Creates a new ModBlock
  140037. * @param name defines the block name
  140038. */
  140039. constructor(name: string);
  140040. /**
  140041. * Gets the current class name
  140042. * @returns the class name
  140043. */
  140044. getClassName(): string;
  140045. /**
  140046. * Gets the left operand input component
  140047. */
  140048. get left(): NodeMaterialConnectionPoint;
  140049. /**
  140050. * Gets the right operand input component
  140051. */
  140052. get right(): NodeMaterialConnectionPoint;
  140053. /**
  140054. * Gets the output component
  140055. */
  140056. get output(): NodeMaterialConnectionPoint;
  140057. protected _buildBlock(state: NodeMaterialBuildState): this;
  140058. }
  140059. }
  140060. declare module BABYLON {
  140061. /**
  140062. * Helper class to push actions to a pool of workers.
  140063. */
  140064. export class WorkerPool implements IDisposable {
  140065. private _workerInfos;
  140066. private _pendingActions;
  140067. /**
  140068. * Constructor
  140069. * @param workers Array of workers to use for actions
  140070. */
  140071. constructor(workers: Array<Worker>);
  140072. /**
  140073. * Terminates all workers and clears any pending actions.
  140074. */
  140075. dispose(): void;
  140076. /**
  140077. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140078. * pended until a worker has completed its action.
  140079. * @param action The action to perform. Call onComplete when the action is complete.
  140080. */
  140081. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140082. private _execute;
  140083. }
  140084. }
  140085. declare module BABYLON {
  140086. /**
  140087. * Configuration for Draco compression
  140088. */
  140089. export interface IDracoCompressionConfiguration {
  140090. /**
  140091. * Configuration for the decoder.
  140092. */
  140093. decoder: {
  140094. /**
  140095. * The url to the WebAssembly module.
  140096. */
  140097. wasmUrl?: string;
  140098. /**
  140099. * The url to the WebAssembly binary.
  140100. */
  140101. wasmBinaryUrl?: string;
  140102. /**
  140103. * The url to the fallback JavaScript module.
  140104. */
  140105. fallbackUrl?: string;
  140106. };
  140107. }
  140108. /**
  140109. * Draco compression (https://google.github.io/draco/)
  140110. *
  140111. * This class wraps the Draco module.
  140112. *
  140113. * **Encoder**
  140114. *
  140115. * The encoder is not currently implemented.
  140116. *
  140117. * **Decoder**
  140118. *
  140119. * 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.
  140120. *
  140121. * To update the configuration, use the following code:
  140122. * ```javascript
  140123. * DracoCompression.Configuration = {
  140124. * decoder: {
  140125. * wasmUrl: "<url to the WebAssembly library>",
  140126. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  140127. * fallbackUrl: "<url to the fallback JavaScript library>",
  140128. * }
  140129. * };
  140130. * ```
  140131. *
  140132. * 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.
  140133. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  140134. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  140135. *
  140136. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  140137. * ```javascript
  140138. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  140139. * ```
  140140. *
  140141. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  140142. */
  140143. export class DracoCompression implements IDisposable {
  140144. private _workerPoolPromise?;
  140145. private _decoderModulePromise?;
  140146. /**
  140147. * The configuration. Defaults to the following urls:
  140148. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  140149. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  140150. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  140151. */
  140152. static Configuration: IDracoCompressionConfiguration;
  140153. /**
  140154. * Returns true if the decoder configuration is available.
  140155. */
  140156. static get DecoderAvailable(): boolean;
  140157. /**
  140158. * Default number of workers to create when creating the draco compression object.
  140159. */
  140160. static DefaultNumWorkers: number;
  140161. private static GetDefaultNumWorkers;
  140162. private static _Default;
  140163. /**
  140164. * Default instance for the draco compression object.
  140165. */
  140166. static get Default(): DracoCompression;
  140167. /**
  140168. * Constructor
  140169. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140170. */
  140171. constructor(numWorkers?: number);
  140172. /**
  140173. * Stop all async operations and release resources.
  140174. */
  140175. dispose(): void;
  140176. /**
  140177. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  140178. * @returns a promise that resolves when ready
  140179. */
  140180. whenReadyAsync(): Promise<void>;
  140181. /**
  140182. * Decode Draco compressed mesh data to vertex data.
  140183. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  140184. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  140185. * @returns A promise that resolves with the decoded vertex data
  140186. */
  140187. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  140188. [kind: string]: number;
  140189. }): Promise<VertexData>;
  140190. }
  140191. }
  140192. declare module BABYLON {
  140193. /**
  140194. * Class for building Constructive Solid Geometry
  140195. */
  140196. export class CSG {
  140197. private polygons;
  140198. /**
  140199. * The world matrix
  140200. */
  140201. matrix: Matrix;
  140202. /**
  140203. * Stores the position
  140204. */
  140205. position: Vector3;
  140206. /**
  140207. * Stores the rotation
  140208. */
  140209. rotation: Vector3;
  140210. /**
  140211. * Stores the rotation quaternion
  140212. */
  140213. rotationQuaternion: Nullable<Quaternion>;
  140214. /**
  140215. * Stores the scaling vector
  140216. */
  140217. scaling: Vector3;
  140218. /**
  140219. * Convert the Mesh to CSG
  140220. * @param mesh The Mesh to convert to CSG
  140221. * @returns A new CSG from the Mesh
  140222. */
  140223. static FromMesh(mesh: Mesh): CSG;
  140224. /**
  140225. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  140226. * @param polygons Polygons used to construct a CSG solid
  140227. */
  140228. private static FromPolygons;
  140229. /**
  140230. * Clones, or makes a deep copy, of the CSG
  140231. * @returns A new CSG
  140232. */
  140233. clone(): CSG;
  140234. /**
  140235. * Unions this CSG with another CSG
  140236. * @param csg The CSG to union against this CSG
  140237. * @returns The unioned CSG
  140238. */
  140239. union(csg: CSG): CSG;
  140240. /**
  140241. * Unions this CSG with another CSG in place
  140242. * @param csg The CSG to union against this CSG
  140243. */
  140244. unionInPlace(csg: CSG): void;
  140245. /**
  140246. * Subtracts this CSG with another CSG
  140247. * @param csg The CSG to subtract against this CSG
  140248. * @returns A new CSG
  140249. */
  140250. subtract(csg: CSG): CSG;
  140251. /**
  140252. * Subtracts this CSG with another CSG in place
  140253. * @param csg The CSG to subtact against this CSG
  140254. */
  140255. subtractInPlace(csg: CSG): void;
  140256. /**
  140257. * Intersect this CSG with another CSG
  140258. * @param csg The CSG to intersect against this CSG
  140259. * @returns A new CSG
  140260. */
  140261. intersect(csg: CSG): CSG;
  140262. /**
  140263. * Intersects this CSG with another CSG in place
  140264. * @param csg The CSG to intersect against this CSG
  140265. */
  140266. intersectInPlace(csg: CSG): void;
  140267. /**
  140268. * Return a new CSG solid with solid and empty space switched. This solid is
  140269. * not modified.
  140270. * @returns A new CSG solid with solid and empty space switched
  140271. */
  140272. inverse(): CSG;
  140273. /**
  140274. * Inverses the CSG in place
  140275. */
  140276. inverseInPlace(): void;
  140277. /**
  140278. * This is used to keep meshes transformations so they can be restored
  140279. * when we build back a Babylon Mesh
  140280. * NB : All CSG operations are performed in world coordinates
  140281. * @param csg The CSG to copy the transform attributes from
  140282. * @returns This CSG
  140283. */
  140284. copyTransformAttributes(csg: CSG): CSG;
  140285. /**
  140286. * Build Raw mesh from CSG
  140287. * Coordinates here are in world space
  140288. * @param name The name of the mesh geometry
  140289. * @param scene The Scene
  140290. * @param keepSubMeshes Specifies if the submeshes should be kept
  140291. * @returns A new Mesh
  140292. */
  140293. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140294. /**
  140295. * Build Mesh from CSG taking material and transforms into account
  140296. * @param name The name of the Mesh
  140297. * @param material The material of the Mesh
  140298. * @param scene The Scene
  140299. * @param keepSubMeshes Specifies if submeshes should be kept
  140300. * @returns The new Mesh
  140301. */
  140302. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140303. }
  140304. }
  140305. declare module BABYLON {
  140306. /**
  140307. * Class used to create a trail following a mesh
  140308. */
  140309. export class TrailMesh extends Mesh {
  140310. private _generator;
  140311. private _autoStart;
  140312. private _running;
  140313. private _diameter;
  140314. private _length;
  140315. private _sectionPolygonPointsCount;
  140316. private _sectionVectors;
  140317. private _sectionNormalVectors;
  140318. private _beforeRenderObserver;
  140319. /**
  140320. * @constructor
  140321. * @param name The value used by scene.getMeshByName() to do a lookup.
  140322. * @param generator The mesh or transform node to generate a trail.
  140323. * @param scene The scene to add this mesh to.
  140324. * @param diameter Diameter of trailing mesh. Default is 1.
  140325. * @param length Length of trailing mesh. Default is 60.
  140326. * @param autoStart Automatically start trailing mesh. Default true.
  140327. */
  140328. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  140329. /**
  140330. * "TrailMesh"
  140331. * @returns "TrailMesh"
  140332. */
  140333. getClassName(): string;
  140334. private _createMesh;
  140335. /**
  140336. * Start trailing mesh.
  140337. */
  140338. start(): void;
  140339. /**
  140340. * Stop trailing mesh.
  140341. */
  140342. stop(): void;
  140343. /**
  140344. * Update trailing mesh geometry.
  140345. */
  140346. update(): void;
  140347. /**
  140348. * Returns a new TrailMesh object.
  140349. * @param name is a string, the name given to the new mesh
  140350. * @param newGenerator use new generator object for cloned trail mesh
  140351. * @returns a new mesh
  140352. */
  140353. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  140354. /**
  140355. * Serializes this trail mesh
  140356. * @param serializationObject object to write serialization to
  140357. */
  140358. serialize(serializationObject: any): void;
  140359. /**
  140360. * Parses a serialized trail mesh
  140361. * @param parsedMesh the serialized mesh
  140362. * @param scene the scene to create the trail mesh in
  140363. * @returns the created trail mesh
  140364. */
  140365. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  140366. }
  140367. }
  140368. declare module BABYLON {
  140369. /**
  140370. * Class containing static functions to help procedurally build meshes
  140371. */
  140372. export class TiledBoxBuilder {
  140373. /**
  140374. * Creates a box mesh
  140375. * 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)
  140376. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140380. * @param name defines the name of the mesh
  140381. * @param options defines the options used to create the mesh
  140382. * @param scene defines the hosting scene
  140383. * @returns the box mesh
  140384. */
  140385. static CreateTiledBox(name: string, options: {
  140386. pattern?: number;
  140387. width?: number;
  140388. height?: number;
  140389. depth?: number;
  140390. tileSize?: number;
  140391. tileWidth?: number;
  140392. tileHeight?: number;
  140393. alignHorizontal?: number;
  140394. alignVertical?: number;
  140395. faceUV?: Vector4[];
  140396. faceColors?: Color4[];
  140397. sideOrientation?: number;
  140398. updatable?: boolean;
  140399. }, scene?: Nullable<Scene>): Mesh;
  140400. }
  140401. }
  140402. declare module BABYLON {
  140403. /**
  140404. * Class containing static functions to help procedurally build meshes
  140405. */
  140406. export class TorusKnotBuilder {
  140407. /**
  140408. * Creates a torus knot mesh
  140409. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  140410. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  140411. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  140412. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  140413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  140416. * @param name defines the name of the mesh
  140417. * @param options defines the options used to create the mesh
  140418. * @param scene defines the hosting scene
  140419. * @returns the torus knot mesh
  140420. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  140421. */
  140422. static CreateTorusKnot(name: string, options: {
  140423. radius?: number;
  140424. tube?: number;
  140425. radialSegments?: number;
  140426. tubularSegments?: number;
  140427. p?: number;
  140428. q?: number;
  140429. updatable?: boolean;
  140430. sideOrientation?: number;
  140431. frontUVs?: Vector4;
  140432. backUVs?: Vector4;
  140433. }, scene: any): Mesh;
  140434. }
  140435. }
  140436. declare module BABYLON {
  140437. /**
  140438. * Polygon
  140439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  140440. */
  140441. export class Polygon {
  140442. /**
  140443. * Creates a rectangle
  140444. * @param xmin bottom X coord
  140445. * @param ymin bottom Y coord
  140446. * @param xmax top X coord
  140447. * @param ymax top Y coord
  140448. * @returns points that make the resulting rectation
  140449. */
  140450. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  140451. /**
  140452. * Creates a circle
  140453. * @param radius radius of circle
  140454. * @param cx scale in x
  140455. * @param cy scale in y
  140456. * @param numberOfSides number of sides that make up the circle
  140457. * @returns points that make the resulting circle
  140458. */
  140459. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  140460. /**
  140461. * Creates a polygon from input string
  140462. * @param input Input polygon data
  140463. * @returns the parsed points
  140464. */
  140465. static Parse(input: string): Vector2[];
  140466. /**
  140467. * Starts building a polygon from x and y coordinates
  140468. * @param x x coordinate
  140469. * @param y y coordinate
  140470. * @returns the started path2
  140471. */
  140472. static StartingAt(x: number, y: number): Path2;
  140473. }
  140474. /**
  140475. * Builds a polygon
  140476. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  140477. */
  140478. export class PolygonMeshBuilder {
  140479. private _points;
  140480. private _outlinepoints;
  140481. private _holes;
  140482. private _name;
  140483. private _scene;
  140484. private _epoints;
  140485. private _eholes;
  140486. private _addToepoint;
  140487. /**
  140488. * Babylon reference to the earcut plugin.
  140489. */
  140490. bjsEarcut: any;
  140491. /**
  140492. * Creates a PolygonMeshBuilder
  140493. * @param name name of the builder
  140494. * @param contours Path of the polygon
  140495. * @param scene scene to add to when creating the mesh
  140496. * @param earcutInjection can be used to inject your own earcut reference
  140497. */
  140498. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  140499. /**
  140500. * Adds a whole within the polygon
  140501. * @param hole Array of points defining the hole
  140502. * @returns this
  140503. */
  140504. addHole(hole: Vector2[]): PolygonMeshBuilder;
  140505. /**
  140506. * Creates the polygon
  140507. * @param updatable If the mesh should be updatable
  140508. * @param depth The depth of the mesh created
  140509. * @returns the created mesh
  140510. */
  140511. build(updatable?: boolean, depth?: number): Mesh;
  140512. /**
  140513. * Creates the polygon
  140514. * @param depth The depth of the mesh created
  140515. * @returns the created VertexData
  140516. */
  140517. buildVertexData(depth?: number): VertexData;
  140518. /**
  140519. * Adds a side to the polygon
  140520. * @param positions points that make the polygon
  140521. * @param normals normals of the polygon
  140522. * @param uvs uvs of the polygon
  140523. * @param indices indices of the polygon
  140524. * @param bounds bounds of the polygon
  140525. * @param points points of the polygon
  140526. * @param depth depth of the polygon
  140527. * @param flip flip of the polygon
  140528. */
  140529. private addSide;
  140530. }
  140531. }
  140532. declare module BABYLON {
  140533. /**
  140534. * Class containing static functions to help procedurally build meshes
  140535. */
  140536. export class PolygonBuilder {
  140537. /**
  140538. * Creates a polygon mesh
  140539. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  140540. * * 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
  140541. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  140544. * * Remember you can only change the shape positions, not their number when updating a polygon
  140545. * @param name defines the name of the mesh
  140546. * @param options defines the options used to create the mesh
  140547. * @param scene defines the hosting scene
  140548. * @param earcutInjection can be used to inject your own earcut reference
  140549. * @returns the polygon mesh
  140550. */
  140551. static CreatePolygon(name: string, options: {
  140552. shape: Vector3[];
  140553. holes?: Vector3[][];
  140554. depth?: number;
  140555. faceUV?: Vector4[];
  140556. faceColors?: Color4[];
  140557. updatable?: boolean;
  140558. sideOrientation?: number;
  140559. frontUVs?: Vector4;
  140560. backUVs?: Vector4;
  140561. wrap?: boolean;
  140562. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140563. /**
  140564. * Creates an extruded polygon mesh, with depth in the Y direction.
  140565. * * 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)
  140566. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140567. * @param name defines the name of the mesh
  140568. * @param options defines the options used to create the mesh
  140569. * @param scene defines the hosting scene
  140570. * @param earcutInjection can be used to inject your own earcut reference
  140571. * @returns the polygon mesh
  140572. */
  140573. static ExtrudePolygon(name: string, options: {
  140574. shape: Vector3[];
  140575. holes?: Vector3[][];
  140576. depth?: number;
  140577. faceUV?: Vector4[];
  140578. faceColors?: Color4[];
  140579. updatable?: boolean;
  140580. sideOrientation?: number;
  140581. frontUVs?: Vector4;
  140582. backUVs?: Vector4;
  140583. wrap?: boolean;
  140584. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140585. }
  140586. }
  140587. declare module BABYLON {
  140588. /**
  140589. * Class containing static functions to help procedurally build meshes
  140590. */
  140591. export class LatheBuilder {
  140592. /**
  140593. * Creates lathe mesh.
  140594. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  140595. * * 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
  140596. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  140597. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  140598. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  140599. * * 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
  140600. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  140601. * * 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
  140602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140606. * @param name defines the name of the mesh
  140607. * @param options defines the options used to create the mesh
  140608. * @param scene defines the hosting scene
  140609. * @returns the lathe mesh
  140610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  140611. */
  140612. static CreateLathe(name: string, options: {
  140613. shape: Vector3[];
  140614. radius?: number;
  140615. tessellation?: number;
  140616. clip?: number;
  140617. arc?: number;
  140618. closed?: boolean;
  140619. updatable?: boolean;
  140620. sideOrientation?: number;
  140621. frontUVs?: Vector4;
  140622. backUVs?: Vector4;
  140623. cap?: number;
  140624. invertUV?: boolean;
  140625. }, scene?: Nullable<Scene>): Mesh;
  140626. }
  140627. }
  140628. declare module BABYLON {
  140629. /**
  140630. * Class containing static functions to help procedurally build meshes
  140631. */
  140632. export class TiledPlaneBuilder {
  140633. /**
  140634. * Creates a tiled plane mesh
  140635. * * The parameter `pattern` will, depending on value, do nothing or
  140636. * * * flip (reflect about central vertical) alternate tiles across and up
  140637. * * * flip every tile on alternate rows
  140638. * * * rotate (180 degs) alternate tiles across and up
  140639. * * * rotate every tile on alternate rows
  140640. * * * flip and rotate alternate tiles across and up
  140641. * * * flip and rotate every tile on alternate rows
  140642. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  140643. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  140644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140646. * * 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)
  140647. * * 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)
  140648. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  140649. * @param name defines the name of the mesh
  140650. * @param options defines the options used to create the mesh
  140651. * @param scene defines the hosting scene
  140652. * @returns the box mesh
  140653. */
  140654. static CreateTiledPlane(name: string, options: {
  140655. pattern?: number;
  140656. tileSize?: number;
  140657. tileWidth?: number;
  140658. tileHeight?: number;
  140659. size?: number;
  140660. width?: number;
  140661. height?: number;
  140662. alignHorizontal?: number;
  140663. alignVertical?: number;
  140664. sideOrientation?: number;
  140665. frontUVs?: Vector4;
  140666. backUVs?: Vector4;
  140667. updatable?: boolean;
  140668. }, scene?: Nullable<Scene>): Mesh;
  140669. }
  140670. }
  140671. declare module BABYLON {
  140672. /**
  140673. * Class containing static functions to help procedurally build meshes
  140674. */
  140675. export class TubeBuilder {
  140676. /**
  140677. * Creates a tube mesh.
  140678. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  140679. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  140680. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  140681. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  140682. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  140683. * * 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)
  140684. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  140685. * * 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
  140686. * * 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
  140687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140691. * @param name defines the name of the mesh
  140692. * @param options defines the options used to create the mesh
  140693. * @param scene defines the hosting scene
  140694. * @returns the tube mesh
  140695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  140696. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  140697. */
  140698. static CreateTube(name: string, options: {
  140699. path: Vector3[];
  140700. radius?: number;
  140701. tessellation?: number;
  140702. radiusFunction?: {
  140703. (i: number, distance: number): number;
  140704. };
  140705. cap?: number;
  140706. arc?: number;
  140707. updatable?: boolean;
  140708. sideOrientation?: number;
  140709. frontUVs?: Vector4;
  140710. backUVs?: Vector4;
  140711. instance?: Mesh;
  140712. invertUV?: boolean;
  140713. }, scene?: Nullable<Scene>): Mesh;
  140714. }
  140715. }
  140716. declare module BABYLON {
  140717. /**
  140718. * Class containing static functions to help procedurally build meshes
  140719. */
  140720. export class IcoSphereBuilder {
  140721. /**
  140722. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  140723. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  140724. * * 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`)
  140725. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  140726. * * 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
  140727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140730. * @param name defines the name of the mesh
  140731. * @param options defines the options used to create the mesh
  140732. * @param scene defines the hosting scene
  140733. * @returns the icosahedron mesh
  140734. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  140735. */
  140736. static CreateIcoSphere(name: string, options: {
  140737. radius?: number;
  140738. radiusX?: number;
  140739. radiusY?: number;
  140740. radiusZ?: number;
  140741. flat?: boolean;
  140742. subdivisions?: number;
  140743. sideOrientation?: number;
  140744. frontUVs?: Vector4;
  140745. backUVs?: Vector4;
  140746. updatable?: boolean;
  140747. }, scene?: Nullable<Scene>): Mesh;
  140748. }
  140749. }
  140750. declare module BABYLON {
  140751. /**
  140752. * Class containing static functions to help procedurally build meshes
  140753. */
  140754. export class DecalBuilder {
  140755. /**
  140756. * Creates a decal mesh.
  140757. * 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
  140758. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  140759. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  140760. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  140761. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  140762. * @param name defines the name of the mesh
  140763. * @param sourceMesh defines the mesh where the decal must be applied
  140764. * @param options defines the options used to create the mesh
  140765. * @param scene defines the hosting scene
  140766. * @returns the decal mesh
  140767. * @see https://doc.babylonjs.com/how_to/decals
  140768. */
  140769. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  140770. position?: Vector3;
  140771. normal?: Vector3;
  140772. size?: Vector3;
  140773. angle?: number;
  140774. }): Mesh;
  140775. }
  140776. }
  140777. declare module BABYLON {
  140778. /**
  140779. * Class containing static functions to help procedurally build meshes
  140780. */
  140781. export class MeshBuilder {
  140782. /**
  140783. * Creates a box mesh
  140784. * * The parameter `size` sets the size (float) of each box side (default 1)
  140785. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  140786. * * 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)
  140787. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140791. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  140792. * @param name defines the name of the mesh
  140793. * @param options defines the options used to create the mesh
  140794. * @param scene defines the hosting scene
  140795. * @returns the box mesh
  140796. */
  140797. static CreateBox(name: string, options: {
  140798. size?: number;
  140799. width?: number;
  140800. height?: number;
  140801. depth?: number;
  140802. faceUV?: Vector4[];
  140803. faceColors?: Color4[];
  140804. sideOrientation?: number;
  140805. frontUVs?: Vector4;
  140806. backUVs?: Vector4;
  140807. wrap?: boolean;
  140808. topBaseAt?: number;
  140809. bottomBaseAt?: number;
  140810. updatable?: boolean;
  140811. }, scene?: Nullable<Scene>): Mesh;
  140812. /**
  140813. * Creates a tiled box mesh
  140814. * * faceTiles sets the pattern, tile size and number of tiles for a face
  140815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140816. * @param name defines the name of the mesh
  140817. * @param options defines the options used to create the mesh
  140818. * @param scene defines the hosting scene
  140819. * @returns the tiled box mesh
  140820. */
  140821. static CreateTiledBox(name: string, options: {
  140822. pattern?: number;
  140823. size?: number;
  140824. width?: number;
  140825. height?: number;
  140826. depth: number;
  140827. tileSize?: number;
  140828. tileWidth?: number;
  140829. tileHeight?: number;
  140830. faceUV?: Vector4[];
  140831. faceColors?: Color4[];
  140832. alignHorizontal?: number;
  140833. alignVertical?: number;
  140834. sideOrientation?: number;
  140835. updatable?: boolean;
  140836. }, scene?: Nullable<Scene>): Mesh;
  140837. /**
  140838. * Creates a sphere mesh
  140839. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  140840. * * 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`)
  140841. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  140842. * * 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
  140843. * * 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)
  140844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140845. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140847. * @param name defines the name of the mesh
  140848. * @param options defines the options used to create the mesh
  140849. * @param scene defines the hosting scene
  140850. * @returns the sphere mesh
  140851. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  140852. */
  140853. static CreateSphere(name: string, options: {
  140854. segments?: number;
  140855. diameter?: number;
  140856. diameterX?: number;
  140857. diameterY?: number;
  140858. diameterZ?: number;
  140859. arc?: number;
  140860. slice?: number;
  140861. sideOrientation?: number;
  140862. frontUVs?: Vector4;
  140863. backUVs?: Vector4;
  140864. updatable?: boolean;
  140865. }, scene?: Nullable<Scene>): Mesh;
  140866. /**
  140867. * Creates a plane polygonal mesh. By default, this is a disc
  140868. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  140869. * * 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
  140870. * * 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
  140871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140874. * @param name defines the name of the mesh
  140875. * @param options defines the options used to create the mesh
  140876. * @param scene defines the hosting scene
  140877. * @returns the plane polygonal mesh
  140878. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  140879. */
  140880. static CreateDisc(name: string, options: {
  140881. radius?: number;
  140882. tessellation?: number;
  140883. arc?: number;
  140884. updatable?: boolean;
  140885. sideOrientation?: number;
  140886. frontUVs?: Vector4;
  140887. backUVs?: Vector4;
  140888. }, scene?: Nullable<Scene>): Mesh;
  140889. /**
  140890. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  140891. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  140892. * * 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`)
  140893. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  140894. * * 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
  140895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140898. * @param name defines the name of the mesh
  140899. * @param options defines the options used to create the mesh
  140900. * @param scene defines the hosting scene
  140901. * @returns the icosahedron mesh
  140902. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  140903. */
  140904. static CreateIcoSphere(name: string, options: {
  140905. radius?: number;
  140906. radiusX?: number;
  140907. radiusY?: number;
  140908. radiusZ?: number;
  140909. flat?: boolean;
  140910. subdivisions?: number;
  140911. sideOrientation?: number;
  140912. frontUVs?: Vector4;
  140913. backUVs?: Vector4;
  140914. updatable?: boolean;
  140915. }, scene?: Nullable<Scene>): Mesh;
  140916. /**
  140917. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  140918. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  140919. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  140920. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  140921. * * 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
  140922. * * 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
  140923. * * 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
  140924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140927. * * 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
  140928. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  140929. * * 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
  140930. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  140931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140932. * @param name defines the name of the mesh
  140933. * @param options defines the options used to create the mesh
  140934. * @param scene defines the hosting scene
  140935. * @returns the ribbon mesh
  140936. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  140937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  140938. */
  140939. static CreateRibbon(name: string, options: {
  140940. pathArray: Vector3[][];
  140941. closeArray?: boolean;
  140942. closePath?: boolean;
  140943. offset?: number;
  140944. updatable?: boolean;
  140945. sideOrientation?: number;
  140946. frontUVs?: Vector4;
  140947. backUVs?: Vector4;
  140948. instance?: Mesh;
  140949. invertUV?: boolean;
  140950. uvs?: Vector2[];
  140951. colors?: Color4[];
  140952. }, scene?: Nullable<Scene>): Mesh;
  140953. /**
  140954. * Creates a cylinder or a cone mesh
  140955. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  140956. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  140957. * * 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.
  140958. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  140959. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  140960. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  140961. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  140962. * * 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).
  140963. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  140964. * * 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).
  140965. * * 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
  140966. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  140967. * * 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
  140968. * * 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.
  140969. * * If `enclose` is false, a ring surface is one element.
  140970. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  140971. * * 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
  140972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  140975. * @param name defines the name of the mesh
  140976. * @param options defines the options used to create the mesh
  140977. * @param scene defines the hosting scene
  140978. * @returns the cylinder mesh
  140979. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  140980. */
  140981. static CreateCylinder(name: string, options: {
  140982. height?: number;
  140983. diameterTop?: number;
  140984. diameterBottom?: number;
  140985. diameter?: number;
  140986. tessellation?: number;
  140987. subdivisions?: number;
  140988. arc?: number;
  140989. faceColors?: Color4[];
  140990. faceUV?: Vector4[];
  140991. updatable?: boolean;
  140992. hasRings?: boolean;
  140993. enclose?: boolean;
  140994. cap?: number;
  140995. sideOrientation?: number;
  140996. frontUVs?: Vector4;
  140997. backUVs?: Vector4;
  140998. }, scene?: Nullable<Scene>): Mesh;
  140999. /**
  141000. * Creates a torus mesh
  141001. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  141002. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  141003. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  141004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141007. * @param name defines the name of the mesh
  141008. * @param options defines the options used to create the mesh
  141009. * @param scene defines the hosting scene
  141010. * @returns the torus mesh
  141011. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  141012. */
  141013. static CreateTorus(name: string, options: {
  141014. diameter?: number;
  141015. thickness?: number;
  141016. tessellation?: number;
  141017. updatable?: boolean;
  141018. sideOrientation?: number;
  141019. frontUVs?: Vector4;
  141020. backUVs?: Vector4;
  141021. }, scene?: Nullable<Scene>): Mesh;
  141022. /**
  141023. * Creates a torus knot mesh
  141024. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141025. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141026. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141027. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141031. * @param name defines the name of the mesh
  141032. * @param options defines the options used to create the mesh
  141033. * @param scene defines the hosting scene
  141034. * @returns the torus knot mesh
  141035. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141036. */
  141037. static CreateTorusKnot(name: string, options: {
  141038. radius?: number;
  141039. tube?: number;
  141040. radialSegments?: number;
  141041. tubularSegments?: number;
  141042. p?: number;
  141043. q?: number;
  141044. updatable?: boolean;
  141045. sideOrientation?: number;
  141046. frontUVs?: Vector4;
  141047. backUVs?: Vector4;
  141048. }, scene?: Nullable<Scene>): Mesh;
  141049. /**
  141050. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141051. * * 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
  141052. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141053. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141054. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141055. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141056. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141057. * * 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
  141058. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141061. * @param name defines the name of the new line system
  141062. * @param options defines the options used to create the line system
  141063. * @param scene defines the hosting scene
  141064. * @returns a new line system mesh
  141065. */
  141066. static CreateLineSystem(name: string, options: {
  141067. lines: Vector3[][];
  141068. updatable?: boolean;
  141069. instance?: Nullable<LinesMesh>;
  141070. colors?: Nullable<Color4[][]>;
  141071. useVertexAlpha?: boolean;
  141072. }, scene: Nullable<Scene>): LinesMesh;
  141073. /**
  141074. * Creates a line mesh
  141075. * 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
  141076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141077. * * The parameter `points` is an array successive Vector3
  141078. * * 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
  141079. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141080. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141081. * * When updating an instance, remember that only point positions can change, not the number of points
  141082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141084. * @param name defines the name of the new line system
  141085. * @param options defines the options used to create the line system
  141086. * @param scene defines the hosting scene
  141087. * @returns a new line mesh
  141088. */
  141089. static CreateLines(name: string, options: {
  141090. points: Vector3[];
  141091. updatable?: boolean;
  141092. instance?: Nullable<LinesMesh>;
  141093. colors?: Color4[];
  141094. useVertexAlpha?: boolean;
  141095. }, scene?: Nullable<Scene>): LinesMesh;
  141096. /**
  141097. * Creates a dashed line mesh
  141098. * * 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
  141099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141100. * * The parameter `points` is an array successive Vector3
  141101. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141102. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141103. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141104. * * 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
  141105. * * When updating an instance, remember that only point positions can change, not the number of points
  141106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141107. * @param name defines the name of the mesh
  141108. * @param options defines the options used to create the mesh
  141109. * @param scene defines the hosting scene
  141110. * @returns the dashed line mesh
  141111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141112. */
  141113. static CreateDashedLines(name: string, options: {
  141114. points: Vector3[];
  141115. dashSize?: number;
  141116. gapSize?: number;
  141117. dashNb?: number;
  141118. updatable?: boolean;
  141119. instance?: LinesMesh;
  141120. }, scene?: Nullable<Scene>): LinesMesh;
  141121. /**
  141122. * 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.
  141123. * * 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.
  141124. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141125. * * 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.
  141126. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  141127. * * 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
  141128. * * 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
  141129. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  141130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  141133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141134. * @param name defines the name of the mesh
  141135. * @param options defines the options used to create the mesh
  141136. * @param scene defines the hosting scene
  141137. * @returns the extruded shape mesh
  141138. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141140. */
  141141. static ExtrudeShape(name: string, options: {
  141142. shape: Vector3[];
  141143. path: Vector3[];
  141144. scale?: number;
  141145. rotation?: number;
  141146. cap?: number;
  141147. updatable?: boolean;
  141148. sideOrientation?: number;
  141149. frontUVs?: Vector4;
  141150. backUVs?: Vector4;
  141151. instance?: Mesh;
  141152. invertUV?: boolean;
  141153. }, scene?: Nullable<Scene>): Mesh;
  141154. /**
  141155. * Creates an custom extruded shape mesh.
  141156. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  141157. * * 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.
  141158. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141159. * * 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
  141160. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  141161. * * 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
  141162. * * It must returns a float value that will be the scale value applied to the shape on each path point
  141163. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  141164. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  141165. * * 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
  141166. * * 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
  141167. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  141168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141172. * @param name defines the name of the mesh
  141173. * @param options defines the options used to create the mesh
  141174. * @param scene defines the hosting scene
  141175. * @returns the custom extruded shape mesh
  141176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  141177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141179. */
  141180. static ExtrudeShapeCustom(name: string, options: {
  141181. shape: Vector3[];
  141182. path: Vector3[];
  141183. scaleFunction?: any;
  141184. rotationFunction?: any;
  141185. ribbonCloseArray?: boolean;
  141186. ribbonClosePath?: boolean;
  141187. cap?: number;
  141188. updatable?: boolean;
  141189. sideOrientation?: number;
  141190. frontUVs?: Vector4;
  141191. backUVs?: Vector4;
  141192. instance?: Mesh;
  141193. invertUV?: boolean;
  141194. }, scene?: Nullable<Scene>): Mesh;
  141195. /**
  141196. * Creates lathe mesh.
  141197. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141198. * * 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
  141199. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141200. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141201. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141202. * * 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
  141203. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141204. * * 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
  141205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141209. * @param name defines the name of the mesh
  141210. * @param options defines the options used to create the mesh
  141211. * @param scene defines the hosting scene
  141212. * @returns the lathe mesh
  141213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141214. */
  141215. static CreateLathe(name: string, options: {
  141216. shape: Vector3[];
  141217. radius?: number;
  141218. tessellation?: number;
  141219. clip?: number;
  141220. arc?: number;
  141221. closed?: boolean;
  141222. updatable?: boolean;
  141223. sideOrientation?: number;
  141224. frontUVs?: Vector4;
  141225. backUVs?: Vector4;
  141226. cap?: number;
  141227. invertUV?: boolean;
  141228. }, scene?: Nullable<Scene>): Mesh;
  141229. /**
  141230. * Creates a tiled plane mesh
  141231. * * You can set a limited pattern arrangement with the tiles
  141232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141235. * @param name defines the name of the mesh
  141236. * @param options defines the options used to create the mesh
  141237. * @param scene defines the hosting scene
  141238. * @returns the plane mesh
  141239. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141240. */
  141241. static CreateTiledPlane(name: string, options: {
  141242. pattern?: number;
  141243. tileSize?: number;
  141244. tileWidth?: number;
  141245. tileHeight?: number;
  141246. size?: number;
  141247. width?: number;
  141248. height?: number;
  141249. alignHorizontal?: number;
  141250. alignVertical?: number;
  141251. sideOrientation?: number;
  141252. frontUVs?: Vector4;
  141253. backUVs?: Vector4;
  141254. updatable?: boolean;
  141255. }, scene?: Nullable<Scene>): Mesh;
  141256. /**
  141257. * Creates a plane mesh
  141258. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  141259. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  141260. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  141261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141264. * @param name defines the name of the mesh
  141265. * @param options defines the options used to create the mesh
  141266. * @param scene defines the hosting scene
  141267. * @returns the plane mesh
  141268. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141269. */
  141270. static CreatePlane(name: string, options: {
  141271. size?: number;
  141272. width?: number;
  141273. height?: number;
  141274. sideOrientation?: number;
  141275. frontUVs?: Vector4;
  141276. backUVs?: Vector4;
  141277. updatable?: boolean;
  141278. sourcePlane?: Plane;
  141279. }, scene?: Nullable<Scene>): Mesh;
  141280. /**
  141281. * Creates a ground mesh
  141282. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  141283. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  141284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141285. * @param name defines the name of the mesh
  141286. * @param options defines the options used to create the mesh
  141287. * @param scene defines the hosting scene
  141288. * @returns the ground mesh
  141289. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  141290. */
  141291. static CreateGround(name: string, options: {
  141292. width?: number;
  141293. height?: number;
  141294. subdivisions?: number;
  141295. subdivisionsX?: number;
  141296. subdivisionsY?: number;
  141297. updatable?: boolean;
  141298. }, scene?: Nullable<Scene>): Mesh;
  141299. /**
  141300. * Creates a tiled ground mesh
  141301. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  141302. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  141303. * * 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
  141304. * * 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
  141305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141306. * @param name defines the name of the mesh
  141307. * @param options defines the options used to create the mesh
  141308. * @param scene defines the hosting scene
  141309. * @returns the tiled ground mesh
  141310. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  141311. */
  141312. static CreateTiledGround(name: string, options: {
  141313. xmin: number;
  141314. zmin: number;
  141315. xmax: number;
  141316. zmax: number;
  141317. subdivisions?: {
  141318. w: number;
  141319. h: number;
  141320. };
  141321. precision?: {
  141322. w: number;
  141323. h: number;
  141324. };
  141325. updatable?: boolean;
  141326. }, scene?: Nullable<Scene>): Mesh;
  141327. /**
  141328. * Creates a ground mesh from a height map
  141329. * * The parameter `url` sets the URL of the height map image resource.
  141330. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  141331. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  141332. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  141333. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  141334. * * 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.
  141335. * * 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).
  141336. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  141337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141338. * @param name defines the name of the mesh
  141339. * @param url defines the url to the height map
  141340. * @param options defines the options used to create the mesh
  141341. * @param scene defines the hosting scene
  141342. * @returns the ground mesh
  141343. * @see https://doc.babylonjs.com/babylon101/height_map
  141344. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  141345. */
  141346. static CreateGroundFromHeightMap(name: string, url: string, options: {
  141347. width?: number;
  141348. height?: number;
  141349. subdivisions?: number;
  141350. minHeight?: number;
  141351. maxHeight?: number;
  141352. colorFilter?: Color3;
  141353. alphaFilter?: number;
  141354. updatable?: boolean;
  141355. onReady?: (mesh: GroundMesh) => void;
  141356. }, scene?: Nullable<Scene>): GroundMesh;
  141357. /**
  141358. * Creates a polygon mesh
  141359. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141360. * * 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
  141361. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141364. * * Remember you can only change the shape positions, not their number when updating a polygon
  141365. * @param name defines the name of the mesh
  141366. * @param options defines the options used to create the mesh
  141367. * @param scene defines the hosting scene
  141368. * @param earcutInjection can be used to inject your own earcut reference
  141369. * @returns the polygon mesh
  141370. */
  141371. static CreatePolygon(name: string, options: {
  141372. shape: Vector3[];
  141373. holes?: Vector3[][];
  141374. depth?: number;
  141375. faceUV?: Vector4[];
  141376. faceColors?: Color4[];
  141377. updatable?: boolean;
  141378. sideOrientation?: number;
  141379. frontUVs?: Vector4;
  141380. backUVs?: Vector4;
  141381. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141382. /**
  141383. * Creates an extruded polygon mesh, with depth in the Y direction.
  141384. * * 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)
  141385. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141386. * @param name defines the name of the mesh
  141387. * @param options defines the options used to create the mesh
  141388. * @param scene defines the hosting scene
  141389. * @param earcutInjection can be used to inject your own earcut reference
  141390. * @returns the polygon mesh
  141391. */
  141392. static ExtrudePolygon(name: string, options: {
  141393. shape: Vector3[];
  141394. holes?: Vector3[][];
  141395. depth?: number;
  141396. faceUV?: Vector4[];
  141397. faceColors?: Color4[];
  141398. updatable?: boolean;
  141399. sideOrientation?: number;
  141400. frontUVs?: Vector4;
  141401. backUVs?: Vector4;
  141402. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141403. /**
  141404. * Creates a tube mesh.
  141405. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141406. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141407. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141408. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141409. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141410. * * 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)
  141411. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141412. * * 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
  141413. * * 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
  141414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141418. * @param name defines the name of the mesh
  141419. * @param options defines the options used to create the mesh
  141420. * @param scene defines the hosting scene
  141421. * @returns the tube mesh
  141422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141423. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141424. */
  141425. static CreateTube(name: string, options: {
  141426. path: Vector3[];
  141427. radius?: number;
  141428. tessellation?: number;
  141429. radiusFunction?: {
  141430. (i: number, distance: number): number;
  141431. };
  141432. cap?: number;
  141433. arc?: number;
  141434. updatable?: boolean;
  141435. sideOrientation?: number;
  141436. frontUVs?: Vector4;
  141437. backUVs?: Vector4;
  141438. instance?: Mesh;
  141439. invertUV?: boolean;
  141440. }, scene?: Nullable<Scene>): Mesh;
  141441. /**
  141442. * Creates a polyhedron mesh
  141443. * * 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
  141444. * * The parameter `size` (positive float, default 1) sets the polygon size
  141445. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141446. * * 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`
  141447. * * 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
  141448. * * 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)`)
  141449. * * 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
  141450. * * 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
  141451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141454. * @param name defines the name of the mesh
  141455. * @param options defines the options used to create the mesh
  141456. * @param scene defines the hosting scene
  141457. * @returns the polyhedron mesh
  141458. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141459. */
  141460. static CreatePolyhedron(name: string, options: {
  141461. type?: number;
  141462. size?: number;
  141463. sizeX?: number;
  141464. sizeY?: number;
  141465. sizeZ?: number;
  141466. custom?: any;
  141467. faceUV?: Vector4[];
  141468. faceColors?: Color4[];
  141469. flat?: boolean;
  141470. updatable?: boolean;
  141471. sideOrientation?: number;
  141472. frontUVs?: Vector4;
  141473. backUVs?: Vector4;
  141474. }, scene?: Nullable<Scene>): Mesh;
  141475. /**
  141476. * Creates a decal mesh.
  141477. * 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
  141478. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141479. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141480. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141481. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141482. * @param name defines the name of the mesh
  141483. * @param sourceMesh defines the mesh where the decal must be applied
  141484. * @param options defines the options used to create the mesh
  141485. * @param scene defines the hosting scene
  141486. * @returns the decal mesh
  141487. * @see https://doc.babylonjs.com/how_to/decals
  141488. */
  141489. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141490. position?: Vector3;
  141491. normal?: Vector3;
  141492. size?: Vector3;
  141493. angle?: number;
  141494. }): Mesh;
  141495. }
  141496. }
  141497. declare module BABYLON {
  141498. /**
  141499. * A simplifier interface for future simplification implementations
  141500. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141501. */
  141502. export interface ISimplifier {
  141503. /**
  141504. * Simplification of a given mesh according to the given settings.
  141505. * Since this requires computation, it is assumed that the function runs async.
  141506. * @param settings The settings of the simplification, including quality and distance
  141507. * @param successCallback A callback that will be called after the mesh was simplified.
  141508. * @param errorCallback in case of an error, this callback will be called. optional.
  141509. */
  141510. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  141511. }
  141512. /**
  141513. * Expected simplification settings.
  141514. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  141515. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141516. */
  141517. export interface ISimplificationSettings {
  141518. /**
  141519. * Gets or sets the expected quality
  141520. */
  141521. quality: number;
  141522. /**
  141523. * Gets or sets the distance when this optimized version should be used
  141524. */
  141525. distance: number;
  141526. /**
  141527. * Gets an already optimized mesh
  141528. */
  141529. optimizeMesh?: boolean;
  141530. }
  141531. /**
  141532. * Class used to specify simplification options
  141533. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141534. */
  141535. export class SimplificationSettings implements ISimplificationSettings {
  141536. /** expected quality */
  141537. quality: number;
  141538. /** distance when this optimized version should be used */
  141539. distance: number;
  141540. /** already optimized mesh */
  141541. optimizeMesh?: boolean | undefined;
  141542. /**
  141543. * Creates a SimplificationSettings
  141544. * @param quality expected quality
  141545. * @param distance distance when this optimized version should be used
  141546. * @param optimizeMesh already optimized mesh
  141547. */
  141548. constructor(
  141549. /** expected quality */
  141550. quality: number,
  141551. /** distance when this optimized version should be used */
  141552. distance: number,
  141553. /** already optimized mesh */
  141554. optimizeMesh?: boolean | undefined);
  141555. }
  141556. /**
  141557. * Interface used to define a simplification task
  141558. */
  141559. export interface ISimplificationTask {
  141560. /**
  141561. * Array of settings
  141562. */
  141563. settings: Array<ISimplificationSettings>;
  141564. /**
  141565. * Simplification type
  141566. */
  141567. simplificationType: SimplificationType;
  141568. /**
  141569. * Mesh to simplify
  141570. */
  141571. mesh: Mesh;
  141572. /**
  141573. * Callback called on success
  141574. */
  141575. successCallback?: () => void;
  141576. /**
  141577. * Defines if parallel processing can be used
  141578. */
  141579. parallelProcessing: boolean;
  141580. }
  141581. /**
  141582. * Queue used to order the simplification tasks
  141583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141584. */
  141585. export class SimplificationQueue {
  141586. private _simplificationArray;
  141587. /**
  141588. * Gets a boolean indicating that the process is still running
  141589. */
  141590. running: boolean;
  141591. /**
  141592. * Creates a new queue
  141593. */
  141594. constructor();
  141595. /**
  141596. * Adds a new simplification task
  141597. * @param task defines a task to add
  141598. */
  141599. addTask(task: ISimplificationTask): void;
  141600. /**
  141601. * Execute next task
  141602. */
  141603. executeNext(): void;
  141604. /**
  141605. * Execute a simplification task
  141606. * @param task defines the task to run
  141607. */
  141608. runSimplification(task: ISimplificationTask): void;
  141609. private getSimplifier;
  141610. }
  141611. /**
  141612. * The implemented types of simplification
  141613. * At the moment only Quadratic Error Decimation is implemented
  141614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141615. */
  141616. export enum SimplificationType {
  141617. /** Quadratic error decimation */
  141618. QUADRATIC = 0
  141619. }
  141620. /**
  141621. * An implementation of the Quadratic Error simplification algorithm.
  141622. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  141623. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  141624. * @author RaananW
  141625. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141626. */
  141627. export class QuadraticErrorSimplification implements ISimplifier {
  141628. private _mesh;
  141629. private triangles;
  141630. private vertices;
  141631. private references;
  141632. private _reconstructedMesh;
  141633. /** Gets or sets the number pf sync interations */
  141634. syncIterations: number;
  141635. /** Gets or sets the aggressiveness of the simplifier */
  141636. aggressiveness: number;
  141637. /** Gets or sets the number of allowed iterations for decimation */
  141638. decimationIterations: number;
  141639. /** Gets or sets the espilon to use for bounding box computation */
  141640. boundingBoxEpsilon: number;
  141641. /**
  141642. * Creates a new QuadraticErrorSimplification
  141643. * @param _mesh defines the target mesh
  141644. */
  141645. constructor(_mesh: Mesh);
  141646. /**
  141647. * Simplification of a given mesh according to the given settings.
  141648. * Since this requires computation, it is assumed that the function runs async.
  141649. * @param settings The settings of the simplification, including quality and distance
  141650. * @param successCallback A callback that will be called after the mesh was simplified.
  141651. */
  141652. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  141653. private runDecimation;
  141654. private initWithMesh;
  141655. private init;
  141656. private reconstructMesh;
  141657. private initDecimatedMesh;
  141658. private isFlipped;
  141659. private updateTriangles;
  141660. private identifyBorder;
  141661. private updateMesh;
  141662. private vertexError;
  141663. private calculateError;
  141664. }
  141665. }
  141666. declare module BABYLON {
  141667. interface Scene {
  141668. /** @hidden (Backing field) */
  141669. _simplificationQueue: SimplificationQueue;
  141670. /**
  141671. * Gets or sets the simplification queue attached to the scene
  141672. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141673. */
  141674. simplificationQueue: SimplificationQueue;
  141675. }
  141676. interface Mesh {
  141677. /**
  141678. * Simplify the mesh according to the given array of settings.
  141679. * Function will return immediately and will simplify async
  141680. * @param settings a collection of simplification settings
  141681. * @param parallelProcessing should all levels calculate parallel or one after the other
  141682. * @param simplificationType the type of simplification to run
  141683. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  141684. * @returns the current mesh
  141685. */
  141686. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  141687. }
  141688. /**
  141689. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  141690. * created in a scene
  141691. */
  141692. export class SimplicationQueueSceneComponent implements ISceneComponent {
  141693. /**
  141694. * The component name helpfull to identify the component in the list of scene components.
  141695. */
  141696. readonly name: string;
  141697. /**
  141698. * The scene the component belongs to.
  141699. */
  141700. scene: Scene;
  141701. /**
  141702. * Creates a new instance of the component for the given scene
  141703. * @param scene Defines the scene to register the component in
  141704. */
  141705. constructor(scene: Scene);
  141706. /**
  141707. * Registers the component in a given scene
  141708. */
  141709. register(): void;
  141710. /**
  141711. * Rebuilds the elements related to this component in case of
  141712. * context lost for instance.
  141713. */
  141714. rebuild(): void;
  141715. /**
  141716. * Disposes the component and the associated ressources
  141717. */
  141718. dispose(): void;
  141719. private _beforeCameraUpdate;
  141720. }
  141721. }
  141722. declare module BABYLON {
  141723. /**
  141724. * Navigation plugin interface to add navigation constrained by a navigation mesh
  141725. */
  141726. export interface INavigationEnginePlugin {
  141727. /**
  141728. * plugin name
  141729. */
  141730. name: string;
  141731. /**
  141732. * Creates a navigation mesh
  141733. * @param meshes array of all the geometry used to compute the navigatio mesh
  141734. * @param parameters bunch of parameters used to filter geometry
  141735. */
  141736. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  141737. /**
  141738. * Create a navigation mesh debug mesh
  141739. * @param scene is where the mesh will be added
  141740. * @returns debug display mesh
  141741. */
  141742. createDebugNavMesh(scene: Scene): Mesh;
  141743. /**
  141744. * Get a navigation mesh constrained position, closest to the parameter position
  141745. * @param position world position
  141746. * @returns the closest point to position constrained by the navigation mesh
  141747. */
  141748. getClosestPoint(position: Vector3): Vector3;
  141749. /**
  141750. * Get a navigation mesh constrained position, closest to the parameter position
  141751. * @param position world position
  141752. * @param result output the closest point to position constrained by the navigation mesh
  141753. */
  141754. getClosestPointToRef(position: Vector3, result: Vector3): void;
  141755. /**
  141756. * Get a navigation mesh constrained position, within a particular radius
  141757. * @param position world position
  141758. * @param maxRadius the maximum distance to the constrained world position
  141759. * @returns the closest point to position constrained by the navigation mesh
  141760. */
  141761. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  141762. /**
  141763. * Get a navigation mesh constrained position, within a particular radius
  141764. * @param position world position
  141765. * @param maxRadius the maximum distance to the constrained world position
  141766. * @param result output the closest point to position constrained by the navigation mesh
  141767. */
  141768. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  141769. /**
  141770. * Compute the final position from a segment made of destination-position
  141771. * @param position world position
  141772. * @param destination world position
  141773. * @returns the resulting point along the navmesh
  141774. */
  141775. moveAlong(position: Vector3, destination: Vector3): Vector3;
  141776. /**
  141777. * Compute the final position from a segment made of destination-position
  141778. * @param position world position
  141779. * @param destination world position
  141780. * @param result output the resulting point along the navmesh
  141781. */
  141782. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  141783. /**
  141784. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  141785. * @param start world position
  141786. * @param end world position
  141787. * @returns array containing world position composing the path
  141788. */
  141789. computePath(start: Vector3, end: Vector3): Vector3[];
  141790. /**
  141791. * If this plugin is supported
  141792. * @returns true if plugin is supported
  141793. */
  141794. isSupported(): boolean;
  141795. /**
  141796. * Create a new Crowd so you can add agents
  141797. * @param maxAgents the maximum agent count in the crowd
  141798. * @param maxAgentRadius the maximum radius an agent can have
  141799. * @param scene to attach the crowd to
  141800. * @returns the crowd you can add agents to
  141801. */
  141802. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  141803. /**
  141804. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  141805. * The queries will try to find a solution within those bounds
  141806. * default is (1,1,1)
  141807. * @param extent x,y,z value that define the extent around the queries point of reference
  141808. */
  141809. setDefaultQueryExtent(extent: Vector3): void;
  141810. /**
  141811. * Get the Bounding box extent specified by setDefaultQueryExtent
  141812. * @returns the box extent values
  141813. */
  141814. getDefaultQueryExtent(): Vector3;
  141815. /**
  141816. * build the navmesh from a previously saved state using getNavmeshData
  141817. * @param data the Uint8Array returned by getNavmeshData
  141818. */
  141819. buildFromNavmeshData(data: Uint8Array): void;
  141820. /**
  141821. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  141822. * @returns data the Uint8Array that can be saved and reused
  141823. */
  141824. getNavmeshData(): Uint8Array;
  141825. /**
  141826. * Get the Bounding box extent result specified by setDefaultQueryExtent
  141827. * @param result output the box extent values
  141828. */
  141829. getDefaultQueryExtentToRef(result: Vector3): void;
  141830. /**
  141831. * Release all resources
  141832. */
  141833. dispose(): void;
  141834. }
  141835. /**
  141836. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  141837. */
  141838. export interface ICrowd {
  141839. /**
  141840. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  141841. * You can attach anything to that node. The node position is updated in the scene update tick.
  141842. * @param pos world position that will be constrained by the navigation mesh
  141843. * @param parameters agent parameters
  141844. * @param transform hooked to the agent that will be update by the scene
  141845. * @returns agent index
  141846. */
  141847. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  141848. /**
  141849. * Returns the agent position in world space
  141850. * @param index agent index returned by addAgent
  141851. * @returns world space position
  141852. */
  141853. getAgentPosition(index: number): Vector3;
  141854. /**
  141855. * Gets the agent position result in world space
  141856. * @param index agent index returned by addAgent
  141857. * @param result output world space position
  141858. */
  141859. getAgentPositionToRef(index: number, result: Vector3): void;
  141860. /**
  141861. * Gets the agent velocity in world space
  141862. * @param index agent index returned by addAgent
  141863. * @returns world space velocity
  141864. */
  141865. getAgentVelocity(index: number): Vector3;
  141866. /**
  141867. * Gets the agent velocity result in world space
  141868. * @param index agent index returned by addAgent
  141869. * @param result output world space velocity
  141870. */
  141871. getAgentVelocityToRef(index: number, result: Vector3): void;
  141872. /**
  141873. * remove a particular agent previously created
  141874. * @param index agent index returned by addAgent
  141875. */
  141876. removeAgent(index: number): void;
  141877. /**
  141878. * get the list of all agents attached to this crowd
  141879. * @returns list of agent indices
  141880. */
  141881. getAgents(): number[];
  141882. /**
  141883. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  141884. * @param deltaTime in seconds
  141885. */
  141886. update(deltaTime: number): void;
  141887. /**
  141888. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  141889. * @param index agent index returned by addAgent
  141890. * @param destination targeted world position
  141891. */
  141892. agentGoto(index: number, destination: Vector3): void;
  141893. /**
  141894. * Teleport the agent to a new position
  141895. * @param index agent index returned by addAgent
  141896. * @param destination targeted world position
  141897. */
  141898. agentTeleport(index: number, destination: Vector3): void;
  141899. /**
  141900. * Update agent parameters
  141901. * @param index agent index returned by addAgent
  141902. * @param parameters agent parameters
  141903. */
  141904. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  141905. /**
  141906. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  141907. * The queries will try to find a solution within those bounds
  141908. * default is (1,1,1)
  141909. * @param extent x,y,z value that define the extent around the queries point of reference
  141910. */
  141911. setDefaultQueryExtent(extent: Vector3): void;
  141912. /**
  141913. * Get the Bounding box extent specified by setDefaultQueryExtent
  141914. * @returns the box extent values
  141915. */
  141916. getDefaultQueryExtent(): Vector3;
  141917. /**
  141918. * Get the Bounding box extent result specified by setDefaultQueryExtent
  141919. * @param result output the box extent values
  141920. */
  141921. getDefaultQueryExtentToRef(result: Vector3): void;
  141922. /**
  141923. * Release all resources
  141924. */
  141925. dispose(): void;
  141926. }
  141927. /**
  141928. * Configures an agent
  141929. */
  141930. export interface IAgentParameters {
  141931. /**
  141932. * Agent radius. [Limit: >= 0]
  141933. */
  141934. radius: number;
  141935. /**
  141936. * Agent height. [Limit: > 0]
  141937. */
  141938. height: number;
  141939. /**
  141940. * Maximum allowed acceleration. [Limit: >= 0]
  141941. */
  141942. maxAcceleration: number;
  141943. /**
  141944. * Maximum allowed speed. [Limit: >= 0]
  141945. */
  141946. maxSpeed: number;
  141947. /**
  141948. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  141949. */
  141950. collisionQueryRange: number;
  141951. /**
  141952. * The path visibility optimization range. [Limit: > 0]
  141953. */
  141954. pathOptimizationRange: number;
  141955. /**
  141956. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  141957. */
  141958. separationWeight: number;
  141959. }
  141960. /**
  141961. * Configures the navigation mesh creation
  141962. */
  141963. export interface INavMeshParameters {
  141964. /**
  141965. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  141966. */
  141967. cs: number;
  141968. /**
  141969. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  141970. */
  141971. ch: number;
  141972. /**
  141973. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  141974. */
  141975. walkableSlopeAngle: number;
  141976. /**
  141977. * Minimum floor to 'ceiling' height that will still allow the floor area to
  141978. * be considered walkable. [Limit: >= 3] [Units: vx]
  141979. */
  141980. walkableHeight: number;
  141981. /**
  141982. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  141983. */
  141984. walkableClimb: number;
  141985. /**
  141986. * The distance to erode/shrink the walkable area of the heightfield away from
  141987. * obstructions. [Limit: >=0] [Units: vx]
  141988. */
  141989. walkableRadius: number;
  141990. /**
  141991. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  141992. */
  141993. maxEdgeLen: number;
  141994. /**
  141995. * The maximum distance a simplfied contour's border edges should deviate
  141996. * the original raw contour. [Limit: >=0] [Units: vx]
  141997. */
  141998. maxSimplificationError: number;
  141999. /**
  142000. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  142001. */
  142002. minRegionArea: number;
  142003. /**
  142004. * Any regions with a span count smaller than this value will, if possible,
  142005. * be merged with larger regions. [Limit: >=0] [Units: vx]
  142006. */
  142007. mergeRegionArea: number;
  142008. /**
  142009. * The maximum number of vertices allowed for polygons generated during the
  142010. * contour to polygon conversion process. [Limit: >= 3]
  142011. */
  142012. maxVertsPerPoly: number;
  142013. /**
  142014. * Sets the sampling distance to use when generating the detail mesh.
  142015. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  142016. */
  142017. detailSampleDist: number;
  142018. /**
  142019. * The maximum distance the detail mesh surface should deviate from heightfield
  142020. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  142021. */
  142022. detailSampleMaxError: number;
  142023. }
  142024. }
  142025. declare module BABYLON {
  142026. /**
  142027. * RecastJS navigation plugin
  142028. */
  142029. export class RecastJSPlugin implements INavigationEnginePlugin {
  142030. /**
  142031. * Reference to the Recast library
  142032. */
  142033. bjsRECAST: any;
  142034. /**
  142035. * plugin name
  142036. */
  142037. name: string;
  142038. /**
  142039. * the first navmesh created. We might extend this to support multiple navmeshes
  142040. */
  142041. navMesh: any;
  142042. /**
  142043. * Initializes the recastJS plugin
  142044. * @param recastInjection can be used to inject your own recast reference
  142045. */
  142046. constructor(recastInjection?: any);
  142047. /**
  142048. * Creates a navigation mesh
  142049. * @param meshes array of all the geometry used to compute the navigatio mesh
  142050. * @param parameters bunch of parameters used to filter geometry
  142051. */
  142052. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142053. /**
  142054. * Create a navigation mesh debug mesh
  142055. * @param scene is where the mesh will be added
  142056. * @returns debug display mesh
  142057. */
  142058. createDebugNavMesh(scene: Scene): Mesh;
  142059. /**
  142060. * Get a navigation mesh constrained position, closest to the parameter position
  142061. * @param position world position
  142062. * @returns the closest point to position constrained by the navigation mesh
  142063. */
  142064. getClosestPoint(position: Vector3): Vector3;
  142065. /**
  142066. * Get a navigation mesh constrained position, closest to the parameter position
  142067. * @param position world position
  142068. * @param result output the closest point to position constrained by the navigation mesh
  142069. */
  142070. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142071. /**
  142072. * Get a navigation mesh constrained position, within a particular radius
  142073. * @param position world position
  142074. * @param maxRadius the maximum distance to the constrained world position
  142075. * @returns the closest point to position constrained by the navigation mesh
  142076. */
  142077. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142078. /**
  142079. * Get a navigation mesh constrained position, within a particular radius
  142080. * @param position world position
  142081. * @param maxRadius the maximum distance to the constrained world position
  142082. * @param result output the closest point to position constrained by the navigation mesh
  142083. */
  142084. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142085. /**
  142086. * Compute the final position from a segment made of destination-position
  142087. * @param position world position
  142088. * @param destination world position
  142089. * @returns the resulting point along the navmesh
  142090. */
  142091. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142092. /**
  142093. * Compute the final position from a segment made of destination-position
  142094. * @param position world position
  142095. * @param destination world position
  142096. * @param result output the resulting point along the navmesh
  142097. */
  142098. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142099. /**
  142100. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142101. * @param start world position
  142102. * @param end world position
  142103. * @returns array containing world position composing the path
  142104. */
  142105. computePath(start: Vector3, end: Vector3): Vector3[];
  142106. /**
  142107. * Create a new Crowd so you can add agents
  142108. * @param maxAgents the maximum agent count in the crowd
  142109. * @param maxAgentRadius the maximum radius an agent can have
  142110. * @param scene to attach the crowd to
  142111. * @returns the crowd you can add agents to
  142112. */
  142113. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142114. /**
  142115. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142116. * The queries will try to find a solution within those bounds
  142117. * default is (1,1,1)
  142118. * @param extent x,y,z value that define the extent around the queries point of reference
  142119. */
  142120. setDefaultQueryExtent(extent: Vector3): void;
  142121. /**
  142122. * Get the Bounding box extent specified by setDefaultQueryExtent
  142123. * @returns the box extent values
  142124. */
  142125. getDefaultQueryExtent(): Vector3;
  142126. /**
  142127. * build the navmesh from a previously saved state using getNavmeshData
  142128. * @param data the Uint8Array returned by getNavmeshData
  142129. */
  142130. buildFromNavmeshData(data: Uint8Array): void;
  142131. /**
  142132. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142133. * @returns data the Uint8Array that can be saved and reused
  142134. */
  142135. getNavmeshData(): Uint8Array;
  142136. /**
  142137. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142138. * @param result output the box extent values
  142139. */
  142140. getDefaultQueryExtentToRef(result: Vector3): void;
  142141. /**
  142142. * Disposes
  142143. */
  142144. dispose(): void;
  142145. /**
  142146. * If this plugin is supported
  142147. * @returns true if plugin is supported
  142148. */
  142149. isSupported(): boolean;
  142150. }
  142151. /**
  142152. * Recast detour crowd implementation
  142153. */
  142154. export class RecastJSCrowd implements ICrowd {
  142155. /**
  142156. * Recast/detour plugin
  142157. */
  142158. bjsRECASTPlugin: RecastJSPlugin;
  142159. /**
  142160. * Link to the detour crowd
  142161. */
  142162. recastCrowd: any;
  142163. /**
  142164. * One transform per agent
  142165. */
  142166. transforms: TransformNode[];
  142167. /**
  142168. * All agents created
  142169. */
  142170. agents: number[];
  142171. /**
  142172. * Link to the scene is kept to unregister the crowd from the scene
  142173. */
  142174. private _scene;
  142175. /**
  142176. * Observer for crowd updates
  142177. */
  142178. private _onBeforeAnimationsObserver;
  142179. /**
  142180. * Constructor
  142181. * @param plugin recastJS plugin
  142182. * @param maxAgents the maximum agent count in the crowd
  142183. * @param maxAgentRadius the maximum radius an agent can have
  142184. * @param scene to attach the crowd to
  142185. * @returns the crowd you can add agents to
  142186. */
  142187. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  142188. /**
  142189. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142190. * You can attach anything to that node. The node position is updated in the scene update tick.
  142191. * @param pos world position that will be constrained by the navigation mesh
  142192. * @param parameters agent parameters
  142193. * @param transform hooked to the agent that will be update by the scene
  142194. * @returns agent index
  142195. */
  142196. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142197. /**
  142198. * Returns the agent position in world space
  142199. * @param index agent index returned by addAgent
  142200. * @returns world space position
  142201. */
  142202. getAgentPosition(index: number): Vector3;
  142203. /**
  142204. * Returns the agent position result in world space
  142205. * @param index agent index returned by addAgent
  142206. * @param result output world space position
  142207. */
  142208. getAgentPositionToRef(index: number, result: Vector3): void;
  142209. /**
  142210. * Returns the agent velocity in world space
  142211. * @param index agent index returned by addAgent
  142212. * @returns world space velocity
  142213. */
  142214. getAgentVelocity(index: number): Vector3;
  142215. /**
  142216. * Returns the agent velocity result in world space
  142217. * @param index agent index returned by addAgent
  142218. * @param result output world space velocity
  142219. */
  142220. getAgentVelocityToRef(index: number, result: Vector3): void;
  142221. /**
  142222. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142223. * @param index agent index returned by addAgent
  142224. * @param destination targeted world position
  142225. */
  142226. agentGoto(index: number, destination: Vector3): void;
  142227. /**
  142228. * Teleport the agent to a new position
  142229. * @param index agent index returned by addAgent
  142230. * @param destination targeted world position
  142231. */
  142232. agentTeleport(index: number, destination: Vector3): void;
  142233. /**
  142234. * Update agent parameters
  142235. * @param index agent index returned by addAgent
  142236. * @param parameters agent parameters
  142237. */
  142238. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142239. /**
  142240. * remove a particular agent previously created
  142241. * @param index agent index returned by addAgent
  142242. */
  142243. removeAgent(index: number): void;
  142244. /**
  142245. * get the list of all agents attached to this crowd
  142246. * @returns list of agent indices
  142247. */
  142248. getAgents(): number[];
  142249. /**
  142250. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142251. * @param deltaTime in seconds
  142252. */
  142253. update(deltaTime: number): void;
  142254. /**
  142255. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142256. * The queries will try to find a solution within those bounds
  142257. * default is (1,1,1)
  142258. * @param extent x,y,z value that define the extent around the queries point of reference
  142259. */
  142260. setDefaultQueryExtent(extent: Vector3): void;
  142261. /**
  142262. * Get the Bounding box extent specified by setDefaultQueryExtent
  142263. * @returns the box extent values
  142264. */
  142265. getDefaultQueryExtent(): Vector3;
  142266. /**
  142267. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142268. * @param result output the box extent values
  142269. */
  142270. getDefaultQueryExtentToRef(result: Vector3): void;
  142271. /**
  142272. * Release all resources
  142273. */
  142274. dispose(): void;
  142275. }
  142276. }
  142277. declare module BABYLON {
  142278. /**
  142279. * Class used to enable access to IndexedDB
  142280. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  142281. */
  142282. export class Database implements IOfflineProvider {
  142283. private _callbackManifestChecked;
  142284. private _currentSceneUrl;
  142285. private _db;
  142286. private _enableSceneOffline;
  142287. private _enableTexturesOffline;
  142288. private _manifestVersionFound;
  142289. private _mustUpdateRessources;
  142290. private _hasReachedQuota;
  142291. private _isSupported;
  142292. private _idbFactory;
  142293. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  142294. private static IsUASupportingBlobStorage;
  142295. /**
  142296. * Gets a boolean indicating if Database storate is enabled (off by default)
  142297. */
  142298. static IDBStorageEnabled: boolean;
  142299. /**
  142300. * Gets a boolean indicating if scene must be saved in the database
  142301. */
  142302. get enableSceneOffline(): boolean;
  142303. /**
  142304. * Gets a boolean indicating if textures must be saved in the database
  142305. */
  142306. get enableTexturesOffline(): boolean;
  142307. /**
  142308. * Creates a new Database
  142309. * @param urlToScene defines the url to load the scene
  142310. * @param callbackManifestChecked defines the callback to use when manifest is checked
  142311. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  142312. */
  142313. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  142314. private static _ParseURL;
  142315. private static _ReturnFullUrlLocation;
  142316. private _checkManifestFile;
  142317. /**
  142318. * Open the database and make it available
  142319. * @param successCallback defines the callback to call on success
  142320. * @param errorCallback defines the callback to call on error
  142321. */
  142322. open(successCallback: () => void, errorCallback: () => void): void;
  142323. /**
  142324. * Loads an image from the database
  142325. * @param url defines the url to load from
  142326. * @param image defines the target DOM image
  142327. */
  142328. loadImage(url: string, image: HTMLImageElement): void;
  142329. private _loadImageFromDBAsync;
  142330. private _saveImageIntoDBAsync;
  142331. private _checkVersionFromDB;
  142332. private _loadVersionFromDBAsync;
  142333. private _saveVersionIntoDBAsync;
  142334. /**
  142335. * Loads a file from database
  142336. * @param url defines the URL to load from
  142337. * @param sceneLoaded defines a callback to call on success
  142338. * @param progressCallBack defines a callback to call when progress changed
  142339. * @param errorCallback defines a callback to call on error
  142340. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  142341. */
  142342. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  142343. private _loadFileAsync;
  142344. private _saveFileAsync;
  142345. /**
  142346. * Validates if xhr data is correct
  142347. * @param xhr defines the request to validate
  142348. * @param dataType defines the expected data type
  142349. * @returns true if data is correct
  142350. */
  142351. private static _ValidateXHRData;
  142352. }
  142353. }
  142354. declare module BABYLON {
  142355. /** @hidden */
  142356. export var gpuUpdateParticlesPixelShader: {
  142357. name: string;
  142358. shader: string;
  142359. };
  142360. }
  142361. declare module BABYLON {
  142362. /** @hidden */
  142363. export var gpuUpdateParticlesVertexShader: {
  142364. name: string;
  142365. shader: string;
  142366. };
  142367. }
  142368. declare module BABYLON {
  142369. /** @hidden */
  142370. export var clipPlaneFragmentDeclaration2: {
  142371. name: string;
  142372. shader: string;
  142373. };
  142374. }
  142375. declare module BABYLON {
  142376. /** @hidden */
  142377. export var gpuRenderParticlesPixelShader: {
  142378. name: string;
  142379. shader: string;
  142380. };
  142381. }
  142382. declare module BABYLON {
  142383. /** @hidden */
  142384. export var clipPlaneVertexDeclaration2: {
  142385. name: string;
  142386. shader: string;
  142387. };
  142388. }
  142389. declare module BABYLON {
  142390. /** @hidden */
  142391. export var gpuRenderParticlesVertexShader: {
  142392. name: string;
  142393. shader: string;
  142394. };
  142395. }
  142396. declare module BABYLON {
  142397. /**
  142398. * This represents a GPU particle system in Babylon
  142399. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  142400. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  142401. */
  142402. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  142403. /**
  142404. * The layer mask we are rendering the particles through.
  142405. */
  142406. layerMask: number;
  142407. private _capacity;
  142408. private _activeCount;
  142409. private _currentActiveCount;
  142410. private _accumulatedCount;
  142411. private _renderEffect;
  142412. private _updateEffect;
  142413. private _buffer0;
  142414. private _buffer1;
  142415. private _spriteBuffer;
  142416. private _updateVAO;
  142417. private _renderVAO;
  142418. private _targetIndex;
  142419. private _sourceBuffer;
  142420. private _targetBuffer;
  142421. private _engine;
  142422. private _currentRenderId;
  142423. private _started;
  142424. private _stopped;
  142425. private _timeDelta;
  142426. private _randomTexture;
  142427. private _randomTexture2;
  142428. private _attributesStrideSize;
  142429. private _updateEffectOptions;
  142430. private _randomTextureSize;
  142431. private _actualFrame;
  142432. private _customEffect;
  142433. private readonly _rawTextureWidth;
  142434. /**
  142435. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  142436. */
  142437. static get IsSupported(): boolean;
  142438. /**
  142439. * An event triggered when the system is disposed.
  142440. */
  142441. onDisposeObservable: Observable<IParticleSystem>;
  142442. /**
  142443. * Gets the maximum number of particles active at the same time.
  142444. * @returns The max number of active particles.
  142445. */
  142446. getCapacity(): number;
  142447. /**
  142448. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  142449. * to override the particles.
  142450. */
  142451. forceDepthWrite: boolean;
  142452. /**
  142453. * Gets or set the number of active particles
  142454. */
  142455. get activeParticleCount(): number;
  142456. set activeParticleCount(value: number);
  142457. private _preWarmDone;
  142458. /**
  142459. * Specifies if the particles are updated in emitter local space or world space.
  142460. */
  142461. isLocal: boolean;
  142462. /**
  142463. * Is this system ready to be used/rendered
  142464. * @return true if the system is ready
  142465. */
  142466. isReady(): boolean;
  142467. /**
  142468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  142469. * @returns True if it has been started, otherwise false.
  142470. */
  142471. isStarted(): boolean;
  142472. /**
  142473. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  142474. * @returns True if it has been stopped, otherwise false.
  142475. */
  142476. isStopped(): boolean;
  142477. /**
  142478. * Gets a boolean indicating that the system is stopping
  142479. * @returns true if the system is currently stopping
  142480. */
  142481. isStopping(): boolean;
  142482. /**
  142483. * Gets the number of particles active at the same time.
  142484. * @returns The number of active particles.
  142485. */
  142486. getActiveCount(): number;
  142487. /**
  142488. * Starts the particle system and begins to emit
  142489. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  142490. */
  142491. start(delay?: number): void;
  142492. /**
  142493. * Stops the particle system.
  142494. */
  142495. stop(): void;
  142496. /**
  142497. * Remove all active particles
  142498. */
  142499. reset(): void;
  142500. /**
  142501. * Returns the string "GPUParticleSystem"
  142502. * @returns a string containing the class name
  142503. */
  142504. getClassName(): string;
  142505. /**
  142506. * Gets the custom effect used to render the particles
  142507. * @param blendMode Blend mode for which the effect should be retrieved
  142508. * @returns The effect
  142509. */
  142510. getCustomEffect(blendMode?: number): Nullable<Effect>;
  142511. /**
  142512. * Sets the custom effect used to render the particles
  142513. * @param effect The effect to set
  142514. * @param blendMode Blend mode for which the effect should be set
  142515. */
  142516. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  142517. /** @hidden */
  142518. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  142519. /**
  142520. * Observable that will be called just before the particles are drawn
  142521. */
  142522. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  142523. /**
  142524. * Gets the name of the particle vertex shader
  142525. */
  142526. get vertexShaderName(): string;
  142527. private _colorGradientsTexture;
  142528. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  142529. /**
  142530. * Adds a new color gradient
  142531. * @param gradient defines the gradient to use (between 0 and 1)
  142532. * @param color1 defines the color to affect to the specified gradient
  142533. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  142534. * @returns the current particle system
  142535. */
  142536. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  142537. private _refreshColorGradient;
  142538. /** Force the system to rebuild all gradients that need to be resync */
  142539. forceRefreshGradients(): void;
  142540. /**
  142541. * Remove a specific color gradient
  142542. * @param gradient defines the gradient to remove
  142543. * @returns the current particle system
  142544. */
  142545. removeColorGradient(gradient: number): GPUParticleSystem;
  142546. private _angularSpeedGradientsTexture;
  142547. private _sizeGradientsTexture;
  142548. private _velocityGradientsTexture;
  142549. private _limitVelocityGradientsTexture;
  142550. private _dragGradientsTexture;
  142551. private _addFactorGradient;
  142552. /**
  142553. * Adds a new size gradient
  142554. * @param gradient defines the gradient to use (between 0 and 1)
  142555. * @param factor defines the size factor to affect to the specified gradient
  142556. * @returns the current particle system
  142557. */
  142558. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  142559. /**
  142560. * Remove a specific size gradient
  142561. * @param gradient defines the gradient to remove
  142562. * @returns the current particle system
  142563. */
  142564. removeSizeGradient(gradient: number): GPUParticleSystem;
  142565. private _refreshFactorGradient;
  142566. /**
  142567. * Adds a new angular speed gradient
  142568. * @param gradient defines the gradient to use (between 0 and 1)
  142569. * @param factor defines the angular speed to affect to the specified gradient
  142570. * @returns the current particle system
  142571. */
  142572. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  142573. /**
  142574. * Remove a specific angular speed gradient
  142575. * @param gradient defines the gradient to remove
  142576. * @returns the current particle system
  142577. */
  142578. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  142579. /**
  142580. * Adds a new velocity gradient
  142581. * @param gradient defines the gradient to use (between 0 and 1)
  142582. * @param factor defines the velocity to affect to the specified gradient
  142583. * @returns the current particle system
  142584. */
  142585. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  142586. /**
  142587. * Remove a specific velocity gradient
  142588. * @param gradient defines the gradient to remove
  142589. * @returns the current particle system
  142590. */
  142591. removeVelocityGradient(gradient: number): GPUParticleSystem;
  142592. /**
  142593. * Adds a new limit velocity gradient
  142594. * @param gradient defines the gradient to use (between 0 and 1)
  142595. * @param factor defines the limit velocity value to affect to the specified gradient
  142596. * @returns the current particle system
  142597. */
  142598. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  142599. /**
  142600. * Remove a specific limit velocity gradient
  142601. * @param gradient defines the gradient to remove
  142602. * @returns the current particle system
  142603. */
  142604. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  142605. /**
  142606. * Adds a new drag gradient
  142607. * @param gradient defines the gradient to use (between 0 and 1)
  142608. * @param factor defines the drag value to affect to the specified gradient
  142609. * @returns the current particle system
  142610. */
  142611. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  142612. /**
  142613. * Remove a specific drag gradient
  142614. * @param gradient defines the gradient to remove
  142615. * @returns the current particle system
  142616. */
  142617. removeDragGradient(gradient: number): GPUParticleSystem;
  142618. /**
  142619. * Not supported by GPUParticleSystem
  142620. * @param gradient defines the gradient to use (between 0 and 1)
  142621. * @param factor defines the emit rate value to affect to the specified gradient
  142622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  142623. * @returns the current particle system
  142624. */
  142625. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  142626. /**
  142627. * Not supported by GPUParticleSystem
  142628. * @param gradient defines the gradient to remove
  142629. * @returns the current particle system
  142630. */
  142631. removeEmitRateGradient(gradient: number): IParticleSystem;
  142632. /**
  142633. * Not supported by GPUParticleSystem
  142634. * @param gradient defines the gradient to use (between 0 and 1)
  142635. * @param factor defines the start size value to affect to the specified gradient
  142636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  142637. * @returns the current particle system
  142638. */
  142639. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  142640. /**
  142641. * Not supported by GPUParticleSystem
  142642. * @param gradient defines the gradient to remove
  142643. * @returns the current particle system
  142644. */
  142645. removeStartSizeGradient(gradient: number): IParticleSystem;
  142646. /**
  142647. * Not supported by GPUParticleSystem
  142648. * @param gradient defines the gradient to use (between 0 and 1)
  142649. * @param min defines the color remap minimal range
  142650. * @param max defines the color remap maximal range
  142651. * @returns the current particle system
  142652. */
  142653. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  142654. /**
  142655. * Not supported by GPUParticleSystem
  142656. * @param gradient defines the gradient to remove
  142657. * @returns the current particle system
  142658. */
  142659. removeColorRemapGradient(): IParticleSystem;
  142660. /**
  142661. * Not supported by GPUParticleSystem
  142662. * @param gradient defines the gradient to use (between 0 and 1)
  142663. * @param min defines the alpha remap minimal range
  142664. * @param max defines the alpha remap maximal range
  142665. * @returns the current particle system
  142666. */
  142667. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  142668. /**
  142669. * Not supported by GPUParticleSystem
  142670. * @param gradient defines the gradient to remove
  142671. * @returns the current particle system
  142672. */
  142673. removeAlphaRemapGradient(): IParticleSystem;
  142674. /**
  142675. * Not supported by GPUParticleSystem
  142676. * @param gradient defines the gradient to use (between 0 and 1)
  142677. * @param color defines the color to affect to the specified gradient
  142678. * @returns the current particle system
  142679. */
  142680. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  142681. /**
  142682. * Not supported by GPUParticleSystem
  142683. * @param gradient defines the gradient to remove
  142684. * @returns the current particle system
  142685. */
  142686. removeRampGradient(): IParticleSystem;
  142687. /**
  142688. * Not supported by GPUParticleSystem
  142689. * @returns the list of ramp gradients
  142690. */
  142691. getRampGradients(): Nullable<Array<Color3Gradient>>;
  142692. /**
  142693. * Not supported by GPUParticleSystem
  142694. * Gets or sets a boolean indicating that ramp gradients must be used
  142695. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  142696. */
  142697. get useRampGradients(): boolean;
  142698. set useRampGradients(value: boolean);
  142699. /**
  142700. * Not supported by GPUParticleSystem
  142701. * @param gradient defines the gradient to use (between 0 and 1)
  142702. * @param factor defines the life time factor to affect to the specified gradient
  142703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  142704. * @returns the current particle system
  142705. */
  142706. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  142707. /**
  142708. * Not supported by GPUParticleSystem
  142709. * @param gradient defines the gradient to remove
  142710. * @returns the current particle system
  142711. */
  142712. removeLifeTimeGradient(gradient: number): IParticleSystem;
  142713. /**
  142714. * Instantiates a GPU particle system.
  142715. * 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.
  142716. * @param name The name of the particle system
  142717. * @param options The options used to create the system
  142718. * @param scene The scene the particle system belongs to
  142719. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  142720. * @param customEffect a custom effect used to change the way particles are rendered by default
  142721. */
  142722. constructor(name: string, options: Partial<{
  142723. capacity: number;
  142724. randomTextureSize: number;
  142725. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  142726. protected _reset(): void;
  142727. private _createUpdateVAO;
  142728. private _createRenderVAO;
  142729. private _initialize;
  142730. /** @hidden */
  142731. _recreateUpdateEffect(): void;
  142732. private _getEffect;
  142733. /**
  142734. * Fill the defines array according to the current settings of the particle system
  142735. * @param defines Array to be updated
  142736. * @param blendMode blend mode to take into account when updating the array
  142737. */
  142738. fillDefines(defines: Array<string>, blendMode?: number): void;
  142739. /**
  142740. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  142741. * @param uniforms Uniforms array to fill
  142742. * @param attributes Attributes array to fill
  142743. * @param samplers Samplers array to fill
  142744. */
  142745. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  142746. /** @hidden */
  142747. _recreateRenderEffect(): Effect;
  142748. /**
  142749. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  142750. * @param preWarm defines if we are in the pre-warmimg phase
  142751. */
  142752. animate(preWarm?: boolean): void;
  142753. private _createFactorGradientTexture;
  142754. private _createSizeGradientTexture;
  142755. private _createAngularSpeedGradientTexture;
  142756. private _createVelocityGradientTexture;
  142757. private _createLimitVelocityGradientTexture;
  142758. private _createDragGradientTexture;
  142759. private _createColorGradientTexture;
  142760. /**
  142761. * Renders the particle system in its current state
  142762. * @param preWarm defines if the system should only update the particles but not render them
  142763. * @returns the current number of particles
  142764. */
  142765. render(preWarm?: boolean): number;
  142766. /**
  142767. * Rebuilds the particle system
  142768. */
  142769. rebuild(): void;
  142770. private _releaseBuffers;
  142771. private _releaseVAOs;
  142772. /**
  142773. * Disposes the particle system and free the associated resources
  142774. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  142775. */
  142776. dispose(disposeTexture?: boolean): void;
  142777. /**
  142778. * Clones the particle system.
  142779. * @param name The name of the cloned object
  142780. * @param newEmitter The new emitter to use
  142781. * @returns the cloned particle system
  142782. */
  142783. clone(name: string, newEmitter: any): GPUParticleSystem;
  142784. /**
  142785. * Serializes the particle system to a JSON object
  142786. * @param serializeTexture defines if the texture must be serialized as well
  142787. * @returns the JSON object
  142788. */
  142789. serialize(serializeTexture?: boolean): any;
  142790. /**
  142791. * Parses a JSON object to create a GPU particle system.
  142792. * @param parsedParticleSystem The JSON object to parse
  142793. * @param scene The scene to create the particle system in
  142794. * @param rootUrl The root url to use to load external dependencies like texture
  142795. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  142796. * @returns the parsed GPU particle system
  142797. */
  142798. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  142799. }
  142800. }
  142801. declare module BABYLON {
  142802. /**
  142803. * Represents a set of particle systems working together to create a specific effect
  142804. */
  142805. export class ParticleSystemSet implements IDisposable {
  142806. /**
  142807. * Gets or sets base Assets URL
  142808. */
  142809. static BaseAssetsUrl: string;
  142810. private _emitterCreationOptions;
  142811. private _emitterNode;
  142812. /**
  142813. * Gets the particle system list
  142814. */
  142815. systems: IParticleSystem[];
  142816. /**
  142817. * Gets the emitter node used with this set
  142818. */
  142819. get emitterNode(): Nullable<TransformNode>;
  142820. /**
  142821. * Creates a new emitter mesh as a sphere
  142822. * @param options defines the options used to create the sphere
  142823. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  142824. * @param scene defines the hosting scene
  142825. */
  142826. setEmitterAsSphere(options: {
  142827. diameter: number;
  142828. segments: number;
  142829. color: Color3;
  142830. }, renderingGroupId: number, scene: Scene): void;
  142831. /**
  142832. * Starts all particle systems of the set
  142833. * @param emitter defines an optional mesh to use as emitter for the particle systems
  142834. */
  142835. start(emitter?: AbstractMesh): void;
  142836. /**
  142837. * Release all associated resources
  142838. */
  142839. dispose(): void;
  142840. /**
  142841. * Serialize the set into a JSON compatible object
  142842. * @param serializeTexture defines if the texture must be serialized as well
  142843. * @returns a JSON compatible representation of the set
  142844. */
  142845. serialize(serializeTexture?: boolean): any;
  142846. /**
  142847. * Parse a new ParticleSystemSet from a serialized source
  142848. * @param data defines a JSON compatible representation of the set
  142849. * @param scene defines the hosting scene
  142850. * @param gpu defines if we want GPU particles or CPU particles
  142851. * @returns a new ParticleSystemSet
  142852. */
  142853. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  142854. }
  142855. }
  142856. declare module BABYLON {
  142857. /**
  142858. * This class is made for on one-liner static method to help creating particle system set.
  142859. */
  142860. export class ParticleHelper {
  142861. /**
  142862. * Gets or sets base Assets URL
  142863. */
  142864. static BaseAssetsUrl: string;
  142865. /** Define the Url to load snippets */
  142866. static SnippetUrl: string;
  142867. /**
  142868. * Create a default particle system that you can tweak
  142869. * @param emitter defines the emitter to use
  142870. * @param capacity defines the system capacity (default is 500 particles)
  142871. * @param scene defines the hosting scene
  142872. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  142873. * @returns the new Particle system
  142874. */
  142875. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  142876. /**
  142877. * This is the main static method (one-liner) of this helper to create different particle systems
  142878. * @param type This string represents the type to the particle system to create
  142879. * @param scene The scene where the particle system should live
  142880. * @param gpu If the system will use gpu
  142881. * @returns the ParticleSystemSet created
  142882. */
  142883. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  142884. /**
  142885. * Static function used to export a particle system to a ParticleSystemSet variable.
  142886. * Please note that the emitter shape is not exported
  142887. * @param systems defines the particle systems to export
  142888. * @returns the created particle system set
  142889. */
  142890. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  142891. /**
  142892. * Creates a particle system from a snippet saved in a remote file
  142893. * @param name defines the name of the particle system to create
  142894. * @param url defines the url to load from
  142895. * @param scene defines the hosting scene
  142896. * @param gpu If the system will use gpu
  142897. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  142898. * @returns a promise that will resolve to the new particle system
  142899. */
  142900. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  142901. /**
  142902. * Creates a particle system from a snippet saved by the particle system editor
  142903. * @param snippetId defines the snippet to load
  142904. * @param scene defines the hosting scene
  142905. * @param gpu If the system will use gpu
  142906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  142907. * @returns a promise that will resolve to the new particle system
  142908. */
  142909. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  142910. }
  142911. }
  142912. declare module BABYLON {
  142913. interface Engine {
  142914. /**
  142915. * Create an effect to use with particle systems.
  142916. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  142917. * the particle system for which you want to create a custom effect in the last parameter
  142918. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  142919. * @param uniformsNames defines a list of attribute names
  142920. * @param samplers defines an array of string used to represent textures
  142921. * @param defines defines the string containing the defines to use to compile the shaders
  142922. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  142923. * @param onCompiled defines a function to call when the effect creation is successful
  142924. * @param onError defines a function to call when the effect creation has failed
  142925. * @param particleSystem the particle system you want to create the effect for
  142926. * @returns the new Effect
  142927. */
  142928. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  142929. }
  142930. interface Mesh {
  142931. /**
  142932. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  142933. * @returns an array of IParticleSystem
  142934. */
  142935. getEmittedParticleSystems(): IParticleSystem[];
  142936. /**
  142937. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  142938. * @returns an array of IParticleSystem
  142939. */
  142940. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  142941. }
  142942. /**
  142943. * @hidden
  142944. */
  142945. export var _IDoNeedToBeInTheBuild: number;
  142946. }
  142947. declare module BABYLON {
  142948. /** Defines the 4 color options */
  142949. export enum PointColor {
  142950. /** color value */
  142951. Color = 2,
  142952. /** uv value */
  142953. UV = 1,
  142954. /** random value */
  142955. Random = 0,
  142956. /** stated value */
  142957. Stated = 3
  142958. }
  142959. /**
  142960. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  142961. * 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.
  142962. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  142963. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  142964. *
  142965. * Full documentation here : TO BE ENTERED
  142966. */
  142967. export class PointsCloudSystem implements IDisposable {
  142968. /**
  142969. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  142970. * Example : var p = SPS.particles[i];
  142971. */
  142972. particles: CloudPoint[];
  142973. /**
  142974. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  142975. */
  142976. nbParticles: number;
  142977. /**
  142978. * This a counter for your own usage. It's not set by any SPS functions.
  142979. */
  142980. counter: number;
  142981. /**
  142982. * The PCS name. This name is also given to the underlying mesh.
  142983. */
  142984. name: string;
  142985. /**
  142986. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  142987. */
  142988. mesh: Mesh;
  142989. /**
  142990. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  142991. * Please read :
  142992. */
  142993. vars: any;
  142994. /**
  142995. * @hidden
  142996. */
  142997. _size: number;
  142998. private _scene;
  142999. private _promises;
  143000. private _positions;
  143001. private _indices;
  143002. private _normals;
  143003. private _colors;
  143004. private _uvs;
  143005. private _indices32;
  143006. private _positions32;
  143007. private _colors32;
  143008. private _uvs32;
  143009. private _updatable;
  143010. private _isVisibilityBoxLocked;
  143011. private _alwaysVisible;
  143012. private _groups;
  143013. private _groupCounter;
  143014. private _computeParticleColor;
  143015. private _computeParticleTexture;
  143016. private _computeParticleRotation;
  143017. private _computeBoundingBox;
  143018. private _isReady;
  143019. /**
  143020. * Creates a PCS (Points Cloud System) object
  143021. * @param name (String) is the PCS name, this will be the underlying mesh name
  143022. * @param pointSize (number) is the size for each point
  143023. * @param scene (Scene) is the scene in which the PCS is added
  143024. * @param options defines the options of the PCS e.g.
  143025. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  143026. */
  143027. constructor(name: string, pointSize: number, scene: Scene, options?: {
  143028. updatable?: boolean;
  143029. });
  143030. /**
  143031. * Builds the PCS underlying mesh. Returns a standard Mesh.
  143032. * If no points were added to the PCS, the returned mesh is just a single point.
  143033. * @returns a promise for the created mesh
  143034. */
  143035. buildMeshAsync(): Promise<Mesh>;
  143036. /**
  143037. * @hidden
  143038. */
  143039. private _buildMesh;
  143040. private _addParticle;
  143041. private _randomUnitVector;
  143042. private _getColorIndicesForCoord;
  143043. private _setPointsColorOrUV;
  143044. private _colorFromTexture;
  143045. private _calculateDensity;
  143046. /**
  143047. * Adds points to the PCS in random positions within a unit sphere
  143048. * @param nb (positive integer) the number of particles to be created from this model
  143049. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  143050. * @returns the number of groups in the system
  143051. */
  143052. addPoints(nb: number, pointFunction?: any): number;
  143053. /**
  143054. * Adds points to the PCS from the surface of the model shape
  143055. * @param mesh is any Mesh object that will be used as a surface model for the points
  143056. * @param nb (positive integer) the number of particles to be created from this model
  143057. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143058. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143059. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143060. * @returns the number of groups in the system
  143061. */
  143062. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143063. /**
  143064. * Adds points to the PCS inside the model shape
  143065. * @param mesh is any Mesh object that will be used as a surface model for the points
  143066. * @param nb (positive integer) the number of particles to be created from this model
  143067. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143068. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143069. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143070. * @returns the number of groups in the system
  143071. */
  143072. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143073. /**
  143074. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  143075. * This method calls `updateParticle()` for each particle of the SPS.
  143076. * For an animated SPS, it is usually called within the render loop.
  143077. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  143078. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  143079. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  143080. * @returns the PCS.
  143081. */
  143082. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  143083. /**
  143084. * Disposes the PCS.
  143085. */
  143086. dispose(): void;
  143087. /**
  143088. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  143089. * doc :
  143090. * @returns the PCS.
  143091. */
  143092. refreshVisibleSize(): PointsCloudSystem;
  143093. /**
  143094. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  143095. * @param size the size (float) of the visibility box
  143096. * note : this doesn't lock the PCS mesh bounding box.
  143097. * doc :
  143098. */
  143099. setVisibilityBox(size: number): void;
  143100. /**
  143101. * Gets whether the PCS is always visible or not
  143102. * doc :
  143103. */
  143104. get isAlwaysVisible(): boolean;
  143105. /**
  143106. * Sets the PCS as always visible or not
  143107. * doc :
  143108. */
  143109. set isAlwaysVisible(val: boolean);
  143110. /**
  143111. * Tells to `setParticles()` to compute the particle rotations or not
  143112. * Default value : false. The PCS is faster when it's set to false
  143113. * Note : particle rotations are only applied to parent particles
  143114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  143115. */
  143116. set computeParticleRotation(val: boolean);
  143117. /**
  143118. * Tells to `setParticles()` to compute the particle colors or not.
  143119. * Default value : true. The PCS is faster when it's set to false.
  143120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143121. */
  143122. set computeParticleColor(val: boolean);
  143123. set computeParticleTexture(val: boolean);
  143124. /**
  143125. * Gets if `setParticles()` computes the particle colors or not.
  143126. * Default value : false. The PCS is faster when it's set to false.
  143127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143128. */
  143129. get computeParticleColor(): boolean;
  143130. /**
  143131. * Gets if `setParticles()` computes the particle textures or not.
  143132. * Default value : false. The PCS is faster when it's set to false.
  143133. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  143134. */
  143135. get computeParticleTexture(): boolean;
  143136. /**
  143137. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  143138. */
  143139. set computeBoundingBox(val: boolean);
  143140. /**
  143141. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  143142. */
  143143. get computeBoundingBox(): boolean;
  143144. /**
  143145. * This function does nothing. It may be overwritten to set all the particle first values.
  143146. * The PCS doesn't call this function, you may have to call it by your own.
  143147. * doc :
  143148. */
  143149. initParticles(): void;
  143150. /**
  143151. * This function does nothing. It may be overwritten to recycle a particle
  143152. * The PCS doesn't call this function, you can to call it
  143153. * doc :
  143154. * @param particle The particle to recycle
  143155. * @returns the recycled particle
  143156. */
  143157. recycleParticle(particle: CloudPoint): CloudPoint;
  143158. /**
  143159. * Updates a particle : this function should be overwritten by the user.
  143160. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  143161. * doc :
  143162. * @example : just set a particle position or velocity and recycle conditions
  143163. * @param particle The particle to update
  143164. * @returns the updated particle
  143165. */
  143166. updateParticle(particle: CloudPoint): CloudPoint;
  143167. /**
  143168. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  143169. * This does nothing and may be overwritten by the user.
  143170. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143171. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143172. * @param update the boolean update value actually passed to setParticles()
  143173. */
  143174. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143175. /**
  143176. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  143177. * This will be passed three parameters.
  143178. * This does nothing and may be overwritten by the user.
  143179. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143181. * @param update the boolean update value actually passed to setParticles()
  143182. */
  143183. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143184. }
  143185. }
  143186. declare module BABYLON {
  143187. /**
  143188. * Represents one particle of a points cloud system.
  143189. */
  143190. export class CloudPoint {
  143191. /**
  143192. * particle global index
  143193. */
  143194. idx: number;
  143195. /**
  143196. * The color of the particle
  143197. */
  143198. color: Nullable<Color4>;
  143199. /**
  143200. * The world space position of the particle.
  143201. */
  143202. position: Vector3;
  143203. /**
  143204. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  143205. */
  143206. rotation: Vector3;
  143207. /**
  143208. * The world space rotation quaternion of the particle.
  143209. */
  143210. rotationQuaternion: Nullable<Quaternion>;
  143211. /**
  143212. * The uv of the particle.
  143213. */
  143214. uv: Nullable<Vector2>;
  143215. /**
  143216. * The current speed of the particle.
  143217. */
  143218. velocity: Vector3;
  143219. /**
  143220. * The pivot point in the particle local space.
  143221. */
  143222. pivot: Vector3;
  143223. /**
  143224. * Must the particle be translated from its pivot point in its local space ?
  143225. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  143226. * Default : false
  143227. */
  143228. translateFromPivot: boolean;
  143229. /**
  143230. * Index of this particle in the global "positions" array (Internal use)
  143231. * @hidden
  143232. */
  143233. _pos: number;
  143234. /**
  143235. * @hidden Index of this particle in the global "indices" array (Internal use)
  143236. */
  143237. _ind: number;
  143238. /**
  143239. * Group this particle belongs to
  143240. */
  143241. _group: PointsGroup;
  143242. /**
  143243. * Group id of this particle
  143244. */
  143245. groupId: number;
  143246. /**
  143247. * Index of the particle in its group id (Internal use)
  143248. */
  143249. idxInGroup: number;
  143250. /**
  143251. * @hidden Particle BoundingInfo object (Internal use)
  143252. */
  143253. _boundingInfo: BoundingInfo;
  143254. /**
  143255. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  143256. */
  143257. _pcs: PointsCloudSystem;
  143258. /**
  143259. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  143260. */
  143261. _stillInvisible: boolean;
  143262. /**
  143263. * @hidden Last computed particle rotation matrix
  143264. */
  143265. _rotationMatrix: number[];
  143266. /**
  143267. * Parent particle Id, if any.
  143268. * Default null.
  143269. */
  143270. parentId: Nullable<number>;
  143271. /**
  143272. * @hidden Internal global position in the PCS.
  143273. */
  143274. _globalPosition: Vector3;
  143275. /**
  143276. * Creates a Point Cloud object.
  143277. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  143278. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  143279. * @param group (PointsGroup) is the group the particle belongs to
  143280. * @param groupId (integer) is the group identifier in the PCS.
  143281. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  143282. * @param pcs defines the PCS it is associated to
  143283. */
  143284. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  143285. /**
  143286. * get point size
  143287. */
  143288. get size(): Vector3;
  143289. /**
  143290. * Set point size
  143291. */
  143292. set size(scale: Vector3);
  143293. /**
  143294. * Legacy support, changed quaternion to rotationQuaternion
  143295. */
  143296. get quaternion(): Nullable<Quaternion>;
  143297. /**
  143298. * Legacy support, changed quaternion to rotationQuaternion
  143299. */
  143300. set quaternion(q: Nullable<Quaternion>);
  143301. /**
  143302. * Returns a boolean. True if the particle intersects a mesh, else false
  143303. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  143304. * @param target is the object (point or mesh) what the intersection is computed against
  143305. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  143306. * @returns true if it intersects
  143307. */
  143308. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  143309. /**
  143310. * get the rotation matrix of the particle
  143311. * @hidden
  143312. */
  143313. getRotationMatrix(m: Matrix): void;
  143314. }
  143315. /**
  143316. * Represents a group of points in a points cloud system
  143317. * * PCS internal tool, don't use it manually.
  143318. */
  143319. export class PointsGroup {
  143320. /**
  143321. * The group id
  143322. * @hidden
  143323. */
  143324. groupID: number;
  143325. /**
  143326. * image data for group (internal use)
  143327. * @hidden
  143328. */
  143329. _groupImageData: Nullable<ArrayBufferView>;
  143330. /**
  143331. * Image Width (internal use)
  143332. * @hidden
  143333. */
  143334. _groupImgWidth: number;
  143335. /**
  143336. * Image Height (internal use)
  143337. * @hidden
  143338. */
  143339. _groupImgHeight: number;
  143340. /**
  143341. * Custom position function (internal use)
  143342. * @hidden
  143343. */
  143344. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  143345. /**
  143346. * density per facet for surface points
  143347. * @hidden
  143348. */
  143349. _groupDensity: number[];
  143350. /**
  143351. * Only when points are colored by texture carries pointer to texture list array
  143352. * @hidden
  143353. */
  143354. _textureNb: number;
  143355. /**
  143356. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  143357. * PCS internal tool, don't use it manually.
  143358. * @hidden
  143359. */
  143360. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  143361. }
  143362. }
  143363. declare module BABYLON {
  143364. interface Scene {
  143365. /** @hidden (Backing field) */
  143366. _physicsEngine: Nullable<IPhysicsEngine>;
  143367. /** @hidden */
  143368. _physicsTimeAccumulator: number;
  143369. /**
  143370. * Gets the current physics engine
  143371. * @returns a IPhysicsEngine or null if none attached
  143372. */
  143373. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  143374. /**
  143375. * Enables physics to the current scene
  143376. * @param gravity defines the scene's gravity for the physics engine
  143377. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  143378. * @return a boolean indicating if the physics engine was initialized
  143379. */
  143380. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  143381. /**
  143382. * Disables and disposes the physics engine associated with the scene
  143383. */
  143384. disablePhysicsEngine(): void;
  143385. /**
  143386. * Gets a boolean indicating if there is an active physics engine
  143387. * @returns a boolean indicating if there is an active physics engine
  143388. */
  143389. isPhysicsEnabled(): boolean;
  143390. /**
  143391. * Deletes a physics compound impostor
  143392. * @param compound defines the compound to delete
  143393. */
  143394. deleteCompoundImpostor(compound: any): void;
  143395. /**
  143396. * An event triggered when physic simulation is about to be run
  143397. */
  143398. onBeforePhysicsObservable: Observable<Scene>;
  143399. /**
  143400. * An event triggered when physic simulation has been done
  143401. */
  143402. onAfterPhysicsObservable: Observable<Scene>;
  143403. }
  143404. interface AbstractMesh {
  143405. /** @hidden */
  143406. _physicsImpostor: Nullable<PhysicsImpostor>;
  143407. /**
  143408. * Gets or sets impostor used for physic simulation
  143409. * @see http://doc.babylonjs.com/features/physics_engine
  143410. */
  143411. physicsImpostor: Nullable<PhysicsImpostor>;
  143412. /**
  143413. * Gets the current physics impostor
  143414. * @see http://doc.babylonjs.com/features/physics_engine
  143415. * @returns a physics impostor or null
  143416. */
  143417. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  143418. /** Apply a physic impulse to the mesh
  143419. * @param force defines the force to apply
  143420. * @param contactPoint defines where to apply the force
  143421. * @returns the current mesh
  143422. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  143423. */
  143424. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  143425. /**
  143426. * Creates a physic joint between two meshes
  143427. * @param otherMesh defines the other mesh to use
  143428. * @param pivot1 defines the pivot to use on this mesh
  143429. * @param pivot2 defines the pivot to use on the other mesh
  143430. * @param options defines additional options (can be plugin dependent)
  143431. * @returns the current mesh
  143432. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  143433. */
  143434. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  143435. /** @hidden */
  143436. _disposePhysicsObserver: Nullable<Observer<Node>>;
  143437. }
  143438. /**
  143439. * Defines the physics engine scene component responsible to manage a physics engine
  143440. */
  143441. export class PhysicsEngineSceneComponent implements ISceneComponent {
  143442. /**
  143443. * The component name helpful to identify the component in the list of scene components.
  143444. */
  143445. readonly name: string;
  143446. /**
  143447. * The scene the component belongs to.
  143448. */
  143449. scene: Scene;
  143450. /**
  143451. * Creates a new instance of the component for the given scene
  143452. * @param scene Defines the scene to register the component in
  143453. */
  143454. constructor(scene: Scene);
  143455. /**
  143456. * Registers the component in a given scene
  143457. */
  143458. register(): void;
  143459. /**
  143460. * Rebuilds the elements related to this component in case of
  143461. * context lost for instance.
  143462. */
  143463. rebuild(): void;
  143464. /**
  143465. * Disposes the component and the associated ressources
  143466. */
  143467. dispose(): void;
  143468. }
  143469. }
  143470. declare module BABYLON {
  143471. /**
  143472. * A helper for physics simulations
  143473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143474. */
  143475. export class PhysicsHelper {
  143476. private _scene;
  143477. private _physicsEngine;
  143478. /**
  143479. * Initializes the Physics helper
  143480. * @param scene Babylon.js scene
  143481. */
  143482. constructor(scene: Scene);
  143483. /**
  143484. * Applies a radial explosion impulse
  143485. * @param origin the origin of the explosion
  143486. * @param radiusOrEventOptions the radius or the options of radial explosion
  143487. * @param strength the explosion strength
  143488. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143489. * @returns A physics radial explosion event, or null
  143490. */
  143491. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143492. /**
  143493. * Applies a radial explosion force
  143494. * @param origin the origin of the explosion
  143495. * @param radiusOrEventOptions the radius or the options of radial explosion
  143496. * @param strength the explosion strength
  143497. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143498. * @returns A physics radial explosion event, or null
  143499. */
  143500. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143501. /**
  143502. * Creates a gravitational field
  143503. * @param origin the origin of the explosion
  143504. * @param radiusOrEventOptions the radius or the options of radial explosion
  143505. * @param strength the explosion strength
  143506. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143507. * @returns A physics gravitational field event, or null
  143508. */
  143509. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  143510. /**
  143511. * Creates a physics updraft event
  143512. * @param origin the origin of the updraft
  143513. * @param radiusOrEventOptions the radius or the options of the updraft
  143514. * @param strength the strength of the updraft
  143515. * @param height the height of the updraft
  143516. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  143517. * @returns A physics updraft event, or null
  143518. */
  143519. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  143520. /**
  143521. * Creates a physics vortex event
  143522. * @param origin the of the vortex
  143523. * @param radiusOrEventOptions the radius or the options of the vortex
  143524. * @param strength the strength of the vortex
  143525. * @param height the height of the vortex
  143526. * @returns a Physics vortex event, or null
  143527. * A physics vortex event or null
  143528. */
  143529. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  143530. }
  143531. /**
  143532. * Represents a physics radial explosion event
  143533. */
  143534. class PhysicsRadialExplosionEvent {
  143535. private _scene;
  143536. private _options;
  143537. private _sphere;
  143538. private _dataFetched;
  143539. /**
  143540. * Initializes a radial explosioin event
  143541. * @param _scene BabylonJS scene
  143542. * @param _options The options for the vortex event
  143543. */
  143544. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  143545. /**
  143546. * Returns the data related to the radial explosion event (sphere).
  143547. * @returns The radial explosion event data
  143548. */
  143549. getData(): PhysicsRadialExplosionEventData;
  143550. /**
  143551. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  143552. * @param impostor A physics imposter
  143553. * @param origin the origin of the explosion
  143554. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  143555. */
  143556. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  143557. /**
  143558. * Triggers affecterd impostors callbacks
  143559. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  143560. */
  143561. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  143562. /**
  143563. * Disposes the sphere.
  143564. * @param force Specifies if the sphere should be disposed by force
  143565. */
  143566. dispose(force?: boolean): void;
  143567. /*** Helpers ***/
  143568. private _prepareSphere;
  143569. private _intersectsWithSphere;
  143570. }
  143571. /**
  143572. * Represents a gravitational field event
  143573. */
  143574. class PhysicsGravitationalFieldEvent {
  143575. private _physicsHelper;
  143576. private _scene;
  143577. private _origin;
  143578. private _options;
  143579. private _tickCallback;
  143580. private _sphere;
  143581. private _dataFetched;
  143582. /**
  143583. * Initializes the physics gravitational field event
  143584. * @param _physicsHelper A physics helper
  143585. * @param _scene BabylonJS scene
  143586. * @param _origin The origin position of the gravitational field event
  143587. * @param _options The options for the vortex event
  143588. */
  143589. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  143590. /**
  143591. * Returns the data related to the gravitational field event (sphere).
  143592. * @returns A gravitational field event
  143593. */
  143594. getData(): PhysicsGravitationalFieldEventData;
  143595. /**
  143596. * Enables the gravitational field.
  143597. */
  143598. enable(): void;
  143599. /**
  143600. * Disables the gravitational field.
  143601. */
  143602. disable(): void;
  143603. /**
  143604. * Disposes the sphere.
  143605. * @param force The force to dispose from the gravitational field event
  143606. */
  143607. dispose(force?: boolean): void;
  143608. private _tick;
  143609. }
  143610. /**
  143611. * Represents a physics updraft event
  143612. */
  143613. class PhysicsUpdraftEvent {
  143614. private _scene;
  143615. private _origin;
  143616. private _options;
  143617. private _physicsEngine;
  143618. private _originTop;
  143619. private _originDirection;
  143620. private _tickCallback;
  143621. private _cylinder;
  143622. private _cylinderPosition;
  143623. private _dataFetched;
  143624. /**
  143625. * Initializes the physics updraft event
  143626. * @param _scene BabylonJS scene
  143627. * @param _origin The origin position of the updraft
  143628. * @param _options The options for the updraft event
  143629. */
  143630. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  143631. /**
  143632. * Returns the data related to the updraft event (cylinder).
  143633. * @returns A physics updraft event
  143634. */
  143635. getData(): PhysicsUpdraftEventData;
  143636. /**
  143637. * Enables the updraft.
  143638. */
  143639. enable(): void;
  143640. /**
  143641. * Disables the updraft.
  143642. */
  143643. disable(): void;
  143644. /**
  143645. * Disposes the cylinder.
  143646. * @param force Specifies if the updraft should be disposed by force
  143647. */
  143648. dispose(force?: boolean): void;
  143649. private getImpostorHitData;
  143650. private _tick;
  143651. /*** Helpers ***/
  143652. private _prepareCylinder;
  143653. private _intersectsWithCylinder;
  143654. }
  143655. /**
  143656. * Represents a physics vortex event
  143657. */
  143658. class PhysicsVortexEvent {
  143659. private _scene;
  143660. private _origin;
  143661. private _options;
  143662. private _physicsEngine;
  143663. private _originTop;
  143664. private _tickCallback;
  143665. private _cylinder;
  143666. private _cylinderPosition;
  143667. private _dataFetched;
  143668. /**
  143669. * Initializes the physics vortex event
  143670. * @param _scene The BabylonJS scene
  143671. * @param _origin The origin position of the vortex
  143672. * @param _options The options for the vortex event
  143673. */
  143674. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  143675. /**
  143676. * Returns the data related to the vortex event (cylinder).
  143677. * @returns The physics vortex event data
  143678. */
  143679. getData(): PhysicsVortexEventData;
  143680. /**
  143681. * Enables the vortex.
  143682. */
  143683. enable(): void;
  143684. /**
  143685. * Disables the cortex.
  143686. */
  143687. disable(): void;
  143688. /**
  143689. * Disposes the sphere.
  143690. * @param force
  143691. */
  143692. dispose(force?: boolean): void;
  143693. private getImpostorHitData;
  143694. private _tick;
  143695. /*** Helpers ***/
  143696. private _prepareCylinder;
  143697. private _intersectsWithCylinder;
  143698. }
  143699. /**
  143700. * Options fot the radial explosion event
  143701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143702. */
  143703. export class PhysicsRadialExplosionEventOptions {
  143704. /**
  143705. * The radius of the sphere for the radial explosion.
  143706. */
  143707. radius: number;
  143708. /**
  143709. * The strenth of the explosion.
  143710. */
  143711. strength: number;
  143712. /**
  143713. * The strenght of the force in correspondence to the distance of the affected object
  143714. */
  143715. falloff: PhysicsRadialImpulseFalloff;
  143716. /**
  143717. * Sphere options for the radial explosion.
  143718. */
  143719. sphere: {
  143720. segments: number;
  143721. diameter: number;
  143722. };
  143723. /**
  143724. * Sphere options for the radial explosion.
  143725. */
  143726. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  143727. }
  143728. /**
  143729. * Options fot the updraft event
  143730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143731. */
  143732. export class PhysicsUpdraftEventOptions {
  143733. /**
  143734. * The radius of the cylinder for the vortex
  143735. */
  143736. radius: number;
  143737. /**
  143738. * The strenth of the updraft.
  143739. */
  143740. strength: number;
  143741. /**
  143742. * The height of the cylinder for the updraft.
  143743. */
  143744. height: number;
  143745. /**
  143746. * The mode for the the updraft.
  143747. */
  143748. updraftMode: PhysicsUpdraftMode;
  143749. }
  143750. /**
  143751. * Options fot the vortex event
  143752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143753. */
  143754. export class PhysicsVortexEventOptions {
  143755. /**
  143756. * The radius of the cylinder for the vortex
  143757. */
  143758. radius: number;
  143759. /**
  143760. * The strenth of the vortex.
  143761. */
  143762. strength: number;
  143763. /**
  143764. * The height of the cylinder for the vortex.
  143765. */
  143766. height: number;
  143767. /**
  143768. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  143769. */
  143770. centripetalForceThreshold: number;
  143771. /**
  143772. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  143773. */
  143774. centripetalForceMultiplier: number;
  143775. /**
  143776. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  143777. */
  143778. centrifugalForceMultiplier: number;
  143779. /**
  143780. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  143781. */
  143782. updraftForceMultiplier: number;
  143783. }
  143784. /**
  143785. * The strenght of the force in correspondence to the distance of the affected object
  143786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143787. */
  143788. export enum PhysicsRadialImpulseFalloff {
  143789. /** Defines that impulse is constant in strength across it's whole radius */
  143790. Constant = 0,
  143791. /** Defines that impulse gets weaker if it's further from the origin */
  143792. Linear = 1
  143793. }
  143794. /**
  143795. * The strength of the force in correspondence to the distance of the affected object
  143796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143797. */
  143798. export enum PhysicsUpdraftMode {
  143799. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  143800. Center = 0,
  143801. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  143802. Perpendicular = 1
  143803. }
  143804. /**
  143805. * Interface for a physics hit data
  143806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143807. */
  143808. export interface PhysicsHitData {
  143809. /**
  143810. * The force applied at the contact point
  143811. */
  143812. force: Vector3;
  143813. /**
  143814. * The contact point
  143815. */
  143816. contactPoint: Vector3;
  143817. /**
  143818. * The distance from the origin to the contact point
  143819. */
  143820. distanceFromOrigin: number;
  143821. }
  143822. /**
  143823. * Interface for radial explosion event data
  143824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143825. */
  143826. export interface PhysicsRadialExplosionEventData {
  143827. /**
  143828. * A sphere used for the radial explosion event
  143829. */
  143830. sphere: Mesh;
  143831. }
  143832. /**
  143833. * Interface for gravitational field event data
  143834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143835. */
  143836. export interface PhysicsGravitationalFieldEventData {
  143837. /**
  143838. * A sphere mesh used for the gravitational field event
  143839. */
  143840. sphere: Mesh;
  143841. }
  143842. /**
  143843. * Interface for updraft event data
  143844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143845. */
  143846. export interface PhysicsUpdraftEventData {
  143847. /**
  143848. * A cylinder used for the updraft event
  143849. */
  143850. cylinder: Mesh;
  143851. }
  143852. /**
  143853. * Interface for vortex event data
  143854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143855. */
  143856. export interface PhysicsVortexEventData {
  143857. /**
  143858. * A cylinder used for the vortex event
  143859. */
  143860. cylinder: Mesh;
  143861. }
  143862. /**
  143863. * Interface for an affected physics impostor
  143864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143865. */
  143866. export interface PhysicsAffectedImpostorWithData {
  143867. /**
  143868. * The impostor affected by the effect
  143869. */
  143870. impostor: PhysicsImpostor;
  143871. /**
  143872. * The data about the hit/horce from the explosion
  143873. */
  143874. hitData: PhysicsHitData;
  143875. }
  143876. }
  143877. declare module BABYLON {
  143878. /** @hidden */
  143879. export var blackAndWhitePixelShader: {
  143880. name: string;
  143881. shader: string;
  143882. };
  143883. }
  143884. declare module BABYLON {
  143885. /**
  143886. * Post process used to render in black and white
  143887. */
  143888. export class BlackAndWhitePostProcess extends PostProcess {
  143889. /**
  143890. * Linear about to convert he result to black and white (default: 1)
  143891. */
  143892. degree: number;
  143893. /**
  143894. * Creates a black and white post process
  143895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  143896. * @param name The name of the effect.
  143897. * @param options The required width/height ratio to downsize to before computing the render pass.
  143898. * @param camera The camera to apply the render pass to.
  143899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143900. * @param engine The engine which the post process will be applied. (default: current engine)
  143901. * @param reusable If the post process can be reused on the same frame. (default: false)
  143902. */
  143903. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143904. }
  143905. }
  143906. declare module BABYLON {
  143907. /**
  143908. * This represents a set of one or more post processes in Babylon.
  143909. * A post process can be used to apply a shader to a texture after it is rendered.
  143910. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  143911. */
  143912. export class PostProcessRenderEffect {
  143913. private _postProcesses;
  143914. private _getPostProcesses;
  143915. private _singleInstance;
  143916. private _cameras;
  143917. private _indicesForCamera;
  143918. /**
  143919. * Name of the effect
  143920. * @hidden
  143921. */
  143922. _name: string;
  143923. /**
  143924. * Instantiates a post process render effect.
  143925. * A post process can be used to apply a shader to a texture after it is rendered.
  143926. * @param engine The engine the effect is tied to
  143927. * @param name The name of the effect
  143928. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  143929. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  143930. */
  143931. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  143932. /**
  143933. * Checks if all the post processes in the effect are supported.
  143934. */
  143935. get isSupported(): boolean;
  143936. /**
  143937. * Updates the current state of the effect
  143938. * @hidden
  143939. */
  143940. _update(): void;
  143941. /**
  143942. * Attaches the effect on cameras
  143943. * @param cameras The camera to attach to.
  143944. * @hidden
  143945. */
  143946. _attachCameras(cameras: Camera): void;
  143947. /**
  143948. * Attaches the effect on cameras
  143949. * @param cameras The camera to attach to.
  143950. * @hidden
  143951. */
  143952. _attachCameras(cameras: Camera[]): void;
  143953. /**
  143954. * Detaches the effect on cameras
  143955. * @param cameras The camera to detatch from.
  143956. * @hidden
  143957. */
  143958. _detachCameras(cameras: Camera): void;
  143959. /**
  143960. * Detatches the effect on cameras
  143961. * @param cameras The camera to detatch from.
  143962. * @hidden
  143963. */
  143964. _detachCameras(cameras: Camera[]): void;
  143965. /**
  143966. * Enables the effect on given cameras
  143967. * @param cameras The camera to enable.
  143968. * @hidden
  143969. */
  143970. _enable(cameras: Camera): void;
  143971. /**
  143972. * Enables the effect on given cameras
  143973. * @param cameras The camera to enable.
  143974. * @hidden
  143975. */
  143976. _enable(cameras: Nullable<Camera[]>): void;
  143977. /**
  143978. * Disables the effect on the given cameras
  143979. * @param cameras The camera to disable.
  143980. * @hidden
  143981. */
  143982. _disable(cameras: Camera): void;
  143983. /**
  143984. * Disables the effect on the given cameras
  143985. * @param cameras The camera to disable.
  143986. * @hidden
  143987. */
  143988. _disable(cameras: Nullable<Camera[]>): void;
  143989. /**
  143990. * Gets a list of the post processes contained in the effect.
  143991. * @param camera The camera to get the post processes on.
  143992. * @returns The list of the post processes in the effect.
  143993. */
  143994. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  143995. }
  143996. }
  143997. declare module BABYLON {
  143998. /** @hidden */
  143999. export var extractHighlightsPixelShader: {
  144000. name: string;
  144001. shader: string;
  144002. };
  144003. }
  144004. declare module BABYLON {
  144005. /**
  144006. * 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.
  144007. */
  144008. export class ExtractHighlightsPostProcess extends PostProcess {
  144009. /**
  144010. * The luminance threshold, pixels below this value will be set to black.
  144011. */
  144012. threshold: number;
  144013. /** @hidden */
  144014. _exposure: number;
  144015. /**
  144016. * Post process which has the input texture to be used when performing highlight extraction
  144017. * @hidden
  144018. */
  144019. _inputPostProcess: Nullable<PostProcess>;
  144020. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144021. }
  144022. }
  144023. declare module BABYLON {
  144024. /** @hidden */
  144025. export var bloomMergePixelShader: {
  144026. name: string;
  144027. shader: string;
  144028. };
  144029. }
  144030. declare module BABYLON {
  144031. /**
  144032. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144033. */
  144034. export class BloomMergePostProcess extends PostProcess {
  144035. /** Weight of the bloom to be added to the original input. */
  144036. weight: number;
  144037. /**
  144038. * Creates a new instance of @see BloomMergePostProcess
  144039. * @param name The name of the effect.
  144040. * @param originalFromInput Post process which's input will be used for the merge.
  144041. * @param blurred Blurred highlights post process which's output will be used.
  144042. * @param weight Weight of the bloom to be added to the original input.
  144043. * @param options The required width/height ratio to downsize to before computing the render pass.
  144044. * @param camera The camera to apply the render pass to.
  144045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144046. * @param engine The engine which the post process will be applied. (default: current engine)
  144047. * @param reusable If the post process can be reused on the same frame. (default: false)
  144048. * @param textureType Type of textures used when performing the post process. (default: 0)
  144049. * @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)
  144050. */
  144051. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  144052. /** Weight of the bloom to be added to the original input. */
  144053. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144054. }
  144055. }
  144056. declare module BABYLON {
  144057. /**
  144058. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  144059. */
  144060. export class BloomEffect extends PostProcessRenderEffect {
  144061. private bloomScale;
  144062. /**
  144063. * @hidden Internal
  144064. */
  144065. _effects: Array<PostProcess>;
  144066. /**
  144067. * @hidden Internal
  144068. */
  144069. _downscale: ExtractHighlightsPostProcess;
  144070. private _blurX;
  144071. private _blurY;
  144072. private _merge;
  144073. /**
  144074. * The luminance threshold to find bright areas of the image to bloom.
  144075. */
  144076. get threshold(): number;
  144077. set threshold(value: number);
  144078. /**
  144079. * The strength of the bloom.
  144080. */
  144081. get weight(): number;
  144082. set weight(value: number);
  144083. /**
  144084. * Specifies the size of the bloom blur kernel, relative to the final output size
  144085. */
  144086. get kernel(): number;
  144087. set kernel(value: number);
  144088. /**
  144089. * Creates a new instance of @see BloomEffect
  144090. * @param scene The scene the effect belongs to.
  144091. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  144092. * @param bloomKernel The size of the kernel to be used when applying the blur.
  144093. * @param bloomWeight The the strength of bloom.
  144094. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144095. * @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)
  144096. */
  144097. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  144098. /**
  144099. * Disposes each of the internal effects for a given camera.
  144100. * @param camera The camera to dispose the effect on.
  144101. */
  144102. disposeEffects(camera: Camera): void;
  144103. /**
  144104. * @hidden Internal
  144105. */
  144106. _updateEffects(): void;
  144107. /**
  144108. * Internal
  144109. * @returns if all the contained post processes are ready.
  144110. * @hidden
  144111. */
  144112. _isReady(): boolean;
  144113. }
  144114. }
  144115. declare module BABYLON {
  144116. /** @hidden */
  144117. export var chromaticAberrationPixelShader: {
  144118. name: string;
  144119. shader: string;
  144120. };
  144121. }
  144122. declare module BABYLON {
  144123. /**
  144124. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  144125. */
  144126. export class ChromaticAberrationPostProcess extends PostProcess {
  144127. /**
  144128. * The amount of seperation of rgb channels (default: 30)
  144129. */
  144130. aberrationAmount: number;
  144131. /**
  144132. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  144133. */
  144134. radialIntensity: number;
  144135. /**
  144136. * 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))
  144137. */
  144138. direction: Vector2;
  144139. /**
  144140. * 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))
  144141. */
  144142. centerPosition: Vector2;
  144143. /**
  144144. * Creates a new instance ChromaticAberrationPostProcess
  144145. * @param name The name of the effect.
  144146. * @param screenWidth The width of the screen to apply the effect on.
  144147. * @param screenHeight The height of the screen to apply the effect on.
  144148. * @param options The required width/height ratio to downsize to before computing the render pass.
  144149. * @param camera The camera to apply the render pass to.
  144150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144151. * @param engine The engine which the post process will be applied. (default: current engine)
  144152. * @param reusable If the post process can be reused on the same frame. (default: false)
  144153. * @param textureType Type of textures used when performing the post process. (default: 0)
  144154. * @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)
  144155. */
  144156. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144157. }
  144158. }
  144159. declare module BABYLON {
  144160. /** @hidden */
  144161. export var circleOfConfusionPixelShader: {
  144162. name: string;
  144163. shader: string;
  144164. };
  144165. }
  144166. declare module BABYLON {
  144167. /**
  144168. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  144169. */
  144170. export class CircleOfConfusionPostProcess extends PostProcess {
  144171. /**
  144172. * 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.
  144173. */
  144174. lensSize: number;
  144175. /**
  144176. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144177. */
  144178. fStop: number;
  144179. /**
  144180. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144181. */
  144182. focusDistance: number;
  144183. /**
  144184. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  144185. */
  144186. focalLength: number;
  144187. private _depthTexture;
  144188. /**
  144189. * Creates a new instance CircleOfConfusionPostProcess
  144190. * @param name The name of the effect.
  144191. * @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.
  144192. * @param options The required width/height ratio to downsize to before computing the render pass.
  144193. * @param camera The camera to apply the render pass to.
  144194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144195. * @param engine The engine which the post process will be applied. (default: current engine)
  144196. * @param reusable If the post process can be reused on the same frame. (default: false)
  144197. * @param textureType Type of textures used when performing the post process. (default: 0)
  144198. * @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)
  144199. */
  144200. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144201. /**
  144202. * 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.
  144203. */
  144204. set depthTexture(value: RenderTargetTexture);
  144205. }
  144206. }
  144207. declare module BABYLON {
  144208. /** @hidden */
  144209. export var colorCorrectionPixelShader: {
  144210. name: string;
  144211. shader: string;
  144212. };
  144213. }
  144214. declare module BABYLON {
  144215. /**
  144216. *
  144217. * This post-process allows the modification of rendered colors by using
  144218. * a 'look-up table' (LUT). This effect is also called Color Grading.
  144219. *
  144220. * The object needs to be provided an url to a texture containing the color
  144221. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  144222. * Use an image editing software to tweak the LUT to match your needs.
  144223. *
  144224. * For an example of a color LUT, see here:
  144225. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  144226. * For explanations on color grading, see here:
  144227. * @see http://udn.epicgames.com/Three/ColorGrading.html
  144228. *
  144229. */
  144230. export class ColorCorrectionPostProcess extends PostProcess {
  144231. private _colorTableTexture;
  144232. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144233. }
  144234. }
  144235. declare module BABYLON {
  144236. /** @hidden */
  144237. export var convolutionPixelShader: {
  144238. name: string;
  144239. shader: string;
  144240. };
  144241. }
  144242. declare module BABYLON {
  144243. /**
  144244. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  144245. * input texture to perform effects such as edge detection or sharpening
  144246. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144247. */
  144248. export class ConvolutionPostProcess extends PostProcess {
  144249. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144250. kernel: number[];
  144251. /**
  144252. * Creates a new instance ConvolutionPostProcess
  144253. * @param name The name of the effect.
  144254. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  144255. * @param options The required width/height ratio to downsize to before computing the render pass.
  144256. * @param camera The camera to apply the render pass to.
  144257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144258. * @param engine The engine which the post process will be applied. (default: current engine)
  144259. * @param reusable If the post process can be reused on the same frame. (default: false)
  144260. * @param textureType Type of textures used when performing the post process. (default: 0)
  144261. */
  144262. constructor(name: string,
  144263. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144264. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144265. /**
  144266. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144267. */
  144268. static EdgeDetect0Kernel: number[];
  144269. /**
  144270. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144271. */
  144272. static EdgeDetect1Kernel: number[];
  144273. /**
  144274. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144275. */
  144276. static EdgeDetect2Kernel: number[];
  144277. /**
  144278. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144279. */
  144280. static SharpenKernel: number[];
  144281. /**
  144282. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144283. */
  144284. static EmbossKernel: number[];
  144285. /**
  144286. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144287. */
  144288. static GaussianKernel: number[];
  144289. }
  144290. }
  144291. declare module BABYLON {
  144292. /**
  144293. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  144294. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  144295. * based on samples that have a large difference in distance than the center pixel.
  144296. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  144297. */
  144298. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  144299. direction: Vector2;
  144300. /**
  144301. * Creates a new instance CircleOfConfusionPostProcess
  144302. * @param name The name of the effect.
  144303. * @param scene The scene the effect belongs to.
  144304. * @param direction The direction the blur should be applied.
  144305. * @param kernel The size of the kernel used to blur.
  144306. * @param options The required width/height ratio to downsize to before computing the render pass.
  144307. * @param camera The camera to apply the render pass to.
  144308. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  144309. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  144310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144311. * @param engine The engine which the post process will be applied. (default: current engine)
  144312. * @param reusable If the post process can be reused on the same frame. (default: false)
  144313. * @param textureType Type of textures used when performing the post process. (default: 0)
  144314. * @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)
  144315. */
  144316. 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);
  144317. }
  144318. }
  144319. declare module BABYLON {
  144320. /** @hidden */
  144321. export var depthOfFieldMergePixelShader: {
  144322. name: string;
  144323. shader: string;
  144324. };
  144325. }
  144326. declare module BABYLON {
  144327. /**
  144328. * Options to be set when merging outputs from the default pipeline.
  144329. */
  144330. export class DepthOfFieldMergePostProcessOptions {
  144331. /**
  144332. * The original image to merge on top of
  144333. */
  144334. originalFromInput: PostProcess;
  144335. /**
  144336. * Parameters to perform the merge of the depth of field effect
  144337. */
  144338. depthOfField?: {
  144339. circleOfConfusion: PostProcess;
  144340. blurSteps: Array<PostProcess>;
  144341. };
  144342. /**
  144343. * Parameters to perform the merge of bloom effect
  144344. */
  144345. bloom?: {
  144346. blurred: PostProcess;
  144347. weight: number;
  144348. };
  144349. }
  144350. /**
  144351. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144352. */
  144353. export class DepthOfFieldMergePostProcess extends PostProcess {
  144354. private blurSteps;
  144355. /**
  144356. * Creates a new instance of DepthOfFieldMergePostProcess
  144357. * @param name The name of the effect.
  144358. * @param originalFromInput Post process which's input will be used for the merge.
  144359. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  144360. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  144361. * @param options The required width/height ratio to downsize to before computing the render pass.
  144362. * @param camera The camera to apply the render pass to.
  144363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144364. * @param engine The engine which the post process will be applied. (default: current engine)
  144365. * @param reusable If the post process can be reused on the same frame. (default: false)
  144366. * @param textureType Type of textures used when performing the post process. (default: 0)
  144367. * @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)
  144368. */
  144369. 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);
  144370. /**
  144371. * Updates the effect with the current post process compile time values and recompiles the shader.
  144372. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  144373. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  144374. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  144375. * @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
  144376. * @param onCompiled Called when the shader has been compiled.
  144377. * @param onError Called if there is an error when compiling a shader.
  144378. */
  144379. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  144380. }
  144381. }
  144382. declare module BABYLON {
  144383. /**
  144384. * Specifies the level of max blur that should be applied when using the depth of field effect
  144385. */
  144386. export enum DepthOfFieldEffectBlurLevel {
  144387. /**
  144388. * Subtle blur
  144389. */
  144390. Low = 0,
  144391. /**
  144392. * Medium blur
  144393. */
  144394. Medium = 1,
  144395. /**
  144396. * Large blur
  144397. */
  144398. High = 2
  144399. }
  144400. /**
  144401. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  144402. */
  144403. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  144404. private _circleOfConfusion;
  144405. /**
  144406. * @hidden Internal, blurs from high to low
  144407. */
  144408. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  144409. private _depthOfFieldBlurY;
  144410. private _dofMerge;
  144411. /**
  144412. * @hidden Internal post processes in depth of field effect
  144413. */
  144414. _effects: Array<PostProcess>;
  144415. /**
  144416. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  144417. */
  144418. set focalLength(value: number);
  144419. get focalLength(): number;
  144420. /**
  144421. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144422. */
  144423. set fStop(value: number);
  144424. get fStop(): number;
  144425. /**
  144426. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144427. */
  144428. set focusDistance(value: number);
  144429. get focusDistance(): number;
  144430. /**
  144431. * 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.
  144432. */
  144433. set lensSize(value: number);
  144434. get lensSize(): number;
  144435. /**
  144436. * Creates a new instance DepthOfFieldEffect
  144437. * @param scene The scene the effect belongs to.
  144438. * @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.
  144439. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144440. * @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)
  144441. */
  144442. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  144443. /**
  144444. * Get the current class name of the current effet
  144445. * @returns "DepthOfFieldEffect"
  144446. */
  144447. getClassName(): string;
  144448. /**
  144449. * 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.
  144450. */
  144451. set depthTexture(value: RenderTargetTexture);
  144452. /**
  144453. * Disposes each of the internal effects for a given camera.
  144454. * @param camera The camera to dispose the effect on.
  144455. */
  144456. disposeEffects(camera: Camera): void;
  144457. /**
  144458. * @hidden Internal
  144459. */
  144460. _updateEffects(): void;
  144461. /**
  144462. * Internal
  144463. * @returns if all the contained post processes are ready.
  144464. * @hidden
  144465. */
  144466. _isReady(): boolean;
  144467. }
  144468. }
  144469. declare module BABYLON {
  144470. /** @hidden */
  144471. export var displayPassPixelShader: {
  144472. name: string;
  144473. shader: string;
  144474. };
  144475. }
  144476. declare module BABYLON {
  144477. /**
  144478. * DisplayPassPostProcess which produces an output the same as it's input
  144479. */
  144480. export class DisplayPassPostProcess extends PostProcess {
  144481. /**
  144482. * Creates the DisplayPassPostProcess
  144483. * @param name The name of the effect.
  144484. * @param options The required width/height ratio to downsize to before computing the render pass.
  144485. * @param camera The camera to apply the render pass to.
  144486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144487. * @param engine The engine which the post process will be applied. (default: current engine)
  144488. * @param reusable If the post process can be reused on the same frame. (default: false)
  144489. */
  144490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144491. }
  144492. }
  144493. declare module BABYLON {
  144494. /** @hidden */
  144495. export var filterPixelShader: {
  144496. name: string;
  144497. shader: string;
  144498. };
  144499. }
  144500. declare module BABYLON {
  144501. /**
  144502. * Applies a kernel filter to the image
  144503. */
  144504. export class FilterPostProcess extends PostProcess {
  144505. /** The matrix to be applied to the image */
  144506. kernelMatrix: Matrix;
  144507. /**
  144508. *
  144509. * @param name The name of the effect.
  144510. * @param kernelMatrix The matrix to be applied to the image
  144511. * @param options The required width/height ratio to downsize to before computing the render pass.
  144512. * @param camera The camera to apply the render pass to.
  144513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144514. * @param engine The engine which the post process will be applied. (default: current engine)
  144515. * @param reusable If the post process can be reused on the same frame. (default: false)
  144516. */
  144517. constructor(name: string,
  144518. /** The matrix to be applied to the image */
  144519. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144520. }
  144521. }
  144522. declare module BABYLON {
  144523. /** @hidden */
  144524. export var fxaaPixelShader: {
  144525. name: string;
  144526. shader: string;
  144527. };
  144528. }
  144529. declare module BABYLON {
  144530. /** @hidden */
  144531. export var fxaaVertexShader: {
  144532. name: string;
  144533. shader: string;
  144534. };
  144535. }
  144536. declare module BABYLON {
  144537. /**
  144538. * Fxaa post process
  144539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  144540. */
  144541. export class FxaaPostProcess extends PostProcess {
  144542. /** @hidden */
  144543. texelWidth: number;
  144544. /** @hidden */
  144545. texelHeight: number;
  144546. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144547. private _getDefines;
  144548. }
  144549. }
  144550. declare module BABYLON {
  144551. /** @hidden */
  144552. export var grainPixelShader: {
  144553. name: string;
  144554. shader: string;
  144555. };
  144556. }
  144557. declare module BABYLON {
  144558. /**
  144559. * The GrainPostProcess adds noise to the image at mid luminance levels
  144560. */
  144561. export class GrainPostProcess extends PostProcess {
  144562. /**
  144563. * The intensity of the grain added (default: 30)
  144564. */
  144565. intensity: number;
  144566. /**
  144567. * If the grain should be randomized on every frame
  144568. */
  144569. animated: boolean;
  144570. /**
  144571. * Creates a new instance of @see GrainPostProcess
  144572. * @param name The name of the effect.
  144573. * @param options The required width/height ratio to downsize to before computing the render pass.
  144574. * @param camera The camera to apply the render pass to.
  144575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144576. * @param engine The engine which the post process will be applied. (default: current engine)
  144577. * @param reusable If the post process can be reused on the same frame. (default: false)
  144578. * @param textureType Type of textures used when performing the post process. (default: 0)
  144579. * @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)
  144580. */
  144581. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144582. }
  144583. }
  144584. declare module BABYLON {
  144585. /** @hidden */
  144586. export var highlightsPixelShader: {
  144587. name: string;
  144588. shader: string;
  144589. };
  144590. }
  144591. declare module BABYLON {
  144592. /**
  144593. * Extracts highlights from the image
  144594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  144595. */
  144596. export class HighlightsPostProcess extends PostProcess {
  144597. /**
  144598. * Extracts highlights from the image
  144599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  144600. * @param name The name of the effect.
  144601. * @param options The required width/height ratio to downsize to before computing the render pass.
  144602. * @param camera The camera to apply the render pass to.
  144603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144604. * @param engine The engine which the post process will be applied. (default: current engine)
  144605. * @param reusable If the post process can be reused on the same frame. (default: false)
  144606. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  144607. */
  144608. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144609. }
  144610. }
  144611. declare module BABYLON {
  144612. /** @hidden */
  144613. export var mrtFragmentDeclaration: {
  144614. name: string;
  144615. shader: string;
  144616. };
  144617. }
  144618. declare module BABYLON {
  144619. /** @hidden */
  144620. export var geometryPixelShader: {
  144621. name: string;
  144622. shader: string;
  144623. };
  144624. }
  144625. declare module BABYLON {
  144626. /** @hidden */
  144627. export var geometryVertexShader: {
  144628. name: string;
  144629. shader: string;
  144630. };
  144631. }
  144632. declare module BABYLON {
  144633. /** @hidden */
  144634. interface ISavedTransformationMatrix {
  144635. world: Matrix;
  144636. viewProjection: Matrix;
  144637. }
  144638. /**
  144639. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  144640. */
  144641. export class GeometryBufferRenderer {
  144642. /**
  144643. * Constant used to retrieve the position texture index in the G-Buffer textures array
  144644. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  144645. */
  144646. static readonly POSITION_TEXTURE_TYPE: number;
  144647. /**
  144648. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  144649. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  144650. */
  144651. static readonly VELOCITY_TEXTURE_TYPE: number;
  144652. /**
  144653. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  144654. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  144655. */
  144656. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  144657. /**
  144658. * Dictionary used to store the previous transformation matrices of each rendered mesh
  144659. * in order to compute objects velocities when enableVelocity is set to "true"
  144660. * @hidden
  144661. */
  144662. _previousTransformationMatrices: {
  144663. [index: number]: ISavedTransformationMatrix;
  144664. };
  144665. /**
  144666. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  144667. * in order to compute objects velocities when enableVelocity is set to "true"
  144668. * @hidden
  144669. */
  144670. _previousBonesTransformationMatrices: {
  144671. [index: number]: Float32Array;
  144672. };
  144673. /**
  144674. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  144675. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  144676. */
  144677. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  144678. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  144679. renderTransparentMeshes: boolean;
  144680. private _scene;
  144681. private _multiRenderTarget;
  144682. private _ratio;
  144683. private _enablePosition;
  144684. private _enableVelocity;
  144685. private _enableReflectivity;
  144686. private _positionIndex;
  144687. private _velocityIndex;
  144688. private _reflectivityIndex;
  144689. protected _effect: Effect;
  144690. protected _cachedDefines: string;
  144691. /**
  144692. * Set the render list (meshes to be rendered) used in the G buffer.
  144693. */
  144694. set renderList(meshes: Mesh[]);
  144695. /**
  144696. * Gets wether or not G buffer are supported by the running hardware.
  144697. * This requires draw buffer supports
  144698. */
  144699. get isSupported(): boolean;
  144700. /**
  144701. * Returns the index of the given texture type in the G-Buffer textures array
  144702. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  144703. * @returns the index of the given texture type in the G-Buffer textures array
  144704. */
  144705. getTextureIndex(textureType: number): number;
  144706. /**
  144707. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  144708. */
  144709. get enablePosition(): boolean;
  144710. /**
  144711. * Sets whether or not objects positions are enabled for the G buffer.
  144712. */
  144713. set enablePosition(enable: boolean);
  144714. /**
  144715. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  144716. */
  144717. get enableVelocity(): boolean;
  144718. /**
  144719. * Sets wether or not objects velocities are enabled for the G buffer.
  144720. */
  144721. set enableVelocity(enable: boolean);
  144722. /**
  144723. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  144724. */
  144725. get enableReflectivity(): boolean;
  144726. /**
  144727. * Sets wether or not objects roughness are enabled for the G buffer.
  144728. */
  144729. set enableReflectivity(enable: boolean);
  144730. /**
  144731. * Gets the scene associated with the buffer.
  144732. */
  144733. get scene(): Scene;
  144734. /**
  144735. * Gets the ratio used by the buffer during its creation.
  144736. * How big is the buffer related to the main canvas.
  144737. */
  144738. get ratio(): number;
  144739. /** @hidden */
  144740. static _SceneComponentInitialization: (scene: Scene) => void;
  144741. /**
  144742. * Creates a new G Buffer for the scene
  144743. * @param scene The scene the buffer belongs to
  144744. * @param ratio How big is the buffer related to the main canvas.
  144745. */
  144746. constructor(scene: Scene, ratio?: number);
  144747. /**
  144748. * Checks wether everything is ready to render a submesh to the G buffer.
  144749. * @param subMesh the submesh to check readiness for
  144750. * @param useInstances is the mesh drawn using instance or not
  144751. * @returns true if ready otherwise false
  144752. */
  144753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  144754. /**
  144755. * Gets the current underlying G Buffer.
  144756. * @returns the buffer
  144757. */
  144758. getGBuffer(): MultiRenderTarget;
  144759. /**
  144760. * Gets the number of samples used to render the buffer (anti aliasing).
  144761. */
  144762. get samples(): number;
  144763. /**
  144764. * Sets the number of samples used to render the buffer (anti aliasing).
  144765. */
  144766. set samples(value: number);
  144767. /**
  144768. * Disposes the renderer and frees up associated resources.
  144769. */
  144770. dispose(): void;
  144771. protected _createRenderTargets(): void;
  144772. private _copyBonesTransformationMatrices;
  144773. }
  144774. }
  144775. declare module BABYLON {
  144776. interface Scene {
  144777. /** @hidden (Backing field) */
  144778. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  144779. /**
  144780. * Gets or Sets the current geometry buffer associated to the scene.
  144781. */
  144782. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  144783. /**
  144784. * Enables a GeometryBufferRender and associates it with the scene
  144785. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  144786. * @returns the GeometryBufferRenderer
  144787. */
  144788. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  144789. /**
  144790. * Disables the GeometryBufferRender associated with the scene
  144791. */
  144792. disableGeometryBufferRenderer(): void;
  144793. }
  144794. /**
  144795. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  144796. * in several rendering techniques.
  144797. */
  144798. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  144799. /**
  144800. * The component name helpful to identify the component in the list of scene components.
  144801. */
  144802. readonly name: string;
  144803. /**
  144804. * The scene the component belongs to.
  144805. */
  144806. scene: Scene;
  144807. /**
  144808. * Creates a new instance of the component for the given scene
  144809. * @param scene Defines the scene to register the component in
  144810. */
  144811. constructor(scene: Scene);
  144812. /**
  144813. * Registers the component in a given scene
  144814. */
  144815. register(): void;
  144816. /**
  144817. * Rebuilds the elements related to this component in case of
  144818. * context lost for instance.
  144819. */
  144820. rebuild(): void;
  144821. /**
  144822. * Disposes the component and the associated ressources
  144823. */
  144824. dispose(): void;
  144825. private _gatherRenderTargets;
  144826. }
  144827. }
  144828. declare module BABYLON {
  144829. /** @hidden */
  144830. export var motionBlurPixelShader: {
  144831. name: string;
  144832. shader: string;
  144833. };
  144834. }
  144835. declare module BABYLON {
  144836. /**
  144837. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  144838. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  144839. * As an example, all you have to do is to create the post-process:
  144840. * var mb = new BABYLON.MotionBlurPostProcess(
  144841. * 'mb', // The name of the effect.
  144842. * scene, // The scene containing the objects to blur according to their velocity.
  144843. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  144844. * camera // The camera to apply the render pass to.
  144845. * );
  144846. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  144847. */
  144848. export class MotionBlurPostProcess extends PostProcess {
  144849. /**
  144850. * Defines how much the image is blurred by the movement. Default value is equal to 1
  144851. */
  144852. motionStrength: number;
  144853. /**
  144854. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  144855. */
  144856. get motionBlurSamples(): number;
  144857. /**
  144858. * Sets the number of iterations to be used for motion blur quality
  144859. */
  144860. set motionBlurSamples(samples: number);
  144861. private _motionBlurSamples;
  144862. private _geometryBufferRenderer;
  144863. /**
  144864. * Creates a new instance MotionBlurPostProcess
  144865. * @param name The name of the effect.
  144866. * @param scene The scene containing the objects to blur according to their velocity.
  144867. * @param options The required width/height ratio to downsize to before computing the render pass.
  144868. * @param camera The camera to apply the render pass to.
  144869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144870. * @param engine The engine which the post process will be applied. (default: current engine)
  144871. * @param reusable If the post process can be reused on the same frame. (default: false)
  144872. * @param textureType Type of textures used when performing the post process. (default: 0)
  144873. * @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)
  144874. */
  144875. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144876. /**
  144877. * Excludes the given skinned mesh from computing bones velocities.
  144878. * 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.
  144879. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  144880. */
  144881. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  144882. /**
  144883. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  144884. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  144885. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  144886. */
  144887. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  144888. /**
  144889. * Disposes the post process.
  144890. * @param camera The camera to dispose the post process on.
  144891. */
  144892. dispose(camera?: Camera): void;
  144893. }
  144894. }
  144895. declare module BABYLON {
  144896. /** @hidden */
  144897. export var refractionPixelShader: {
  144898. name: string;
  144899. shader: string;
  144900. };
  144901. }
  144902. declare module BABYLON {
  144903. /**
  144904. * Post process which applies a refractin texture
  144905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  144906. */
  144907. export class RefractionPostProcess extends PostProcess {
  144908. /** the base color of the refraction (used to taint the rendering) */
  144909. color: Color3;
  144910. /** simulated refraction depth */
  144911. depth: number;
  144912. /** the coefficient of the base color (0 to remove base color tainting) */
  144913. colorLevel: number;
  144914. private _refTexture;
  144915. private _ownRefractionTexture;
  144916. /**
  144917. * Gets or sets the refraction texture
  144918. * Please note that you are responsible for disposing the texture if you set it manually
  144919. */
  144920. get refractionTexture(): Texture;
  144921. set refractionTexture(value: Texture);
  144922. /**
  144923. * Initializes the RefractionPostProcess
  144924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  144925. * @param name The name of the effect.
  144926. * @param refractionTextureUrl Url of the refraction texture to use
  144927. * @param color the base color of the refraction (used to taint the rendering)
  144928. * @param depth simulated refraction depth
  144929. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  144930. * @param camera The camera to apply the render pass to.
  144931. * @param options The required width/height ratio to downsize to before computing the render pass.
  144932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144933. * @param engine The engine which the post process will be applied. (default: current engine)
  144934. * @param reusable If the post process can be reused on the same frame. (default: false)
  144935. */
  144936. constructor(name: string, refractionTextureUrl: string,
  144937. /** the base color of the refraction (used to taint the rendering) */
  144938. color: Color3,
  144939. /** simulated refraction depth */
  144940. depth: number,
  144941. /** the coefficient of the base color (0 to remove base color tainting) */
  144942. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144943. /**
  144944. * Disposes of the post process
  144945. * @param camera Camera to dispose post process on
  144946. */
  144947. dispose(camera: Camera): void;
  144948. }
  144949. }
  144950. declare module BABYLON {
  144951. /** @hidden */
  144952. export var sharpenPixelShader: {
  144953. name: string;
  144954. shader: string;
  144955. };
  144956. }
  144957. declare module BABYLON {
  144958. /**
  144959. * The SharpenPostProcess applies a sharpen kernel to every pixel
  144960. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144961. */
  144962. export class SharpenPostProcess extends PostProcess {
  144963. /**
  144964. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  144965. */
  144966. colorAmount: number;
  144967. /**
  144968. * How much sharpness should be applied (default: 0.3)
  144969. */
  144970. edgeAmount: number;
  144971. /**
  144972. * Creates a new instance ConvolutionPostProcess
  144973. * @param name The name of the effect.
  144974. * @param options The required width/height ratio to downsize to before computing the render pass.
  144975. * @param camera The camera to apply the render pass to.
  144976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144977. * @param engine The engine which the post process will be applied. (default: current engine)
  144978. * @param reusable If the post process can be reused on the same frame. (default: false)
  144979. * @param textureType Type of textures used when performing the post process. (default: 0)
  144980. * @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)
  144981. */
  144982. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144983. }
  144984. }
  144985. declare module BABYLON {
  144986. /**
  144987. * PostProcessRenderPipeline
  144988. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  144989. */
  144990. export class PostProcessRenderPipeline {
  144991. private engine;
  144992. private _renderEffects;
  144993. private _renderEffectsForIsolatedPass;
  144994. /**
  144995. * List of inspectable custom properties (used by the Inspector)
  144996. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  144997. */
  144998. inspectableCustomProperties: IInspectable[];
  144999. /**
  145000. * @hidden
  145001. */
  145002. protected _cameras: Camera[];
  145003. /** @hidden */
  145004. _name: string;
  145005. /**
  145006. * Gets pipeline name
  145007. */
  145008. get name(): string;
  145009. /** Gets the list of attached cameras */
  145010. get cameras(): Camera[];
  145011. /**
  145012. * Initializes a PostProcessRenderPipeline
  145013. * @param engine engine to add the pipeline to
  145014. * @param name name of the pipeline
  145015. */
  145016. constructor(engine: Engine, name: string);
  145017. /**
  145018. * Gets the class name
  145019. * @returns "PostProcessRenderPipeline"
  145020. */
  145021. getClassName(): string;
  145022. /**
  145023. * If all the render effects in the pipeline are supported
  145024. */
  145025. get isSupported(): boolean;
  145026. /**
  145027. * Adds an effect to the pipeline
  145028. * @param renderEffect the effect to add
  145029. */
  145030. addEffect(renderEffect: PostProcessRenderEffect): void;
  145031. /** @hidden */
  145032. _rebuild(): void;
  145033. /** @hidden */
  145034. _enableEffect(renderEffectName: string, cameras: Camera): void;
  145035. /** @hidden */
  145036. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  145037. /** @hidden */
  145038. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145039. /** @hidden */
  145040. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145041. /** @hidden */
  145042. _attachCameras(cameras: Camera, unique: boolean): void;
  145043. /** @hidden */
  145044. _attachCameras(cameras: Camera[], unique: boolean): void;
  145045. /** @hidden */
  145046. _detachCameras(cameras: Camera): void;
  145047. /** @hidden */
  145048. _detachCameras(cameras: Nullable<Camera[]>): void;
  145049. /** @hidden */
  145050. _update(): void;
  145051. /** @hidden */
  145052. _reset(): void;
  145053. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  145054. /**
  145055. * Disposes of the pipeline
  145056. */
  145057. dispose(): void;
  145058. }
  145059. }
  145060. declare module BABYLON {
  145061. /**
  145062. * PostProcessRenderPipelineManager class
  145063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145064. */
  145065. export class PostProcessRenderPipelineManager {
  145066. private _renderPipelines;
  145067. /**
  145068. * Initializes a PostProcessRenderPipelineManager
  145069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145070. */
  145071. constructor();
  145072. /**
  145073. * Gets the list of supported render pipelines
  145074. */
  145075. get supportedPipelines(): PostProcessRenderPipeline[];
  145076. /**
  145077. * Adds a pipeline to the manager
  145078. * @param renderPipeline The pipeline to add
  145079. */
  145080. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  145081. /**
  145082. * Attaches a camera to the pipeline
  145083. * @param renderPipelineName The name of the pipeline to attach to
  145084. * @param cameras the camera to attach
  145085. * @param unique if the camera can be attached multiple times to the pipeline
  145086. */
  145087. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  145088. /**
  145089. * Detaches a camera from the pipeline
  145090. * @param renderPipelineName The name of the pipeline to detach from
  145091. * @param cameras the camera to detach
  145092. */
  145093. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  145094. /**
  145095. * Enables an effect by name on a pipeline
  145096. * @param renderPipelineName the name of the pipeline to enable the effect in
  145097. * @param renderEffectName the name of the effect to enable
  145098. * @param cameras the cameras that the effect should be enabled on
  145099. */
  145100. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145101. /**
  145102. * Disables an effect by name on a pipeline
  145103. * @param renderPipelineName the name of the pipeline to disable the effect in
  145104. * @param renderEffectName the name of the effect to disable
  145105. * @param cameras the cameras that the effect should be disabled on
  145106. */
  145107. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145108. /**
  145109. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  145110. */
  145111. update(): void;
  145112. /** @hidden */
  145113. _rebuild(): void;
  145114. /**
  145115. * Disposes of the manager and pipelines
  145116. */
  145117. dispose(): void;
  145118. }
  145119. }
  145120. declare module BABYLON {
  145121. interface Scene {
  145122. /** @hidden (Backing field) */
  145123. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145124. /**
  145125. * Gets the postprocess render pipeline manager
  145126. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145127. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145128. */
  145129. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145130. }
  145131. /**
  145132. * Defines the Render Pipeline scene component responsible to rendering pipelines
  145133. */
  145134. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  145135. /**
  145136. * The component name helpfull to identify the component in the list of scene components.
  145137. */
  145138. readonly name: string;
  145139. /**
  145140. * The scene the component belongs to.
  145141. */
  145142. scene: Scene;
  145143. /**
  145144. * Creates a new instance of the component for the given scene
  145145. * @param scene Defines the scene to register the component in
  145146. */
  145147. constructor(scene: Scene);
  145148. /**
  145149. * Registers the component in a given scene
  145150. */
  145151. register(): void;
  145152. /**
  145153. * Rebuilds the elements related to this component in case of
  145154. * context lost for instance.
  145155. */
  145156. rebuild(): void;
  145157. /**
  145158. * Disposes the component and the associated ressources
  145159. */
  145160. dispose(): void;
  145161. private _gatherRenderTargets;
  145162. }
  145163. }
  145164. declare module BABYLON {
  145165. /**
  145166. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  145167. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145168. */
  145169. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145170. private _scene;
  145171. private _camerasToBeAttached;
  145172. /**
  145173. * ID of the sharpen post process,
  145174. */
  145175. private readonly SharpenPostProcessId;
  145176. /**
  145177. * @ignore
  145178. * ID of the image processing post process;
  145179. */
  145180. readonly ImageProcessingPostProcessId: string;
  145181. /**
  145182. * @ignore
  145183. * ID of the Fast Approximate Anti-Aliasing post process;
  145184. */
  145185. readonly FxaaPostProcessId: string;
  145186. /**
  145187. * ID of the chromatic aberration post process,
  145188. */
  145189. private readonly ChromaticAberrationPostProcessId;
  145190. /**
  145191. * ID of the grain post process
  145192. */
  145193. private readonly GrainPostProcessId;
  145194. /**
  145195. * Sharpen post process which will apply a sharpen convolution to enhance edges
  145196. */
  145197. sharpen: SharpenPostProcess;
  145198. private _sharpenEffect;
  145199. private bloom;
  145200. /**
  145201. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  145202. */
  145203. depthOfField: DepthOfFieldEffect;
  145204. /**
  145205. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  145206. */
  145207. fxaa: FxaaPostProcess;
  145208. /**
  145209. * Image post processing pass used to perform operations such as tone mapping or color grading.
  145210. */
  145211. imageProcessing: ImageProcessingPostProcess;
  145212. /**
  145213. * Chromatic aberration post process which will shift rgb colors in the image
  145214. */
  145215. chromaticAberration: ChromaticAberrationPostProcess;
  145216. private _chromaticAberrationEffect;
  145217. /**
  145218. * Grain post process which add noise to the image
  145219. */
  145220. grain: GrainPostProcess;
  145221. private _grainEffect;
  145222. /**
  145223. * Glow post process which adds a glow to emissive areas of the image
  145224. */
  145225. private _glowLayer;
  145226. /**
  145227. * Animations which can be used to tweak settings over a period of time
  145228. */
  145229. animations: Animation[];
  145230. private _imageProcessingConfigurationObserver;
  145231. private _sharpenEnabled;
  145232. private _bloomEnabled;
  145233. private _depthOfFieldEnabled;
  145234. private _depthOfFieldBlurLevel;
  145235. private _fxaaEnabled;
  145236. private _imageProcessingEnabled;
  145237. private _defaultPipelineTextureType;
  145238. private _bloomScale;
  145239. private _chromaticAberrationEnabled;
  145240. private _grainEnabled;
  145241. private _buildAllowed;
  145242. /**
  145243. * Gets active scene
  145244. */
  145245. get scene(): Scene;
  145246. /**
  145247. * Enable or disable the sharpen process from the pipeline
  145248. */
  145249. set sharpenEnabled(enabled: boolean);
  145250. get sharpenEnabled(): boolean;
  145251. private _resizeObserver;
  145252. private _hardwareScaleLevel;
  145253. private _bloomKernel;
  145254. /**
  145255. * Specifies the size of the bloom blur kernel, relative to the final output size
  145256. */
  145257. get bloomKernel(): number;
  145258. set bloomKernel(value: number);
  145259. /**
  145260. * Specifies the weight of the bloom in the final rendering
  145261. */
  145262. private _bloomWeight;
  145263. /**
  145264. * Specifies the luma threshold for the area that will be blurred by the bloom
  145265. */
  145266. private _bloomThreshold;
  145267. private _hdr;
  145268. /**
  145269. * The strength of the bloom.
  145270. */
  145271. set bloomWeight(value: number);
  145272. get bloomWeight(): number;
  145273. /**
  145274. * The strength of the bloom.
  145275. */
  145276. set bloomThreshold(value: number);
  145277. get bloomThreshold(): number;
  145278. /**
  145279. * The scale of the bloom, lower value will provide better performance.
  145280. */
  145281. set bloomScale(value: number);
  145282. get bloomScale(): number;
  145283. /**
  145284. * Enable or disable the bloom from the pipeline
  145285. */
  145286. set bloomEnabled(enabled: boolean);
  145287. get bloomEnabled(): boolean;
  145288. private _rebuildBloom;
  145289. /**
  145290. * If the depth of field is enabled.
  145291. */
  145292. get depthOfFieldEnabled(): boolean;
  145293. set depthOfFieldEnabled(enabled: boolean);
  145294. /**
  145295. * Blur level of the depth of field effect. (Higher blur will effect performance)
  145296. */
  145297. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  145298. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  145299. /**
  145300. * If the anti aliasing is enabled.
  145301. */
  145302. set fxaaEnabled(enabled: boolean);
  145303. get fxaaEnabled(): boolean;
  145304. private _samples;
  145305. /**
  145306. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  145307. */
  145308. set samples(sampleCount: number);
  145309. get samples(): number;
  145310. /**
  145311. * If image processing is enabled.
  145312. */
  145313. set imageProcessingEnabled(enabled: boolean);
  145314. get imageProcessingEnabled(): boolean;
  145315. /**
  145316. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  145317. */
  145318. set glowLayerEnabled(enabled: boolean);
  145319. get glowLayerEnabled(): boolean;
  145320. /**
  145321. * Gets the glow layer (or null if not defined)
  145322. */
  145323. get glowLayer(): Nullable<GlowLayer>;
  145324. /**
  145325. * Enable or disable the chromaticAberration process from the pipeline
  145326. */
  145327. set chromaticAberrationEnabled(enabled: boolean);
  145328. get chromaticAberrationEnabled(): boolean;
  145329. /**
  145330. * Enable or disable the grain process from the pipeline
  145331. */
  145332. set grainEnabled(enabled: boolean);
  145333. get grainEnabled(): boolean;
  145334. /**
  145335. * @constructor
  145336. * @param name - The rendering pipeline name (default: "")
  145337. * @param hdr - If high dynamic range textures should be used (default: true)
  145338. * @param scene - The scene linked to this pipeline (default: the last created scene)
  145339. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  145340. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  145341. */
  145342. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  145343. /**
  145344. * Get the class name
  145345. * @returns "DefaultRenderingPipeline"
  145346. */
  145347. getClassName(): string;
  145348. /**
  145349. * Force the compilation of the entire pipeline.
  145350. */
  145351. prepare(): void;
  145352. private _hasCleared;
  145353. private _prevPostProcess;
  145354. private _prevPrevPostProcess;
  145355. private _setAutoClearAndTextureSharing;
  145356. private _depthOfFieldSceneObserver;
  145357. private _buildPipeline;
  145358. private _disposePostProcesses;
  145359. /**
  145360. * Adds a camera to the pipeline
  145361. * @param camera the camera to be added
  145362. */
  145363. addCamera(camera: Camera): void;
  145364. /**
  145365. * Removes a camera from the pipeline
  145366. * @param camera the camera to remove
  145367. */
  145368. removeCamera(camera: Camera): void;
  145369. /**
  145370. * Dispose of the pipeline and stop all post processes
  145371. */
  145372. dispose(): void;
  145373. /**
  145374. * Serialize the rendering pipeline (Used when exporting)
  145375. * @returns the serialized object
  145376. */
  145377. serialize(): any;
  145378. /**
  145379. * Parse the serialized pipeline
  145380. * @param source Source pipeline.
  145381. * @param scene The scene to load the pipeline to.
  145382. * @param rootUrl The URL of the serialized pipeline.
  145383. * @returns An instantiated pipeline from the serialized object.
  145384. */
  145385. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  145386. }
  145387. }
  145388. declare module BABYLON {
  145389. /** @hidden */
  145390. export var lensHighlightsPixelShader: {
  145391. name: string;
  145392. shader: string;
  145393. };
  145394. }
  145395. declare module BABYLON {
  145396. /** @hidden */
  145397. export var depthOfFieldPixelShader: {
  145398. name: string;
  145399. shader: string;
  145400. };
  145401. }
  145402. declare module BABYLON {
  145403. /**
  145404. * BABYLON.JS Chromatic Aberration GLSL Shader
  145405. * Author: Olivier Guyot
  145406. * Separates very slightly R, G and B colors on the edges of the screen
  145407. * Inspired by Francois Tarlier & Martins Upitis
  145408. */
  145409. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  145410. /**
  145411. * @ignore
  145412. * The chromatic aberration PostProcess id in the pipeline
  145413. */
  145414. LensChromaticAberrationEffect: string;
  145415. /**
  145416. * @ignore
  145417. * The highlights enhancing PostProcess id in the pipeline
  145418. */
  145419. HighlightsEnhancingEffect: string;
  145420. /**
  145421. * @ignore
  145422. * The depth-of-field PostProcess id in the pipeline
  145423. */
  145424. LensDepthOfFieldEffect: string;
  145425. private _scene;
  145426. private _depthTexture;
  145427. private _grainTexture;
  145428. private _chromaticAberrationPostProcess;
  145429. private _highlightsPostProcess;
  145430. private _depthOfFieldPostProcess;
  145431. private _edgeBlur;
  145432. private _grainAmount;
  145433. private _chromaticAberration;
  145434. private _distortion;
  145435. private _highlightsGain;
  145436. private _highlightsThreshold;
  145437. private _dofDistance;
  145438. private _dofAperture;
  145439. private _dofDarken;
  145440. private _dofPentagon;
  145441. private _blurNoise;
  145442. /**
  145443. * @constructor
  145444. *
  145445. * Effect parameters are as follow:
  145446. * {
  145447. * chromatic_aberration: number; // from 0 to x (1 for realism)
  145448. * edge_blur: number; // from 0 to x (1 for realism)
  145449. * distortion: number; // from 0 to x (1 for realism)
  145450. * grain_amount: number; // from 0 to 1
  145451. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  145452. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  145453. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  145454. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  145455. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  145456. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  145457. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  145458. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  145459. * }
  145460. * Note: if an effect parameter is unset, effect is disabled
  145461. *
  145462. * @param name The rendering pipeline name
  145463. * @param parameters - An object containing all parameters (see above)
  145464. * @param scene The scene linked to this pipeline
  145465. * @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)
  145466. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145467. */
  145468. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  145469. /**
  145470. * Get the class name
  145471. * @returns "LensRenderingPipeline"
  145472. */
  145473. getClassName(): string;
  145474. /**
  145475. * Gets associated scene
  145476. */
  145477. get scene(): Scene;
  145478. /**
  145479. * Gets or sets the edge blur
  145480. */
  145481. get edgeBlur(): number;
  145482. set edgeBlur(value: number);
  145483. /**
  145484. * Gets or sets the grain amount
  145485. */
  145486. get grainAmount(): number;
  145487. set grainAmount(value: number);
  145488. /**
  145489. * Gets or sets the chromatic aberration amount
  145490. */
  145491. get chromaticAberration(): number;
  145492. set chromaticAberration(value: number);
  145493. /**
  145494. * Gets or sets the depth of field aperture
  145495. */
  145496. get dofAperture(): number;
  145497. set dofAperture(value: number);
  145498. /**
  145499. * Gets or sets the edge distortion
  145500. */
  145501. get edgeDistortion(): number;
  145502. set edgeDistortion(value: number);
  145503. /**
  145504. * Gets or sets the depth of field distortion
  145505. */
  145506. get dofDistortion(): number;
  145507. set dofDistortion(value: number);
  145508. /**
  145509. * Gets or sets the darken out of focus amount
  145510. */
  145511. get darkenOutOfFocus(): number;
  145512. set darkenOutOfFocus(value: number);
  145513. /**
  145514. * Gets or sets a boolean indicating if blur noise is enabled
  145515. */
  145516. get blurNoise(): boolean;
  145517. set blurNoise(value: boolean);
  145518. /**
  145519. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  145520. */
  145521. get pentagonBokeh(): boolean;
  145522. set pentagonBokeh(value: boolean);
  145523. /**
  145524. * Gets or sets the highlight grain amount
  145525. */
  145526. get highlightsGain(): number;
  145527. set highlightsGain(value: number);
  145528. /**
  145529. * Gets or sets the highlight threshold
  145530. */
  145531. get highlightsThreshold(): number;
  145532. set highlightsThreshold(value: number);
  145533. /**
  145534. * Sets the amount of blur at the edges
  145535. * @param amount blur amount
  145536. */
  145537. setEdgeBlur(amount: number): void;
  145538. /**
  145539. * Sets edge blur to 0
  145540. */
  145541. disableEdgeBlur(): void;
  145542. /**
  145543. * Sets the amout of grain
  145544. * @param amount Amount of grain
  145545. */
  145546. setGrainAmount(amount: number): void;
  145547. /**
  145548. * Set grain amount to 0
  145549. */
  145550. disableGrain(): void;
  145551. /**
  145552. * Sets the chromatic aberration amount
  145553. * @param amount amount of chromatic aberration
  145554. */
  145555. setChromaticAberration(amount: number): void;
  145556. /**
  145557. * Sets chromatic aberration amount to 0
  145558. */
  145559. disableChromaticAberration(): void;
  145560. /**
  145561. * Sets the EdgeDistortion amount
  145562. * @param amount amount of EdgeDistortion
  145563. */
  145564. setEdgeDistortion(amount: number): void;
  145565. /**
  145566. * Sets edge distortion to 0
  145567. */
  145568. disableEdgeDistortion(): void;
  145569. /**
  145570. * Sets the FocusDistance amount
  145571. * @param amount amount of FocusDistance
  145572. */
  145573. setFocusDistance(amount: number): void;
  145574. /**
  145575. * Disables depth of field
  145576. */
  145577. disableDepthOfField(): void;
  145578. /**
  145579. * Sets the Aperture amount
  145580. * @param amount amount of Aperture
  145581. */
  145582. setAperture(amount: number): void;
  145583. /**
  145584. * Sets the DarkenOutOfFocus amount
  145585. * @param amount amount of DarkenOutOfFocus
  145586. */
  145587. setDarkenOutOfFocus(amount: number): void;
  145588. private _pentagonBokehIsEnabled;
  145589. /**
  145590. * Creates a pentagon bokeh effect
  145591. */
  145592. enablePentagonBokeh(): void;
  145593. /**
  145594. * Disables the pentagon bokeh effect
  145595. */
  145596. disablePentagonBokeh(): void;
  145597. /**
  145598. * Enables noise blur
  145599. */
  145600. enableNoiseBlur(): void;
  145601. /**
  145602. * Disables noise blur
  145603. */
  145604. disableNoiseBlur(): void;
  145605. /**
  145606. * Sets the HighlightsGain amount
  145607. * @param amount amount of HighlightsGain
  145608. */
  145609. setHighlightsGain(amount: number): void;
  145610. /**
  145611. * Sets the HighlightsThreshold amount
  145612. * @param amount amount of HighlightsThreshold
  145613. */
  145614. setHighlightsThreshold(amount: number): void;
  145615. /**
  145616. * Disables highlights
  145617. */
  145618. disableHighlights(): void;
  145619. /**
  145620. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  145621. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  145622. */
  145623. dispose(disableDepthRender?: boolean): void;
  145624. private _createChromaticAberrationPostProcess;
  145625. private _createHighlightsPostProcess;
  145626. private _createDepthOfFieldPostProcess;
  145627. private _createGrainTexture;
  145628. }
  145629. }
  145630. declare module BABYLON {
  145631. /** @hidden */
  145632. export var ssao2PixelShader: {
  145633. name: string;
  145634. shader: string;
  145635. };
  145636. }
  145637. declare module BABYLON {
  145638. /** @hidden */
  145639. export var ssaoCombinePixelShader: {
  145640. name: string;
  145641. shader: string;
  145642. };
  145643. }
  145644. declare module BABYLON {
  145645. /**
  145646. * Render pipeline to produce ssao effect
  145647. */
  145648. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  145649. /**
  145650. * @ignore
  145651. * The PassPostProcess id in the pipeline that contains the original scene color
  145652. */
  145653. SSAOOriginalSceneColorEffect: string;
  145654. /**
  145655. * @ignore
  145656. * The SSAO PostProcess id in the pipeline
  145657. */
  145658. SSAORenderEffect: string;
  145659. /**
  145660. * @ignore
  145661. * The horizontal blur PostProcess id in the pipeline
  145662. */
  145663. SSAOBlurHRenderEffect: string;
  145664. /**
  145665. * @ignore
  145666. * The vertical blur PostProcess id in the pipeline
  145667. */
  145668. SSAOBlurVRenderEffect: string;
  145669. /**
  145670. * @ignore
  145671. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  145672. */
  145673. SSAOCombineRenderEffect: string;
  145674. /**
  145675. * The output strength of the SSAO post-process. Default value is 1.0.
  145676. */
  145677. totalStrength: number;
  145678. /**
  145679. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  145680. */
  145681. maxZ: number;
  145682. /**
  145683. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  145684. */
  145685. minZAspect: number;
  145686. private _samples;
  145687. /**
  145688. * Number of samples used for the SSAO calculations. Default value is 8
  145689. */
  145690. set samples(n: number);
  145691. get samples(): number;
  145692. private _textureSamples;
  145693. /**
  145694. * Number of samples to use for antialiasing
  145695. */
  145696. set textureSamples(n: number);
  145697. get textureSamples(): number;
  145698. /**
  145699. * Ratio object used for SSAO ratio and blur ratio
  145700. */
  145701. private _ratio;
  145702. /**
  145703. * Dynamically generated sphere sampler.
  145704. */
  145705. private _sampleSphere;
  145706. /**
  145707. * Blur filter offsets
  145708. */
  145709. private _samplerOffsets;
  145710. private _expensiveBlur;
  145711. /**
  145712. * If bilateral blur should be used
  145713. */
  145714. set expensiveBlur(b: boolean);
  145715. get expensiveBlur(): boolean;
  145716. /**
  145717. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  145718. */
  145719. radius: number;
  145720. /**
  145721. * The base color of the SSAO post-process
  145722. * The final result is "base + ssao" between [0, 1]
  145723. */
  145724. base: number;
  145725. /**
  145726. * Support test.
  145727. */
  145728. static get IsSupported(): boolean;
  145729. private _scene;
  145730. private _depthTexture;
  145731. private _normalTexture;
  145732. private _randomTexture;
  145733. private _originalColorPostProcess;
  145734. private _ssaoPostProcess;
  145735. private _blurHPostProcess;
  145736. private _blurVPostProcess;
  145737. private _ssaoCombinePostProcess;
  145738. /**
  145739. * Gets active scene
  145740. */
  145741. get scene(): Scene;
  145742. /**
  145743. * @constructor
  145744. * @param name The rendering pipeline name
  145745. * @param scene The scene linked to this pipeline
  145746. * @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 }
  145747. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145748. */
  145749. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  145750. /**
  145751. * Get the class name
  145752. * @returns "SSAO2RenderingPipeline"
  145753. */
  145754. getClassName(): string;
  145755. /**
  145756. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  145757. */
  145758. dispose(disableGeometryBufferRenderer?: boolean): void;
  145759. private _createBlurPostProcess;
  145760. /** @hidden */
  145761. _rebuild(): void;
  145762. private _bits;
  145763. private _radicalInverse_VdC;
  145764. private _hammersley;
  145765. private _hemisphereSample_uniform;
  145766. private _generateHemisphere;
  145767. private _createSSAOPostProcess;
  145768. private _createSSAOCombinePostProcess;
  145769. private _createRandomTexture;
  145770. /**
  145771. * Serialize the rendering pipeline (Used when exporting)
  145772. * @returns the serialized object
  145773. */
  145774. serialize(): any;
  145775. /**
  145776. * Parse the serialized pipeline
  145777. * @param source Source pipeline.
  145778. * @param scene The scene to load the pipeline to.
  145779. * @param rootUrl The URL of the serialized pipeline.
  145780. * @returns An instantiated pipeline from the serialized object.
  145781. */
  145782. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  145783. }
  145784. }
  145785. declare module BABYLON {
  145786. /** @hidden */
  145787. export var ssaoPixelShader: {
  145788. name: string;
  145789. shader: string;
  145790. };
  145791. }
  145792. declare module BABYLON {
  145793. /**
  145794. * Render pipeline to produce ssao effect
  145795. */
  145796. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  145797. /**
  145798. * @ignore
  145799. * The PassPostProcess id in the pipeline that contains the original scene color
  145800. */
  145801. SSAOOriginalSceneColorEffect: string;
  145802. /**
  145803. * @ignore
  145804. * The SSAO PostProcess id in the pipeline
  145805. */
  145806. SSAORenderEffect: string;
  145807. /**
  145808. * @ignore
  145809. * The horizontal blur PostProcess id in the pipeline
  145810. */
  145811. SSAOBlurHRenderEffect: string;
  145812. /**
  145813. * @ignore
  145814. * The vertical blur PostProcess id in the pipeline
  145815. */
  145816. SSAOBlurVRenderEffect: string;
  145817. /**
  145818. * @ignore
  145819. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  145820. */
  145821. SSAOCombineRenderEffect: string;
  145822. /**
  145823. * The output strength of the SSAO post-process. Default value is 1.0.
  145824. */
  145825. totalStrength: number;
  145826. /**
  145827. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  145828. */
  145829. radius: number;
  145830. /**
  145831. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  145832. * Must not be equal to fallOff and superior to fallOff.
  145833. * Default value is 0.0075
  145834. */
  145835. area: number;
  145836. /**
  145837. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  145838. * Must not be equal to area and inferior to area.
  145839. * Default value is 0.000001
  145840. */
  145841. fallOff: number;
  145842. /**
  145843. * The base color of the SSAO post-process
  145844. * The final result is "base + ssao" between [0, 1]
  145845. */
  145846. base: number;
  145847. private _scene;
  145848. private _depthTexture;
  145849. private _randomTexture;
  145850. private _originalColorPostProcess;
  145851. private _ssaoPostProcess;
  145852. private _blurHPostProcess;
  145853. private _blurVPostProcess;
  145854. private _ssaoCombinePostProcess;
  145855. private _firstUpdate;
  145856. /**
  145857. * Gets active scene
  145858. */
  145859. get scene(): Scene;
  145860. /**
  145861. * @constructor
  145862. * @param name - The rendering pipeline name
  145863. * @param scene - The scene linked to this pipeline
  145864. * @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 }
  145865. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  145866. */
  145867. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  145868. /**
  145869. * Get the class name
  145870. * @returns "SSAORenderingPipeline"
  145871. */
  145872. getClassName(): string;
  145873. /**
  145874. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  145875. */
  145876. dispose(disableDepthRender?: boolean): void;
  145877. private _createBlurPostProcess;
  145878. /** @hidden */
  145879. _rebuild(): void;
  145880. private _createSSAOPostProcess;
  145881. private _createSSAOCombinePostProcess;
  145882. private _createRandomTexture;
  145883. }
  145884. }
  145885. declare module BABYLON {
  145886. /** @hidden */
  145887. export var screenSpaceReflectionPixelShader: {
  145888. name: string;
  145889. shader: string;
  145890. };
  145891. }
  145892. declare module BABYLON {
  145893. /**
  145894. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  145895. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  145896. */
  145897. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  145898. /**
  145899. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  145900. */
  145901. threshold: number;
  145902. /**
  145903. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  145904. */
  145905. strength: number;
  145906. /**
  145907. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  145908. */
  145909. reflectionSpecularFalloffExponent: number;
  145910. /**
  145911. * 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]
  145912. */
  145913. step: number;
  145914. /**
  145915. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  145916. */
  145917. roughnessFactor: number;
  145918. private _geometryBufferRenderer;
  145919. private _enableSmoothReflections;
  145920. private _reflectionSamples;
  145921. private _smoothSteps;
  145922. /**
  145923. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  145924. * @param name The name of the effect.
  145925. * @param scene The scene containing the objects to calculate reflections.
  145926. * @param options The required width/height ratio to downsize to before computing the render pass.
  145927. * @param camera The camera to apply the render pass to.
  145928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145929. * @param engine The engine which the post process will be applied. (default: current engine)
  145930. * @param reusable If the post process can be reused on the same frame. (default: false)
  145931. * @param textureType Type of textures used when performing the post process. (default: 0)
  145932. * @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)
  145933. */
  145934. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145935. /**
  145936. * Gets wether or not smoothing reflections is enabled.
  145937. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  145938. */
  145939. get enableSmoothReflections(): boolean;
  145940. /**
  145941. * Sets wether or not smoothing reflections is enabled.
  145942. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  145943. */
  145944. set enableSmoothReflections(enabled: boolean);
  145945. /**
  145946. * Gets the number of samples taken while computing reflections. More samples count is high,
  145947. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  145948. */
  145949. get reflectionSamples(): number;
  145950. /**
  145951. * Sets the number of samples taken while computing reflections. More samples count is high,
  145952. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  145953. */
  145954. set reflectionSamples(samples: number);
  145955. /**
  145956. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  145957. * more the post-process will require GPU power and can generate a drop in FPS.
  145958. * Default value (5.0) work pretty well in all cases but can be adjusted.
  145959. */
  145960. get smoothSteps(): number;
  145961. set smoothSteps(steps: number);
  145962. private _updateEffectDefines;
  145963. }
  145964. }
  145965. declare module BABYLON {
  145966. /** @hidden */
  145967. export var standardPixelShader: {
  145968. name: string;
  145969. shader: string;
  145970. };
  145971. }
  145972. declare module BABYLON {
  145973. /**
  145974. * Standard rendering pipeline
  145975. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  145976. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  145977. */
  145978. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145979. /**
  145980. * Public members
  145981. */
  145982. /**
  145983. * Post-process which contains the original scene color before the pipeline applies all the effects
  145984. */
  145985. originalPostProcess: Nullable<PostProcess>;
  145986. /**
  145987. * Post-process used to down scale an image x4
  145988. */
  145989. downSampleX4PostProcess: Nullable<PostProcess>;
  145990. /**
  145991. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  145992. */
  145993. brightPassPostProcess: Nullable<PostProcess>;
  145994. /**
  145995. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  145996. */
  145997. blurHPostProcesses: PostProcess[];
  145998. /**
  145999. * Post-process array storing all the vertical blur post-processes used by the pipeline
  146000. */
  146001. blurVPostProcesses: PostProcess[];
  146002. /**
  146003. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  146004. */
  146005. textureAdderPostProcess: Nullable<PostProcess>;
  146006. /**
  146007. * Post-process used to create volumetric lighting effect
  146008. */
  146009. volumetricLightPostProcess: Nullable<PostProcess>;
  146010. /**
  146011. * Post-process used to smooth the previous volumetric light post-process on the X axis
  146012. */
  146013. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  146014. /**
  146015. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  146016. */
  146017. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  146018. /**
  146019. * Post-process used to merge the volumetric light effect and the real scene color
  146020. */
  146021. volumetricLightMergePostProces: Nullable<PostProcess>;
  146022. /**
  146023. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  146024. */
  146025. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  146026. /**
  146027. * Base post-process used to calculate the average luminance of the final image for HDR
  146028. */
  146029. luminancePostProcess: Nullable<PostProcess>;
  146030. /**
  146031. * Post-processes used to create down sample post-processes in order to get
  146032. * the average luminance of the final image for HDR
  146033. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  146034. */
  146035. luminanceDownSamplePostProcesses: PostProcess[];
  146036. /**
  146037. * Post-process used to create a HDR effect (light adaptation)
  146038. */
  146039. hdrPostProcess: Nullable<PostProcess>;
  146040. /**
  146041. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  146042. */
  146043. textureAdderFinalPostProcess: Nullable<PostProcess>;
  146044. /**
  146045. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  146046. */
  146047. lensFlareFinalPostProcess: Nullable<PostProcess>;
  146048. /**
  146049. * Post-process used to merge the final HDR post-process and the real scene color
  146050. */
  146051. hdrFinalPostProcess: Nullable<PostProcess>;
  146052. /**
  146053. * Post-process used to create a lens flare effect
  146054. */
  146055. lensFlarePostProcess: Nullable<PostProcess>;
  146056. /**
  146057. * Post-process that merges the result of the lens flare post-process and the real scene color
  146058. */
  146059. lensFlareComposePostProcess: Nullable<PostProcess>;
  146060. /**
  146061. * Post-process used to create a motion blur effect
  146062. */
  146063. motionBlurPostProcess: Nullable<PostProcess>;
  146064. /**
  146065. * Post-process used to create a depth of field effect
  146066. */
  146067. depthOfFieldPostProcess: Nullable<PostProcess>;
  146068. /**
  146069. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146070. */
  146071. fxaaPostProcess: Nullable<FxaaPostProcess>;
  146072. /**
  146073. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  146074. */
  146075. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  146076. /**
  146077. * Represents the brightness threshold in order to configure the illuminated surfaces
  146078. */
  146079. brightThreshold: number;
  146080. /**
  146081. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  146082. */
  146083. blurWidth: number;
  146084. /**
  146085. * Sets if the blur for highlighted surfaces must be only horizontal
  146086. */
  146087. horizontalBlur: boolean;
  146088. /**
  146089. * Gets the overall exposure used by the pipeline
  146090. */
  146091. get exposure(): number;
  146092. /**
  146093. * Sets the overall exposure used by the pipeline
  146094. */
  146095. set exposure(value: number);
  146096. /**
  146097. * Texture used typically to simulate "dirty" on camera lens
  146098. */
  146099. lensTexture: Nullable<Texture>;
  146100. /**
  146101. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  146102. */
  146103. volumetricLightCoefficient: number;
  146104. /**
  146105. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  146106. */
  146107. volumetricLightPower: number;
  146108. /**
  146109. * Used the set the blur intensity to smooth the volumetric lights
  146110. */
  146111. volumetricLightBlurScale: number;
  146112. /**
  146113. * Light (spot or directional) used to generate the volumetric lights rays
  146114. * The source light must have a shadow generate so the pipeline can get its
  146115. * depth map
  146116. */
  146117. sourceLight: Nullable<SpotLight | DirectionalLight>;
  146118. /**
  146119. * For eye adaptation, represents the minimum luminance the eye can see
  146120. */
  146121. hdrMinimumLuminance: number;
  146122. /**
  146123. * For eye adaptation, represents the decrease luminance speed
  146124. */
  146125. hdrDecreaseRate: number;
  146126. /**
  146127. * For eye adaptation, represents the increase luminance speed
  146128. */
  146129. hdrIncreaseRate: number;
  146130. /**
  146131. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146132. */
  146133. get hdrAutoExposure(): boolean;
  146134. /**
  146135. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146136. */
  146137. set hdrAutoExposure(value: boolean);
  146138. /**
  146139. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  146140. */
  146141. lensColorTexture: Nullable<Texture>;
  146142. /**
  146143. * The overall strengh for the lens flare effect
  146144. */
  146145. lensFlareStrength: number;
  146146. /**
  146147. * Dispersion coefficient for lens flare ghosts
  146148. */
  146149. lensFlareGhostDispersal: number;
  146150. /**
  146151. * Main lens flare halo width
  146152. */
  146153. lensFlareHaloWidth: number;
  146154. /**
  146155. * Based on the lens distortion effect, defines how much the lens flare result
  146156. * is distorted
  146157. */
  146158. lensFlareDistortionStrength: number;
  146159. /**
  146160. * Configures the blur intensity used for for lens flare (halo)
  146161. */
  146162. lensFlareBlurWidth: number;
  146163. /**
  146164. * Lens star texture must be used to simulate rays on the flares and is available
  146165. * in the documentation
  146166. */
  146167. lensStarTexture: Nullable<Texture>;
  146168. /**
  146169. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  146170. * flare effect by taking account of the dirt texture
  146171. */
  146172. lensFlareDirtTexture: Nullable<Texture>;
  146173. /**
  146174. * Represents the focal length for the depth of field effect
  146175. */
  146176. depthOfFieldDistance: number;
  146177. /**
  146178. * Represents the blur intensity for the blurred part of the depth of field effect
  146179. */
  146180. depthOfFieldBlurWidth: number;
  146181. /**
  146182. * Gets how much the image is blurred by the movement while using the motion blur post-process
  146183. */
  146184. get motionStrength(): number;
  146185. /**
  146186. * Sets how much the image is blurred by the movement while using the motion blur post-process
  146187. */
  146188. set motionStrength(strength: number);
  146189. /**
  146190. * Gets wether or not the motion blur post-process is object based or screen based.
  146191. */
  146192. get objectBasedMotionBlur(): boolean;
  146193. /**
  146194. * Sets wether or not the motion blur post-process should be object based or screen based
  146195. */
  146196. set objectBasedMotionBlur(value: boolean);
  146197. /**
  146198. * List of animations for the pipeline (IAnimatable implementation)
  146199. */
  146200. animations: Animation[];
  146201. /**
  146202. * Private members
  146203. */
  146204. private _scene;
  146205. private _currentDepthOfFieldSource;
  146206. private _basePostProcess;
  146207. private _fixedExposure;
  146208. private _currentExposure;
  146209. private _hdrAutoExposure;
  146210. private _hdrCurrentLuminance;
  146211. private _motionStrength;
  146212. private _isObjectBasedMotionBlur;
  146213. private _floatTextureType;
  146214. private _camerasToBeAttached;
  146215. private _ratio;
  146216. private _bloomEnabled;
  146217. private _depthOfFieldEnabled;
  146218. private _vlsEnabled;
  146219. private _lensFlareEnabled;
  146220. private _hdrEnabled;
  146221. private _motionBlurEnabled;
  146222. private _fxaaEnabled;
  146223. private _screenSpaceReflectionsEnabled;
  146224. private _motionBlurSamples;
  146225. private _volumetricLightStepsCount;
  146226. private _samples;
  146227. /**
  146228. * @ignore
  146229. * Specifies if the bloom pipeline is enabled
  146230. */
  146231. get BloomEnabled(): boolean;
  146232. set BloomEnabled(enabled: boolean);
  146233. /**
  146234. * @ignore
  146235. * Specifies if the depth of field pipeline is enabed
  146236. */
  146237. get DepthOfFieldEnabled(): boolean;
  146238. set DepthOfFieldEnabled(enabled: boolean);
  146239. /**
  146240. * @ignore
  146241. * Specifies if the lens flare pipeline is enabed
  146242. */
  146243. get LensFlareEnabled(): boolean;
  146244. set LensFlareEnabled(enabled: boolean);
  146245. /**
  146246. * @ignore
  146247. * Specifies if the HDR pipeline is enabled
  146248. */
  146249. get HDREnabled(): boolean;
  146250. set HDREnabled(enabled: boolean);
  146251. /**
  146252. * @ignore
  146253. * Specifies if the volumetric lights scattering effect is enabled
  146254. */
  146255. get VLSEnabled(): boolean;
  146256. set VLSEnabled(enabled: boolean);
  146257. /**
  146258. * @ignore
  146259. * Specifies if the motion blur effect is enabled
  146260. */
  146261. get MotionBlurEnabled(): boolean;
  146262. set MotionBlurEnabled(enabled: boolean);
  146263. /**
  146264. * Specifies if anti-aliasing is enabled
  146265. */
  146266. get fxaaEnabled(): boolean;
  146267. set fxaaEnabled(enabled: boolean);
  146268. /**
  146269. * Specifies if screen space reflections are enabled.
  146270. */
  146271. get screenSpaceReflectionsEnabled(): boolean;
  146272. set screenSpaceReflectionsEnabled(enabled: boolean);
  146273. /**
  146274. * Specifies the number of steps used to calculate the volumetric lights
  146275. * Typically in interval [50, 200]
  146276. */
  146277. get volumetricLightStepsCount(): number;
  146278. set volumetricLightStepsCount(count: number);
  146279. /**
  146280. * Specifies the number of samples used for the motion blur effect
  146281. * Typically in interval [16, 64]
  146282. */
  146283. get motionBlurSamples(): number;
  146284. set motionBlurSamples(samples: number);
  146285. /**
  146286. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146287. */
  146288. get samples(): number;
  146289. set samples(sampleCount: number);
  146290. /**
  146291. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146292. * @constructor
  146293. * @param name The rendering pipeline name
  146294. * @param scene The scene linked to this pipeline
  146295. * @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)
  146296. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  146297. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146298. */
  146299. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  146300. private _buildPipeline;
  146301. private _createDownSampleX4PostProcess;
  146302. private _createBrightPassPostProcess;
  146303. private _createBlurPostProcesses;
  146304. private _createTextureAdderPostProcess;
  146305. private _createVolumetricLightPostProcess;
  146306. private _createLuminancePostProcesses;
  146307. private _createHdrPostProcess;
  146308. private _createLensFlarePostProcess;
  146309. private _createDepthOfFieldPostProcess;
  146310. private _createMotionBlurPostProcess;
  146311. private _getDepthTexture;
  146312. private _disposePostProcesses;
  146313. /**
  146314. * Dispose of the pipeline and stop all post processes
  146315. */
  146316. dispose(): void;
  146317. /**
  146318. * Serialize the rendering pipeline (Used when exporting)
  146319. * @returns the serialized object
  146320. */
  146321. serialize(): any;
  146322. /**
  146323. * Parse the serialized pipeline
  146324. * @param source Source pipeline.
  146325. * @param scene The scene to load the pipeline to.
  146326. * @param rootUrl The URL of the serialized pipeline.
  146327. * @returns An instantiated pipeline from the serialized object.
  146328. */
  146329. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  146330. /**
  146331. * Luminance steps
  146332. */
  146333. static LuminanceSteps: number;
  146334. }
  146335. }
  146336. declare module BABYLON {
  146337. /** @hidden */
  146338. export var stereoscopicInterlacePixelShader: {
  146339. name: string;
  146340. shader: string;
  146341. };
  146342. }
  146343. declare module BABYLON {
  146344. /**
  146345. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  146346. */
  146347. export class StereoscopicInterlacePostProcessI extends PostProcess {
  146348. private _stepSize;
  146349. private _passedProcess;
  146350. /**
  146351. * Initializes a StereoscopicInterlacePostProcessI
  146352. * @param name The name of the effect.
  146353. * @param rigCameras The rig cameras to be appled to the post process
  146354. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  146355. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  146356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146357. * @param engine The engine which the post process will be applied. (default: current engine)
  146358. * @param reusable If the post process can be reused on the same frame. (default: false)
  146359. */
  146360. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146361. }
  146362. /**
  146363. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  146364. */
  146365. export class StereoscopicInterlacePostProcess extends PostProcess {
  146366. private _stepSize;
  146367. private _passedProcess;
  146368. /**
  146369. * Initializes a StereoscopicInterlacePostProcess
  146370. * @param name The name of the effect.
  146371. * @param rigCameras The rig cameras to be appled to the post process
  146372. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  146373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146374. * @param engine The engine which the post process will be applied. (default: current engine)
  146375. * @param reusable If the post process can be reused on the same frame. (default: false)
  146376. */
  146377. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146378. }
  146379. }
  146380. declare module BABYLON {
  146381. /** @hidden */
  146382. export var tonemapPixelShader: {
  146383. name: string;
  146384. shader: string;
  146385. };
  146386. }
  146387. declare module BABYLON {
  146388. /** Defines operator used for tonemapping */
  146389. export enum TonemappingOperator {
  146390. /** Hable */
  146391. Hable = 0,
  146392. /** Reinhard */
  146393. Reinhard = 1,
  146394. /** HejiDawson */
  146395. HejiDawson = 2,
  146396. /** Photographic */
  146397. Photographic = 3
  146398. }
  146399. /**
  146400. * Defines a post process to apply tone mapping
  146401. */
  146402. export class TonemapPostProcess extends PostProcess {
  146403. private _operator;
  146404. /** Defines the required exposure adjustement */
  146405. exposureAdjustment: number;
  146406. /**
  146407. * Creates a new TonemapPostProcess
  146408. * @param name defines the name of the postprocess
  146409. * @param _operator defines the operator to use
  146410. * @param exposureAdjustment defines the required exposure adjustement
  146411. * @param camera defines the camera to use (can be null)
  146412. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  146413. * @param engine defines the hosting engine (can be ignore if camera is set)
  146414. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  146415. */
  146416. constructor(name: string, _operator: TonemappingOperator,
  146417. /** Defines the required exposure adjustement */
  146418. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  146419. }
  146420. }
  146421. declare module BABYLON {
  146422. /** @hidden */
  146423. export var volumetricLightScatteringPixelShader: {
  146424. name: string;
  146425. shader: string;
  146426. };
  146427. }
  146428. declare module BABYLON {
  146429. /** @hidden */
  146430. export var volumetricLightScatteringPassVertexShader: {
  146431. name: string;
  146432. shader: string;
  146433. };
  146434. }
  146435. declare module BABYLON {
  146436. /** @hidden */
  146437. export var volumetricLightScatteringPassPixelShader: {
  146438. name: string;
  146439. shader: string;
  146440. };
  146441. }
  146442. declare module BABYLON {
  146443. /**
  146444. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  146445. */
  146446. export class VolumetricLightScatteringPostProcess extends PostProcess {
  146447. private _volumetricLightScatteringPass;
  146448. private _volumetricLightScatteringRTT;
  146449. private _viewPort;
  146450. private _screenCoordinates;
  146451. private _cachedDefines;
  146452. /**
  146453. * If not undefined, the mesh position is computed from the attached node position
  146454. */
  146455. attachedNode: {
  146456. position: Vector3;
  146457. };
  146458. /**
  146459. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  146460. */
  146461. customMeshPosition: Vector3;
  146462. /**
  146463. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  146464. */
  146465. useCustomMeshPosition: boolean;
  146466. /**
  146467. * If the post-process should inverse the light scattering direction
  146468. */
  146469. invert: boolean;
  146470. /**
  146471. * The internal mesh used by the post-process
  146472. */
  146473. mesh: Mesh;
  146474. /**
  146475. * @hidden
  146476. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  146477. */
  146478. get useDiffuseColor(): boolean;
  146479. set useDiffuseColor(useDiffuseColor: boolean);
  146480. /**
  146481. * Array containing the excluded meshes not rendered in the internal pass
  146482. */
  146483. excludedMeshes: AbstractMesh[];
  146484. /**
  146485. * Controls the overall intensity of the post-process
  146486. */
  146487. exposure: number;
  146488. /**
  146489. * Dissipates each sample's contribution in range [0, 1]
  146490. */
  146491. decay: number;
  146492. /**
  146493. * Controls the overall intensity of each sample
  146494. */
  146495. weight: number;
  146496. /**
  146497. * Controls the density of each sample
  146498. */
  146499. density: number;
  146500. /**
  146501. * @constructor
  146502. * @param name The post-process name
  146503. * @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)
  146504. * @param camera The camera that the post-process will be attached to
  146505. * @param mesh The mesh used to create the light scattering
  146506. * @param samples The post-process quality, default 100
  146507. * @param samplingModeThe post-process filtering mode
  146508. * @param engine The babylon engine
  146509. * @param reusable If the post-process is reusable
  146510. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  146511. */
  146512. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  146513. /**
  146514. * Returns the string "VolumetricLightScatteringPostProcess"
  146515. * @returns "VolumetricLightScatteringPostProcess"
  146516. */
  146517. getClassName(): string;
  146518. private _isReady;
  146519. /**
  146520. * Sets the new light position for light scattering effect
  146521. * @param position The new custom light position
  146522. */
  146523. setCustomMeshPosition(position: Vector3): void;
  146524. /**
  146525. * Returns the light position for light scattering effect
  146526. * @return Vector3 The custom light position
  146527. */
  146528. getCustomMeshPosition(): Vector3;
  146529. /**
  146530. * Disposes the internal assets and detaches the post-process from the camera
  146531. */
  146532. dispose(camera: Camera): void;
  146533. /**
  146534. * Returns the render target texture used by the post-process
  146535. * @return the render target texture used by the post-process
  146536. */
  146537. getPass(): RenderTargetTexture;
  146538. private _meshExcluded;
  146539. private _createPass;
  146540. private _updateMeshScreenCoordinates;
  146541. /**
  146542. * Creates a default mesh for the Volumeric Light Scattering post-process
  146543. * @param name The mesh name
  146544. * @param scene The scene where to create the mesh
  146545. * @return the default mesh
  146546. */
  146547. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  146548. }
  146549. }
  146550. declare module BABYLON {
  146551. interface Scene {
  146552. /** @hidden (Backing field) */
  146553. _boundingBoxRenderer: BoundingBoxRenderer;
  146554. /** @hidden (Backing field) */
  146555. _forceShowBoundingBoxes: boolean;
  146556. /**
  146557. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  146558. */
  146559. forceShowBoundingBoxes: boolean;
  146560. /**
  146561. * Gets the bounding box renderer associated with the scene
  146562. * @returns a BoundingBoxRenderer
  146563. */
  146564. getBoundingBoxRenderer(): BoundingBoxRenderer;
  146565. }
  146566. interface AbstractMesh {
  146567. /** @hidden (Backing field) */
  146568. _showBoundingBox: boolean;
  146569. /**
  146570. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  146571. */
  146572. showBoundingBox: boolean;
  146573. }
  146574. /**
  146575. * Component responsible of rendering the bounding box of the meshes in a scene.
  146576. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  146577. */
  146578. export class BoundingBoxRenderer implements ISceneComponent {
  146579. /**
  146580. * The component name helpfull to identify the component in the list of scene components.
  146581. */
  146582. readonly name: string;
  146583. /**
  146584. * The scene the component belongs to.
  146585. */
  146586. scene: Scene;
  146587. /**
  146588. * Color of the bounding box lines placed in front of an object
  146589. */
  146590. frontColor: Color3;
  146591. /**
  146592. * Color of the bounding box lines placed behind an object
  146593. */
  146594. backColor: Color3;
  146595. /**
  146596. * Defines if the renderer should show the back lines or not
  146597. */
  146598. showBackLines: boolean;
  146599. /**
  146600. * Observable raised before rendering a bounding box
  146601. */
  146602. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  146603. /**
  146604. * Observable raised after rendering a bounding box
  146605. */
  146606. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  146607. /**
  146608. * @hidden
  146609. */
  146610. renderList: SmartArray<BoundingBox>;
  146611. private _colorShader;
  146612. private _vertexBuffers;
  146613. private _indexBuffer;
  146614. private _fillIndexBuffer;
  146615. private _fillIndexData;
  146616. /**
  146617. * Instantiates a new bounding box renderer in a scene.
  146618. * @param scene the scene the renderer renders in
  146619. */
  146620. constructor(scene: Scene);
  146621. /**
  146622. * Registers the component in a given scene
  146623. */
  146624. register(): void;
  146625. private _evaluateSubMesh;
  146626. private _activeMesh;
  146627. private _prepareRessources;
  146628. private _createIndexBuffer;
  146629. /**
  146630. * Rebuilds the elements related to this component in case of
  146631. * context lost for instance.
  146632. */
  146633. rebuild(): void;
  146634. /**
  146635. * @hidden
  146636. */
  146637. reset(): void;
  146638. /**
  146639. * Render the bounding boxes of a specific rendering group
  146640. * @param renderingGroupId defines the rendering group to render
  146641. */
  146642. render(renderingGroupId: number): void;
  146643. /**
  146644. * In case of occlusion queries, we can render the occlusion bounding box through this method
  146645. * @param mesh Define the mesh to render the occlusion bounding box for
  146646. */
  146647. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  146648. /**
  146649. * Dispose and release the resources attached to this renderer.
  146650. */
  146651. dispose(): void;
  146652. }
  146653. }
  146654. declare module BABYLON {
  146655. interface Scene {
  146656. /** @hidden (Backing field) */
  146657. _depthRenderer: {
  146658. [id: string]: DepthRenderer;
  146659. };
  146660. /**
  146661. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  146662. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  146663. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  146664. * @returns the created depth renderer
  146665. */
  146666. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  146667. /**
  146668. * Disables a depth renderer for a given camera
  146669. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  146670. */
  146671. disableDepthRenderer(camera?: Nullable<Camera>): void;
  146672. }
  146673. /**
  146674. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  146675. * in several rendering techniques.
  146676. */
  146677. export class DepthRendererSceneComponent implements ISceneComponent {
  146678. /**
  146679. * The component name helpfull to identify the component in the list of scene components.
  146680. */
  146681. readonly name: string;
  146682. /**
  146683. * The scene the component belongs to.
  146684. */
  146685. scene: Scene;
  146686. /**
  146687. * Creates a new instance of the component for the given scene
  146688. * @param scene Defines the scene to register the component in
  146689. */
  146690. constructor(scene: Scene);
  146691. /**
  146692. * Registers the component in a given scene
  146693. */
  146694. register(): void;
  146695. /**
  146696. * Rebuilds the elements related to this component in case of
  146697. * context lost for instance.
  146698. */
  146699. rebuild(): void;
  146700. /**
  146701. * Disposes the component and the associated ressources
  146702. */
  146703. dispose(): void;
  146704. private _gatherRenderTargets;
  146705. private _gatherActiveCameraRenderTargets;
  146706. }
  146707. }
  146708. declare module BABYLON {
  146709. /** @hidden */
  146710. export var outlinePixelShader: {
  146711. name: string;
  146712. shader: string;
  146713. };
  146714. }
  146715. declare module BABYLON {
  146716. /** @hidden */
  146717. export var outlineVertexShader: {
  146718. name: string;
  146719. shader: string;
  146720. };
  146721. }
  146722. declare module BABYLON {
  146723. interface Scene {
  146724. /** @hidden */
  146725. _outlineRenderer: OutlineRenderer;
  146726. /**
  146727. * Gets the outline renderer associated with the scene
  146728. * @returns a OutlineRenderer
  146729. */
  146730. getOutlineRenderer(): OutlineRenderer;
  146731. }
  146732. interface AbstractMesh {
  146733. /** @hidden (Backing field) */
  146734. _renderOutline: boolean;
  146735. /**
  146736. * Gets or sets a boolean indicating if the outline must be rendered as well
  146737. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  146738. */
  146739. renderOutline: boolean;
  146740. /** @hidden (Backing field) */
  146741. _renderOverlay: boolean;
  146742. /**
  146743. * Gets or sets a boolean indicating if the overlay must be rendered as well
  146744. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  146745. */
  146746. renderOverlay: boolean;
  146747. }
  146748. /**
  146749. * This class is responsible to draw bothe outline/overlay of meshes.
  146750. * It should not be used directly but through the available method on mesh.
  146751. */
  146752. export class OutlineRenderer implements ISceneComponent {
  146753. /**
  146754. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  146755. */
  146756. private static _StencilReference;
  146757. /**
  146758. * The name of the component. Each component must have a unique name.
  146759. */
  146760. name: string;
  146761. /**
  146762. * The scene the component belongs to.
  146763. */
  146764. scene: Scene;
  146765. /**
  146766. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  146767. */
  146768. zOffset: number;
  146769. private _engine;
  146770. private _effect;
  146771. private _cachedDefines;
  146772. private _savedDepthWrite;
  146773. /**
  146774. * Instantiates a new outline renderer. (There could be only one per scene).
  146775. * @param scene Defines the scene it belongs to
  146776. */
  146777. constructor(scene: Scene);
  146778. /**
  146779. * Register the component to one instance of a scene.
  146780. */
  146781. register(): void;
  146782. /**
  146783. * Rebuilds the elements related to this component in case of
  146784. * context lost for instance.
  146785. */
  146786. rebuild(): void;
  146787. /**
  146788. * Disposes the component and the associated ressources.
  146789. */
  146790. dispose(): void;
  146791. /**
  146792. * Renders the outline in the canvas.
  146793. * @param subMesh Defines the sumesh to render
  146794. * @param batch Defines the batch of meshes in case of instances
  146795. * @param useOverlay Defines if the rendering is for the overlay or the outline
  146796. */
  146797. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  146798. /**
  146799. * Returns whether or not the outline renderer is ready for a given submesh.
  146800. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  146801. * @param subMesh Defines the submesh to check readyness for
  146802. * @param useInstances Defines wheter wee are trying to render instances or not
  146803. * @returns true if ready otherwise false
  146804. */
  146805. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146806. private _beforeRenderingMesh;
  146807. private _afterRenderingMesh;
  146808. }
  146809. }
  146810. declare module BABYLON {
  146811. /**
  146812. * Defines the basic options interface of a Sprite Frame Source Size.
  146813. */
  146814. export interface ISpriteJSONSpriteSourceSize {
  146815. /**
  146816. * number of the original width of the Frame
  146817. */
  146818. w: number;
  146819. /**
  146820. * number of the original height of the Frame
  146821. */
  146822. h: number;
  146823. }
  146824. /**
  146825. * Defines the basic options interface of a Sprite Frame Data.
  146826. */
  146827. export interface ISpriteJSONSpriteFrameData {
  146828. /**
  146829. * number of the x offset of the Frame
  146830. */
  146831. x: number;
  146832. /**
  146833. * number of the y offset of the Frame
  146834. */
  146835. y: number;
  146836. /**
  146837. * number of the width of the Frame
  146838. */
  146839. w: number;
  146840. /**
  146841. * number of the height of the Frame
  146842. */
  146843. h: number;
  146844. }
  146845. /**
  146846. * Defines the basic options interface of a JSON Sprite.
  146847. */
  146848. export interface ISpriteJSONSprite {
  146849. /**
  146850. * string name of the Frame
  146851. */
  146852. filename: string;
  146853. /**
  146854. * ISpriteJSONSpriteFrame basic object of the frame data
  146855. */
  146856. frame: ISpriteJSONSpriteFrameData;
  146857. /**
  146858. * boolean to flag is the frame was rotated.
  146859. */
  146860. rotated: boolean;
  146861. /**
  146862. * boolean to flag is the frame was trimmed.
  146863. */
  146864. trimmed: boolean;
  146865. /**
  146866. * ISpriteJSONSpriteFrame basic object of the source data
  146867. */
  146868. spriteSourceSize: ISpriteJSONSpriteFrameData;
  146869. /**
  146870. * ISpriteJSONSpriteFrame basic object of the source data
  146871. */
  146872. sourceSize: ISpriteJSONSpriteSourceSize;
  146873. }
  146874. /**
  146875. * Defines the basic options interface of a JSON atlas.
  146876. */
  146877. export interface ISpriteJSONAtlas {
  146878. /**
  146879. * Array of objects that contain the frame data.
  146880. */
  146881. frames: Array<ISpriteJSONSprite>;
  146882. /**
  146883. * object basic object containing the sprite meta data.
  146884. */
  146885. meta?: object;
  146886. }
  146887. }
  146888. declare module BABYLON {
  146889. /** @hidden */
  146890. export var spriteMapPixelShader: {
  146891. name: string;
  146892. shader: string;
  146893. };
  146894. }
  146895. declare module BABYLON {
  146896. /** @hidden */
  146897. export var spriteMapVertexShader: {
  146898. name: string;
  146899. shader: string;
  146900. };
  146901. }
  146902. declare module BABYLON {
  146903. /**
  146904. * Defines the basic options interface of a SpriteMap
  146905. */
  146906. export interface ISpriteMapOptions {
  146907. /**
  146908. * Vector2 of the number of cells in the grid.
  146909. */
  146910. stageSize?: Vector2;
  146911. /**
  146912. * Vector2 of the size of the output plane in World Units.
  146913. */
  146914. outputSize?: Vector2;
  146915. /**
  146916. * Vector3 of the position of the output plane in World Units.
  146917. */
  146918. outputPosition?: Vector3;
  146919. /**
  146920. * Vector3 of the rotation of the output plane.
  146921. */
  146922. outputRotation?: Vector3;
  146923. /**
  146924. * number of layers that the system will reserve in resources.
  146925. */
  146926. layerCount?: number;
  146927. /**
  146928. * number of max animation frames a single cell will reserve in resources.
  146929. */
  146930. maxAnimationFrames?: number;
  146931. /**
  146932. * number cell index of the base tile when the system compiles.
  146933. */
  146934. baseTile?: number;
  146935. /**
  146936. * boolean flip the sprite after its been repositioned by the framing data.
  146937. */
  146938. flipU?: boolean;
  146939. /**
  146940. * Vector3 scalar of the global RGB values of the SpriteMap.
  146941. */
  146942. colorMultiply?: Vector3;
  146943. }
  146944. /**
  146945. * Defines the IDisposable interface in order to be cleanable from resources.
  146946. */
  146947. export interface ISpriteMap extends IDisposable {
  146948. /**
  146949. * String name of the SpriteMap.
  146950. */
  146951. name: string;
  146952. /**
  146953. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  146954. */
  146955. atlasJSON: ISpriteJSONAtlas;
  146956. /**
  146957. * Texture of the SpriteMap.
  146958. */
  146959. spriteSheet: Texture;
  146960. /**
  146961. * The parameters to initialize the SpriteMap with.
  146962. */
  146963. options: ISpriteMapOptions;
  146964. }
  146965. /**
  146966. * Class used to manage a grid restricted sprite deployment on an Output plane.
  146967. */
  146968. export class SpriteMap implements ISpriteMap {
  146969. /** The Name of the spriteMap */
  146970. name: string;
  146971. /** The JSON file with the frame and meta data */
  146972. atlasJSON: ISpriteJSONAtlas;
  146973. /** The systems Sprite Sheet Texture */
  146974. spriteSheet: Texture;
  146975. /** Arguments passed with the Constructor */
  146976. options: ISpriteMapOptions;
  146977. /** Public Sprite Storage array, parsed from atlasJSON */
  146978. sprites: Array<ISpriteJSONSprite>;
  146979. /** Returns the Number of Sprites in the System */
  146980. get spriteCount(): number;
  146981. /** Returns the Position of Output Plane*/
  146982. get position(): Vector3;
  146983. /** Returns the Position of Output Plane*/
  146984. set position(v: Vector3);
  146985. /** Returns the Rotation of Output Plane*/
  146986. get rotation(): Vector3;
  146987. /** Returns the Rotation of Output Plane*/
  146988. set rotation(v: Vector3);
  146989. /** Sets the AnimationMap*/
  146990. get animationMap(): RawTexture;
  146991. /** Sets the AnimationMap*/
  146992. set animationMap(v: RawTexture);
  146993. /** Scene that the SpriteMap was created in */
  146994. private _scene;
  146995. /** Texture Buffer of Float32 that holds tile frame data*/
  146996. private _frameMap;
  146997. /** Texture Buffers of Float32 that holds tileMap data*/
  146998. private _tileMaps;
  146999. /** Texture Buffer of Float32 that holds Animation Data*/
  147000. private _animationMap;
  147001. /** Custom ShaderMaterial Central to the System*/
  147002. private _material;
  147003. /** Custom ShaderMaterial Central to the System*/
  147004. private _output;
  147005. /** Systems Time Ticker*/
  147006. private _time;
  147007. /**
  147008. * Creates a new SpriteMap
  147009. * @param name defines the SpriteMaps Name
  147010. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  147011. * @param spriteSheet is the Texture that the Sprites are on.
  147012. * @param options a basic deployment configuration
  147013. * @param scene The Scene that the map is deployed on
  147014. */
  147015. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  147016. /**
  147017. * Returns tileID location
  147018. * @returns Vector2 the cell position ID
  147019. */
  147020. getTileID(): Vector2;
  147021. /**
  147022. * Gets the UV location of the mouse over the SpriteMap.
  147023. * @returns Vector2 the UV position of the mouse interaction
  147024. */
  147025. getMousePosition(): Vector2;
  147026. /**
  147027. * Creates the "frame" texture Buffer
  147028. * -------------------------------------
  147029. * Structure of frames
  147030. * "filename": "Falling-Water-2.png",
  147031. * "frame": {"x":69,"y":103,"w":24,"h":32},
  147032. * "rotated": true,
  147033. * "trimmed": true,
  147034. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  147035. * "sourceSize": {"w":32,"h":32}
  147036. * @returns RawTexture of the frameMap
  147037. */
  147038. private _createFrameBuffer;
  147039. /**
  147040. * Creates the tileMap texture Buffer
  147041. * @param buffer normally and array of numbers, or a false to generate from scratch
  147042. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  147043. * @returns RawTexture of the tileMap
  147044. */
  147045. private _createTileBuffer;
  147046. /**
  147047. * Modifies the data of the tileMaps
  147048. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  147049. * @param pos is the iVector2 Coordinates of the Tile
  147050. * @param tile The SpriteIndex of the new Tile
  147051. */
  147052. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  147053. /**
  147054. * Creates the animationMap texture Buffer
  147055. * @param buffer normally and array of numbers, or a false to generate from scratch
  147056. * @returns RawTexture of the animationMap
  147057. */
  147058. private _createTileAnimationBuffer;
  147059. /**
  147060. * Modifies the data of the animationMap
  147061. * @param cellID is the Index of the Sprite
  147062. * @param _frame is the target Animation frame
  147063. * @param toCell is the Target Index of the next frame of the animation
  147064. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  147065. * @param speed is a global scalar of the time variable on the map.
  147066. */
  147067. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  147068. /**
  147069. * Exports the .tilemaps file
  147070. */
  147071. saveTileMaps(): void;
  147072. /**
  147073. * Imports the .tilemaps file
  147074. * @param url of the .tilemaps file
  147075. */
  147076. loadTileMaps(url: string): void;
  147077. /**
  147078. * Release associated resources
  147079. */
  147080. dispose(): void;
  147081. }
  147082. }
  147083. declare module BABYLON {
  147084. /**
  147085. * Class used to manage multiple sprites of different sizes on the same spritesheet
  147086. * @see http://doc.babylonjs.com/babylon101/sprites
  147087. */
  147088. export class SpritePackedManager extends SpriteManager {
  147089. /** defines the packed manager's name */
  147090. name: string;
  147091. /**
  147092. * Creates a new sprite manager from a packed sprite sheet
  147093. * @param name defines the manager's name
  147094. * @param imgUrl defines the sprite sheet url
  147095. * @param capacity defines the maximum allowed number of sprites
  147096. * @param scene defines the hosting scene
  147097. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  147098. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  147099. * @param samplingMode defines the smapling mode to use with spritesheet
  147100. * @param fromPacked set to true; do not alter
  147101. */
  147102. constructor(
  147103. /** defines the packed manager's name */
  147104. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  147105. }
  147106. }
  147107. declare module BABYLON {
  147108. /**
  147109. * Defines the list of states available for a task inside a AssetsManager
  147110. */
  147111. export enum AssetTaskState {
  147112. /**
  147113. * Initialization
  147114. */
  147115. INIT = 0,
  147116. /**
  147117. * Running
  147118. */
  147119. RUNNING = 1,
  147120. /**
  147121. * Done
  147122. */
  147123. DONE = 2,
  147124. /**
  147125. * Error
  147126. */
  147127. ERROR = 3
  147128. }
  147129. /**
  147130. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  147131. */
  147132. export abstract class AbstractAssetTask {
  147133. /**
  147134. * Task name
  147135. */ name: string;
  147136. /**
  147137. * Callback called when the task is successful
  147138. */
  147139. onSuccess: (task: any) => void;
  147140. /**
  147141. * Callback called when the task is not successful
  147142. */
  147143. onError: (task: any, message?: string, exception?: any) => void;
  147144. /**
  147145. * Creates a new AssetsManager
  147146. * @param name defines the name of the task
  147147. */
  147148. constructor(
  147149. /**
  147150. * Task name
  147151. */ name: string);
  147152. private _isCompleted;
  147153. private _taskState;
  147154. private _errorObject;
  147155. /**
  147156. * Get if the task is completed
  147157. */
  147158. get isCompleted(): boolean;
  147159. /**
  147160. * Gets the current state of the task
  147161. */
  147162. get taskState(): AssetTaskState;
  147163. /**
  147164. * Gets the current error object (if task is in error)
  147165. */
  147166. get errorObject(): {
  147167. message?: string;
  147168. exception?: any;
  147169. };
  147170. /**
  147171. * Internal only
  147172. * @hidden
  147173. */
  147174. _setErrorObject(message?: string, exception?: any): void;
  147175. /**
  147176. * Execute the current task
  147177. * @param scene defines the scene where you want your assets to be loaded
  147178. * @param onSuccess is a callback called when the task is successfully executed
  147179. * @param onError is a callback called if an error occurs
  147180. */
  147181. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147182. /**
  147183. * Execute the current task
  147184. * @param scene defines the scene where you want your assets to be loaded
  147185. * @param onSuccess is a callback called when the task is successfully executed
  147186. * @param onError is a callback called if an error occurs
  147187. */
  147188. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147189. /**
  147190. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  147191. * This can be used with failed tasks that have the reason for failure fixed.
  147192. */
  147193. reset(): void;
  147194. private onErrorCallback;
  147195. private onDoneCallback;
  147196. }
  147197. /**
  147198. * Define the interface used by progress events raised during assets loading
  147199. */
  147200. export interface IAssetsProgressEvent {
  147201. /**
  147202. * Defines the number of remaining tasks to process
  147203. */
  147204. remainingCount: number;
  147205. /**
  147206. * Defines the total number of tasks
  147207. */
  147208. totalCount: number;
  147209. /**
  147210. * Defines the task that was just processed
  147211. */
  147212. task: AbstractAssetTask;
  147213. }
  147214. /**
  147215. * Class used to share progress information about assets loading
  147216. */
  147217. export class AssetsProgressEvent implements IAssetsProgressEvent {
  147218. /**
  147219. * Defines the number of remaining tasks to process
  147220. */
  147221. remainingCount: number;
  147222. /**
  147223. * Defines the total number of tasks
  147224. */
  147225. totalCount: number;
  147226. /**
  147227. * Defines the task that was just processed
  147228. */
  147229. task: AbstractAssetTask;
  147230. /**
  147231. * Creates a AssetsProgressEvent
  147232. * @param remainingCount defines the number of remaining tasks to process
  147233. * @param totalCount defines the total number of tasks
  147234. * @param task defines the task that was just processed
  147235. */
  147236. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  147237. }
  147238. /**
  147239. * Define a task used by AssetsManager to load meshes
  147240. */
  147241. export class MeshAssetTask extends AbstractAssetTask {
  147242. /**
  147243. * Defines the name of the task
  147244. */
  147245. name: string;
  147246. /**
  147247. * Defines the list of mesh's names you want to load
  147248. */
  147249. meshesNames: any;
  147250. /**
  147251. * Defines the root url to use as a base to load your meshes and associated resources
  147252. */
  147253. rootUrl: string;
  147254. /**
  147255. * Defines the filename or File of the scene to load from
  147256. */
  147257. sceneFilename: string | File;
  147258. /**
  147259. * Gets the list of loaded meshes
  147260. */
  147261. loadedMeshes: Array<AbstractMesh>;
  147262. /**
  147263. * Gets the list of loaded particle systems
  147264. */
  147265. loadedParticleSystems: Array<IParticleSystem>;
  147266. /**
  147267. * Gets the list of loaded skeletons
  147268. */
  147269. loadedSkeletons: Array<Skeleton>;
  147270. /**
  147271. * Gets the list of loaded animation groups
  147272. */
  147273. loadedAnimationGroups: Array<AnimationGroup>;
  147274. /**
  147275. * Callback called when the task is successful
  147276. */
  147277. onSuccess: (task: MeshAssetTask) => void;
  147278. /**
  147279. * Callback called when the task is successful
  147280. */
  147281. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  147282. /**
  147283. * Creates a new MeshAssetTask
  147284. * @param name defines the name of the task
  147285. * @param meshesNames defines the list of mesh's names you want to load
  147286. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  147287. * @param sceneFilename defines the filename or File of the scene to load from
  147288. */
  147289. constructor(
  147290. /**
  147291. * Defines the name of the task
  147292. */
  147293. name: string,
  147294. /**
  147295. * Defines the list of mesh's names you want to load
  147296. */
  147297. meshesNames: any,
  147298. /**
  147299. * Defines the root url to use as a base to load your meshes and associated resources
  147300. */
  147301. rootUrl: string,
  147302. /**
  147303. * Defines the filename or File of the scene to load from
  147304. */
  147305. sceneFilename: string | File);
  147306. /**
  147307. * Execute the current task
  147308. * @param scene defines the scene where you want your assets to be loaded
  147309. * @param onSuccess is a callback called when the task is successfully executed
  147310. * @param onError is a callback called if an error occurs
  147311. */
  147312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147313. }
  147314. /**
  147315. * Define a task used by AssetsManager to load text content
  147316. */
  147317. export class TextFileAssetTask extends AbstractAssetTask {
  147318. /**
  147319. * Defines the name of the task
  147320. */
  147321. name: string;
  147322. /**
  147323. * Defines the location of the file to load
  147324. */
  147325. url: string;
  147326. /**
  147327. * Gets the loaded text string
  147328. */
  147329. text: string;
  147330. /**
  147331. * Callback called when the task is successful
  147332. */
  147333. onSuccess: (task: TextFileAssetTask) => void;
  147334. /**
  147335. * Callback called when the task is successful
  147336. */
  147337. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  147338. /**
  147339. * Creates a new TextFileAssetTask object
  147340. * @param name defines the name of the task
  147341. * @param url defines the location of the file to load
  147342. */
  147343. constructor(
  147344. /**
  147345. * Defines the name of the task
  147346. */
  147347. name: string,
  147348. /**
  147349. * Defines the location of the file to load
  147350. */
  147351. url: string);
  147352. /**
  147353. * Execute the current task
  147354. * @param scene defines the scene where you want your assets to be loaded
  147355. * @param onSuccess is a callback called when the task is successfully executed
  147356. * @param onError is a callback called if an error occurs
  147357. */
  147358. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147359. }
  147360. /**
  147361. * Define a task used by AssetsManager to load binary data
  147362. */
  147363. export class BinaryFileAssetTask extends AbstractAssetTask {
  147364. /**
  147365. * Defines the name of the task
  147366. */
  147367. name: string;
  147368. /**
  147369. * Defines the location of the file to load
  147370. */
  147371. url: string;
  147372. /**
  147373. * Gets the lodaded data (as an array buffer)
  147374. */
  147375. data: ArrayBuffer;
  147376. /**
  147377. * Callback called when the task is successful
  147378. */
  147379. onSuccess: (task: BinaryFileAssetTask) => void;
  147380. /**
  147381. * Callback called when the task is successful
  147382. */
  147383. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  147384. /**
  147385. * Creates a new BinaryFileAssetTask object
  147386. * @param name defines the name of the new task
  147387. * @param url defines the location of the file to load
  147388. */
  147389. constructor(
  147390. /**
  147391. * Defines the name of the task
  147392. */
  147393. name: string,
  147394. /**
  147395. * Defines the location of the file to load
  147396. */
  147397. url: string);
  147398. /**
  147399. * Execute the current task
  147400. * @param scene defines the scene where you want your assets to be loaded
  147401. * @param onSuccess is a callback called when the task is successfully executed
  147402. * @param onError is a callback called if an error occurs
  147403. */
  147404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147405. }
  147406. /**
  147407. * Define a task used by AssetsManager to load images
  147408. */
  147409. export class ImageAssetTask extends AbstractAssetTask {
  147410. /**
  147411. * Defines the name of the task
  147412. */
  147413. name: string;
  147414. /**
  147415. * Defines the location of the image to load
  147416. */
  147417. url: string;
  147418. /**
  147419. * Gets the loaded images
  147420. */
  147421. image: HTMLImageElement;
  147422. /**
  147423. * Callback called when the task is successful
  147424. */
  147425. onSuccess: (task: ImageAssetTask) => void;
  147426. /**
  147427. * Callback called when the task is successful
  147428. */
  147429. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  147430. /**
  147431. * Creates a new ImageAssetTask
  147432. * @param name defines the name of the task
  147433. * @param url defines the location of the image to load
  147434. */
  147435. constructor(
  147436. /**
  147437. * Defines the name of the task
  147438. */
  147439. name: string,
  147440. /**
  147441. * Defines the location of the image to load
  147442. */
  147443. url: string);
  147444. /**
  147445. * Execute the current task
  147446. * @param scene defines the scene where you want your assets to be loaded
  147447. * @param onSuccess is a callback called when the task is successfully executed
  147448. * @param onError is a callback called if an error occurs
  147449. */
  147450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147451. }
  147452. /**
  147453. * Defines the interface used by texture loading tasks
  147454. */
  147455. export interface ITextureAssetTask<TEX extends BaseTexture> {
  147456. /**
  147457. * Gets the loaded texture
  147458. */
  147459. texture: TEX;
  147460. }
  147461. /**
  147462. * Define a task used by AssetsManager to load 2D textures
  147463. */
  147464. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  147465. /**
  147466. * Defines the name of the task
  147467. */
  147468. name: string;
  147469. /**
  147470. * Defines the location of the file to load
  147471. */
  147472. url: string;
  147473. /**
  147474. * Defines if mipmap should not be generated (default is false)
  147475. */
  147476. noMipmap?: boolean | undefined;
  147477. /**
  147478. * Defines if texture must be inverted on Y axis (default is true)
  147479. */
  147480. invertY: boolean;
  147481. /**
  147482. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147483. */
  147484. samplingMode: number;
  147485. /**
  147486. * Gets the loaded texture
  147487. */
  147488. texture: Texture;
  147489. /**
  147490. * Callback called when the task is successful
  147491. */
  147492. onSuccess: (task: TextureAssetTask) => void;
  147493. /**
  147494. * Callback called when the task is successful
  147495. */
  147496. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  147497. /**
  147498. * Creates a new TextureAssetTask object
  147499. * @param name defines the name of the task
  147500. * @param url defines the location of the file to load
  147501. * @param noMipmap defines if mipmap should not be generated (default is false)
  147502. * @param invertY defines if texture must be inverted on Y axis (default is true)
  147503. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147504. */
  147505. constructor(
  147506. /**
  147507. * Defines the name of the task
  147508. */
  147509. name: string,
  147510. /**
  147511. * Defines the location of the file to load
  147512. */
  147513. url: string,
  147514. /**
  147515. * Defines if mipmap should not be generated (default is false)
  147516. */
  147517. noMipmap?: boolean | undefined,
  147518. /**
  147519. * Defines if texture must be inverted on Y axis (default is true)
  147520. */
  147521. invertY?: boolean,
  147522. /**
  147523. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147524. */
  147525. samplingMode?: number);
  147526. /**
  147527. * Execute the current task
  147528. * @param scene defines the scene where you want your assets to be loaded
  147529. * @param onSuccess is a callback called when the task is successfully executed
  147530. * @param onError is a callback called if an error occurs
  147531. */
  147532. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147533. }
  147534. /**
  147535. * Define a task used by AssetsManager to load cube textures
  147536. */
  147537. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  147538. /**
  147539. * Defines the name of the task
  147540. */
  147541. name: string;
  147542. /**
  147543. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147544. */
  147545. url: string;
  147546. /**
  147547. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147548. */
  147549. extensions?: string[] | undefined;
  147550. /**
  147551. * Defines if mipmaps should not be generated (default is false)
  147552. */
  147553. noMipmap?: boolean | undefined;
  147554. /**
  147555. * Defines the explicit list of files (undefined by default)
  147556. */
  147557. files?: string[] | undefined;
  147558. /**
  147559. * Gets the loaded texture
  147560. */
  147561. texture: CubeTexture;
  147562. /**
  147563. * Callback called when the task is successful
  147564. */
  147565. onSuccess: (task: CubeTextureAssetTask) => void;
  147566. /**
  147567. * Callback called when the task is successful
  147568. */
  147569. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  147570. /**
  147571. * Creates a new CubeTextureAssetTask
  147572. * @param name defines the name of the task
  147573. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147574. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147575. * @param noMipmap defines if mipmaps should not be generated (default is false)
  147576. * @param files defines the explicit list of files (undefined by default)
  147577. */
  147578. constructor(
  147579. /**
  147580. * Defines the name of the task
  147581. */
  147582. name: string,
  147583. /**
  147584. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147585. */
  147586. url: string,
  147587. /**
  147588. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147589. */
  147590. extensions?: string[] | undefined,
  147591. /**
  147592. * Defines if mipmaps should not be generated (default is false)
  147593. */
  147594. noMipmap?: boolean | undefined,
  147595. /**
  147596. * Defines the explicit list of files (undefined by default)
  147597. */
  147598. files?: string[] | undefined);
  147599. /**
  147600. * Execute the current task
  147601. * @param scene defines the scene where you want your assets to be loaded
  147602. * @param onSuccess is a callback called when the task is successfully executed
  147603. * @param onError is a callback called if an error occurs
  147604. */
  147605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147606. }
  147607. /**
  147608. * Define a task used by AssetsManager to load HDR cube textures
  147609. */
  147610. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  147611. /**
  147612. * Defines the name of the task
  147613. */
  147614. name: string;
  147615. /**
  147616. * Defines the location of the file to load
  147617. */
  147618. url: string;
  147619. /**
  147620. * Defines the desired size (the more it increases the longer the generation will be)
  147621. */
  147622. size: number;
  147623. /**
  147624. * Defines if mipmaps should not be generated (default is false)
  147625. */
  147626. noMipmap: boolean;
  147627. /**
  147628. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  147629. */
  147630. generateHarmonics: boolean;
  147631. /**
  147632. * 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)
  147633. */
  147634. gammaSpace: boolean;
  147635. /**
  147636. * Internal Use Only
  147637. */
  147638. reserved: boolean;
  147639. /**
  147640. * Gets the loaded texture
  147641. */
  147642. texture: HDRCubeTexture;
  147643. /**
  147644. * Callback called when the task is successful
  147645. */
  147646. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  147647. /**
  147648. * Callback called when the task is successful
  147649. */
  147650. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  147651. /**
  147652. * Creates a new HDRCubeTextureAssetTask object
  147653. * @param name defines the name of the task
  147654. * @param url defines the location of the file to load
  147655. * @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.
  147656. * @param noMipmap defines if mipmaps should not be generated (default is false)
  147657. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  147658. * @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)
  147659. * @param reserved Internal use only
  147660. */
  147661. constructor(
  147662. /**
  147663. * Defines the name of the task
  147664. */
  147665. name: string,
  147666. /**
  147667. * Defines the location of the file to load
  147668. */
  147669. url: string,
  147670. /**
  147671. * Defines the desired size (the more it increases the longer the generation will be)
  147672. */
  147673. size: number,
  147674. /**
  147675. * Defines if mipmaps should not be generated (default is false)
  147676. */
  147677. noMipmap?: boolean,
  147678. /**
  147679. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  147680. */
  147681. generateHarmonics?: boolean,
  147682. /**
  147683. * 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)
  147684. */
  147685. gammaSpace?: boolean,
  147686. /**
  147687. * Internal Use Only
  147688. */
  147689. reserved?: boolean);
  147690. /**
  147691. * Execute the current task
  147692. * @param scene defines the scene where you want your assets to be loaded
  147693. * @param onSuccess is a callback called when the task is successfully executed
  147694. * @param onError is a callback called if an error occurs
  147695. */
  147696. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147697. }
  147698. /**
  147699. * Define a task used by AssetsManager to load Equirectangular cube textures
  147700. */
  147701. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  147702. /**
  147703. * Defines the name of the task
  147704. */
  147705. name: string;
  147706. /**
  147707. * Defines the location of the file to load
  147708. */
  147709. url: string;
  147710. /**
  147711. * Defines the desired size (the more it increases the longer the generation will be)
  147712. */
  147713. size: number;
  147714. /**
  147715. * Defines if mipmaps should not be generated (default is false)
  147716. */
  147717. noMipmap: boolean;
  147718. /**
  147719. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  147720. * but the standard material would require them in Gamma space) (default is true)
  147721. */
  147722. gammaSpace: boolean;
  147723. /**
  147724. * Gets the loaded texture
  147725. */
  147726. texture: EquiRectangularCubeTexture;
  147727. /**
  147728. * Callback called when the task is successful
  147729. */
  147730. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  147731. /**
  147732. * Callback called when the task is successful
  147733. */
  147734. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  147735. /**
  147736. * Creates a new EquiRectangularCubeTextureAssetTask object
  147737. * @param name defines the name of the task
  147738. * @param url defines the location of the file to load
  147739. * @param size defines the desired size (the more it increases the longer the generation will be)
  147740. * If the size is omitted this implies you are using a preprocessed cubemap.
  147741. * @param noMipmap defines if mipmaps should not be generated (default is false)
  147742. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  147743. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  147744. * (default is true)
  147745. */
  147746. constructor(
  147747. /**
  147748. * Defines the name of the task
  147749. */
  147750. name: string,
  147751. /**
  147752. * Defines the location of the file to load
  147753. */
  147754. url: string,
  147755. /**
  147756. * Defines the desired size (the more it increases the longer the generation will be)
  147757. */
  147758. size: number,
  147759. /**
  147760. * Defines if mipmaps should not be generated (default is false)
  147761. */
  147762. noMipmap?: boolean,
  147763. /**
  147764. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  147765. * but the standard material would require them in Gamma space) (default is true)
  147766. */
  147767. gammaSpace?: boolean);
  147768. /**
  147769. * Execute the current task
  147770. * @param scene defines the scene where you want your assets to be loaded
  147771. * @param onSuccess is a callback called when the task is successfully executed
  147772. * @param onError is a callback called if an error occurs
  147773. */
  147774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147775. }
  147776. /**
  147777. * This class can be used to easily import assets into a scene
  147778. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  147779. */
  147780. export class AssetsManager {
  147781. private _scene;
  147782. private _isLoading;
  147783. protected _tasks: AbstractAssetTask[];
  147784. protected _waitingTasksCount: number;
  147785. protected _totalTasksCount: number;
  147786. /**
  147787. * Callback called when all tasks are processed
  147788. */
  147789. onFinish: (tasks: AbstractAssetTask[]) => void;
  147790. /**
  147791. * Callback called when a task is successful
  147792. */
  147793. onTaskSuccess: (task: AbstractAssetTask) => void;
  147794. /**
  147795. * Callback called when a task had an error
  147796. */
  147797. onTaskError: (task: AbstractAssetTask) => void;
  147798. /**
  147799. * Callback called when a task is done (whatever the result is)
  147800. */
  147801. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  147802. /**
  147803. * Observable called when all tasks are processed
  147804. */
  147805. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  147806. /**
  147807. * Observable called when a task had an error
  147808. */
  147809. onTaskErrorObservable: Observable<AbstractAssetTask>;
  147810. /**
  147811. * Observable called when all tasks were executed
  147812. */
  147813. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  147814. /**
  147815. * Observable called when a task is done (whatever the result is)
  147816. */
  147817. onProgressObservable: Observable<IAssetsProgressEvent>;
  147818. /**
  147819. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  147820. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  147821. */
  147822. useDefaultLoadingScreen: boolean;
  147823. /**
  147824. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  147825. * when all assets have been downloaded.
  147826. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  147827. */
  147828. autoHideLoadingUI: boolean;
  147829. /**
  147830. * Creates a new AssetsManager
  147831. * @param scene defines the scene to work on
  147832. */
  147833. constructor(scene: Scene);
  147834. /**
  147835. * Add a MeshAssetTask to the list of active tasks
  147836. * @param taskName defines the name of the new task
  147837. * @param meshesNames defines the name of meshes to load
  147838. * @param rootUrl defines the root url to use to locate files
  147839. * @param sceneFilename defines the filename of the scene file
  147840. * @returns a new MeshAssetTask object
  147841. */
  147842. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  147843. /**
  147844. * Add a TextFileAssetTask to the list of active tasks
  147845. * @param taskName defines the name of the new task
  147846. * @param url defines the url of the file to load
  147847. * @returns a new TextFileAssetTask object
  147848. */
  147849. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  147850. /**
  147851. * Add a BinaryFileAssetTask to the list of active tasks
  147852. * @param taskName defines the name of the new task
  147853. * @param url defines the url of the file to load
  147854. * @returns a new BinaryFileAssetTask object
  147855. */
  147856. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  147857. /**
  147858. * Add a ImageAssetTask to the list of active tasks
  147859. * @param taskName defines the name of the new task
  147860. * @param url defines the url of the file to load
  147861. * @returns a new ImageAssetTask object
  147862. */
  147863. addImageTask(taskName: string, url: string): ImageAssetTask;
  147864. /**
  147865. * Add a TextureAssetTask to the list of active tasks
  147866. * @param taskName defines the name of the new task
  147867. * @param url defines the url of the file to load
  147868. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  147869. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  147870. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  147871. * @returns a new TextureAssetTask object
  147872. */
  147873. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  147874. /**
  147875. * Add a CubeTextureAssetTask to the list of active tasks
  147876. * @param taskName defines the name of the new task
  147877. * @param url defines the url of the file to load
  147878. * @param extensions defines the extension to use to load the cube map (can be null)
  147879. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  147880. * @param files defines the list of files to load (can be null)
  147881. * @returns a new CubeTextureAssetTask object
  147882. */
  147883. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  147884. /**
  147885. *
  147886. * Add a HDRCubeTextureAssetTask to the list of active tasks
  147887. * @param taskName defines the name of the new task
  147888. * @param url defines the url of the file to load
  147889. * @param size defines the size you want for the cubemap (can be null)
  147890. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  147891. * @param generateHarmonics defines if you want to automatically generate (true by default)
  147892. * @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)
  147893. * @param reserved Internal use only
  147894. * @returns a new HDRCubeTextureAssetTask object
  147895. */
  147896. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  147897. /**
  147898. *
  147899. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  147900. * @param taskName defines the name of the new task
  147901. * @param url defines the url of the file to load
  147902. * @param size defines the size you want for the cubemap (can be null)
  147903. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  147904. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  147905. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  147906. * @returns a new EquiRectangularCubeTextureAssetTask object
  147907. */
  147908. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  147909. /**
  147910. * Remove a task from the assets manager.
  147911. * @param task the task to remove
  147912. */
  147913. removeTask(task: AbstractAssetTask): void;
  147914. private _decreaseWaitingTasksCount;
  147915. private _runTask;
  147916. /**
  147917. * Reset the AssetsManager and remove all tasks
  147918. * @return the current instance of the AssetsManager
  147919. */
  147920. reset(): AssetsManager;
  147921. /**
  147922. * Start the loading process
  147923. * @return the current instance of the AssetsManager
  147924. */
  147925. load(): AssetsManager;
  147926. /**
  147927. * Start the loading process as an async operation
  147928. * @return a promise returning the list of failed tasks
  147929. */
  147930. loadAsync(): Promise<void>;
  147931. }
  147932. }
  147933. declare module BABYLON {
  147934. /**
  147935. * Wrapper class for promise with external resolve and reject.
  147936. */
  147937. export class Deferred<T> {
  147938. /**
  147939. * The promise associated with this deferred object.
  147940. */
  147941. readonly promise: Promise<T>;
  147942. private _resolve;
  147943. private _reject;
  147944. /**
  147945. * The resolve method of the promise associated with this deferred object.
  147946. */
  147947. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  147948. /**
  147949. * The reject method of the promise associated with this deferred object.
  147950. */
  147951. get reject(): (reason?: any) => void;
  147952. /**
  147953. * Constructor for this deferred object.
  147954. */
  147955. constructor();
  147956. }
  147957. }
  147958. declare module BABYLON {
  147959. /**
  147960. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  147961. */
  147962. export class MeshExploder {
  147963. private _centerMesh;
  147964. private _meshes;
  147965. private _meshesOrigins;
  147966. private _toCenterVectors;
  147967. private _scaledDirection;
  147968. private _newPosition;
  147969. private _centerPosition;
  147970. /**
  147971. * Explodes meshes from a center mesh.
  147972. * @param meshes The meshes to explode.
  147973. * @param centerMesh The mesh to be center of explosion.
  147974. */
  147975. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  147976. private _setCenterMesh;
  147977. /**
  147978. * Get class name
  147979. * @returns "MeshExploder"
  147980. */
  147981. getClassName(): string;
  147982. /**
  147983. * "Exploded meshes"
  147984. * @returns Array of meshes with the centerMesh at index 0.
  147985. */
  147986. getMeshes(): Array<Mesh>;
  147987. /**
  147988. * Explodes meshes giving a specific direction
  147989. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  147990. */
  147991. explode(direction?: number): void;
  147992. }
  147993. }
  147994. declare module BABYLON {
  147995. /**
  147996. * Class used to help managing file picking and drag'n'drop
  147997. */
  147998. export class FilesInput {
  147999. /**
  148000. * List of files ready to be loaded
  148001. */
  148002. static get FilesToLoad(): {
  148003. [key: string]: File;
  148004. };
  148005. /**
  148006. * Callback called when a file is processed
  148007. */
  148008. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  148009. private _engine;
  148010. private _currentScene;
  148011. private _sceneLoadedCallback;
  148012. private _progressCallback;
  148013. private _additionalRenderLoopLogicCallback;
  148014. private _textureLoadingCallback;
  148015. private _startingProcessingFilesCallback;
  148016. private _onReloadCallback;
  148017. private _errorCallback;
  148018. private _elementToMonitor;
  148019. private _sceneFileToLoad;
  148020. private _filesToLoad;
  148021. /**
  148022. * Creates a new FilesInput
  148023. * @param engine defines the rendering engine
  148024. * @param scene defines the hosting scene
  148025. * @param sceneLoadedCallback callback called when scene is loaded
  148026. * @param progressCallback callback called to track progress
  148027. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  148028. * @param textureLoadingCallback callback called when a texture is loading
  148029. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  148030. * @param onReloadCallback callback called when a reload is requested
  148031. * @param errorCallback callback call if an error occurs
  148032. */
  148033. 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);
  148034. private _dragEnterHandler;
  148035. private _dragOverHandler;
  148036. private _dropHandler;
  148037. /**
  148038. * Calls this function to listen to drag'n'drop events on a specific DOM element
  148039. * @param elementToMonitor defines the DOM element to track
  148040. */
  148041. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  148042. /**
  148043. * Release all associated resources
  148044. */
  148045. dispose(): void;
  148046. private renderFunction;
  148047. private drag;
  148048. private drop;
  148049. private _traverseFolder;
  148050. private _processFiles;
  148051. /**
  148052. * Load files from a drop event
  148053. * @param event defines the drop event to use as source
  148054. */
  148055. loadFiles(event: any): void;
  148056. private _processReload;
  148057. /**
  148058. * Reload the current scene from the loaded files
  148059. */
  148060. reload(): void;
  148061. }
  148062. }
  148063. declare module BABYLON {
  148064. /**
  148065. * Defines the root class used to create scene optimization to use with SceneOptimizer
  148066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148067. */
  148068. export class SceneOptimization {
  148069. /**
  148070. * Defines the priority of this optimization (0 by default which means first in the list)
  148071. */
  148072. priority: number;
  148073. /**
  148074. * Gets a string describing the action executed by the current optimization
  148075. * @returns description string
  148076. */
  148077. getDescription(): string;
  148078. /**
  148079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148080. * @param scene defines the current scene where to apply this optimization
  148081. * @param optimizer defines the current optimizer
  148082. * @returns true if everything that can be done was applied
  148083. */
  148084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148085. /**
  148086. * Creates the SceneOptimization object
  148087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148088. * @param desc defines the description associated with the optimization
  148089. */
  148090. constructor(
  148091. /**
  148092. * Defines the priority of this optimization (0 by default which means first in the list)
  148093. */
  148094. priority?: number);
  148095. }
  148096. /**
  148097. * Defines an optimization used to reduce the size of render target textures
  148098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148099. */
  148100. export class TextureOptimization extends SceneOptimization {
  148101. /**
  148102. * Defines the priority of this optimization (0 by default which means first in the list)
  148103. */
  148104. priority: number;
  148105. /**
  148106. * 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
  148107. */
  148108. maximumSize: number;
  148109. /**
  148110. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148111. */
  148112. step: number;
  148113. /**
  148114. * Gets a string describing the action executed by the current optimization
  148115. * @returns description string
  148116. */
  148117. getDescription(): string;
  148118. /**
  148119. * Creates the TextureOptimization object
  148120. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148121. * @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
  148122. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148123. */
  148124. constructor(
  148125. /**
  148126. * Defines the priority of this optimization (0 by default which means first in the list)
  148127. */
  148128. priority?: number,
  148129. /**
  148130. * 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
  148131. */
  148132. maximumSize?: number,
  148133. /**
  148134. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148135. */
  148136. step?: number);
  148137. /**
  148138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148139. * @param scene defines the current scene where to apply this optimization
  148140. * @param optimizer defines the current optimizer
  148141. * @returns true if everything that can be done was applied
  148142. */
  148143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148144. }
  148145. /**
  148146. * Defines an optimization used to increase or decrease the rendering resolution
  148147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148148. */
  148149. export class HardwareScalingOptimization extends SceneOptimization {
  148150. /**
  148151. * Defines the priority of this optimization (0 by default which means first in the list)
  148152. */
  148153. priority: number;
  148154. /**
  148155. * Defines the maximum scale to use (2 by default)
  148156. */
  148157. maximumScale: number;
  148158. /**
  148159. * Defines the step to use between two passes (0.5 by default)
  148160. */
  148161. step: number;
  148162. private _currentScale;
  148163. private _directionOffset;
  148164. /**
  148165. * Gets a string describing the action executed by the current optimization
  148166. * @return description string
  148167. */
  148168. getDescription(): string;
  148169. /**
  148170. * Creates the HardwareScalingOptimization object
  148171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148172. * @param maximumScale defines the maximum scale to use (2 by default)
  148173. * @param step defines the step to use between two passes (0.5 by default)
  148174. */
  148175. constructor(
  148176. /**
  148177. * Defines the priority of this optimization (0 by default which means first in the list)
  148178. */
  148179. priority?: number,
  148180. /**
  148181. * Defines the maximum scale to use (2 by default)
  148182. */
  148183. maximumScale?: number,
  148184. /**
  148185. * Defines the step to use between two passes (0.5 by default)
  148186. */
  148187. step?: number);
  148188. /**
  148189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148190. * @param scene defines the current scene where to apply this optimization
  148191. * @param optimizer defines the current optimizer
  148192. * @returns true if everything that can be done was applied
  148193. */
  148194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148195. }
  148196. /**
  148197. * Defines an optimization used to remove shadows
  148198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148199. */
  148200. export class ShadowsOptimization extends SceneOptimization {
  148201. /**
  148202. * Gets a string describing the action executed by the current optimization
  148203. * @return description string
  148204. */
  148205. getDescription(): string;
  148206. /**
  148207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148208. * @param scene defines the current scene where to apply this optimization
  148209. * @param optimizer defines the current optimizer
  148210. * @returns true if everything that can be done was applied
  148211. */
  148212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148213. }
  148214. /**
  148215. * Defines an optimization used to turn post-processes off
  148216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148217. */
  148218. export class PostProcessesOptimization extends SceneOptimization {
  148219. /**
  148220. * Gets a string describing the action executed by the current optimization
  148221. * @return description string
  148222. */
  148223. getDescription(): string;
  148224. /**
  148225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148226. * @param scene defines the current scene where to apply this optimization
  148227. * @param optimizer defines the current optimizer
  148228. * @returns true if everything that can be done was applied
  148229. */
  148230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148231. }
  148232. /**
  148233. * Defines an optimization used to turn lens flares off
  148234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148235. */
  148236. export class LensFlaresOptimization extends SceneOptimization {
  148237. /**
  148238. * Gets a string describing the action executed by the current optimization
  148239. * @return description string
  148240. */
  148241. getDescription(): string;
  148242. /**
  148243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148244. * @param scene defines the current scene where to apply this optimization
  148245. * @param optimizer defines the current optimizer
  148246. * @returns true if everything that can be done was applied
  148247. */
  148248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148249. }
  148250. /**
  148251. * Defines an optimization based on user defined callback.
  148252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148253. */
  148254. export class CustomOptimization extends SceneOptimization {
  148255. /**
  148256. * Callback called to apply the custom optimization.
  148257. */
  148258. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  148259. /**
  148260. * Callback called to get custom description
  148261. */
  148262. onGetDescription: () => string;
  148263. /**
  148264. * Gets a string describing the action executed by the current optimization
  148265. * @returns description string
  148266. */
  148267. getDescription(): string;
  148268. /**
  148269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148270. * @param scene defines the current scene where to apply this optimization
  148271. * @param optimizer defines the current optimizer
  148272. * @returns true if everything that can be done was applied
  148273. */
  148274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148275. }
  148276. /**
  148277. * Defines an optimization used to turn particles off
  148278. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148279. */
  148280. export class ParticlesOptimization extends SceneOptimization {
  148281. /**
  148282. * Gets a string describing the action executed by the current optimization
  148283. * @return description string
  148284. */
  148285. getDescription(): string;
  148286. /**
  148287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148288. * @param scene defines the current scene where to apply this optimization
  148289. * @param optimizer defines the current optimizer
  148290. * @returns true if everything that can be done was applied
  148291. */
  148292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148293. }
  148294. /**
  148295. * Defines an optimization used to turn render targets off
  148296. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148297. */
  148298. export class RenderTargetsOptimization extends SceneOptimization {
  148299. /**
  148300. * Gets a string describing the action executed by the current optimization
  148301. * @return description string
  148302. */
  148303. getDescription(): string;
  148304. /**
  148305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148306. * @param scene defines the current scene where to apply this optimization
  148307. * @param optimizer defines the current optimizer
  148308. * @returns true if everything that can be done was applied
  148309. */
  148310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148311. }
  148312. /**
  148313. * Defines an optimization used to merge meshes with compatible materials
  148314. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148315. */
  148316. export class MergeMeshesOptimization extends SceneOptimization {
  148317. private static _UpdateSelectionTree;
  148318. /**
  148319. * Gets or sets a boolean which defines if optimization octree has to be updated
  148320. */
  148321. static get UpdateSelectionTree(): boolean;
  148322. /**
  148323. * Gets or sets a boolean which defines if optimization octree has to be updated
  148324. */
  148325. static set UpdateSelectionTree(value: boolean);
  148326. /**
  148327. * Gets a string describing the action executed by the current optimization
  148328. * @return description string
  148329. */
  148330. getDescription(): string;
  148331. private _canBeMerged;
  148332. /**
  148333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148334. * @param scene defines the current scene where to apply this optimization
  148335. * @param optimizer defines the current optimizer
  148336. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  148337. * @returns true if everything that can be done was applied
  148338. */
  148339. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  148340. }
  148341. /**
  148342. * Defines a list of options used by SceneOptimizer
  148343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148344. */
  148345. export class SceneOptimizerOptions {
  148346. /**
  148347. * Defines the target frame rate to reach (60 by default)
  148348. */
  148349. targetFrameRate: number;
  148350. /**
  148351. * Defines the interval between two checkes (2000ms by default)
  148352. */
  148353. trackerDuration: number;
  148354. /**
  148355. * Gets the list of optimizations to apply
  148356. */
  148357. optimizations: SceneOptimization[];
  148358. /**
  148359. * Creates a new list of options used by SceneOptimizer
  148360. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  148361. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  148362. */
  148363. constructor(
  148364. /**
  148365. * Defines the target frame rate to reach (60 by default)
  148366. */
  148367. targetFrameRate?: number,
  148368. /**
  148369. * Defines the interval between two checkes (2000ms by default)
  148370. */
  148371. trackerDuration?: number);
  148372. /**
  148373. * Add a new optimization
  148374. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  148375. * @returns the current SceneOptimizerOptions
  148376. */
  148377. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  148378. /**
  148379. * Add a new custom optimization
  148380. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  148381. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  148382. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148383. * @returns the current SceneOptimizerOptions
  148384. */
  148385. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  148386. /**
  148387. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  148388. * @param targetFrameRate defines the target frame rate (60 by default)
  148389. * @returns a SceneOptimizerOptions object
  148390. */
  148391. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148392. /**
  148393. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  148394. * @param targetFrameRate defines the target frame rate (60 by default)
  148395. * @returns a SceneOptimizerOptions object
  148396. */
  148397. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148398. /**
  148399. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  148400. * @param targetFrameRate defines the target frame rate (60 by default)
  148401. * @returns a SceneOptimizerOptions object
  148402. */
  148403. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148404. }
  148405. /**
  148406. * Class used to run optimizations in order to reach a target frame rate
  148407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148408. */
  148409. export class SceneOptimizer implements IDisposable {
  148410. private _isRunning;
  148411. private _options;
  148412. private _scene;
  148413. private _currentPriorityLevel;
  148414. private _targetFrameRate;
  148415. private _trackerDuration;
  148416. private _currentFrameRate;
  148417. private _sceneDisposeObserver;
  148418. private _improvementMode;
  148419. /**
  148420. * Defines an observable called when the optimizer reaches the target frame rate
  148421. */
  148422. onSuccessObservable: Observable<SceneOptimizer>;
  148423. /**
  148424. * Defines an observable called when the optimizer enables an optimization
  148425. */
  148426. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  148427. /**
  148428. * Defines an observable called when the optimizer is not able to reach the target frame rate
  148429. */
  148430. onFailureObservable: Observable<SceneOptimizer>;
  148431. /**
  148432. * Gets a boolean indicating if the optimizer is in improvement mode
  148433. */
  148434. get isInImprovementMode(): boolean;
  148435. /**
  148436. * Gets the current priority level (0 at start)
  148437. */
  148438. get currentPriorityLevel(): number;
  148439. /**
  148440. * Gets the current frame rate checked by the SceneOptimizer
  148441. */
  148442. get currentFrameRate(): number;
  148443. /**
  148444. * Gets or sets the current target frame rate (60 by default)
  148445. */
  148446. get targetFrameRate(): number;
  148447. /**
  148448. * Gets or sets the current target frame rate (60 by default)
  148449. */
  148450. set targetFrameRate(value: number);
  148451. /**
  148452. * Gets or sets the current interval between two checks (every 2000ms by default)
  148453. */
  148454. get trackerDuration(): number;
  148455. /**
  148456. * Gets or sets the current interval between two checks (every 2000ms by default)
  148457. */
  148458. set trackerDuration(value: number);
  148459. /**
  148460. * Gets the list of active optimizations
  148461. */
  148462. get optimizations(): SceneOptimization[];
  148463. /**
  148464. * Creates a new SceneOptimizer
  148465. * @param scene defines the scene to work on
  148466. * @param options defines the options to use with the SceneOptimizer
  148467. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  148468. * @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)
  148469. */
  148470. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  148471. /**
  148472. * Stops the current optimizer
  148473. */
  148474. stop(): void;
  148475. /**
  148476. * Reset the optimizer to initial step (current priority level = 0)
  148477. */
  148478. reset(): void;
  148479. /**
  148480. * Start the optimizer. By default it will try to reach a specific framerate
  148481. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  148482. */
  148483. start(): void;
  148484. private _checkCurrentState;
  148485. /**
  148486. * Release all resources
  148487. */
  148488. dispose(): void;
  148489. /**
  148490. * Helper function to create a SceneOptimizer with one single line of code
  148491. * @param scene defines the scene to work on
  148492. * @param options defines the options to use with the SceneOptimizer
  148493. * @param onSuccess defines a callback to call on success
  148494. * @param onFailure defines a callback to call on failure
  148495. * @returns the new SceneOptimizer object
  148496. */
  148497. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  148498. }
  148499. }
  148500. declare module BABYLON {
  148501. /**
  148502. * Class used to serialize a scene into a string
  148503. */
  148504. export class SceneSerializer {
  148505. /**
  148506. * Clear cache used by a previous serialization
  148507. */
  148508. static ClearCache(): void;
  148509. /**
  148510. * Serialize a scene into a JSON compatible object
  148511. * @param scene defines the scene to serialize
  148512. * @returns a JSON compatible object
  148513. */
  148514. static Serialize(scene: Scene): any;
  148515. /**
  148516. * Serialize a mesh into a JSON compatible object
  148517. * @param toSerialize defines the mesh to serialize
  148518. * @param withParents defines if parents must be serialized as well
  148519. * @param withChildren defines if children must be serialized as well
  148520. * @returns a JSON compatible object
  148521. */
  148522. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  148523. }
  148524. }
  148525. declare module BABYLON {
  148526. /**
  148527. * Class used to host texture specific utilities
  148528. */
  148529. export class TextureTools {
  148530. /**
  148531. * Uses the GPU to create a copy texture rescaled at a given size
  148532. * @param texture Texture to copy from
  148533. * @param width defines the desired width
  148534. * @param height defines the desired height
  148535. * @param useBilinearMode defines if bilinear mode has to be used
  148536. * @return the generated texture
  148537. */
  148538. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  148539. }
  148540. }
  148541. declare module BABYLON {
  148542. /**
  148543. * This represents the different options available for the video capture.
  148544. */
  148545. export interface VideoRecorderOptions {
  148546. /** Defines the mime type of the video. */
  148547. mimeType: string;
  148548. /** Defines the FPS the video should be recorded at. */
  148549. fps: number;
  148550. /** Defines the chunk size for the recording data. */
  148551. recordChunckSize: number;
  148552. /** The audio tracks to attach to the recording. */
  148553. audioTracks?: MediaStreamTrack[];
  148554. }
  148555. /**
  148556. * This can help with recording videos from BabylonJS.
  148557. * This is based on the available WebRTC functionalities of the browser.
  148558. *
  148559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  148560. */
  148561. export class VideoRecorder {
  148562. private static readonly _defaultOptions;
  148563. /**
  148564. * Returns whether or not the VideoRecorder is available in your browser.
  148565. * @param engine Defines the Babylon Engine.
  148566. * @returns true if supported otherwise false.
  148567. */
  148568. static IsSupported(engine: Engine): boolean;
  148569. private readonly _options;
  148570. private _canvas;
  148571. private _mediaRecorder;
  148572. private _recordedChunks;
  148573. private _fileName;
  148574. private _resolve;
  148575. private _reject;
  148576. /**
  148577. * True when a recording is already in progress.
  148578. */
  148579. get isRecording(): boolean;
  148580. /**
  148581. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  148582. * @param engine Defines the BabylonJS Engine you wish to record.
  148583. * @param options Defines options that can be used to customize the capture.
  148584. */
  148585. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  148586. /**
  148587. * Stops the current recording before the default capture timeout passed in the startRecording function.
  148588. */
  148589. stopRecording(): void;
  148590. /**
  148591. * Starts recording the canvas for a max duration specified in parameters.
  148592. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  148593. * If null no automatic download will start and you can rely on the promise to get the data back.
  148594. * @param maxDuration Defines the maximum recording time in seconds.
  148595. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  148596. * @return A promise callback at the end of the recording with the video data in Blob.
  148597. */
  148598. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  148599. /**
  148600. * Releases internal resources used during the recording.
  148601. */
  148602. dispose(): void;
  148603. private _handleDataAvailable;
  148604. private _handleError;
  148605. private _handleStop;
  148606. }
  148607. }
  148608. declare module BABYLON {
  148609. /**
  148610. * Class containing a set of static utilities functions for screenshots
  148611. */
  148612. export class ScreenshotTools {
  148613. /**
  148614. * Captures a screenshot of the current rendering
  148615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148616. * @param engine defines the rendering engine
  148617. * @param camera defines the source camera
  148618. * @param size This parameter can be set to a single number or to an object with the
  148619. * following (optional) properties: precision, width, height. If a single number is passed,
  148620. * it will be used for both width and height. If an object is passed, the screenshot size
  148621. * will be derived from the parameters. The precision property is a multiplier allowing
  148622. * rendering at a higher or lower resolution
  148623. * @param successCallback defines the callback receives a single parameter which contains the
  148624. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  148625. * src parameter of an <img> to display it
  148626. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  148627. * Check your browser for supported MIME types
  148628. */
  148629. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  148630. /**
  148631. * Captures a screenshot of the current rendering
  148632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148633. * @param engine defines the rendering engine
  148634. * @param camera defines the source camera
  148635. * @param size This parameter can be set to a single number or to an object with the
  148636. * following (optional) properties: precision, width, height. If a single number is passed,
  148637. * it will be used for both width and height. If an object is passed, the screenshot size
  148638. * will be derived from the parameters. The precision property is a multiplier allowing
  148639. * rendering at a higher or lower resolution
  148640. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  148641. * Check your browser for supported MIME types
  148642. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  148643. * to the src parameter of an <img> to display it
  148644. */
  148645. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  148646. /**
  148647. * Generates an image screenshot from the specified camera.
  148648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148649. * @param engine The engine to use for rendering
  148650. * @param camera The camera to use for rendering
  148651. * @param size This parameter can be set to a single number or to an object with the
  148652. * following (optional) properties: precision, width, height. If a single number is passed,
  148653. * it will be used for both width and height. If an object is passed, the screenshot size
  148654. * will be derived from the parameters. The precision property is a multiplier allowing
  148655. * rendering at a higher or lower resolution
  148656. * @param successCallback The callback receives a single parameter which contains the
  148657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  148658. * src parameter of an <img> to display it
  148659. * @param mimeType The MIME type of the screenshot image (default: image/png).
  148660. * Check your browser for supported MIME types
  148661. * @param samples Texture samples (default: 1)
  148662. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  148663. * @param fileName A name for for the downloaded file.
  148664. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  148665. */
  148666. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  148667. /**
  148668. * Generates an image screenshot from the specified camera.
  148669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148670. * @param engine The engine to use for rendering
  148671. * @param camera The camera to use for rendering
  148672. * @param size This parameter can be set to a single number or to an object with the
  148673. * following (optional) properties: precision, width, height. If a single number is passed,
  148674. * it will be used for both width and height. If an object is passed, the screenshot size
  148675. * will be derived from the parameters. The precision property is a multiplier allowing
  148676. * rendering at a higher or lower resolution
  148677. * @param mimeType The MIME type of the screenshot image (default: image/png).
  148678. * Check your browser for supported MIME types
  148679. * @param samples Texture samples (default: 1)
  148680. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  148681. * @param fileName A name for for the downloaded file.
  148682. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  148683. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  148684. * to the src parameter of an <img> to display it
  148685. */
  148686. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  148687. /**
  148688. * Gets height and width for screenshot size
  148689. * @private
  148690. */
  148691. private static _getScreenshotSize;
  148692. }
  148693. }
  148694. declare module BABYLON {
  148695. /**
  148696. * Interface for a data buffer
  148697. */
  148698. export interface IDataBuffer {
  148699. /**
  148700. * Reads bytes from the data buffer.
  148701. * @param byteOffset The byte offset to read
  148702. * @param byteLength The byte length to read
  148703. * @returns A promise that resolves when the bytes are read
  148704. */
  148705. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  148706. /**
  148707. * The byte length of the buffer.
  148708. */
  148709. readonly byteLength: number;
  148710. }
  148711. /**
  148712. * Utility class for reading from a data buffer
  148713. */
  148714. export class DataReader {
  148715. /**
  148716. * The data buffer associated with this data reader.
  148717. */
  148718. readonly buffer: IDataBuffer;
  148719. /**
  148720. * The current byte offset from the beginning of the data buffer.
  148721. */
  148722. byteOffset: number;
  148723. private _dataView;
  148724. private _dataByteOffset;
  148725. /**
  148726. * Constructor
  148727. * @param buffer The buffer to read
  148728. */
  148729. constructor(buffer: IDataBuffer);
  148730. /**
  148731. * Loads the given byte length.
  148732. * @param byteLength The byte length to load
  148733. * @returns A promise that resolves when the load is complete
  148734. */
  148735. loadAsync(byteLength: number): Promise<void>;
  148736. /**
  148737. * Read a unsigned 32-bit integer from the currently loaded data range.
  148738. * @returns The 32-bit integer read
  148739. */
  148740. readUint32(): number;
  148741. /**
  148742. * Read a byte array from the currently loaded data range.
  148743. * @param byteLength The byte length to read
  148744. * @returns The byte array read
  148745. */
  148746. readUint8Array(byteLength: number): Uint8Array;
  148747. /**
  148748. * Read a string from the currently loaded data range.
  148749. * @param byteLength The byte length to read
  148750. * @returns The string read
  148751. */
  148752. readString(byteLength: number): string;
  148753. /**
  148754. * Skips the given byte length the currently loaded data range.
  148755. * @param byteLength The byte length to skip
  148756. */
  148757. skipBytes(byteLength: number): void;
  148758. }
  148759. }
  148760. declare module BABYLON {
  148761. /**
  148762. * Class for storing data to local storage if available or in-memory storage otherwise
  148763. */
  148764. export class DataStorage {
  148765. private static _Storage;
  148766. private static _GetStorage;
  148767. /**
  148768. * Reads a string from the data storage
  148769. * @param key The key to read
  148770. * @param defaultValue The value if the key doesn't exist
  148771. * @returns The string value
  148772. */
  148773. static ReadString(key: string, defaultValue: string): string;
  148774. /**
  148775. * Writes a string to the data storage
  148776. * @param key The key to write
  148777. * @param value The value to write
  148778. */
  148779. static WriteString(key: string, value: string): void;
  148780. /**
  148781. * Reads a boolean from the data storage
  148782. * @param key The key to read
  148783. * @param defaultValue The value if the key doesn't exist
  148784. * @returns The boolean value
  148785. */
  148786. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  148787. /**
  148788. * Writes a boolean to the data storage
  148789. * @param key The key to write
  148790. * @param value The value to write
  148791. */
  148792. static WriteBoolean(key: string, value: boolean): void;
  148793. /**
  148794. * Reads a number from the data storage
  148795. * @param key The key to read
  148796. * @param defaultValue The value if the key doesn't exist
  148797. * @returns The number value
  148798. */
  148799. static ReadNumber(key: string, defaultValue: number): number;
  148800. /**
  148801. * Writes a number to the data storage
  148802. * @param key The key to write
  148803. * @param value The value to write
  148804. */
  148805. static WriteNumber(key: string, value: number): void;
  148806. }
  148807. }
  148808. declare module BABYLON {
  148809. /**
  148810. * Options used for hit testing
  148811. */
  148812. export interface IWebXRLegacyHitTestOptions {
  148813. /**
  148814. * Only test when user interacted with the scene. Default - hit test every frame
  148815. */
  148816. testOnPointerDownOnly?: boolean;
  148817. /**
  148818. * The node to use to transform the local results to world coordinates
  148819. */
  148820. worldParentNode?: TransformNode;
  148821. }
  148822. /**
  148823. * Interface defining the babylon result of raycasting/hit-test
  148824. */
  148825. export interface IWebXRLegacyHitResult {
  148826. /**
  148827. * Transformation matrix that can be applied to a node that will put it in the hit point location
  148828. */
  148829. transformationMatrix: Matrix;
  148830. /**
  148831. * The native hit test result
  148832. */
  148833. xrHitResult: XRHitResult | XRHitTestResult;
  148834. }
  148835. /**
  148836. * The currently-working hit-test module.
  148837. * Hit test (or Ray-casting) is used to interact with the real world.
  148838. * For further information read here - https://github.com/immersive-web/hit-test
  148839. */
  148840. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  148841. /**
  148842. * options to use when constructing this feature
  148843. */
  148844. readonly options: IWebXRLegacyHitTestOptions;
  148845. private _direction;
  148846. private _mat;
  148847. private _onSelectEnabled;
  148848. private _origin;
  148849. /**
  148850. * The module's name
  148851. */
  148852. static readonly Name: string;
  148853. /**
  148854. * The (Babylon) version of this module.
  148855. * This is an integer representing the implementation version.
  148856. * This number does not correspond to the WebXR specs version
  148857. */
  148858. static readonly Version: number;
  148859. /**
  148860. * Populated with the last native XR Hit Results
  148861. */
  148862. lastNativeXRHitResults: XRHitResult[];
  148863. /**
  148864. * Triggered when new babylon (transformed) hit test results are available
  148865. */
  148866. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  148867. /**
  148868. * Creates a new instance of the (legacy version) hit test feature
  148869. * @param _xrSessionManager an instance of WebXRSessionManager
  148870. * @param options options to use when constructing this feature
  148871. */
  148872. constructor(_xrSessionManager: WebXRSessionManager,
  148873. /**
  148874. * options to use when constructing this feature
  148875. */
  148876. options?: IWebXRLegacyHitTestOptions);
  148877. /**
  148878. * execute a hit test with an XR Ray
  148879. *
  148880. * @param xrSession a native xrSession that will execute this hit test
  148881. * @param xrRay the ray (position and direction) to use for ray-casting
  148882. * @param referenceSpace native XR reference space to use for the hit-test
  148883. * @param filter filter function that will filter the results
  148884. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  148885. */
  148886. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  148887. /**
  148888. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  148889. * @param event the (select) event to use to select with
  148890. * @param referenceSpace the reference space to use for this hit test
  148891. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  148892. */
  148893. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148894. /**
  148895. * attach this feature
  148896. * Will usually be called by the features manager
  148897. *
  148898. * @returns true if successful.
  148899. */
  148900. attach(): boolean;
  148901. /**
  148902. * detach this feature.
  148903. * Will usually be called by the features manager
  148904. *
  148905. * @returns true if successful.
  148906. */
  148907. detach(): boolean;
  148908. /**
  148909. * Dispose this feature and all of the resources attached
  148910. */
  148911. dispose(): void;
  148912. protected _onXRFrame(frame: XRFrame): void;
  148913. private _onHitTestResults;
  148914. private _onSelect;
  148915. }
  148916. }
  148917. declare module BABYLON {
  148918. /**
  148919. * Options used in the plane detector module
  148920. */
  148921. export interface IWebXRPlaneDetectorOptions {
  148922. /**
  148923. * The node to use to transform the local results to world coordinates
  148924. */
  148925. worldParentNode?: TransformNode;
  148926. }
  148927. /**
  148928. * A babylon interface for a WebXR plane.
  148929. * A Plane is actually a polygon, built from N points in space
  148930. *
  148931. * Supported in chrome 79, not supported in canary 81 ATM
  148932. */
  148933. export interface IWebXRPlane {
  148934. /**
  148935. * a babylon-assigned ID for this polygon
  148936. */
  148937. id: number;
  148938. /**
  148939. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  148940. */
  148941. polygonDefinition: Array<Vector3>;
  148942. /**
  148943. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  148944. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  148945. */
  148946. transformationMatrix: Matrix;
  148947. /**
  148948. * the native xr-plane object
  148949. */
  148950. xrPlane: XRPlane;
  148951. }
  148952. /**
  148953. * The plane detector is used to detect planes in the real world when in AR
  148954. * For more information see https://github.com/immersive-web/real-world-geometry/
  148955. */
  148956. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  148957. private _options;
  148958. private _detectedPlanes;
  148959. private _enabled;
  148960. private _lastFrameDetected;
  148961. /**
  148962. * The module's name
  148963. */
  148964. static readonly Name: string;
  148965. /**
  148966. * The (Babylon) version of this module.
  148967. * This is an integer representing the implementation version.
  148968. * This number does not correspond to the WebXR specs version
  148969. */
  148970. static readonly Version: number;
  148971. /**
  148972. * Observers registered here will be executed when a new plane was added to the session
  148973. */
  148974. onPlaneAddedObservable: Observable<IWebXRPlane>;
  148975. /**
  148976. * Observers registered here will be executed when a plane is no longer detected in the session
  148977. */
  148978. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  148979. /**
  148980. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  148981. * This can execute N times every frame
  148982. */
  148983. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  148984. /**
  148985. * construct a new Plane Detector
  148986. * @param _xrSessionManager an instance of xr Session manager
  148987. * @param _options configuration to use when constructing this feature
  148988. */
  148989. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  148990. /**
  148991. * Dispose this feature and all of the resources attached
  148992. */
  148993. dispose(): void;
  148994. protected _onXRFrame(frame: XRFrame): void;
  148995. private _init;
  148996. private _updatePlaneWithXRPlane;
  148997. /**
  148998. * avoiding using Array.find for global support.
  148999. * @param xrPlane the plane to find in the array
  149000. */
  149001. private findIndexInPlaneArray;
  149002. }
  149003. }
  149004. declare module BABYLON {
  149005. /**
  149006. * Configuration options of the anchor system
  149007. */
  149008. export interface IWebXRAnchorSystemOptions {
  149009. /**
  149010. * Should a new anchor be added every time a select event is triggered
  149011. */
  149012. addAnchorOnSelect?: boolean;
  149013. /**
  149014. * should the anchor system use plane detection.
  149015. * If set to true, the plane-detection feature should be set using setPlaneDetector
  149016. */
  149017. usePlaneDetection?: boolean;
  149018. /**
  149019. * a node that will be used to convert local to world coordinates
  149020. */
  149021. worldParentNode?: TransformNode;
  149022. }
  149023. /**
  149024. * A babylon container for an XR Anchor
  149025. */
  149026. export interface IWebXRAnchor {
  149027. /**
  149028. * A babylon-assigned ID for this anchor
  149029. */
  149030. id: number;
  149031. /**
  149032. * Transformation matrix to apply to an object attached to this anchor
  149033. */
  149034. transformationMatrix: Matrix;
  149035. /**
  149036. * The native anchor object
  149037. */
  149038. xrAnchor: XRAnchor;
  149039. }
  149040. /**
  149041. * An implementation of the anchor system of WebXR.
  149042. * Note that the current documented implementation is not available in any browser. Future implementations
  149043. * will use the frame to create an anchor and not the session or a detected plane
  149044. * For further information see https://github.com/immersive-web/anchors/
  149045. */
  149046. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  149047. private _options;
  149048. private _enabled;
  149049. private _hitTestModule;
  149050. private _lastFrameDetected;
  149051. private _onSelect;
  149052. private _planeDetector;
  149053. private _trackedAnchors;
  149054. /**
  149055. * The module's name
  149056. */
  149057. static readonly Name: string;
  149058. /**
  149059. * The (Babylon) version of this module.
  149060. * This is an integer representing the implementation version.
  149061. * This number does not correspond to the WebXR specs version
  149062. */
  149063. static readonly Version: number;
  149064. /**
  149065. * Observers registered here will be executed when a new anchor was added to the session
  149066. */
  149067. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  149068. /**
  149069. * Observers registered here will be executed when an anchor was removed from the session
  149070. */
  149071. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  149072. /**
  149073. * Observers registered here will be executed when an existing anchor updates
  149074. * This can execute N times every frame
  149075. */
  149076. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  149077. /**
  149078. * constructs a new anchor system
  149079. * @param _xrSessionManager an instance of WebXRSessionManager
  149080. * @param _options configuration object for this feature
  149081. */
  149082. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  149083. /**
  149084. * Add anchor at a specific XR point.
  149085. *
  149086. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  149087. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  149088. * @returns a promise the fulfills when the anchor was created
  149089. */
  149090. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  149091. /**
  149092. * attach this feature
  149093. * Will usually be called by the features manager
  149094. *
  149095. * @returns true if successful.
  149096. */
  149097. attach(): boolean;
  149098. /**
  149099. * detach this feature.
  149100. * Will usually be called by the features manager
  149101. *
  149102. * @returns true if successful.
  149103. */
  149104. detach(): boolean;
  149105. /**
  149106. * Dispose this feature and all of the resources attached
  149107. */
  149108. dispose(): void;
  149109. /**
  149110. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  149111. * @param hitTestModule the hit-test module to use.
  149112. */
  149113. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  149114. /**
  149115. * set the plane detector to use in order to create anchors from frames
  149116. * @param planeDetector the plane-detector module to use
  149117. * @param enable enable plane-anchors. default is true
  149118. */
  149119. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  149120. protected _onXRFrame(frame: XRFrame): void;
  149121. /**
  149122. * avoiding using Array.find for global support.
  149123. * @param xrAnchor the plane to find in the array
  149124. */
  149125. private _findIndexInAnchorArray;
  149126. private _updateAnchorWithXRFrame;
  149127. }
  149128. }
  149129. declare module BABYLON {
  149130. /**
  149131. * Options interface for the background remover plugin
  149132. */
  149133. export interface IWebXRBackgroundRemoverOptions {
  149134. /**
  149135. * Further background meshes to disable when entering AR
  149136. */
  149137. backgroundMeshes?: AbstractMesh[];
  149138. /**
  149139. * flags to configure the removal of the environment helper.
  149140. * If not set, the entire background will be removed. If set, flags should be set as well.
  149141. */
  149142. environmentHelperRemovalFlags?: {
  149143. /**
  149144. * Should the skybox be removed (default false)
  149145. */
  149146. skyBox?: boolean;
  149147. /**
  149148. * Should the ground be removed (default false)
  149149. */
  149150. ground?: boolean;
  149151. };
  149152. /**
  149153. * don't disable the environment helper
  149154. */
  149155. ignoreEnvironmentHelper?: boolean;
  149156. }
  149157. /**
  149158. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  149159. */
  149160. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  149161. /**
  149162. * read-only options to be used in this module
  149163. */
  149164. readonly options: IWebXRBackgroundRemoverOptions;
  149165. /**
  149166. * The module's name
  149167. */
  149168. static readonly Name: string;
  149169. /**
  149170. * The (Babylon) version of this module.
  149171. * This is an integer representing the implementation version.
  149172. * This number does not correspond to the WebXR specs version
  149173. */
  149174. static readonly Version: number;
  149175. /**
  149176. * registered observers will be triggered when the background state changes
  149177. */
  149178. onBackgroundStateChangedObservable: Observable<boolean>;
  149179. /**
  149180. * constructs a new background remover module
  149181. * @param _xrSessionManager the session manager for this module
  149182. * @param options read-only options to be used in this module
  149183. */
  149184. constructor(_xrSessionManager: WebXRSessionManager,
  149185. /**
  149186. * read-only options to be used in this module
  149187. */
  149188. options?: IWebXRBackgroundRemoverOptions);
  149189. /**
  149190. * attach this feature
  149191. * Will usually be called by the features manager
  149192. *
  149193. * @returns true if successful.
  149194. */
  149195. attach(): boolean;
  149196. /**
  149197. * detach this feature.
  149198. * Will usually be called by the features manager
  149199. *
  149200. * @returns true if successful.
  149201. */
  149202. detach(): boolean;
  149203. /**
  149204. * Dispose this feature and all of the resources attached
  149205. */
  149206. dispose(): void;
  149207. protected _onXRFrame(_xrFrame: XRFrame): void;
  149208. private _setBackgroundState;
  149209. }
  149210. }
  149211. declare module BABYLON {
  149212. /**
  149213. * Options for the controller physics feature
  149214. */
  149215. export class IWebXRControllerPhysicsOptions {
  149216. /**
  149217. * Should the headset get its own impostor
  149218. */
  149219. enableHeadsetImpostor?: boolean;
  149220. /**
  149221. * Optional parameters for the headset impostor
  149222. */
  149223. headsetImpostorParams?: {
  149224. /**
  149225. * The type of impostor to create. Default is sphere
  149226. */
  149227. impostorType: number;
  149228. /**
  149229. * the size of the impostor. Defaults to 10cm
  149230. */
  149231. impostorSize?: number | {
  149232. width: number;
  149233. height: number;
  149234. depth: number;
  149235. };
  149236. /**
  149237. * Friction definitions
  149238. */
  149239. friction?: number;
  149240. /**
  149241. * Restitution
  149242. */
  149243. restitution?: number;
  149244. };
  149245. /**
  149246. * The physics properties of the future impostors
  149247. */
  149248. physicsProperties?: {
  149249. /**
  149250. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  149251. * Note that this requires a physics engine that supports mesh impostors!
  149252. */
  149253. useControllerMesh?: boolean;
  149254. /**
  149255. * The type of impostor to create. Default is sphere
  149256. */
  149257. impostorType?: number;
  149258. /**
  149259. * the size of the impostor. Defaults to 10cm
  149260. */
  149261. impostorSize?: number | {
  149262. width: number;
  149263. height: number;
  149264. depth: number;
  149265. };
  149266. /**
  149267. * Friction definitions
  149268. */
  149269. friction?: number;
  149270. /**
  149271. * Restitution
  149272. */
  149273. restitution?: number;
  149274. };
  149275. /**
  149276. * the xr input to use with this pointer selection
  149277. */
  149278. xrInput: WebXRInput;
  149279. }
  149280. /**
  149281. * Add physics impostor to your webxr controllers,
  149282. * including naive calculation of their linear and angular velocity
  149283. */
  149284. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  149285. private readonly _options;
  149286. private _attachController;
  149287. private _controllers;
  149288. private _debugMode;
  149289. private _delta;
  149290. private _headsetImpostor?;
  149291. private _headsetMesh?;
  149292. private _lastTimestamp;
  149293. private _tmpQuaternion;
  149294. private _tmpVector;
  149295. /**
  149296. * The module's name
  149297. */
  149298. static readonly Name: string;
  149299. /**
  149300. * The (Babylon) version of this module.
  149301. * This is an integer representing the implementation version.
  149302. * This number does not correspond to the webxr specs version
  149303. */
  149304. static readonly Version: number;
  149305. /**
  149306. * Construct a new Controller Physics Feature
  149307. * @param _xrSessionManager the corresponding xr session manager
  149308. * @param _options options to create this feature with
  149309. */
  149310. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  149311. /**
  149312. * @hidden
  149313. * enable debugging - will show console outputs and the impostor mesh
  149314. */
  149315. _enablePhysicsDebug(): void;
  149316. /**
  149317. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  149318. * @param xrController the controller to add
  149319. */
  149320. addController(xrController: WebXRInputSource): void;
  149321. /**
  149322. * attach this feature
  149323. * Will usually be called by the features manager
  149324. *
  149325. * @returns true if successful.
  149326. */
  149327. attach(): boolean;
  149328. /**
  149329. * detach this feature.
  149330. * Will usually be called by the features manager
  149331. *
  149332. * @returns true if successful.
  149333. */
  149334. detach(): boolean;
  149335. /**
  149336. * Get the headset impostor, if enabled
  149337. * @returns the impostor
  149338. */
  149339. getHeadsetImpostor(): PhysicsImpostor | undefined;
  149340. /**
  149341. * Get the physics impostor of a specific controller.
  149342. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  149343. * @param controller the controller or the controller id of which to get the impostor
  149344. * @returns the impostor or null
  149345. */
  149346. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  149347. /**
  149348. * Update the physics properties provided in the constructor
  149349. * @param newProperties the new properties object
  149350. */
  149351. setPhysicsProperties(newProperties: {
  149352. impostorType?: number;
  149353. impostorSize?: number | {
  149354. width: number;
  149355. height: number;
  149356. depth: number;
  149357. };
  149358. friction?: number;
  149359. restitution?: number;
  149360. }): void;
  149361. protected _onXRFrame(_xrFrame: any): void;
  149362. private _detachController;
  149363. }
  149364. }
  149365. declare module BABYLON {
  149366. /**
  149367. * Options used for hit testing (version 2)
  149368. */
  149369. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  149370. /**
  149371. * Do not create a permanent hit test. Will usually be used when only
  149372. * transient inputs are needed.
  149373. */
  149374. disablePermanentHitTest?: boolean;
  149375. /**
  149376. * Enable transient (for example touch-based) hit test inspections
  149377. */
  149378. enableTransientHitTest?: boolean;
  149379. /**
  149380. * Offset ray for the permanent hit test
  149381. */
  149382. offsetRay?: Vector3;
  149383. /**
  149384. * Offset ray for the transient hit test
  149385. */
  149386. transientOffsetRay?: Vector3;
  149387. /**
  149388. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  149389. */
  149390. useReferenceSpace?: boolean;
  149391. }
  149392. /**
  149393. * Interface defining the babylon result of hit-test
  149394. */
  149395. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  149396. /**
  149397. * The input source that generated this hit test (if transient)
  149398. */
  149399. inputSource?: XRInputSource;
  149400. /**
  149401. * Is this a transient hit test
  149402. */
  149403. isTransient?: boolean;
  149404. /**
  149405. * Position of the hit test result
  149406. */
  149407. position: Vector3;
  149408. /**
  149409. * Rotation of the hit test result
  149410. */
  149411. rotationQuaternion: Quaternion;
  149412. }
  149413. /**
  149414. * The currently-working hit-test module.
  149415. * Hit test (or Ray-casting) is used to interact with the real world.
  149416. * For further information read here - https://github.com/immersive-web/hit-test
  149417. *
  149418. * Tested on chrome (mobile) 80.
  149419. */
  149420. export class WebXRHitTest extends WebXRAbstractFeature {
  149421. /**
  149422. * options to use when constructing this feature
  149423. */
  149424. readonly options: IWebXRHitTestOptions;
  149425. private _tmpMat;
  149426. private _tmpPos;
  149427. private _tmpQuat;
  149428. private _transientXrHitTestSource;
  149429. private _xrHitTestSource;
  149430. private initHitTestSource;
  149431. /**
  149432. * The module's name
  149433. */
  149434. static readonly Name: string;
  149435. /**
  149436. * The (Babylon) version of this module.
  149437. * This is an integer representing the implementation version.
  149438. * This number does not correspond to the WebXR specs version
  149439. */
  149440. static readonly Version: number;
  149441. /**
  149442. * When set to true, each hit test will have its own position/rotation objects
  149443. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  149444. * the developers will clone them or copy them as they see fit.
  149445. */
  149446. autoCloneTransformation: boolean;
  149447. /**
  149448. * Populated with the last native XR Hit Results
  149449. */
  149450. lastNativeXRHitResults: XRHitResult[];
  149451. /**
  149452. * Triggered when new babylon (transformed) hit test results are available
  149453. */
  149454. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  149455. /**
  149456. * Use this to temporarily pause hit test checks.
  149457. */
  149458. paused: boolean;
  149459. /**
  149460. * Creates a new instance of the hit test feature
  149461. * @param _xrSessionManager an instance of WebXRSessionManager
  149462. * @param options options to use when constructing this feature
  149463. */
  149464. constructor(_xrSessionManager: WebXRSessionManager,
  149465. /**
  149466. * options to use when constructing this feature
  149467. */
  149468. options?: IWebXRHitTestOptions);
  149469. /**
  149470. * attach this feature
  149471. * Will usually be called by the features manager
  149472. *
  149473. * @returns true if successful.
  149474. */
  149475. attach(): boolean;
  149476. /**
  149477. * detach this feature.
  149478. * Will usually be called by the features manager
  149479. *
  149480. * @returns true if successful.
  149481. */
  149482. detach(): boolean;
  149483. /**
  149484. * Dispose this feature and all of the resources attached
  149485. */
  149486. dispose(): void;
  149487. protected _onXRFrame(frame: XRFrame): void;
  149488. private _processWebXRHitTestResult;
  149489. }
  149490. }
  149491. declare module BABYLON {
  149492. /**
  149493. * The motion controller class for all microsoft mixed reality controllers
  149494. */
  149495. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  149496. protected readonly _mapping: {
  149497. defaultButton: {
  149498. valueNodeName: string;
  149499. unpressedNodeName: string;
  149500. pressedNodeName: string;
  149501. };
  149502. defaultAxis: {
  149503. valueNodeName: string;
  149504. minNodeName: string;
  149505. maxNodeName: string;
  149506. };
  149507. buttons: {
  149508. "xr-standard-trigger": {
  149509. rootNodeName: string;
  149510. componentProperty: string;
  149511. states: string[];
  149512. };
  149513. "xr-standard-squeeze": {
  149514. rootNodeName: string;
  149515. componentProperty: string;
  149516. states: string[];
  149517. };
  149518. "xr-standard-touchpad": {
  149519. rootNodeName: string;
  149520. labelAnchorNodeName: string;
  149521. touchPointNodeName: string;
  149522. };
  149523. "xr-standard-thumbstick": {
  149524. rootNodeName: string;
  149525. componentProperty: string;
  149526. states: string[];
  149527. };
  149528. };
  149529. axes: {
  149530. "xr-standard-touchpad": {
  149531. "x-axis": {
  149532. rootNodeName: string;
  149533. };
  149534. "y-axis": {
  149535. rootNodeName: string;
  149536. };
  149537. };
  149538. "xr-standard-thumbstick": {
  149539. "x-axis": {
  149540. rootNodeName: string;
  149541. };
  149542. "y-axis": {
  149543. rootNodeName: string;
  149544. };
  149545. };
  149546. };
  149547. };
  149548. /**
  149549. * The base url used to load the left and right controller models
  149550. */
  149551. static MODEL_BASE_URL: string;
  149552. /**
  149553. * The name of the left controller model file
  149554. */
  149555. static MODEL_LEFT_FILENAME: string;
  149556. /**
  149557. * The name of the right controller model file
  149558. */
  149559. static MODEL_RIGHT_FILENAME: string;
  149560. profileId: string;
  149561. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  149562. protected _getFilenameAndPath(): {
  149563. filename: string;
  149564. path: string;
  149565. };
  149566. protected _getModelLoadingConstraints(): boolean;
  149567. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  149568. protected _setRootMesh(meshes: AbstractMesh[]): void;
  149569. protected _updateModel(): void;
  149570. }
  149571. }
  149572. declare module BABYLON {
  149573. /**
  149574. * The motion controller class for oculus touch (quest, rift).
  149575. * This class supports legacy mapping as well the standard xr mapping
  149576. */
  149577. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  149578. private _forceLegacyControllers;
  149579. private _modelRootNode;
  149580. /**
  149581. * The base url used to load the left and right controller models
  149582. */
  149583. static MODEL_BASE_URL: string;
  149584. /**
  149585. * The name of the left controller model file
  149586. */
  149587. static MODEL_LEFT_FILENAME: string;
  149588. /**
  149589. * The name of the right controller model file
  149590. */
  149591. static MODEL_RIGHT_FILENAME: string;
  149592. /**
  149593. * Base Url for the Quest controller model.
  149594. */
  149595. static QUEST_MODEL_BASE_URL: string;
  149596. profileId: string;
  149597. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  149598. protected _getFilenameAndPath(): {
  149599. filename: string;
  149600. path: string;
  149601. };
  149602. protected _getModelLoadingConstraints(): boolean;
  149603. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  149604. protected _setRootMesh(meshes: AbstractMesh[]): void;
  149605. protected _updateModel(): void;
  149606. /**
  149607. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  149608. * between the touch and touch 2.
  149609. */
  149610. private _isQuest;
  149611. }
  149612. }
  149613. declare module BABYLON {
  149614. /**
  149615. * The motion controller class for the standard HTC-Vive controllers
  149616. */
  149617. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  149618. private _modelRootNode;
  149619. /**
  149620. * The base url used to load the left and right controller models
  149621. */
  149622. static MODEL_BASE_URL: string;
  149623. /**
  149624. * File name for the controller model.
  149625. */
  149626. static MODEL_FILENAME: string;
  149627. profileId: string;
  149628. /**
  149629. * Create a new Vive motion controller object
  149630. * @param scene the scene to use to create this controller
  149631. * @param gamepadObject the corresponding gamepad object
  149632. * @param handedness the handedness of the controller
  149633. */
  149634. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  149635. protected _getFilenameAndPath(): {
  149636. filename: string;
  149637. path: string;
  149638. };
  149639. protected _getModelLoadingConstraints(): boolean;
  149640. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  149641. protected _setRootMesh(meshes: AbstractMesh[]): void;
  149642. protected _updateModel(): void;
  149643. }
  149644. }
  149645. declare module BABYLON {
  149646. /**
  149647. * A cursor which tracks a point on a path
  149648. */
  149649. export class PathCursor {
  149650. private path;
  149651. /**
  149652. * Stores path cursor callbacks for when an onchange event is triggered
  149653. */
  149654. private _onchange;
  149655. /**
  149656. * The value of the path cursor
  149657. */
  149658. value: number;
  149659. /**
  149660. * The animation array of the path cursor
  149661. */
  149662. animations: Animation[];
  149663. /**
  149664. * Initializes the path cursor
  149665. * @param path The path to track
  149666. */
  149667. constructor(path: Path2);
  149668. /**
  149669. * Gets the cursor point on the path
  149670. * @returns A point on the path cursor at the cursor location
  149671. */
  149672. getPoint(): Vector3;
  149673. /**
  149674. * Moves the cursor ahead by the step amount
  149675. * @param step The amount to move the cursor forward
  149676. * @returns This path cursor
  149677. */
  149678. moveAhead(step?: number): PathCursor;
  149679. /**
  149680. * Moves the cursor behind by the step amount
  149681. * @param step The amount to move the cursor back
  149682. * @returns This path cursor
  149683. */
  149684. moveBack(step?: number): PathCursor;
  149685. /**
  149686. * Moves the cursor by the step amount
  149687. * If the step amount is greater than one, an exception is thrown
  149688. * @param step The amount to move the cursor
  149689. * @returns This path cursor
  149690. */
  149691. move(step: number): PathCursor;
  149692. /**
  149693. * Ensures that the value is limited between zero and one
  149694. * @returns This path cursor
  149695. */
  149696. private ensureLimits;
  149697. /**
  149698. * Runs onchange callbacks on change (used by the animation engine)
  149699. * @returns This path cursor
  149700. */
  149701. private raiseOnChange;
  149702. /**
  149703. * Executes a function on change
  149704. * @param f A path cursor onchange callback
  149705. * @returns This path cursor
  149706. */
  149707. onchange(f: (cursor: PathCursor) => void): PathCursor;
  149708. }
  149709. }
  149710. declare module BABYLON {
  149711. /** @hidden */
  149712. export class ShaderCodeInliner {
  149713. static readonly InlineToken: string;
  149714. static readonly RegexpFindFunctionNameAndType: RegExp;
  149715. private _sourceCode;
  149716. private _functionDescr;
  149717. private _numMaxIterations;
  149718. debug: boolean;
  149719. get code(): string;
  149720. constructor(sourceCode: string, numMaxIterations?: number);
  149721. processCode(): void;
  149722. private _collectFunctions;
  149723. private _processInlining;
  149724. private _extractBetweenMarkers;
  149725. private _skipWhitespaces;
  149726. private _removeComments;
  149727. private _replaceFunctionCallsByCode;
  149728. private _findBackward;
  149729. private _escapeRegExp;
  149730. private _replaceNames;
  149731. }
  149732. }
  149733. declare module BABYLON {
  149734. /** @hidden */
  149735. export var blurPixelShader: {
  149736. name: string;
  149737. shader: string;
  149738. };
  149739. }
  149740. declare module BABYLON {
  149741. /** @hidden */
  149742. export var pointCloudVertexDeclaration: {
  149743. name: string;
  149744. shader: string;
  149745. };
  149746. }
  149747. // Mixins
  149748. interface Window {
  149749. mozIndexedDB: IDBFactory;
  149750. webkitIndexedDB: IDBFactory;
  149751. msIndexedDB: IDBFactory;
  149752. webkitURL: typeof URL;
  149753. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  149754. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  149755. WebGLRenderingContext: WebGLRenderingContext;
  149756. MSGesture: MSGesture;
  149757. CANNON: any;
  149758. AudioContext: AudioContext;
  149759. webkitAudioContext: AudioContext;
  149760. PointerEvent: any;
  149761. Math: Math;
  149762. Uint8Array: Uint8ArrayConstructor;
  149763. Float32Array: Float32ArrayConstructor;
  149764. mozURL: typeof URL;
  149765. msURL: typeof URL;
  149766. VRFrameData: any; // WebVR, from specs 1.1
  149767. DracoDecoderModule: any;
  149768. setImmediate(handler: (...args: any[]) => void): number;
  149769. }
  149770. interface HTMLCanvasElement {
  149771. requestPointerLock(): void;
  149772. msRequestPointerLock?(): void;
  149773. mozRequestPointerLock?(): void;
  149774. webkitRequestPointerLock?(): void;
  149775. /** Track wether a record is in progress */
  149776. isRecording: boolean;
  149777. /** Capture Stream method defined by some browsers */
  149778. captureStream(fps?: number): MediaStream;
  149779. }
  149780. interface CanvasRenderingContext2D {
  149781. msImageSmoothingEnabled: boolean;
  149782. }
  149783. interface MouseEvent {
  149784. mozMovementX: number;
  149785. mozMovementY: number;
  149786. webkitMovementX: number;
  149787. webkitMovementY: number;
  149788. msMovementX: number;
  149789. msMovementY: number;
  149790. }
  149791. interface Navigator {
  149792. mozGetVRDevices: (any: any) => any;
  149793. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  149794. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  149795. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  149796. webkitGetGamepads(): Gamepad[];
  149797. msGetGamepads(): Gamepad[];
  149798. webkitGamepads(): Gamepad[];
  149799. }
  149800. interface HTMLVideoElement {
  149801. mozSrcObject: any;
  149802. }
  149803. interface Math {
  149804. fround(x: number): number;
  149805. imul(a: number, b: number): number;
  149806. }
  149807. interface WebGLRenderingContext {
  149808. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  149809. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  149810. vertexAttribDivisor(index: number, divisor: number): void;
  149811. createVertexArray(): any;
  149812. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  149813. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  149814. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  149815. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  149816. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  149817. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  149818. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  149819. // Queries
  149820. createQuery(): WebGLQuery;
  149821. deleteQuery(query: WebGLQuery): void;
  149822. beginQuery(target: number, query: WebGLQuery): void;
  149823. endQuery(target: number): void;
  149824. getQueryParameter(query: WebGLQuery, pname: number): any;
  149825. getQuery(target: number, pname: number): any;
  149826. MAX_SAMPLES: number;
  149827. RGBA8: number;
  149828. READ_FRAMEBUFFER: number;
  149829. DRAW_FRAMEBUFFER: number;
  149830. UNIFORM_BUFFER: number;
  149831. HALF_FLOAT_OES: number;
  149832. RGBA16F: number;
  149833. RGBA32F: number;
  149834. R32F: number;
  149835. RG32F: number;
  149836. RGB32F: number;
  149837. R16F: number;
  149838. RG16F: number;
  149839. RGB16F: number;
  149840. RED: number;
  149841. RG: number;
  149842. R8: number;
  149843. RG8: number;
  149844. UNSIGNED_INT_24_8: number;
  149845. DEPTH24_STENCIL8: number;
  149846. MIN: number;
  149847. MAX: number;
  149848. /* Multiple Render Targets */
  149849. drawBuffers(buffers: number[]): void;
  149850. readBuffer(src: number): void;
  149851. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  149852. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  149853. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  149854. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  149855. // Occlusion Query
  149856. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  149857. ANY_SAMPLES_PASSED: number;
  149858. QUERY_RESULT_AVAILABLE: number;
  149859. QUERY_RESULT: number;
  149860. }
  149861. interface WebGLProgram {
  149862. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  149863. }
  149864. interface EXT_disjoint_timer_query {
  149865. QUERY_COUNTER_BITS_EXT: number;
  149866. TIME_ELAPSED_EXT: number;
  149867. TIMESTAMP_EXT: number;
  149868. GPU_DISJOINT_EXT: number;
  149869. QUERY_RESULT_EXT: number;
  149870. QUERY_RESULT_AVAILABLE_EXT: number;
  149871. queryCounterEXT(query: WebGLQuery, target: number): void;
  149872. createQueryEXT(): WebGLQuery;
  149873. beginQueryEXT(target: number, query: WebGLQuery): void;
  149874. endQueryEXT(target: number): void;
  149875. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  149876. deleteQueryEXT(query: WebGLQuery): void;
  149877. }
  149878. interface WebGLUniformLocation {
  149879. _currentState: any;
  149880. }
  149881. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  149882. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  149883. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  149884. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  149885. interface WebGLRenderingContext {
  149886. readonly RASTERIZER_DISCARD: number;
  149887. readonly DEPTH_COMPONENT24: number;
  149888. readonly TEXTURE_3D: number;
  149889. readonly TEXTURE_2D_ARRAY: number;
  149890. readonly TEXTURE_COMPARE_FUNC: number;
  149891. readonly TEXTURE_COMPARE_MODE: number;
  149892. readonly COMPARE_REF_TO_TEXTURE: number;
  149893. readonly TEXTURE_WRAP_R: number;
  149894. readonly HALF_FLOAT: number;
  149895. readonly RGB8: number;
  149896. readonly RED_INTEGER: number;
  149897. readonly RG_INTEGER: number;
  149898. readonly RGB_INTEGER: number;
  149899. readonly RGBA_INTEGER: number;
  149900. readonly R8_SNORM: number;
  149901. readonly RG8_SNORM: number;
  149902. readonly RGB8_SNORM: number;
  149903. readonly RGBA8_SNORM: number;
  149904. readonly R8I: number;
  149905. readonly RG8I: number;
  149906. readonly RGB8I: number;
  149907. readonly RGBA8I: number;
  149908. readonly R8UI: number;
  149909. readonly RG8UI: number;
  149910. readonly RGB8UI: number;
  149911. readonly RGBA8UI: number;
  149912. readonly R16I: number;
  149913. readonly RG16I: number;
  149914. readonly RGB16I: number;
  149915. readonly RGBA16I: number;
  149916. readonly R16UI: number;
  149917. readonly RG16UI: number;
  149918. readonly RGB16UI: number;
  149919. readonly RGBA16UI: number;
  149920. readonly R32I: number;
  149921. readonly RG32I: number;
  149922. readonly RGB32I: number;
  149923. readonly RGBA32I: number;
  149924. readonly R32UI: number;
  149925. readonly RG32UI: number;
  149926. readonly RGB32UI: number;
  149927. readonly RGBA32UI: number;
  149928. readonly RGB10_A2UI: number;
  149929. readonly R11F_G11F_B10F: number;
  149930. readonly RGB9_E5: number;
  149931. readonly RGB10_A2: number;
  149932. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  149933. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  149934. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  149935. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  149936. readonly DEPTH_COMPONENT32F: number;
  149937. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  149938. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  149939. 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;
  149940. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  149941. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  149942. readonly TRANSFORM_FEEDBACK: number;
  149943. readonly INTERLEAVED_ATTRIBS: number;
  149944. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  149945. createTransformFeedback(): WebGLTransformFeedback;
  149946. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  149947. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  149948. beginTransformFeedback(primitiveMode: number): void;
  149949. endTransformFeedback(): void;
  149950. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  149951. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  149952. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  149953. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  149954. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  149955. }
  149956. interface ImageBitmap {
  149957. readonly width: number;
  149958. readonly height: number;
  149959. close(): void;
  149960. }
  149961. interface WebGLQuery extends WebGLObject {
  149962. }
  149963. declare var WebGLQuery: {
  149964. prototype: WebGLQuery;
  149965. new(): WebGLQuery;
  149966. };
  149967. interface WebGLSampler extends WebGLObject {
  149968. }
  149969. declare var WebGLSampler: {
  149970. prototype: WebGLSampler;
  149971. new(): WebGLSampler;
  149972. };
  149973. interface WebGLSync extends WebGLObject {
  149974. }
  149975. declare var WebGLSync: {
  149976. prototype: WebGLSync;
  149977. new(): WebGLSync;
  149978. };
  149979. interface WebGLTransformFeedback extends WebGLObject {
  149980. }
  149981. declare var WebGLTransformFeedback: {
  149982. prototype: WebGLTransformFeedback;
  149983. new(): WebGLTransformFeedback;
  149984. };
  149985. interface WebGLVertexArrayObject extends WebGLObject {
  149986. }
  149987. declare var WebGLVertexArrayObject: {
  149988. prototype: WebGLVertexArrayObject;
  149989. new(): WebGLVertexArrayObject;
  149990. };
  149991. // Type definitions for WebVR API
  149992. // Project: https://w3c.github.io/webvr/
  149993. // Definitions by: six a <https://github.com/lostfictions>
  149994. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  149995. interface VRDisplay extends EventTarget {
  149996. /**
  149997. * Dictionary of capabilities describing the VRDisplay.
  149998. */
  149999. readonly capabilities: VRDisplayCapabilities;
  150000. /**
  150001. * z-depth defining the far plane of the eye view frustum
  150002. * enables mapping of values in the render target depth
  150003. * attachment to scene coordinates. Initially set to 10000.0.
  150004. */
  150005. depthFar: number;
  150006. /**
  150007. * z-depth defining the near plane of the eye view frustum
  150008. * enables mapping of values in the render target depth
  150009. * attachment to scene coordinates. Initially set to 0.01.
  150010. */
  150011. depthNear: number;
  150012. /**
  150013. * An identifier for this distinct VRDisplay. Used as an
  150014. * association point in the Gamepad API.
  150015. */
  150016. readonly displayId: number;
  150017. /**
  150018. * A display name, a user-readable name identifying it.
  150019. */
  150020. readonly displayName: string;
  150021. readonly isConnected: boolean;
  150022. readonly isPresenting: boolean;
  150023. /**
  150024. * If this VRDisplay supports room-scale experiences, the optional
  150025. * stage attribute contains details on the room-scale parameters.
  150026. */
  150027. readonly stageParameters: VRStageParameters | null;
  150028. /**
  150029. * Passing the value returned by `requestAnimationFrame` to
  150030. * `cancelAnimationFrame` will unregister the callback.
  150031. * @param handle Define the hanle of the request to cancel
  150032. */
  150033. cancelAnimationFrame(handle: number): void;
  150034. /**
  150035. * Stops presenting to the VRDisplay.
  150036. * @returns a promise to know when it stopped
  150037. */
  150038. exitPresent(): Promise<void>;
  150039. /**
  150040. * Return the current VREyeParameters for the given eye.
  150041. * @param whichEye Define the eye we want the parameter for
  150042. * @returns the eye parameters
  150043. */
  150044. getEyeParameters(whichEye: string): VREyeParameters;
  150045. /**
  150046. * Populates the passed VRFrameData with the information required to render
  150047. * the current frame.
  150048. * @param frameData Define the data structure to populate
  150049. * @returns true if ok otherwise false
  150050. */
  150051. getFrameData(frameData: VRFrameData): boolean;
  150052. /**
  150053. * Get the layers currently being presented.
  150054. * @returns the list of VR layers
  150055. */
  150056. getLayers(): VRLayer[];
  150057. /**
  150058. * Return a VRPose containing the future predicted pose of the VRDisplay
  150059. * when the current frame will be presented. The value returned will not
  150060. * change until JavaScript has returned control to the browser.
  150061. *
  150062. * The VRPose will contain the position, orientation, velocity,
  150063. * and acceleration of each of these properties.
  150064. * @returns the pose object
  150065. */
  150066. getPose(): VRPose;
  150067. /**
  150068. * Return the current instantaneous pose of the VRDisplay, with no
  150069. * prediction applied.
  150070. * @returns the current instantaneous pose
  150071. */
  150072. getImmediatePose(): VRPose;
  150073. /**
  150074. * The callback passed to `requestAnimationFrame` will be called
  150075. * any time a new frame should be rendered. When the VRDisplay is
  150076. * presenting the callback will be called at the native refresh
  150077. * rate of the HMD. When not presenting this function acts
  150078. * identically to how window.requestAnimationFrame acts. Content should
  150079. * make no assumptions of frame rate or vsync behavior as the HMD runs
  150080. * asynchronously from other displays and at differing refresh rates.
  150081. * @param callback Define the eaction to run next frame
  150082. * @returns the request handle it
  150083. */
  150084. requestAnimationFrame(callback: FrameRequestCallback): number;
  150085. /**
  150086. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  150087. * Repeat calls while already presenting will update the VRLayers being displayed.
  150088. * @param layers Define the list of layer to present
  150089. * @returns a promise to know when the request has been fulfilled
  150090. */
  150091. requestPresent(layers: VRLayer[]): Promise<void>;
  150092. /**
  150093. * Reset the pose for this display, treating its current position and
  150094. * orientation as the "origin/zero" values. VRPose.position,
  150095. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  150096. * updated when calling resetPose(). This should be called in only
  150097. * sitting-space experiences.
  150098. */
  150099. resetPose(): void;
  150100. /**
  150101. * The VRLayer provided to the VRDisplay will be captured and presented
  150102. * in the HMD. Calling this function has the same effect on the source
  150103. * canvas as any other operation that uses its source image, and canvases
  150104. * created without preserveDrawingBuffer set to true will be cleared.
  150105. * @param pose Define the pose to submit
  150106. */
  150107. submitFrame(pose?: VRPose): void;
  150108. }
  150109. declare var VRDisplay: {
  150110. prototype: VRDisplay;
  150111. new(): VRDisplay;
  150112. };
  150113. interface VRLayer {
  150114. leftBounds?: number[] | Float32Array | null;
  150115. rightBounds?: number[] | Float32Array | null;
  150116. source?: HTMLCanvasElement | null;
  150117. }
  150118. interface VRDisplayCapabilities {
  150119. readonly canPresent: boolean;
  150120. readonly hasExternalDisplay: boolean;
  150121. readonly hasOrientation: boolean;
  150122. readonly hasPosition: boolean;
  150123. readonly maxLayers: number;
  150124. }
  150125. interface VREyeParameters {
  150126. /** @deprecated */
  150127. readonly fieldOfView: VRFieldOfView;
  150128. readonly offset: Float32Array;
  150129. readonly renderHeight: number;
  150130. readonly renderWidth: number;
  150131. }
  150132. interface VRFieldOfView {
  150133. readonly downDegrees: number;
  150134. readonly leftDegrees: number;
  150135. readonly rightDegrees: number;
  150136. readonly upDegrees: number;
  150137. }
  150138. interface VRFrameData {
  150139. readonly leftProjectionMatrix: Float32Array;
  150140. readonly leftViewMatrix: Float32Array;
  150141. readonly pose: VRPose;
  150142. readonly rightProjectionMatrix: Float32Array;
  150143. readonly rightViewMatrix: Float32Array;
  150144. readonly timestamp: number;
  150145. }
  150146. interface VRPose {
  150147. readonly angularAcceleration: Float32Array | null;
  150148. readonly angularVelocity: Float32Array | null;
  150149. readonly linearAcceleration: Float32Array | null;
  150150. readonly linearVelocity: Float32Array | null;
  150151. readonly orientation: Float32Array | null;
  150152. readonly position: Float32Array | null;
  150153. readonly timestamp: number;
  150154. }
  150155. interface VRStageParameters {
  150156. sittingToStandingTransform?: Float32Array;
  150157. sizeX?: number;
  150158. sizeY?: number;
  150159. }
  150160. interface Navigator {
  150161. getVRDisplays(): Promise<VRDisplay[]>;
  150162. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  150163. }
  150164. interface Window {
  150165. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  150166. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  150167. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  150168. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150169. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150170. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  150171. }
  150172. interface Gamepad {
  150173. readonly displayId: number;
  150174. }
  150175. type XRSessionMode =
  150176. | "inline"
  150177. | "immersive-vr"
  150178. | "immersive-ar";
  150179. type XRReferenceSpaceType =
  150180. | "viewer"
  150181. | "local"
  150182. | "local-floor"
  150183. | "bounded-floor"
  150184. | "unbounded";
  150185. type XREnvironmentBlendMode =
  150186. | "opaque"
  150187. | "additive"
  150188. | "alpha-blend";
  150189. type XRVisibilityState =
  150190. | "visible"
  150191. | "visible-blurred"
  150192. | "hidden";
  150193. type XRHandedness =
  150194. | "none"
  150195. | "left"
  150196. | "right";
  150197. type XRTargetRayMode =
  150198. | "gaze"
  150199. | "tracked-pointer"
  150200. | "screen";
  150201. type XREye =
  150202. | "none"
  150203. | "left"
  150204. | "right";
  150205. type XREventType =
  150206. | "devicechange"
  150207. | "visibilitychange"
  150208. | "end"
  150209. | "inputsourceschange"
  150210. | "select"
  150211. | "selectstart"
  150212. | "selectend"
  150213. | "squeeze"
  150214. | "squeezestart"
  150215. | "squeezeend"
  150216. | "reset";
  150217. interface XRSpace extends EventTarget {
  150218. }
  150219. interface XRRenderState {
  150220. depthNear?: number;
  150221. depthFar?: number;
  150222. inlineVerticalFieldOfView?: number;
  150223. baseLayer?: XRWebGLLayer;
  150224. }
  150225. interface XRInputSource {
  150226. handedness: XRHandedness;
  150227. targetRayMode: XRTargetRayMode;
  150228. targetRaySpace: XRSpace;
  150229. gripSpace: XRSpace | undefined;
  150230. gamepad: Gamepad | undefined;
  150231. profiles: Array<string>;
  150232. }
  150233. interface XRSessionInit {
  150234. optionalFeatures?: string[];
  150235. requiredFeatures?: string[];
  150236. }
  150237. interface XRSession extends XRAnchorCreator {
  150238. addEventListener: Function;
  150239. removeEventListener: Function;
  150240. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  150241. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  150242. requestAnimationFrame: Function;
  150243. end(): Promise<void>;
  150244. renderState: XRRenderState;
  150245. inputSources: Array<XRInputSource>;
  150246. // hit test
  150247. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  150248. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  150249. // legacy AR hit test
  150250. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150251. // legacy plane detection
  150252. updateWorldTrackingState(options: {
  150253. planeDetectionState?: { enabled: boolean; }
  150254. }): void;
  150255. }
  150256. interface XRReferenceSpace extends XRSpace {
  150257. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  150258. onreset: any;
  150259. }
  150260. type XRPlaneSet = Set<XRPlane>;
  150261. type XRAnchorSet = Set<XRAnchor>;
  150262. interface XRFrame {
  150263. session: XRSession;
  150264. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  150265. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  150266. // AR
  150267. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  150268. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  150269. // Anchors
  150270. trackedAnchors?: XRAnchorSet;
  150271. // Planes
  150272. worldInformation: {
  150273. detectedPlanes?: XRPlaneSet;
  150274. };
  150275. }
  150276. interface XRViewerPose extends XRPose {
  150277. views: Array<XRView>;
  150278. }
  150279. interface XRPose {
  150280. transform: XRRigidTransform;
  150281. emulatedPosition: boolean;
  150282. }
  150283. interface XRWebGLLayerOptions {
  150284. antialias?: boolean;
  150285. depth?: boolean;
  150286. stencil?: boolean;
  150287. alpha?: boolean;
  150288. multiview?: boolean;
  150289. framebufferScaleFactor?: number;
  150290. }
  150291. declare var XRWebGLLayer: {
  150292. prototype: XRWebGLLayer;
  150293. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  150294. };
  150295. interface XRWebGLLayer {
  150296. framebuffer: WebGLFramebuffer;
  150297. framebufferWidth: number;
  150298. framebufferHeight: number;
  150299. getViewport: Function;
  150300. }
  150301. declare class XRRigidTransform {
  150302. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  150303. position: DOMPointReadOnly;
  150304. orientation: DOMPointReadOnly;
  150305. matrix: Float32Array;
  150306. inverse: XRRigidTransform;
  150307. }
  150308. interface XRView {
  150309. eye: XREye;
  150310. projectionMatrix: Float32Array;
  150311. transform: XRRigidTransform;
  150312. }
  150313. interface XRInputSourceChangeEvent {
  150314. session: XRSession;
  150315. removed: Array<XRInputSource>;
  150316. added: Array<XRInputSource>;
  150317. }
  150318. interface XRInputSourceEvent extends Event {
  150319. readonly frame: XRFrame;
  150320. readonly inputSource: XRInputSource;
  150321. }
  150322. // Experimental(er) features
  150323. declare class XRRay {
  150324. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  150325. origin: DOMPointReadOnly;
  150326. direction: DOMPointReadOnly;
  150327. matrix: Float32Array;
  150328. }
  150329. declare enum XRHitTestTrackableType {
  150330. "point",
  150331. "plane"
  150332. }
  150333. interface XRHitResult {
  150334. hitMatrix: Float32Array;
  150335. }
  150336. interface XRTransientInputHitTestResult {
  150337. readonly inputSource: XRInputSource;
  150338. readonly results: Array<XRHitTestResult>;
  150339. }
  150340. interface XRHitTestResult {
  150341. getPose(baseSpace: XRSpace): XRPose | undefined;
  150342. }
  150343. interface XRHitTestSource {
  150344. cancel(): void;
  150345. }
  150346. interface XRTransientInputHitTestSource {
  150347. cancel(): void;
  150348. }
  150349. interface XRHitTestOptionsInit {
  150350. space: XRSpace;
  150351. entityTypes?: Array<XRHitTestTrackableType>;
  150352. offsetRay?: XRRay;
  150353. }
  150354. interface XRTransientInputHitTestOptionsInit {
  150355. profile: string;
  150356. entityTypes?: Array<XRHitTestTrackableType>;
  150357. offsetRay?: XRRay;
  150358. }
  150359. interface XRAnchor {
  150360. // remove?
  150361. id?: string;
  150362. anchorSpace: XRSpace;
  150363. lastChangedTime: number;
  150364. detach(): void;
  150365. }
  150366. interface XRPlane extends XRAnchorCreator {
  150367. orientation: "Horizontal" | "Vertical";
  150368. planeSpace: XRSpace;
  150369. polygon: Array<DOMPointReadOnly>;
  150370. lastChangedTime: number;
  150371. }
  150372. interface XRAnchorCreator {
  150373. // AR Anchors
  150374. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  150375. }